[Opentnl-cvs] tnl/zap input.cpp,1.2,1.3 input.h,1.2,1.3 main.cpp,1.69,1.70 winJoystick.cpp,1.19,1.20
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-09-28 17:34:23
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30367/zap Modified Files: input.cpp input.h main.cpp winJoystick.cpp Log Message: Updated controller code to autodetect controller type on Win32 Index: input.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/input.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input.h 25 Sep 2004 01:26:37 -0000 1.2 --- input.h 28 Sep 2004 17:34:13 -0000 1.3 *************** *** 68,71 **** --- 68,73 ---- void InitJoystick(); + const char *GetJoystickName(); + S32 autodetectJoystickType(); void ShutdownJoystick(); bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask); Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** main.cpp 17 Sep 2004 00:14:34 -0000 1.69 --- main.cpp 28 Sep 2004 17:34:13 -0000 1.70 *************** *** 690,693 **** --- 690,694 ---- SFXObject::init(); InitJoystick(); + OptionsMenuUserInterface::joystickType = autodetectJoystickType(); glutInitWindowSize(800, 600); Index: input.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/input.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input.cpp 25 Sep 2004 01:26:37 -0000 1.2 --- input.cpp 28 Sep 2004 17:34:13 -0000 1.3 *************** *** 144,147 **** --- 144,169 ---- } } + else if(OptionsMenuUserInterface::joystickType == SaitekDualAnalog) + { + static U32 retMasks[12] = { + ControllerButton1, + ControllerButton2, + ControllerButton3, + ControllerButton4, + ControllerButton5, + ControllerButton6, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + 0, + ControllerButton1, + ControllerButtonBack, + 0, + }; + U32 retMask = 0; + for(S32 i = 0; i < 12; i++) + if(buttonMask & (1 << i)) + retMask |= retMasks[i]; + buttonMask = retMask; + } else if(OptionsMenuUserInterface::joystickType == PS2DualShock) { *************** *** 191,194 **** --- 213,237 ---- } + S32 autodetectJoystickType() + { + S32 ret = -1; + TNL_JOURNAL_READ_BLOCK(JoystickAutodetect, + TNL_JOURNAL_READ((&ret)); + return ret; + ) + const char *joystickName = GetJoystickName(); + if(!strncmp(joystickName, "WingMan", 7)) + ret = LogitechWingman; + else if(strstr(joystickName, "XBox")) + ret = XBoxController; + else if(!strcmp(joystickName, "4 axis 16 button joystick")) + ret = PS2DualShock; + else if(strstr(joystickName, "P880")) + ret = SaitekDualAnalog; + TNL_JOURNAL_WRITE_BLOCK(JoystickAutodetect, + TNL_JOURNAL_WRITE((ret)); + ) + return ret; + } static bool updateMoveJournaled( Move *theMove, U32 &buttonMask ) Index: winJoystick.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/winJoystick.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** winJoystick.cpp 25 Sep 2004 01:26:37 -0000 1.19 --- winJoystick.cpp 28 Sep 2004 17:34:13 -0000 1.20 *************** *** 93,96 **** --- 93,97 ---- LPDIRECTINPUT8 gDirectInput = NULL; LPDIRECTINPUTDEVICE8 gJoystick = NULL; + char gJoystickName[MAX_PATH] = ""; void InitJoystick() *************** *** 109,116 **** if( FAILED(gJoystick->SetDataFormat( &c_dfDIJoystick2 ) ) ) return; - - // since we passed in a NULL window, we don't bother setting the cooperative level. } BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, --- 110,119 ---- if( FAILED(gJoystick->SetDataFormat( &c_dfDIJoystick2 ) ) ) return; } + const char *GetJoystickName() + { + return gJoystickName; + } BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, *************** *** 120,124 **** if(FAILED(gDirectInput->CreateDevice( pdidInstance->guidInstance, &gJoystick, NULL ))) return DIENUM_CONTINUE; ! return DIENUM_STOP; } --- 123,127 ---- if(FAILED(gDirectInput->CreateDevice( pdidInstance->guidInstance, &gJoystick, NULL ))) return DIENUM_CONTINUE; ! strcpy(gJoystickName, pdidInstance->tszProductName); return DIENUM_STOP; } |