Mercurial > sdl-ios-xcode
comparison src/video/ggi/SDL_ggievents.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 |
---|---|
40 #include "SDL_ggivideo.h" | 40 #include "SDL_ggivideo.h" |
41 #include "SDL_ggievents_c.h" | 41 #include "SDL_ggievents_c.h" |
42 | 42 |
43 /* The translation tables from a GGI keycode to a SDL keysym */ | 43 /* The translation tables from a GGI keycode to a SDL keysym */ |
44 static SDLKey keymap[128]; | 44 static SDLKey keymap[128]; |
45 static SDL_keysym *GGI_TranslateKey (ggi_event * ev, SDL_keysym * keysym); | 45 static SDL_keysym *GGI_TranslateKey(ggi_event * ev, SDL_keysym * keysym); |
46 | 46 |
47 static int posted = 0; | 47 static int posted = 0; |
48 | 48 |
49 void | 49 void |
50 GGI_PumpEvents (_THIS) | 50 GGI_PumpEvents(_THIS) |
51 { | 51 { |
52 struct timeval *tvp, tv = { 0, 0 }; | 52 struct timeval *tvp, tv = { 0, 0 }; |
53 ggi_event ev; | 53 ggi_event ev; |
54 | 54 |
55 tvp = &tv; | 55 tvp = &tv; |
56 | 56 |
57 /* ggiFlush(VIS); */ | 57 /* ggiFlush(VIS); */ |
58 | 58 |
59 while (ggiEventPoll (VIS, emAll, tvp)) | 59 while (ggiEventPoll(VIS, emAll, tvp)) |
60 /* while (ggiEventPoll(VIS, (emKeyboard | emPointer | emCommand), tvp)) */ | 60 /* while (ggiEventPoll(VIS, (emKeyboard | emPointer | emCommand), tvp)) */ |
61 { | 61 { |
62 int queueevent_mouse = 0, queueevent_kbd = 0; | 62 int queueevent_mouse = 0, queueevent_kbd = 0; |
63 static int buttons = 0; | 63 static int buttons = 0; |
64 static int mouse_x = 0, mouse_y = 0, mouse_z = 0; | 64 static int mouse_x = 0, mouse_y = 0, mouse_z = 0; |
71 | 71 |
72 /* FIXME: We do not actually want all events, only | 72 /* FIXME: We do not actually want all events, only |
73 * mouse and keyboard events. Having to handle all | 73 * mouse and keyboard events. Having to handle all |
74 * events will slow things down. */ | 74 * events will slow things down. */ |
75 | 75 |
76 ggiEventRead (VIS, &ev, emAll); | 76 ggiEventRead(VIS, &ev, emAll); |
77 /* ggiEventRead(VIS, &ev, (emKeyboard | emPointer | emCommand)); */ | 77 /* ggiEventRead(VIS, &ev, (emKeyboard | emPointer | emCommand)); */ |
78 | 78 |
79 switch (ev.any.type) { | 79 switch (ev.any.type) { |
80 case evPtrRelative: | 80 case evPtrRelative: |
81 x = ev.pmove.x; | 81 x = ev.pmove.x; |
82 y = ev.pmove.y; | 82 y = ev.pmove.y; |
83 z = ev.pmove.wheel; | 83 z = ev.pmove.wheel; |
84 posted += SDL_PrivateMouseMotion (0, 1, x, y); | 84 posted += SDL_PrivateMouseMotion(0, 1, x, y); |
85 break; | 85 break; |
86 case evPtrAbsolute: | 86 case evPtrAbsolute: |
87 if (mouse_x != ev.pmove.x || mouse_y != ev.pmove.y | 87 if (mouse_x != ev.pmove.x || mouse_y != ev.pmove.y |
88 || mouse_z != ev.pmove.wheel) { | 88 || mouse_z != ev.pmove.wheel) { |
89 x = ev.pmove.x - mouse_x; | 89 x = ev.pmove.x - mouse_x; |
90 y = ev.pmove.y - mouse_y; | 90 y = ev.pmove.y - mouse_y; |
91 z = ev.pmove.wheel - mouse_z; | 91 z = ev.pmove.wheel - mouse_z; |
92 mouse_x = ev.pmove.x; | 92 mouse_x = ev.pmove.x; |
93 mouse_y = ev.pmove.y; | 93 mouse_y = ev.pmove.y; |
94 mouse_z = ev.pmove.wheel; | 94 mouse_z = ev.pmove.wheel; |
95 posted += SDL_PrivateMouseMotion (0, 1, x, y); | 95 posted += SDL_PrivateMouseMotion(0, 1, x, y); |
96 } | 96 } |
97 break; | 97 break; |
98 case evPtrButtonPress: | 98 case evPtrButtonPress: |
99 posted += | 99 posted += |
100 SDL_PrivateMouseButton (SDL_PRESSED, ev.pbutton.button, 0, 0); | 100 SDL_PrivateMouseButton(SDL_PRESSED, ev.pbutton.button, 0, 0); |
101 break; | 101 break; |
102 case evPtrButtonRelease: | 102 case evPtrButtonRelease: |
103 posted += | 103 posted += |
104 SDL_PrivateMouseButton (SDL_RELEASED, ev.pbutton.button, | 104 SDL_PrivateMouseButton(SDL_RELEASED, ev.pbutton.button, 0, 0); |
105 0, 0); | |
106 break; | 105 break; |
107 case evKeyPress: | 106 case evKeyPress: |
108 case evKeyRepeat: | 107 case evKeyRepeat: |
109 posted += | 108 posted += |
110 SDL_PrivateKeyboard (SDL_PRESSED, | 109 SDL_PrivateKeyboard(SDL_PRESSED, |
111 GGI_TranslateKey (&ev, &keysym)); | 110 GGI_TranslateKey(&ev, &keysym)); |
112 break; | 111 break; |
113 case evKeyRelease: | 112 case evKeyRelease: |
114 posted += | 113 posted += |
115 SDL_PrivateKeyboard (SDL_RELEASED, | 114 SDL_PrivateKeyboard(SDL_RELEASED, |
116 GGI_TranslateKey (&ev, &keysym)); | 115 GGI_TranslateKey(&ev, &keysym)); |
117 break; | 116 break; |
118 case evCommand: | 117 case evCommand: |
119 fprintf (stderr, "Command event %x recieved\n", ev.cmd.code); | 118 fprintf(stderr, "Command event %x recieved\n", ev.cmd.code); |
120 break; | 119 break; |
121 default: | 120 default: |
122 fprintf (stderr, "Unhandled event type %d\n", ev.any.type); | 121 fprintf(stderr, "Unhandled event type %d\n", ev.any.type); |
123 break; | 122 break; |
124 } | 123 } |
125 } | 124 } |
126 | 125 |
127 } | 126 } |
128 | 127 |
129 void | 128 void |
130 GGI_InitOSKeymap (_THIS) | 129 GGI_InitOSKeymap(_THIS) |
131 { | 130 { |
132 int i; | 131 int i; |
133 | 132 |
134 /* Initialize the GGI key translation table */ | 133 /* Initialize the GGI key translation table */ |
135 for (i = 0; i < SDL_arraysize (keymap); ++i) | 134 for (i = 0; i < SDL_arraysize(keymap); ++i) |
136 keymap[i] = SDLK_UNKNOWN; | 135 keymap[i] = SDLK_UNKNOWN; |
137 | 136 |
138 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; | 137 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; |
139 keymap[SCANCODE_1] = SDLK_1; | 138 keymap[SCANCODE_1] = SDLK_1; |
140 keymap[SCANCODE_2] = SDLK_2; | 139 keymap[SCANCODE_2] = SDLK_2; |
254 } | 253 } |
255 | 254 |
256 | 255 |
257 | 256 |
258 static SDL_keysym * | 257 static SDL_keysym * |
259 GGI_TranslateKey (gii_event * ev, SDL_keysym * keysym) | 258 GGI_TranslateKey(gii_event * ev, SDL_keysym * keysym) |
260 { | 259 { |
261 /* Set the keysym information */ | 260 /* Set the keysym information */ |
262 keysym->scancode = ev->key.button; | 261 keysym->scancode = ev->key.button; |
263 keysym->sym = keymap[ev->key.button]; | 262 keysym->sym = keymap[ev->key.button]; |
264 keysym->mod = KMOD_NONE; | 263 keysym->mod = KMOD_NONE; |
265 | 264 |
266 /* If UNICODE is on, get the UNICODE value for the key */ | 265 /* If UNICODE is on, get the UNICODE value for the key */ |
267 keysym->unicode = 0; | 266 keysym->unicode = 0; |
268 if (SDL_TranslateUNICODE) { | 267 if (SDL_TranslateUNICODE) { |
269 keysym->unicode = GII_UNICODE (ev->key.sym); | 268 keysym->unicode = GII_UNICODE(ev->key.sym); |
270 } | 269 } |
271 | 270 |
272 return keysym; | 271 return keysym; |
273 } | 272 } |
274 | 273 |