Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_biosevents.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 |
---|---|
60 }; | 60 }; |
61 | 61 |
62 /* The translation tables from a console scancode to a SDL keysym */ | 62 /* The translation tables from a console scancode to a SDL keysym */ |
63 static SDLKey keymap[ATARIBIOS_MAXKEYS]; | 63 static SDLKey keymap[ATARIBIOS_MAXKEYS]; |
64 | 64 |
65 static SDL_keysym *TranslateKey (int scancode, int asciicode, | 65 static SDL_keysym *TranslateKey(int scancode, int asciicode, |
66 SDL_keysym * keysym, SDL_bool pressed); | 66 SDL_keysym * keysym, SDL_bool pressed); |
67 static void UpdateSpecialKeys (int special_keys_state); | 67 static void UpdateSpecialKeys(int special_keys_state); |
68 | 68 |
69 void | 69 void |
70 AtariBios_InitOSKeymap (_THIS) | 70 AtariBios_InitOSKeymap(_THIS) |
71 { | 71 { |
72 int i, vectors_mask; | 72 int i, vectors_mask; |
73 unsigned long dummy; | 73 unsigned long dummy; |
74 | 74 |
75 SDL_memset (bios_currentkeyboard, 0, sizeof (bios_currentkeyboard)); | 75 SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard)); |
76 SDL_memset (bios_previouskeyboard, 0, sizeof (bios_previouskeyboard)); | 76 SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard)); |
77 | 77 |
78 /* Initialize keymap */ | 78 /* Initialize keymap */ |
79 for (i = 0; i < sizeof (keymap); i++) | 79 for (i = 0; i < sizeof(keymap); i++) |
80 keymap[i] = SDLK_UNKNOWN; | 80 keymap[i] = SDLK_UNKNOWN; |
81 | 81 |
82 /* Functions keys */ | 82 /* Functions keys */ |
83 for (i = 0; i < 10; i++) | 83 for (i = 0; i < 10; i++) |
84 keymap[SCANCODE_F1 + i] = SDLK_F1 + i; | 84 keymap[SCANCODE_F1 + i] = SDLK_F1 + i; |
103 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; | 103 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; |
104 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; | 104 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; |
105 keymap[SCANCODE_LEFTALT] = SDLK_LALT; | 105 keymap[SCANCODE_LEFTALT] = SDLK_LALT; |
106 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; | 106 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; |
107 | 107 |
108 use_dev_mouse = (SDL_AtariDevMouse_Open () != 0) ? SDL_TRUE : SDL_FALSE; | 108 use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; |
109 | 109 |
110 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | 110 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ |
111 if (!use_dev_mouse) { | 111 if (!use_dev_mouse) { |
112 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | 112 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ |
113 } | 113 } |
114 if (Getcookie (C_MiNT, &dummy) == C_FOUND) { | 114 if (Getcookie(C_MiNT, &dummy) == C_FOUND) { |
115 vectors_mask = 0; | 115 vectors_mask = 0; |
116 } | 116 } |
117 | 117 |
118 SDL_AtariXbios_InstallVectors (vectors_mask); | 118 SDL_AtariXbios_InstallVectors(vectors_mask); |
119 } | 119 } |
120 | 120 |
121 void | 121 void |
122 AtariBios_PumpEvents (_THIS) | 122 AtariBios_PumpEvents(_THIS) |
123 { | 123 { |
124 int i; | 124 int i; |
125 SDL_keysym keysym; | 125 SDL_keysym keysym; |
126 | 126 |
127 /* Update pressed keys */ | 127 /* Update pressed keys */ |
128 SDL_memset (bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); | 128 SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); |
129 | 129 |
130 while (Bconstat (_CON)) { | 130 while (Bconstat(_CON)) { |
131 unsigned long key_pressed; | 131 unsigned long key_pressed; |
132 unsigned char asciicode, scancode; | 132 unsigned char asciicode, scancode; |
133 | 133 |
134 key_pressed = Bconin (_CON); | 134 key_pressed = Bconin(_CON); |
135 | 135 |
136 asciicode = key_pressed; | 136 asciicode = key_pressed; |
137 scancode = key_pressed >> 16; | 137 scancode = key_pressed >> 16; |
138 | 138 |
139 bios_currentkeyboard[scancode] = 0xFF; | 139 bios_currentkeyboard[scancode] = 0xFF; |
140 bios_currentascii[scancode] = asciicode; | 140 bios_currentascii[scancode] = asciicode; |
141 } | 141 } |
142 | 142 |
143 /* Read special keys */ | 143 /* Read special keys */ |
144 UpdateSpecialKeys (Kbshift (-1)); | 144 UpdateSpecialKeys(Kbshift(-1)); |
145 | 145 |
146 /* Now generate events */ | 146 /* Now generate events */ |
147 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { | 147 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { |
148 /* Key pressed ? */ | 148 /* Key pressed ? */ |
149 if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) | 149 if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) |
150 SDL_PrivateKeyboard (SDL_PRESSED, | 150 SDL_PrivateKeyboard(SDL_PRESSED, |
151 TranslateKey (i, bios_currentascii[i], | 151 TranslateKey(i, bios_currentascii[i], |
152 &keysym, SDL_TRUE)); | 152 &keysym, SDL_TRUE)); |
153 | 153 |
154 /* Key unpressed ? */ | 154 /* Key unpressed ? */ |
155 if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) | 155 if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) |
156 SDL_PrivateKeyboard (SDL_RELEASED, | 156 SDL_PrivateKeyboard(SDL_RELEASED, |
157 TranslateKey (i, bios_currentascii[i], | 157 TranslateKey(i, bios_currentascii[i], |
158 &keysym, SDL_FALSE)); | 158 &keysym, SDL_FALSE)); |
159 } | 159 } |
160 | 160 |
161 if (use_dev_mouse) { | 161 if (use_dev_mouse) { |
162 SDL_AtariDevMouse_PostMouseEvents (this, SDL_TRUE); | 162 SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); |
163 } else { | 163 } else { |
164 SDL_AtariXbios_PostMouseEvents (this, SDL_TRUE); | 164 SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); |
165 } | 165 } |
166 | 166 |
167 /* Will be previous table */ | 167 /* Will be previous table */ |
168 SDL_memcpy (bios_previouskeyboard, bios_currentkeyboard, | 168 SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, |
169 ATARIBIOS_MAXKEYS); | 169 ATARIBIOS_MAXKEYS); |
170 } | 170 } |
171 | 171 |
172 static void | 172 static void |
173 UpdateSpecialKeys (int special_keys_state) | 173 UpdateSpecialKeys(int special_keys_state) |
174 { | 174 { |
175 #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ | 175 #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ |
176 { \ | 176 { \ |
177 if (special_keys_state & (1<<(numbit))) { \ | 177 if (special_keys_state & (1<<(numbit))) { \ |
178 bios_currentkeyboard[scancode]=0xFF; \ | 178 bios_currentkeyboard[scancode]=0xFF; \ |
179 bios_currentascii[scancode]=0; \ | 179 bios_currentascii[scancode]=0; \ |
180 } \ | 180 } \ |
181 } | 181 } |
182 | 182 |
183 UPDATE_SPECIAL_KEYS (K_RSHIFT, SCANCODE_RIGHTSHIFT); | 183 UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); |
184 UPDATE_SPECIAL_KEYS (K_LSHIFT, SCANCODE_LEFTSHIFT); | 184 UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); |
185 UPDATE_SPECIAL_KEYS (K_CTRL, SCANCODE_LEFTCONTROL); | 185 UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); |
186 UPDATE_SPECIAL_KEYS (K_ALT, SCANCODE_LEFTALT); | 186 UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); |
187 UPDATE_SPECIAL_KEYS (K_CAPSLOCK, SCANCODE_CAPSLOCK); | 187 UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); |
188 } | 188 } |
189 | 189 |
190 static SDL_keysym * | 190 static SDL_keysym * |
191 TranslateKey (int scancode, int asciicode, SDL_keysym * keysym, | 191 TranslateKey(int scancode, int asciicode, SDL_keysym * keysym, |
192 SDL_bool pressed) | 192 SDL_bool pressed) |
193 { | 193 { |
194 /* Set the keysym information */ | 194 /* Set the keysym information */ |
195 keysym->scancode = scancode; | 195 keysym->scancode = scancode; |
196 | 196 |
197 if (asciicode) | 197 if (asciicode) |
207 | 207 |
208 return (keysym); | 208 return (keysym); |
209 } | 209 } |
210 | 210 |
211 void | 211 void |
212 AtariBios_ShutdownEvents (void) | 212 AtariBios_ShutdownEvents(void) |
213 { | 213 { |
214 SDL_AtariXbios_RestoreVectors (); | 214 SDL_AtariXbios_RestoreVectors(); |
215 if (use_dev_mouse) { | 215 if (use_dev_mouse) { |
216 SDL_AtariDevMouse_Close (); | 216 SDL_AtariDevMouse_Close(); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 /* vi: set ts=4 sw=4 expandtab: */ | 220 /* vi: set ts=4 sw=4 expandtab: */ |