Mercurial > sdl-ios-xcode
comparison src/video/dc/SDL_dcevents.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 | 11134dc42da8 |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
29 | 29 |
30 #include <dc/maple.h> | 30 #include <dc/maple.h> |
31 #include <dc/maple/mouse.h> | 31 #include <dc/maple/mouse.h> |
32 #include <dc/maple/keyboard.h> | 32 #include <dc/maple/keyboard.h> |
33 | 33 |
34 const static unsigned short sdl_key[]= { | 34 const static unsigned short sdl_key[] = { |
35 /*0*/ 0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', | 35 /*0 */ 0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', |
36 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', | 36 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', |
37 'u', 'v', 'w', 'x', 'y', 'z', | 37 'u', 'v', 'w', 'x', 'y', 'z', |
38 /*1e*/ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', | 38 /*1e */ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', |
39 /*28*/ SDLK_RETURN, SDLK_ESCAPE, SDLK_BACKSPACE, SDLK_TAB, SDLK_SPACE, SDLK_MINUS, SDLK_PLUS, SDLK_LEFTBRACKET, | 39 /*28 */ SDLK_RETURN, SDLK_ESCAPE, SDLK_BACKSPACE, SDLK_TAB, SDLK_SPACE, |
40 SDLK_RIGHTBRACKET, SDLK_BACKSLASH , 0, SDLK_SEMICOLON, SDLK_QUOTE, | 40 SDLK_MINUS, SDLK_PLUS, SDLK_LEFTBRACKET, |
41 /*35*/ '~', SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_CAPSLOCK, | 41 SDLK_RIGHTBRACKET, SDLK_BACKSLASH, 0, SDLK_SEMICOLON, SDLK_QUOTE, |
42 SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12, | 42 /*35 */ '~', SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_CAPSLOCK, |
43 /*46*/ SDLK_PRINT, SDLK_SCROLLOCK, SDLK_PAUSE, SDLK_INSERT, SDLK_HOME, SDLK_PAGEUP, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN, SDLK_RIGHT, SDLK_LEFT, SDLK_DOWN, SDLK_UP, | 43 SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, |
44 /*53*/ SDLK_NUMLOCK, SDLK_KP_DIVIDE, SDLK_KP_MULTIPLY, SDLK_KP_MINUS, SDLK_KP_PLUS, SDLK_KP_ENTER, | 44 SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12, |
45 SDLK_KP1, SDLK_KP2, SDLK_KP3, SDLK_KP4, SDLK_KP5, SDLK_KP6, | 45 /*46 */ SDLK_PRINT, SDLK_SCROLLOCK, SDLK_PAUSE, SDLK_INSERT, SDLK_HOME, |
46 /*5f*/ SDLK_KP7, SDLK_KP8, SDLK_KP9, SDLK_KP0, SDLK_KP_PERIOD, 0 /* S3 */ | 46 SDLK_PAGEUP, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN, SDLK_RIGHT, |
47 SDLK_LEFT, SDLK_DOWN, SDLK_UP, | |
48 /*53 */ SDLK_NUMLOCK, SDLK_KP_DIVIDE, SDLK_KP_MULTIPLY, SDLK_KP_MINUS, | |
49 SDLK_KP_PLUS, SDLK_KP_ENTER, | |
50 SDLK_KP1, SDLK_KP2, SDLK_KP3, SDLK_KP4, SDLK_KP5, SDLK_KP6, | |
51 /*5f */ SDLK_KP7, SDLK_KP8, SDLK_KP9, SDLK_KP0, SDLK_KP_PERIOD, 0 | |
52 /* S3 */ | |
47 }; | 53 }; |
48 | 54 |
49 const static unsigned short sdl_shift[] = { | 55 const static unsigned short sdl_shift[] = { |
50 SDLK_LCTRL,SDLK_LSHIFT,SDLK_LALT,0 /* S1 */, | 56 SDLK_LCTRL, SDLK_LSHIFT, SDLK_LALT, 0 /* S1 */ , |
51 SDLK_RCTRL,SDLK_RSHIFT,SDLK_RALT,0 /* S2 */, | 57 SDLK_RCTRL, SDLK_RSHIFT, SDLK_RALT, 0 /* S2 */ , |
52 }; | 58 }; |
53 | 59 |
54 #define MOUSE_WHEELUP (1<<4) | 60 #define MOUSE_WHEELUP (1<<4) |
55 #define MOUSE_WHEELDOWN (1<<5) | 61 #define MOUSE_WHEELDOWN (1<<5) |
56 | 62 |
57 static void mouse_update(void) | 63 static void |
64 mouse_update (void) | |
58 { | 65 { |
59 const static char sdl_mousebtn[] = { | 66 const static char sdl_mousebtn[] = { |
60 MOUSE_LEFTBUTTON, | 67 MOUSE_LEFTBUTTON, |
61 MOUSE_RIGHTBUTTON, | 68 MOUSE_RIGHTBUTTON, |
62 MOUSE_SIDEBUTTON, | 69 MOUSE_SIDEBUTTON, |
63 MOUSE_WHEELUP, | 70 MOUSE_WHEELUP, |
64 MOUSE_WHEELDOWN | 71 MOUSE_WHEELDOWN |
65 }; | 72 }; |
66 | 73 |
67 uint8 addr; | 74 uint8 addr; |
68 mouse_cond_t cond; | 75 mouse_cond_t cond; |
69 | 76 |
70 static int prev_buttons; | 77 static int prev_buttons; |
71 int buttons,changed; | 78 int buttons, changed; |
72 int i; | 79 int i; |
73 | 80 |
74 if ((addr = maple_first_mouse())==0 || mouse_get_cond(addr, &cond)<0) return; | 81 if ((addr = maple_first_mouse ()) == 0 |
82 || mouse_get_cond (addr, &cond) < 0) | |
83 return; | |
75 | 84 |
76 buttons = cond.buttons^0xff; | 85 buttons = cond.buttons ^ 0xff; |
77 if (cond.dz<0) buttons|=MOUSE_WHEELUP; | 86 if (cond.dz < 0) |
78 if (cond.dz>0) buttons|=MOUSE_WHEELDOWN; | 87 buttons |= MOUSE_WHEELUP; |
88 if (cond.dz > 0) | |
89 buttons |= MOUSE_WHEELDOWN; | |
79 | 90 |
80 if (cond.dx||cond.dy) SDL_PrivateMouseMotion(0,1,cond.dx,cond.dy); | 91 if (cond.dx || cond.dy) |
92 SDL_PrivateMouseMotion (0, 1, cond.dx, cond.dy); | |
81 | 93 |
82 changed = buttons^prev_buttons; | 94 changed = buttons ^ prev_buttons; |
83 for(i=0;i<sizeof(sdl_mousebtn);i++) { | 95 for (i = 0; i < sizeof (sdl_mousebtn); i++) { |
84 if (changed & sdl_mousebtn[i]) { | 96 if (changed & sdl_mousebtn[i]) { |
85 SDL_PrivateMouseButton((buttons & sdl_mousebtn[i])?SDL_PRESSED:SDL_RELEASED,i,0,0); | 97 SDL_PrivateMouseButton ((buttons & sdl_mousebtn[i]) ? |
86 } | 98 SDL_PRESSED : SDL_RELEASED, i, 0, 0); |
87 } | 99 } |
88 prev_buttons = buttons; | 100 } |
101 prev_buttons = buttons; | |
89 } | 102 } |
90 | 103 |
91 static void keyboard_update(void) | 104 static void |
105 keyboard_update (void) | |
92 { | 106 { |
93 static kbd_state_t old_state; | 107 static kbd_state_t old_state; |
94 static uint8 old_addr; | 108 static uint8 old_addr; |
95 | 109 |
96 kbd_state_t *state; | 110 kbd_state_t *state; |
97 uint8 addr; | 111 uint8 addr; |
98 int port,unit; | 112 int port, unit; |
99 | 113 |
100 int shiftkeys; | 114 int shiftkeys; |
101 SDL_keysym keysym; | 115 SDL_keysym keysym; |
102 | 116 |
103 int i; | 117 int i; |
104 | 118 |
105 addr = maple_first_kb(); | 119 addr = maple_first_kb (); |
106 | 120 |
107 if (addr==0) return; | 121 if (addr == 0) |
122 return; | |
108 | 123 |
109 if (addr!=old_addr) { | 124 if (addr != old_addr) { |
110 old_addr = addr; | 125 old_addr = addr; |
111 SDL_memset(&old_state,0,sizeof(old_state)); | 126 SDL_memset (&old_state, 0, sizeof (old_state)); |
112 } | 127 } |
113 | 128 |
114 maple_raddr(addr,&port,&unit); | 129 maple_raddr (addr, &port, &unit); |
115 | 130 |
116 state = maple_dev_state(port,unit); | 131 state = maple_dev_state (port, unit); |
117 if (!state) return; | 132 if (!state) |
133 return; | |
118 | 134 |
119 shiftkeys = state->shift_keys ^ old_state.shift_keys; | 135 shiftkeys = state->shift_keys ^ old_state.shift_keys; |
120 for(i=0;i<sizeof(sdl_shift);i++) { | 136 for (i = 0; i < sizeof (sdl_shift); i++) { |
121 if ((shiftkeys>>i)&1) { | 137 if ((shiftkeys >> i) & 1) { |
122 keysym.sym = sdl_shift[i]; | 138 keysym.sym = sdl_shift[i]; |
123 SDL_PrivateKeyboard(((state->shift_keys>>i)&1)?SDL_PRESSED:SDL_RELEASED,&keysym); | 139 SDL_PrivateKeyboard (((state-> |
124 } | 140 shift_keys >> i) & 1) ? SDL_PRESSED : |
125 } | 141 SDL_RELEASED, &keysym); |
142 } | |
143 } | |
126 | 144 |
127 for(i=0;i<sizeof(sdl_key);i++) { | 145 for (i = 0; i < sizeof (sdl_key); i++) { |
128 if (state->matrix[i]!=old_state.matrix[i]) { | 146 if (state->matrix[i] != old_state.matrix[i]) { |
129 int key = sdl_key[i]; | 147 int key = sdl_key[i]; |
130 if (key) { | 148 if (key) { |
131 keysym.sym = key; | 149 keysym.sym = key; |
132 SDL_PrivateKeyboard(state->matrix[i]?SDL_PRESSED:SDL_RELEASED,&keysym); | 150 SDL_PrivateKeyboard (state-> |
133 } | 151 matrix[i] ? SDL_PRESSED : |
134 } | 152 SDL_RELEASED, &keysym); |
135 } | 153 } |
154 } | |
155 } | |
136 | 156 |
137 old_state = *state; | 157 old_state = *state; |
138 } | 158 } |
139 | 159 |
140 void DC_PumpEvents(_THIS) | 160 void |
161 DC_PumpEvents (_THIS) | |
141 { | 162 { |
142 keyboard_update(); | 163 keyboard_update (); |
143 mouse_update(); | 164 mouse_update (); |
144 } | 165 } |
145 | 166 |
146 void DC_InitOSKeymap(_THIS) | 167 void |
168 DC_InitOSKeymap (_THIS) | |
147 { | 169 { |
148 /* do nothing. */ | 170 /* do nothing. */ |
149 } | 171 } |
150 | 172 |
151 /* end of SDL_dcevents.c ... */ | 173 /* end of SDL_dcevents.c ... */ |
152 | 174 /* vi: set ts=4 sw=4 expandtab: */ |