From 2e783d976902ea1ce8d6558d3c49282dc644301a Mon Sep 17 00:00:00 2001 From: luisr142004 Date: Sat, 5 Jun 2010 01:38:22 +0000 Subject: space changes, merge #defines, language fix, and code reorder/cleanup :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5614 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../DirectInput/DirectInputJoystick.cpp | 2 +- Source/Core/InputCommon/Src/SDL_Util.cpp | 18 ++++++------- Source/Core/InputCommon/Src/XInput_Util.cpp | 31 +++++++++++----------- Source/Core/InputCommon/Src/XInput_Util.h | 1 - 4 files changed, 25 insertions(+), 27 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp index 7731577629..c1234f7f4c 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp @@ -455,7 +455,7 @@ std::string Joystick::Axis::GetName() const { std::ostringstream ss; // axis - if ( m_index < 6 ) + if ( m_index < 6 ) { ss << "Axis " << "XYZ"[m_index%3]; if ( m_index > 2 ) diff --git a/Source/Core/InputCommon/Src/SDL_Util.cpp b/Source/Core/InputCommon/Src/SDL_Util.cpp index cf97a608fb..0ae94ad95e 100644 --- a/Source/Core/InputCommon/Src/SDL_Util.cpp +++ b/Source/Core/InputCommon/Src/SDL_Util.cpp @@ -56,7 +56,7 @@ bool SearchDevices(std::vector &_joyinfo, int &_NumPads, int &_ // Get device status int numjoy = SDL_NumJoysticks(); - for (int i = 0; i < numjoy; i++ ) + for (int i = 0; i < numjoy; i++) { CONTROLLER_INFO Tmp; @@ -97,16 +97,16 @@ bool SearchDevices(std::vector &_joyinfo, int &_NumPads, int &_ // Avoid extreme axis values // --------------------- -/* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the +/* Function: We have to avoid very big values because some triggers are -0x8000 in the unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */ bool AvoidValues(int value, bool NoTriggerFilter) { // Avoid detecting very small or very big (for triggers) values - if( (value > -0x1000 && value < 0x1000) // Small values + if((value > -0x1000 && value < 0x1000) // Small values || ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values return true; // Avoid else - return false; // Keep + return false; // Keep } @@ -141,14 +141,14 @@ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int h if(Hat) { for(int i = 0; i < hats; i++) - { + { value = SDL_JoystickGetHat(joy, i); if(value) { pressed = i; type = InputCommon::CTL_HAT; Succeed = true; - } + } } } @@ -156,7 +156,7 @@ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int h if(Button) { for(int i = 0; i < buttons; i++) - { + { // Some kind of bug in SDL 1.3 would give button 9 and 10 (nonexistent) the value 48 on the 360 pad if (SDL_JoystickGetButton(joy, i) > 1) continue; @@ -174,7 +174,7 @@ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int h if(XInput && LeftRight) { for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++) - { + { if(XInput::GetXI(ControllerID, i)) { pressed = i + 1000; @@ -209,7 +209,7 @@ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int h } // Only accept the escape key else if (KeyboardKey == WXK_ESCAPE) - { + { Succeed = true; KeyboardKey = 0; pressed = -1; diff --git a/Source/Core/InputCommon/Src/XInput_Util.cpp b/Source/Core/InputCommon/Src/XInput_Util.cpp index 0e9d6f4b24..88e0d0e54c 100644 --- a/Source/Core/InputCommon/Src/XInput_Util.cpp +++ b/Source/Core/InputCommon/Src/XInput_Util.cpp @@ -48,9 +48,10 @@ namespace XInput struct CONTROLER_STATE { - XINPUT_STATE state; - bool bConnected; + XINPUT_STATE state; + bool bConnected; }; + CONTROLER_STATE g_Controllers[MAX_CONTROLLERS]; @@ -61,33 +62,32 @@ CONTROLER_STATE g_Controllers[MAX_CONTROLLERS]; we currently only try to connect to XInput device 0 */ void Init() { - // Init state - //ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS ); + // Init state + //ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS ); // Declaration DWORD dwResult; // Calculate the number of connected XInput devices for( DWORD i = 0; i < MAX_CONTROLLERS; i++ ) - { - // Simply get the state of the controller from XInput. - dwResult = XInputGetState( i, &g_Controllers[i].state ); - - if( dwResult == ERROR_SUCCESS ) - g_Controllers[i].bConnected = true; - else - g_Controllers[i].bConnected = false; - } + { + // Simply get the state of the controller from XInput. + dwResult = XInputGetState( i, &g_Controllers[i].state ); -} + if( dwResult == ERROR_SUCCESS ) + g_Controllers[i].bConnected = true; + else + g_Controllers[i].bConnected = false; + } +} // Get the trigger status // ------------------- int GetXI(int Controller, int Button) { // Update the internal status - DWORD dwResult; + DWORD dwResult; dwResult = XInputGetState(Controller, &g_Controllers[Controller].state); if (dwResult != ERROR_SUCCESS) return -1; @@ -105,7 +105,6 @@ int GetXI(int Controller, int Button) } } - // Check if a certain controller is connected // ------------------- bool IsConnected(int Controller) diff --git a/Source/Core/InputCommon/Src/XInput_Util.h b/Source/Core/InputCommon/Src/XInput_Util.h index fd4b23bb98..411e1958a0 100644 --- a/Source/Core/InputCommon/Src/XInput_Util.h +++ b/Source/Core/InputCommon/Src/XInput_Util.h @@ -36,7 +36,6 @@ void Init(); int GetXI(int Controller, int Button); bool IsConnected(int Controller); - } // XInput #endif -- cgit v1.2.3