Mercurial > sdl-ios-xcode
comparison src/video/dga/SDL_dgaevents.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 |
---|---|
34 | 34 |
35 /* get function pointers... */ | 35 /* get function pointers... */ |
36 #include "../x11/SDL_x11dyn.h" | 36 #include "../x11/SDL_x11dyn.h" |
37 | 37 |
38 /* Heheh we're using X11 event code */ | 38 /* Heheh we're using X11 event code */ |
39 extern int X11_Pending (Display * display); | 39 extern int X11_Pending(Display * display); |
40 extern void X11_InitKeymap (void); | 40 extern void X11_InitKeymap(void); |
41 extern SDLKey X11_TranslateKeycode (Display * display, KeyCode kc); | 41 extern SDLKey X11_TranslateKeycode(Display * display, KeyCode kc); |
42 | 42 |
43 static int | 43 static int |
44 DGA_DispatchEvent (_THIS) | 44 DGA_DispatchEvent(_THIS) |
45 { | 45 { |
46 int posted; | 46 int posted; |
47 SDL_NAME (XDGAEvent) xevent; | 47 SDL_NAME(XDGAEvent) xevent; |
48 | 48 |
49 XNextEvent (DGA_Display, (XEvent *) & xevent); | 49 XNextEvent(DGA_Display, (XEvent *) & xevent); |
50 | 50 |
51 posted = 0; | 51 posted = 0; |
52 xevent.type -= DGA_event_base; | 52 xevent.type -= DGA_event_base; |
53 switch (xevent.type) { | 53 switch (xevent.type) { |
54 | 54 |
55 /* Mouse motion? */ | 55 /* Mouse motion? */ |
56 case MotionNotify: | 56 case MotionNotify: |
57 { | 57 { |
58 if (SDL_VideoSurface) { | 58 if (SDL_VideoSurface) { |
59 posted = SDL_PrivateMouseMotion (0, 1, | 59 posted = SDL_PrivateMouseMotion(0, 1, |
60 xevent.xmotion.dx, | 60 xevent.xmotion.dx, |
61 xevent.xmotion.dy); | 61 xevent.xmotion.dy); |
62 } | 62 } |
63 } | 63 } |
64 break; | 64 break; |
65 | 65 |
66 /* Mouse button press? */ | 66 /* Mouse button press? */ |
67 case ButtonPress: | 67 case ButtonPress: |
68 { | 68 { |
69 posted = SDL_PrivateMouseButton (SDL_PRESSED, | 69 posted = SDL_PrivateMouseButton(SDL_PRESSED, |
70 xevent.xbutton.button, 0, 0); | 70 xevent.xbutton.button, 0, 0); |
71 } | 71 } |
72 break; | 72 break; |
73 | 73 |
74 /* Mouse button release? */ | 74 /* Mouse button release? */ |
75 case ButtonRelease: | 75 case ButtonRelease: |
76 { | 76 { |
77 posted = SDL_PrivateMouseButton (SDL_RELEASED, | 77 posted = SDL_PrivateMouseButton(SDL_RELEASED, |
78 xevent.xbutton.button, 0, 0); | 78 xevent.xbutton.button, 0, 0); |
79 } | 79 } |
80 break; | 80 break; |
81 | 81 |
82 /* Key press? */ | 82 /* Key press? */ |
83 case KeyPress: | 83 case KeyPress: |
84 { | 84 { |
85 SDL_keysym keysym; | 85 SDL_keysym keysym; |
86 KeyCode keycode; | 86 KeyCode keycode; |
87 XKeyEvent xkey; | 87 XKeyEvent xkey; |
88 | 88 |
89 SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); | 89 SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); |
90 keycode = xkey.keycode; | 90 keycode = xkey.keycode; |
91 #ifdef DEBUG_XEVENTS | 91 #ifdef DEBUG_XEVENTS |
92 printf ("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); | 92 printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); |
93 #endif | 93 #endif |
94 /* Get the translated SDL virtual keysym */ | 94 /* Get the translated SDL virtual keysym */ |
95 keysym.scancode = keycode; | 95 keysym.scancode = keycode; |
96 keysym.sym = X11_TranslateKeycode (DGA_Display, keycode); | 96 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); |
97 keysym.mod = KMOD_NONE; | 97 keysym.mod = KMOD_NONE; |
98 keysym.unicode = 0; | 98 keysym.unicode = 0; |
99 | 99 |
100 /* Look up the translated value for the key event */ | 100 /* Look up the translated value for the key event */ |
101 if (SDL_TranslateUNICODE) { | 101 if (SDL_TranslateUNICODE) { |
102 static XComposeStatus state; | 102 static XComposeStatus state; |
103 char keybuf[32]; | 103 char keybuf[32]; |
104 | 104 |
105 if (XLookupString | 105 if (XLookupString |
106 (&xkey, keybuf, sizeof (keybuf), NULL, &state)) { | 106 (&xkey, keybuf, sizeof(keybuf), NULL, &state)) { |
107 /* | 107 /* |
108 * FIXME: XLookupString() may yield more than one | 108 * FIXME: XLookupString() may yield more than one |
109 * character, so we need a mechanism to allow for | 109 * character, so we need a mechanism to allow for |
110 * this (perhaps null keypress events with a | 110 * this (perhaps null keypress events with a |
111 * unicode value) | 111 * unicode value) |
112 */ | 112 */ |
113 keysym.unicode = (Uint8) keybuf[0]; | 113 keysym.unicode = (Uint8) keybuf[0]; |
114 } | 114 } |
115 } | 115 } |
116 posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym); | 116 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
117 } | 117 } |
118 break; | 118 break; |
119 | 119 |
120 /* Key release? */ | 120 /* Key release? */ |
121 case KeyRelease: | 121 case KeyRelease: |
122 { | 122 { |
123 SDL_keysym keysym; | 123 SDL_keysym keysym; |
124 KeyCode keycode; | 124 KeyCode keycode; |
125 XKeyEvent xkey; | 125 XKeyEvent xkey; |
126 | 126 |
127 SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); | 127 SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); |
128 keycode = xkey.keycode; | 128 keycode = xkey.keycode; |
129 #ifdef DEBUG_XEVENTS | 129 #ifdef DEBUG_XEVENTS |
130 printf ("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); | 130 printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); |
131 #endif | 131 #endif |
132 /* Get the translated SDL virtual keysym */ | 132 /* Get the translated SDL virtual keysym */ |
133 keysym.scancode = keycode; | 133 keysym.scancode = keycode; |
134 keysym.sym = X11_TranslateKeycode (DGA_Display, keycode); | 134 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); |
135 keysym.mod = KMOD_NONE; | 135 keysym.mod = KMOD_NONE; |
136 keysym.unicode = 0; | 136 keysym.unicode = 0; |
137 posted = SDL_PrivateKeyboard (SDL_RELEASED, &keysym); | 137 posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); |
138 } | 138 } |
139 break; | 139 break; |
140 | 140 |
141 break; | 141 break; |
142 | 142 |
143 } | 143 } |
144 return (posted); | 144 return (posted); |
145 } | 145 } |
146 | 146 |
147 void | 147 void |
148 DGA_PumpEvents (_THIS) | 148 DGA_PumpEvents(_THIS) |
149 { | 149 { |
150 /* Keep processing pending events */ | 150 /* Keep processing pending events */ |
151 LOCK_DISPLAY (); | 151 LOCK_DISPLAY(); |
152 while (X11_Pending (DGA_Display)) { | 152 while (X11_Pending(DGA_Display)) { |
153 DGA_DispatchEvent (this); | 153 DGA_DispatchEvent(this); |
154 } | 154 } |
155 UNLOCK_DISPLAY (); | 155 UNLOCK_DISPLAY(); |
156 } | 156 } |
157 | 157 |
158 void | 158 void |
159 DGA_InitOSKeymap (_THIS) | 159 DGA_InitOSKeymap(_THIS) |
160 { | 160 { |
161 X11_InitKeymap (); | 161 X11_InitKeymap(); |
162 } | 162 } |
163 | 163 |
164 /* vi: set ts=4 sw=4 expandtab: */ | 164 /* vi: set ts=4 sw=4 expandtab: */ |