Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_gemdosevents.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
66 }; | 66 }; |
67 | 67 |
68 /* The translation tables from a console scancode to a SDL keysym */ | 68 /* The translation tables from a console scancode to a SDL keysym */ |
69 static SDLKey keymap[ATARIBIOS_MAXKEYS]; | 69 static SDLKey keymap[ATARIBIOS_MAXKEYS]; |
70 | 70 |
71 static SDL_keysym *TranslateKey (int scancode, int asciicode, | 71 static SDL_keysym *TranslateKey(int scancode, int asciicode, |
72 SDL_keysym * keysym, SDL_bool pressed); | 72 SDL_keysym * keysym, SDL_bool pressed); |
73 static void UpdateSpecialKeys (int special_keys_state); | 73 static void UpdateSpecialKeys(int special_keys_state); |
74 | 74 |
75 void | 75 void |
76 AtariGemdos_InitOSKeymap (_THIS) | 76 AtariGemdos_InitOSKeymap(_THIS) |
77 { | 77 { |
78 int i, vectors_mask; | 78 int i, vectors_mask; |
79 unsigned long dummy; | 79 unsigned long dummy; |
80 | 80 |
81 SDL_memset (gemdos_currentkeyboard, 0, sizeof (gemdos_currentkeyboard)); | 81 SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard)); |
82 SDL_memset (gemdos_previouskeyboard, 0, sizeof (gemdos_previouskeyboard)); | 82 SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard)); |
83 | 83 |
84 /* Initialize keymap */ | 84 /* Initialize keymap */ |
85 for (i = 0; i < sizeof (keymap); i++) | 85 for (i = 0; i < sizeof(keymap); i++) |
86 keymap[i] = SDLK_UNKNOWN; | 86 keymap[i] = SDLK_UNKNOWN; |
87 | 87 |
88 /* Functions keys */ | 88 /* Functions keys */ |
89 for (i = 0; i < 10; i++) | 89 for (i = 0; i < 10; i++) |
90 keymap[SCANCODE_F1 + i] = SDLK_F1 + i; | 90 keymap[SCANCODE_F1 + i] = SDLK_F1 + i; |
109 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; | 109 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; |
110 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; | 110 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; |
111 keymap[SCANCODE_LEFTALT] = SDLK_LALT; | 111 keymap[SCANCODE_LEFTALT] = SDLK_LALT; |
112 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; | 112 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; |
113 | 113 |
114 use_dev_mouse = (SDL_AtariDevMouse_Open () != 0) ? SDL_TRUE : SDL_FALSE; | 114 use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; |
115 | 115 |
116 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | 116 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ |
117 if (!use_dev_mouse) { | 117 if (!use_dev_mouse) { |
118 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | 118 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ |
119 } | 119 } |
120 if (Getcookie (C_MiNT, &dummy) == C_FOUND) { | 120 if (Getcookie(C_MiNT, &dummy) == C_FOUND) { |
121 vectors_mask = 0; | 121 vectors_mask = 0; |
122 } | 122 } |
123 SDL_AtariXbios_InstallVectors (vectors_mask); | 123 SDL_AtariXbios_InstallVectors(vectors_mask); |
124 } | 124 } |
125 | 125 |
126 void | 126 void |
127 AtariGemdos_PumpEvents (_THIS) | 127 AtariGemdos_PumpEvents(_THIS) |
128 { | 128 { |
129 int i; | 129 int i; |
130 SDL_keysym keysym; | 130 SDL_keysym keysym; |
131 | 131 |
132 /* Update pressed keys */ | 132 /* Update pressed keys */ |
133 SDL_memset (gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS); | 133 SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS); |
134 | 134 |
135 while (Cconis () != DEV_BUSY) { | 135 while (Cconis() != DEV_BUSY) { |
136 unsigned long key_pressed; | 136 unsigned long key_pressed; |
137 unsigned char scancode, asciicode; | 137 unsigned char scancode, asciicode; |
138 | 138 |
139 key_pressed = Cnecin (); | 139 key_pressed = Cnecin(); |
140 | 140 |
141 asciicode = key_pressed; | 141 asciicode = key_pressed; |
142 scancode = key_pressed >> 16; | 142 scancode = key_pressed >> 16; |
143 | 143 |
144 gemdos_currentkeyboard[scancode] = 0xFF; | 144 gemdos_currentkeyboard[scancode] = 0xFF; |
145 gemdos_currentascii[scancode] = asciicode; | 145 gemdos_currentascii[scancode] = asciicode; |
146 } | 146 } |
147 | 147 |
148 /* Read special keys */ | 148 /* Read special keys */ |
149 UpdateSpecialKeys (Kbshift (-1)); | 149 UpdateSpecialKeys(Kbshift(-1)); |
150 | 150 |
151 /* Now generate events */ | 151 /* Now generate events */ |
152 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { | 152 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { |
153 /* Key pressed ? */ | 153 /* Key pressed ? */ |
154 if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i]) | 154 if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i]) |
155 SDL_PrivateKeyboard (SDL_PRESSED, | 155 SDL_PrivateKeyboard(SDL_PRESSED, |
156 TranslateKey (i, gemdos_currentascii[i], | 156 TranslateKey(i, gemdos_currentascii[i], |
157 &keysym, SDL_TRUE)); | 157 &keysym, SDL_TRUE)); |
158 | 158 |
159 /* Key unpressed ? */ | 159 /* Key unpressed ? */ |
160 if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i]) | 160 if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i]) |
161 SDL_PrivateKeyboard (SDL_RELEASED, | 161 SDL_PrivateKeyboard(SDL_RELEASED, |
162 TranslateKey (i, gemdos_currentascii[i], | 162 TranslateKey(i, gemdos_currentascii[i], |
163 &keysym, SDL_FALSE)); | 163 &keysym, SDL_FALSE)); |
164 } | 164 } |
165 | 165 |
166 if (use_dev_mouse) { | 166 if (use_dev_mouse) { |
167 SDL_AtariDevMouse_PostMouseEvents (this, SDL_TRUE); | 167 SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); |
168 } else { | 168 } else { |
169 SDL_AtariXbios_PostMouseEvents (this, SDL_TRUE); | 169 SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); |
170 } | 170 } |
171 | 171 |
172 /* Will be previous table */ | 172 /* Will be previous table */ |
173 SDL_memcpy (gemdos_previouskeyboard, gemdos_currentkeyboard, | 173 SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, |
174 ATARIBIOS_MAXKEYS); | 174 ATARIBIOS_MAXKEYS); |
175 } | 175 } |
176 | 176 |
177 static void | 177 static void |
178 UpdateSpecialKeys (int special_keys_state) | 178 UpdateSpecialKeys(int special_keys_state) |
179 { | 179 { |
180 #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ | 180 #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ |
181 { \ | 181 { \ |
182 if (special_keys_state & (1<<(numbit))) { \ | 182 if (special_keys_state & (1<<(numbit))) { \ |
183 gemdos_currentkeyboard[scancode]=0xFF; \ | 183 gemdos_currentkeyboard[scancode]=0xFF; \ |
184 gemdos_currentascii[scancode]=0; \ | 184 gemdos_currentascii[scancode]=0; \ |
185 } \ | 185 } \ |
186 } | 186 } |
187 | 187 |
188 UPDATE_SPECIAL_KEYS (K_RSHIFT, SCANCODE_RIGHTSHIFT); | 188 UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); |
189 UPDATE_SPECIAL_KEYS (K_LSHIFT, SCANCODE_LEFTSHIFT); | 189 UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); |
190 UPDATE_SPECIAL_KEYS (K_CTRL, SCANCODE_LEFTCONTROL); | 190 UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); |
191 UPDATE_SPECIAL_KEYS (K_ALT, SCANCODE_LEFTALT); | 191 UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); |
192 UPDATE_SPECIAL_KEYS (K_CAPSLOCK, SCANCODE_CAPSLOCK); | 192 UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); |
193 } | 193 } |
194 | 194 |
195 static SDL_keysym * | 195 static SDL_keysym * |
196 TranslateKey (int scancode, int asciicode, SDL_keysym * keysym, | 196 TranslateKey(int scancode, int asciicode, SDL_keysym * keysym, |
197 SDL_bool pressed) | 197 SDL_bool pressed) |
198 { | 198 { |
199 /* Set the keysym information */ | 199 /* Set the keysym information */ |
200 keysym->scancode = scancode; | 200 keysym->scancode = scancode; |
201 | 201 |
202 if (asciicode) | 202 if (asciicode) |
212 | 212 |
213 return (keysym); | 213 return (keysym); |
214 } | 214 } |
215 | 215 |
216 void | 216 void |
217 AtariGemdos_ShutdownEvents (void) | 217 AtariGemdos_ShutdownEvents(void) |
218 { | 218 { |
219 SDL_AtariXbios_RestoreVectors (); | 219 SDL_AtariXbios_RestoreVectors(); |
220 if (use_dev_mouse) { | 220 if (use_dev_mouse) { |
221 SDL_AtariDevMouse_Close (); | 221 SDL_AtariDevMouse_Close(); |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 /* vi: set ts=4 sw=4 expandtab: */ | 225 /* vi: set ts=4 sw=4 expandtab: */ |