Mercurial > sdl-ios-xcode
annotate src/video/gem/SDL_gemevents.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | c9b51268668f |
children | adc8ff3c9597 |
rev | line source |
---|---|
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
13 Lesser General Public License for more details. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 * GEM SDL video driver implementation |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 * inspired from the Dummy SDL driver |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 * |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * Patrice Mandin |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 * and work from |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <string.h> |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include <gem.h> |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #include "SDL.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #include "SDL_sysevents.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #include "SDL_events_c.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #include "SDL_gemvideo.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #include "SDL_gemevents_c.h" |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
41 #include "SDL_atarikeys.h" /* for keyboard scancodes */ |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
42 #include "SDL_atarievents_c.h" |
1310
a201a8c62522
Add flag to post mouse button events or not, and use defined function to post them
Patrice Mandin <patmandin@gmail.com>
parents:
1267
diff
changeset
|
43 #include "SDL_xbiosevents_c.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 /* Defines */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #define ATARIBIOS_MAXKEYS 128 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 /* Variables */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 /* The translation tables from a console scancode to a SDL keysym */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 static SDLKey keymap[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 /* Functions prototypes */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
60 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym, |
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
61 SDL_bool pressed); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 static int do_messages(_THIS, short *message); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 static void do_keyboard(short kc, short ks); |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
64 static void do_mouse(_THIS, short mx, short my, short mb, short ks); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 /* Functions */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
68 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym, |
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
69 SDL_bool pressed) |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 /* Set the keysym information */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 keysym->scancode = scancode; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 if (asciicode) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 keysym->sym = asciicode; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 else |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 keysym->sym = keymap[scancode]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 keysym->mod = KMOD_NONE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 keysym->unicode = 0; |
1221
8ef3e7e92a91
Use a simple table for Unicode translation
Patrice Mandin <patmandin@gmail.com>
parents:
1209
diff
changeset
|
81 if (SDL_TranslateUNICODE && pressed) { |
8ef3e7e92a91
Use a simple table for Unicode translation
Patrice Mandin <patmandin@gmail.com>
parents:
1209
diff
changeset
|
82 keysym->unicode = SDL_AtariToUnicodeTable[asciicode]; |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
83 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 return(keysym); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 void GEM_InitOSKeymap(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 int i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
92 SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
93 SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
94 SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 /* Initialize keymap */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 for ( i=0; i<sizeof(keymap); i++ ) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 keymap[i] = SDLK_UNKNOWN; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 /* Functions keys */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 for ( i = 0; i<10; i++ ) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 keymap[SCANCODE_F1 + i] = SDLK_F1+i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 /* Cursor keypad */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 keymap[SCANCODE_HELP] = SDLK_HELP; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 keymap[SCANCODE_UNDO] = SDLK_UNDO; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 keymap[SCANCODE_INSERT] = SDLK_INSERT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 keymap[SCANCODE_CLRHOME] = SDLK_HOME; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 keymap[SCANCODE_UP] = SDLK_UP; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 keymap[SCANCODE_DOWN] = SDLK_DOWN; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 keymap[SCANCODE_RIGHT] = SDLK_RIGHT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 keymap[SCANCODE_LEFT] = SDLK_LEFT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 /* Special keys */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 keymap[SCANCODE_TAB] = SDLK_TAB; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 keymap[SCANCODE_ENTER] = SDLK_RETURN; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 keymap[SCANCODE_DELETE] = SDLK_DELETE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 keymap[SCANCODE_LEFTALT] = SDLK_LALT; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 /* Mouse init */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 GEM_mouse_relative = SDL_FALSE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 void GEM_PumpEvents(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 { |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
132 short mousex, mousey, mouseb, dummy; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
133 short kstate, prevkc, prevks; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 int i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 SDL_keysym keysym; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
137 SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
138 prevkc = prevks = 0; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 for (;;) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 { |
1092
1f37386ef508
Forgot variable declaration
Patrice Mandin <patmandin@gmail.com>
parents:
1091
diff
changeset
|
142 int quit, resultat, event_mask, mouse_event; |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
143 short buffer[8], kc; |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
144 short x2,y2,w2,h2; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
146 quit = |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
147 mouse_event = |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
148 x2=y2=w2=h2 = 0; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
150 event_mask = MU_MESAG|MU_TIMER|MU_KEYBD; |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
151 if (!GEM_fullscreen && (GEM_handle>=0)) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
152 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
153 event_mask |= MU_M1; |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
154 if ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
155 mouse_event = MO_LEAVE; |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
156 } else { |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
157 mouse_event = MO_ENTER; |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
158 } |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
159 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
160 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 resultat = evnt_multi( |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
162 event_mask, |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 0,0,0, |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
164 mouse_event,x2,y2,w2,h2, |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
165 0,0,0,0,0, |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 buffer, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 10, |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
168 &dummy,&dummy,&dummy,&kstate,&kc,&dummy |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 ); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 /* Message event ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 if (resultat & MU_MESAG) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 quit = do_messages(this, buffer); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 /* Keyboard event ? */ |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
176 if (resultat & MU_KEYBD) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 if ((prevkc != kc) || (prevks != kstate)) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
178 do_keyboard(kc,kstate); |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
179 } else { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
180 /* Avoid looping, if repeating same key */ |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
181 break; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
182 } |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
183 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
185 /* Mouse entering/leaving window */ |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
186 if (resultat & MU_M1) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
187 if (this->input_grab == SDL_GRAB_OFF) { |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
188 if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
189 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
190 } else { |
1088
6091b9ca1a97
Don't generate multiple mouse focus events
Patrice Mandin <patmandin@gmail.com>
parents:
1074
diff
changeset
|
191 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
6091b9ca1a97
Don't generate multiple mouse focus events
Patrice Mandin <patmandin@gmail.com>
parents:
1074
diff
changeset
|
192 } |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
193 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
194 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
195 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 /* Timer event ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 if ((resultat & MU_TIMER) || quit) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 /* Update mouse */ |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
202 graf_mkstate(&mousex, &mousey, &mouseb, &kstate); |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
203 do_mouse(this, mousex, mousey, mouseb, kstate); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
205 /* Now generate keyboard events */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 for (i=0; i<ATARIBIOS_MAXKEYS; i++) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 /* Key pressed ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
209 SDL_PrivateKeyboard(SDL_PRESSED, |
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
210 TranslateKey(i, gem_currentascii[i], &keysym, SDL_TRUE)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 /* Key unpressed ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 if (gem_previouskeyboard[i] && !gem_currentkeyboard[i]) |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
214 SDL_PrivateKeyboard(SDL_RELEASED, |
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
215 TranslateKey(i, gem_currentascii[i], &keysym, SDL_FALSE)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
218 SDL_memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard)); |
996
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
219 |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
220 /* Refresh window name ? */ |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
221 if (GEM_refresh_name) { |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
222 if ( SDL_GetAppState() & SDL_APPACTIVE ) { |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
223 /* Fullscreen/windowed */ |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
224 if (GEM_title_name) { |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
225 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
226 } |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
227 } else { |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
228 /* Iconified */ |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
229 if (GEM_icon_name) { |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
230 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
231 } |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
232 } |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
233 GEM_refresh_name = SDL_FALSE; |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
234 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 static int do_messages(_THIS, short *message) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 int quit, posted; |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
240 short x2,y2,w2,h2; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 quit=0; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 switch (message[0]) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 case WM_CLOSED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 case AP_TERM: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 posted = SDL_PrivateQuit(); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 quit=1; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 case WM_MOVED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 case WM_TOPPED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 wind_set(message[3],WF_TOP,message[4],0,0,0); |
1091
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
254 /* Continue with TOP event processing */ |
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
255 case WM_ONTOP: |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
1074
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
257 if (VDI_setpalette) { |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
258 VDI_setpalette(this, VDI_curpalette); |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
259 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 case WM_REDRAW: |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
262 if (!GEM_lock_redraw) { |
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
263 GEM_wind_redraw(this, message[3],&message[4]); |
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
264 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 case WM_ICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 case WM_ALLICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 /* If we're active, make ourselves inactive */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 if ( SDL_GetAppState() & SDL_APPACTIVE ) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 /* Send an internal deactivate event */ |
1088
6091b9ca1a97
Don't generate multiple mouse focus events
Patrice Mandin <patmandin@gmail.com>
parents:
1074
diff
changeset
|
272 SDL_PrivateAppActive(0, SDL_APPACTIVE); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 } |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
274 /* Update window title */ |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
275 if (GEM_refresh_name && GEM_icon_name) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
276 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
277 GEM_refresh_name = SDL_FALSE; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
278 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 case WM_UNICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 /* If we're not active, make ourselves active */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 /* Send an internal activate event */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 SDL_PrivateAppActive(1, SDL_APPACTIVE); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 } |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
287 if (GEM_refresh_name && GEM_title_name) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
288 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
289 GEM_refresh_name = SDL_FALSE; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
290 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 case WM_SIZED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]); |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
294 wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */ |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
296 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
297 SDL_PrivateResize(w2, h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 case WM_FULLED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 short x,y,w,h; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 if (GEM_win_fulled) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 GEM_win_fulled = SDL_FALSE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 } else { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 x = GEM_desk_x; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 y = GEM_desk_y; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 w = GEM_desk_w; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 h = GEM_desk_h; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 GEM_win_fulled = SDL_TRUE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 wind_set (message[3], WF_CURRXYWH, x, y, w, h); |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
314 wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
315 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
316 SDL_PrivateResize(w2, h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 case WM_BOTTOMED: |
1091
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
320 wind_set(message[3],WF_BOTTOM,0,0,0,0); |
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
321 /* Continue with BOTTOM event processing */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 case WM_UNTOPPED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
1074
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
324 if (VDI_setpalette) { |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
325 VDI_setpalette(this, VDI_oldpalette); |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
326 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 return quit; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 static void do_keyboard(short kc, short ks) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 int scancode, asciicode; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 if (kc) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 scancode=(kc>>8) & 127; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 asciicode=kc & 255; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 gem_currentkeyboard[scancode]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 gem_currentascii[scancode]=asciicode; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 /* Read special keys */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 if (ks & K_RSHIFT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 if (ks & K_LSHIFT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 if (ks & K_CTRL) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 if (ks & K_ALT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
356 static void do_mouse(_THIS, short mx, short my, short mb, short ks) |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 { |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
358 static short prevmousex=0, prevmousey=0, prevmouseb=0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
359 short x2, y2, w2, h2; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
360 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
361 /* Don't return mouse events if out of window */ |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
362 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
363 return; |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
364 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
365 |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
366 /* Retrieve window coords, and generate mouse events accordingly */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
367 x2 = y2 = 0; |
928
6c87754f324c
Forgot to initialize maximum position for mouse
Patrice Mandin <patmandin@gmail.com>
parents:
927
diff
changeset
|
368 w2 = VDI_w; |
6c87754f324c
Forgot to initialize maximum position for mouse
Patrice Mandin <patmandin@gmail.com>
parents:
927
diff
changeset
|
369 h2 = VDI_h; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
370 if ((!GEM_fullscreen) && (GEM_handle>=0)) { |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
371 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
372 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
373 /* Do not generate mouse button event if out of window working area */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
374 if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) { |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
375 mb=prevmouseb; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
376 } |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
377 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
378 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 /* Mouse motion ? */ |
1267
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
380 if (GEM_mouse_relative) { |
1310
a201a8c62522
Add flag to post mouse button events or not, and use defined function to post them
Patrice Mandin <patmandin@gmail.com>
parents:
1267
diff
changeset
|
381 SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE); |
1267
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
382 } else { |
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
383 if ((prevmousex!=mx) || (prevmousey!=my)) { |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
384 int posx, posy; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
385 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
386 /* Give mouse position relative to window position */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
387 posx = mx - x2; |
927
c5689bd09eaa
Wrong check for minimum mouse position
Patrice Mandin <patmandin@gmail.com>
parents:
926
diff
changeset
|
388 if (posx<0) posx = 0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
389 if (posx>w2) posx = w2-1; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
390 posy = my - y2; |
927
c5689bd09eaa
Wrong check for minimum mouse position
Patrice Mandin <patmandin@gmail.com>
parents:
926
diff
changeset
|
391 if (posy<0) posy = 0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
392 if (posy>h2) posy = h2-1; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
393 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
394 SDL_PrivateMouseMotion(0, 0, posx, posy); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 prevmousex = mx; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 prevmousey = my; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 /* Mouse button ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 if (prevmouseb!=mb) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 int i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
404 for (i=0;i<2;i++) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 int curbutton, prevbutton; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 curbutton = mb & (1<<i); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 prevbutton = prevmouseb & (1<<i); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
410 if (curbutton && !prevbutton) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
411 SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
413 if (!curbutton && prevbutton) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
414 SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 prevmouseb = mb; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
419 |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
420 /* Read special keys */ |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
421 if (ks & K_RSHIFT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
422 gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
423 if (ks & K_LSHIFT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
424 gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
425 if (ks & K_CTRL) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
426 gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
427 if (ks & K_ALT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
428 gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 } |