comparison src/video/dga/SDL_dgaevents.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 3ba88cb7eb1b
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
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 DGA_DispatchEvent(_THIS) 43 static int
44 DGA_DispatchEvent (_THIS)
44 { 45 {
45 int posted; 46 int posted;
46 SDL_NAME(XDGAEvent) xevent; 47 SDL_NAME (XDGAEvent) xevent;
47 48
48 XNextEvent(DGA_Display, (XEvent *)&xevent); 49 XNextEvent (DGA_Display, (XEvent *) & xevent);
49 50
50 posted = 0; 51 posted = 0;
51 xevent.type -= DGA_event_base; 52 xevent.type -= DGA_event_base;
52 switch (xevent.type) { 53 switch (xevent.type) {
53 54
54 /* Mouse motion? */ 55 /* Mouse motion? */
55 case MotionNotify: { 56 case MotionNotify:
56 if ( SDL_VideoSurface ) { 57 {
57 posted = SDL_PrivateMouseMotion(0, 1, 58 if (SDL_VideoSurface) {
58 xevent.xmotion.dx, xevent.xmotion.dy); 59 posted = SDL_PrivateMouseMotion (0, 1,
59 } 60 xevent.xmotion.dx,
60 } 61 xevent.xmotion.dy);
61 break; 62 }
63 }
64 break;
62 65
63 /* Mouse button press? */ 66 /* Mouse button press? */
64 case ButtonPress: { 67 case ButtonPress:
65 posted = SDL_PrivateMouseButton(SDL_PRESSED, 68 {
66 xevent.xbutton.button, 0, 0); 69 posted = SDL_PrivateMouseButton (SDL_PRESSED,
67 } 70 xevent.xbutton.button, 0, 0);
68 break; 71 }
72 break;
69 73
70 /* Mouse button release? */ 74 /* Mouse button release? */
71 case ButtonRelease: { 75 case ButtonRelease:
72 posted = SDL_PrivateMouseButton(SDL_RELEASED, 76 {
73 xevent.xbutton.button, 0, 0); 77 posted = SDL_PrivateMouseButton (SDL_RELEASED,
74 } 78 xevent.xbutton.button, 0, 0);
75 break; 79 }
80 break;
76 81
77 /* Key press? */ 82 /* Key press? */
78 case KeyPress: { 83 case KeyPress:
79 SDL_keysym keysym; 84 {
80 KeyCode keycode; 85 SDL_keysym keysym;
81 XKeyEvent xkey; 86 KeyCode keycode;
87 XKeyEvent xkey;
82 88
83 SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); 89 SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey);
84 keycode = xkey.keycode; 90 keycode = xkey.keycode;
85 #ifdef DEBUG_XEVENTS 91 #ifdef DEBUG_XEVENTS
86 printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); 92 printf ("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode);
87 #endif 93 #endif
88 /* Get the translated SDL virtual keysym */ 94 /* Get the translated SDL virtual keysym */
89 keysym.scancode = keycode; 95 keysym.scancode = keycode;
90 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); 96 keysym.sym = X11_TranslateKeycode (DGA_Display, keycode);
91 keysym.mod = KMOD_NONE; 97 keysym.mod = KMOD_NONE;
92 keysym.unicode = 0; 98 keysym.unicode = 0;
93 99
94 /* Look up the translated value for the key event */ 100 /* Look up the translated value for the key event */
95 if ( SDL_TranslateUNICODE ) { 101 if (SDL_TranslateUNICODE) {
96 static XComposeStatus state; 102 static XComposeStatus state;
97 char keybuf[32]; 103 char keybuf[32];
98 104
99 if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, &state) ) { 105 if (XLookupString
100 /* 106 (&xkey, keybuf, sizeof (keybuf), NULL, &state)) {
101 * FIXME: XLookupString() may yield more than one 107 /*
102 * character, so we need a mechanism to allow for 108 * FIXME: XLookupString() may yield more than one
103 * this (perhaps null keypress events with a 109 * character, so we need a mechanism to allow for
104 * unicode value) 110 * this (perhaps null keypress events with a
105 */ 111 * unicode value)
106 keysym.unicode = (Uint8)keybuf[0]; 112 */
107 } 113 keysym.unicode = (Uint8) keybuf[0];
108 } 114 }
109 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); 115 }
110 } 116 posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
111 break; 117 }
118 break;
112 119
113 /* Key release? */ 120 /* Key release? */
114 case KeyRelease: { 121 case KeyRelease:
115 SDL_keysym keysym; 122 {
116 KeyCode keycode; 123 SDL_keysym keysym;
117 XKeyEvent xkey; 124 KeyCode keycode;
125 XKeyEvent xkey;
118 126
119 SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); 127 SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey);
120 keycode = xkey.keycode; 128 keycode = xkey.keycode;
121 #ifdef DEBUG_XEVENTS 129 #ifdef DEBUG_XEVENTS
122 printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); 130 printf ("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode);
123 #endif 131 #endif
124 /* Get the translated SDL virtual keysym */ 132 /* Get the translated SDL virtual keysym */
125 keysym.scancode = keycode; 133 keysym.scancode = keycode;
126 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); 134 keysym.sym = X11_TranslateKeycode (DGA_Display, keycode);
127 keysym.mod = KMOD_NONE; 135 keysym.mod = KMOD_NONE;
128 keysym.unicode = 0; 136 keysym.unicode = 0;
129 posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); 137 posted = SDL_PrivateKeyboard (SDL_RELEASED, &keysym);
130 } 138 }
131 break; 139 break;
132 140
133 break; 141 break;
134 142
135 } 143 }
136 return(posted); 144 return (posted);
137 } 145 }
138 146
139 void DGA_PumpEvents(_THIS) 147 void
148 DGA_PumpEvents (_THIS)
140 { 149 {
141 /* Keep processing pending events */ 150 /* Keep processing pending events */
142 LOCK_DISPLAY(); 151 LOCK_DISPLAY ();
143 while ( X11_Pending(DGA_Display) ) { 152 while (X11_Pending (DGA_Display)) {
144 DGA_DispatchEvent(this); 153 DGA_DispatchEvent (this);
145 } 154 }
146 UNLOCK_DISPLAY(); 155 UNLOCK_DISPLAY ();
147 } 156 }
148 157
149 void DGA_InitOSKeymap(_THIS) 158 void
159 DGA_InitOSKeymap (_THIS)
150 { 160 {
151 X11_InitKeymap(); 161 X11_InitKeymap ();
152 } 162 }
153 163
164 /* vi: set ts=4 sw=4 expandtab: */