comparison src/video/dc/SDL_dcevents.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
59 59
60 #define MOUSE_WHEELUP (1<<4) 60 #define MOUSE_WHEELUP (1<<4)
61 #define MOUSE_WHEELDOWN (1<<5) 61 #define MOUSE_WHEELDOWN (1<<5)
62 62
63 static void 63 static void
64 mouse_update (void) 64 mouse_update(void)
65 { 65 {
66 const static char sdl_mousebtn[] = { 66 const static char sdl_mousebtn[] = {
67 MOUSE_LEFTBUTTON, 67 MOUSE_LEFTBUTTON,
68 MOUSE_RIGHTBUTTON, 68 MOUSE_RIGHTBUTTON,
69 MOUSE_SIDEBUTTON, 69 MOUSE_SIDEBUTTON,
76 76
77 static int prev_buttons; 77 static int prev_buttons;
78 int buttons, changed; 78 int buttons, changed;
79 int i; 79 int i;
80 80
81 if ((addr = maple_first_mouse ()) == 0 81 if ((addr = maple_first_mouse()) == 0 || mouse_get_cond(addr, &cond) < 0)
82 || mouse_get_cond (addr, &cond) < 0)
83 return; 82 return;
84 83
85 buttons = cond.buttons ^ 0xff; 84 buttons = cond.buttons ^ 0xff;
86 if (cond.dz < 0) 85 if (cond.dz < 0)
87 buttons |= MOUSE_WHEELUP; 86 buttons |= MOUSE_WHEELUP;
88 if (cond.dz > 0) 87 if (cond.dz > 0)
89 buttons |= MOUSE_WHEELDOWN; 88 buttons |= MOUSE_WHEELDOWN;
90 89
91 if (cond.dx || cond.dy) 90 if (cond.dx || cond.dy)
92 SDL_PrivateMouseMotion (0, 1, cond.dx, cond.dy); 91 SDL_PrivateMouseMotion(0, 1, cond.dx, cond.dy);
93 92
94 changed = buttons ^ prev_buttons; 93 changed = buttons ^ prev_buttons;
95 for (i = 0; i < sizeof (sdl_mousebtn); i++) { 94 for (i = 0; i < sizeof(sdl_mousebtn); i++) {
96 if (changed & sdl_mousebtn[i]) { 95 if (changed & sdl_mousebtn[i]) {
97 SDL_PrivateMouseButton ((buttons & sdl_mousebtn[i]) ? 96 SDL_PrivateMouseButton((buttons & sdl_mousebtn[i]) ?
98 SDL_PRESSED : SDL_RELEASED, i, 0, 0); 97 SDL_PRESSED : SDL_RELEASED, i, 0, 0);
99 } 98 }
100 } 99 }
101 prev_buttons = buttons; 100 prev_buttons = buttons;
102 } 101 }
103 102
104 static void 103 static void
105 keyboard_update (void) 104 keyboard_update(void)
106 { 105 {
107 static kbd_state_t old_state; 106 static kbd_state_t old_state;
108 static uint8 old_addr; 107 static uint8 old_addr;
109 108
110 kbd_state_t *state; 109 kbd_state_t *state;
114 int shiftkeys; 113 int shiftkeys;
115 SDL_keysym keysym; 114 SDL_keysym keysym;
116 115
117 int i; 116 int i;
118 117
119 addr = maple_first_kb (); 118 addr = maple_first_kb();
120 119
121 if (addr == 0) 120 if (addr == 0)
122 return; 121 return;
123 122
124 if (addr != old_addr) { 123 if (addr != old_addr) {
125 old_addr = addr; 124 old_addr = addr;
126 SDL_memset (&old_state, 0, sizeof (old_state)); 125 SDL_memset(&old_state, 0, sizeof(old_state));
127 } 126 }
128 127
129 maple_raddr (addr, &port, &unit); 128 maple_raddr(addr, &port, &unit);
130 129
131 state = maple_dev_state (port, unit); 130 state = maple_dev_state(port, unit);
132 if (!state) 131 if (!state)
133 return; 132 return;
134 133
135 shiftkeys = state->shift_keys ^ old_state.shift_keys; 134 shiftkeys = state->shift_keys ^ old_state.shift_keys;
136 for (i = 0; i < sizeof (sdl_shift); i++) { 135 for (i = 0; i < sizeof(sdl_shift); i++) {
137 if ((shiftkeys >> i) & 1) { 136 if ((shiftkeys >> i) & 1) {
138 keysym.sym = sdl_shift[i]; 137 keysym.sym = sdl_shift[i];
139 SDL_PrivateKeyboard (((state-> 138 SDL_PrivateKeyboard(((state->
140 shift_keys >> i) & 1) ? SDL_PRESSED : 139 shift_keys >> i) & 1) ? SDL_PRESSED :
141 SDL_RELEASED, &keysym); 140 SDL_RELEASED, &keysym);
142 } 141 }
143 } 142 }
144 143
145 for (i = 0; i < sizeof (sdl_key); i++) { 144 for (i = 0; i < sizeof(sdl_key); i++) {
146 if (state->matrix[i] != old_state.matrix[i]) { 145 if (state->matrix[i] != old_state.matrix[i]) {
147 int key = sdl_key[i]; 146 int key = sdl_key[i];
148 if (key) { 147 if (key) {
149 keysym.sym = key; 148 keysym.sym = key;
150 SDL_PrivateKeyboard (state-> 149 SDL_PrivateKeyboard(state->
151 matrix[i] ? SDL_PRESSED : 150 matrix[i] ? SDL_PRESSED :
152 SDL_RELEASED, &keysym); 151 SDL_RELEASED, &keysym);
153 } 152 }
154 } 153 }
155 } 154 }
156 155
157 old_state = *state; 156 old_state = *state;
158 } 157 }
159 158
160 void 159 void
161 DC_PumpEvents (_THIS) 160 DC_PumpEvents(_THIS)
162 { 161 {
163 keyboard_update (); 162 keyboard_update();
164 mouse_update (); 163 mouse_update();
165 } 164 }
166 165
167 void 166 void
168 DC_InitOSKeymap (_THIS) 167 DC_InitOSKeymap(_THIS)
169 { 168 {
170 /* do nothing. */ 169 /* do nothing. */
171 } 170 }
172 171
173 /* end of SDL_dcevents.c ... */ 172 /* end of SDL_dcevents.c ... */