comparison src/joystick/win32/SDL_dxjoystick.c @ 2698:e1da92da346c gsoc2008_nds

Clean up.
author Darren Alton <dalton@stevens.edu>
date Wed, 27 Aug 2008 04:23:38 +0000
parents fe19afb86473
children
comparison
equal deleted inserted replaced
2697:c9121b04cffa 2698:e1da92da346c
224 joystick->hwdata->buffered = 1; 224 joystick->hwdata->buffered = 1;
225 joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); 225 joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
226 226
227 result = 227 result =
228 IDirectInput_CreateDevice(dinput, 228 IDirectInput_CreateDevice(dinput,
229 &SYS_Joystick[joystick->index]. 229 &SYS_Joystick[joystick->index].guidInstance,
230 guidInstance, &device, NULL); 230 &device, NULL);
231 if (FAILED(result)) { 231 if (FAILED(result)) {
232 SetDIerror("IDirectInput::CreateDevice", result); 232 SetDIerror("IDirectInput::CreateDevice", result);
233 return (-1); 233 return (-1);
234 } 234 }
235 235
236 /* Now get the IDirectInputDevice2 interface, instead. */ 236 /* Now get the IDirectInputDevice2 interface, instead. */
237 result = IDirectInputDevice_QueryInterface(device, 237 result = IDirectInputDevice_QueryInterface(device,
238 &IID_IDirectInputDevice2, 238 &IID_IDirectInputDevice2,
239 (LPVOID *) & joystick-> 239 (LPVOID *) & joystick->hwdata->
240 hwdata->InputDevice); 240 InputDevice);
241 /* We are done with this object. Use the stored one from now on. */ 241 /* We are done with this object. Use the stored one from now on. */
242 IDirectInputDevice_Release(device); 242 IDirectInputDevice_Release(device);
243 243
244 if (FAILED(result)) { 244 if (FAILED(result)) {
245 SetDIerror("IDirectInputDevice::QueryInterface", result); 245 SetDIerror("IDirectInputDevice::QueryInterface", result);
247 } 247 }
248 248
249 /* Aquire shared access. Exclusive access is required for forces, 249 /* Aquire shared access. Exclusive access is required for forces,
250 * though. */ 250 * though. */
251 result = 251 result =
252 IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata-> 252 IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->InputDevice,
253 InputDevice, SDL_Window, 253 SDL_Window,
254 DISCL_EXCLUSIVE | 254 DISCL_EXCLUSIVE |
255 DISCL_BACKGROUND); 255 DISCL_BACKGROUND);
256 if (FAILED(result)) { 256 if (FAILED(result)) {
257 SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result); 257 SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result);
258 return (-1); 258 return (-1);
287 return (-1); 287 return (-1);
288 } 288 }
289 289
290 /* reset all accuators. */ 290 /* reset all accuators. */
291 result = 291 result =
292 IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata-> 292 IDirectInputDevice2_SendForceFeedbackCommand(joystick->
293 InputDevice, 293 hwdata->InputDevice,
294 DISFFC_RESET); 294 DISFFC_RESET);
295 295
296 if (FAILED(result)) { 296 if (FAILED(result)) {
297 SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand", 297 SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand",
298 result); 298 result);
479 479
480 break; 480 break;
481 481
482 case BUTTON: 482 case BUTTON:
483 SDL_PrivateJoystickButton_Int(joystick, in->num, 483 SDL_PrivateJoystickButton_Int(joystick, in->num,
484 (Uint8) (state. 484 (Uint8) (state.rgbButtons[in->ofs -
485 rgbButtons[in->ofs - 485 DIJOFS_BUTTON0]
486 DIJOFS_BUTTON0]
487 ? SDL_PRESSED : 486 ? SDL_PRESSED :
488 SDL_RELEASED)); 487 SDL_RELEASED));
489 break; 488 break;
490 case HAT: 489 case HAT:
491 { 490 {
537 SDL_PrivateJoystickAxis(joystick, in->num, 536 SDL_PrivateJoystickAxis(joystick, in->num,
538 (Sint16) evtbuf[i].dwData); 537 (Sint16) evtbuf[i].dwData);
539 break; 538 break;
540 case BUTTON: 539 case BUTTON:
541 SDL_PrivateJoystickButton(joystick, in->num, 540 SDL_PrivateJoystickButton(joystick, in->num,
542 (Uint8) (evtbuf[i]. 541 (Uint8) (evtbuf[i].dwData ?
543 dwData ? SDL_PRESSED : 542 SDL_PRESSED :
544 SDL_RELEASED)); 543 SDL_RELEASED));
545 break; 544 break;
546 case HAT: 545 case HAT:
547 { 546 {
548 Uint8 pos = TranslatePOV(evtbuf[i].dwData); 547 Uint8 pos = TranslatePOV(evtbuf[i].dwData);