Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_ikbdevents.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 |
---|---|
69 static int caps_state; /* caps lock state */ | 69 static int caps_state; /* caps lock state */ |
70 _KEYTAB *curtables; | 70 _KEYTAB *curtables; |
71 static unsigned char *tab_unshift, *tab_shift, *tab_caps; | 71 static unsigned char *tab_unshift, *tab_shift, *tab_caps; |
72 static SDLKey keymap[ATARIBIOS_MAXKEYS]; | 72 static SDLKey keymap[ATARIBIOS_MAXKEYS]; |
73 | 73 |
74 static SDL_keysym *TranslateKey (int scancode, int numkeytable, | 74 static SDL_keysym *TranslateKey(int scancode, int numkeytable, |
75 SDL_keysym * keysym, SDL_bool pressed); | 75 SDL_keysym * keysym, SDL_bool pressed); |
76 | 76 |
77 void | 77 void |
78 AtariIkbd_InitOSKeymap (_THIS) | 78 AtariIkbd_InitOSKeymap(_THIS) |
79 { | 79 { |
80 int i; | 80 int i; |
81 | 81 |
82 SDL_memset (SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS); | 82 SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS); |
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; |
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 /* Read XBIOS tables for scancode -> ascii translation */ | 114 /* Read XBIOS tables for scancode -> ascii translation */ |
115 curtables = Keytbl (KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE); | 115 curtables = Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE); |
116 tab_unshift = curtables->unshift; | 116 tab_unshift = curtables->unshift; |
117 tab_shift = curtables->shift; | 117 tab_shift = curtables->shift; |
118 tab_caps = curtables->caps; | 118 tab_caps = curtables->caps; |
119 | 119 |
120 /* Set Caps lock initial state */ | 120 /* Set Caps lock initial state */ |
121 caps_state = (Kbshift (-1) & (1 << K_CAPSLOCK)); | 121 caps_state = (Kbshift(-1) & (1 << K_CAPSLOCK)); |
122 | 122 |
123 /* Now install our handler */ | 123 /* Now install our handler */ |
124 SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; | 124 SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; |
125 atari_prevmouseb = 0; | 125 atari_prevmouseb = 0; |
126 | 126 |
127 Supexec (SDL_AtariIkbdInstall); | 127 Supexec(SDL_AtariIkbdInstall); |
128 } | 128 } |
129 | 129 |
130 static int | 130 static int |
131 atari_GetButton (int button) | 131 atari_GetButton(int button) |
132 { | 132 { |
133 switch (button) { | 133 switch (button) { |
134 case 0: | 134 case 0: |
135 return SDL_BUTTON_RIGHT; | 135 return SDL_BUTTON_RIGHT; |
136 break; | 136 break; |
140 break; | 140 break; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 void | 144 void |
145 AtariIkbd_PumpEvents (_THIS) | 145 AtariIkbd_PumpEvents(_THIS) |
146 { | 146 { |
147 int i; | 147 int i; |
148 SDL_keysym keysym; | 148 SDL_keysym keysym; |
149 int specialkeys; | 149 int specialkeys; |
150 | 150 |
167 | 167 |
168 /* Now generate events */ | 168 /* Now generate events */ |
169 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { | 169 for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { |
170 /* Key pressed ? */ | 170 /* Key pressed ? */ |
171 if (SDL_AtariIkbd_keyboard[i] == KEY_PRESSED) { | 171 if (SDL_AtariIkbd_keyboard[i] == KEY_PRESSED) { |
172 SDL_PrivateKeyboard (SDL_PRESSED, | 172 SDL_PrivateKeyboard(SDL_PRESSED, |
173 TranslateKey (i, specialkeys, &keysym, | 173 TranslateKey(i, specialkeys, &keysym, |
174 SDL_TRUE)); | 174 SDL_TRUE)); |
175 SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; | 175 SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; |
176 } | 176 } |
177 | 177 |
178 /* Key released ? */ | 178 /* Key released ? */ |
179 if (SDL_AtariIkbd_keyboard[i] == KEY_RELEASED) { | 179 if (SDL_AtariIkbd_keyboard[i] == KEY_RELEASED) { |
180 SDL_PrivateKeyboard (SDL_RELEASED, | 180 SDL_PrivateKeyboard(SDL_RELEASED, |
181 TranslateKey (i, specialkeys, &keysym, | 181 TranslateKey(i, specialkeys, &keysym, |
182 SDL_FALSE)); | 182 SDL_FALSE)); |
183 SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; | 183 SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 /*--- Send mouse events ---*/ | 187 /*--- Send mouse events ---*/ |
188 | 188 |
189 /* Mouse motion ? */ | 189 /* Mouse motion ? */ |
190 if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) { | 190 if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) { |
191 SDL_PrivateMouseMotion (0, 1, SDL_AtariIkbd_mousex, | 191 SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, |
192 SDL_AtariIkbd_mousey); | 192 SDL_AtariIkbd_mousey); |
193 SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; | 193 SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; |
194 } | 194 } |
195 | 195 |
196 /* Mouse button ? */ | 196 /* Mouse button ? */ |
197 if (SDL_AtariIkbd_mouseb != atari_prevmouseb) { | 197 if (SDL_AtariIkbd_mouseb != atari_prevmouseb) { |
200 | 200 |
201 curbutton = SDL_AtariIkbd_mouseb & (1 << i); | 201 curbutton = SDL_AtariIkbd_mouseb & (1 << i); |
202 prevbutton = atari_prevmouseb & (1 << i); | 202 prevbutton = atari_prevmouseb & (1 << i); |
203 | 203 |
204 if (curbutton && !prevbutton) { | 204 if (curbutton && !prevbutton) { |
205 SDL_PrivateMouseButton (SDL_PRESSED, | 205 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); |
206 atari_GetButton (i), 0, 0); | |
207 } | 206 } |
208 if (!curbutton && prevbutton) { | 207 if (!curbutton && prevbutton) { |
209 SDL_PrivateMouseButton (SDL_RELEASED, | 208 SDL_PrivateMouseButton(SDL_RELEASED, |
210 atari_GetButton (i), 0, 0); | 209 atari_GetButton(i), 0, 0); |
211 } | 210 } |
212 } | 211 } |
213 atari_prevmouseb = SDL_AtariIkbd_mouseb; | 212 atari_prevmouseb = SDL_AtariIkbd_mouseb; |
214 } | 213 } |
215 } | 214 } |
216 | 215 |
217 static SDL_keysym * | 216 static SDL_keysym * |
218 TranslateKey (int scancode, int numkeytable, SDL_keysym * keysym, | 217 TranslateKey(int scancode, int numkeytable, SDL_keysym * keysym, |
219 SDL_bool pressed) | 218 SDL_bool pressed) |
220 { | 219 { |
221 unsigned char asciicode; | 220 unsigned char asciicode; |
222 | 221 |
223 /* Set the keysym information */ | 222 /* Set the keysym information */ |
224 keysym->scancode = scancode; | 223 keysym->scancode = scancode; |
249 | 248 |
250 return (keysym); | 249 return (keysym); |
251 } | 250 } |
252 | 251 |
253 void | 252 void |
254 AtariIkbd_ShutdownEvents (void) | 253 AtariIkbd_ShutdownEvents(void) |
255 { | 254 { |
256 Supexec (SDL_AtariIkbdUninstall); | 255 Supexec(SDL_AtariIkbdUninstall); |
257 } | 256 } |
258 | 257 |
259 /* vi: set ts=4 sw=4 expandtab: */ | 258 /* vi: set ts=4 sw=4 expandtab: */ |