Commit 73665cff authored by Martin Schultz's avatar Martin Schultz

added hack for analog trigger on windows of xbox 360 gamepad

parent 6fc9cc54
cmake @ a0eb0dda
Subproject commit c4eead9bcb430fed3e99ee0df0f2b06559df5db4 Subproject commit a0eb0dda91ce5d621d47de52bcecdd494b00e353
...@@ -144,6 +144,11 @@ private: ...@@ -144,6 +144,11 @@ private:
bool isMapped( GamePadButton _button ); bool isMapped( GamePadButton _button );
void printPressedButtonHelper( GamePadButton _b, const char *_TRUE, const char *_false ); void printPressedButtonHelper( GamePadButton _b, const char *_TRUE, const char *_false );
//
// HACK for trigger mapping on windows of xbox 360 gamepad:
//
bool isXBox360OnWindows;
}; };
ACGL_SMARTPOINTER_TYPEDEFS(GamePad) ACGL_SMARTPOINTER_TYPEDEFS(GamePad)
......
...@@ -40,6 +40,7 @@ GamePad::GamePad( int _n ) ...@@ -40,6 +40,7 @@ GamePad::GamePad( int _n )
mMinSensitivity = 0.0f; mMinSensitivity = 0.0f;
mButtonState = NULL; mButtonState = NULL;
mLastButtonState = NULL; mLastButtonState = NULL;
isXBox360OnWindows = false;
#if defined( ACGL_COMPILE_WITH_GLFW ) #if defined( ACGL_COMPILE_WITH_GLFW )
int numberOfJoysticksFound = 0; int numberOfJoysticksFound = 0;
...@@ -196,11 +197,8 @@ GamePad::GamePad( int _n ) ...@@ -196,11 +197,8 @@ GamePad::GamePad( int _n )
setButtonMapping(LEFT_PAD_WEST, 13); setButtonMapping(LEFT_PAD_WEST, 13);
//setButtonMapping(LEFT_TRIGGER, 2 + mNumberOfButtons); // axis 2 isXBox360OnWindows = true;
//setButtonMapping(RIGHT_TRIGGER, 5 + mNumberOfButtons); // axis 5
//setAxisMapping(LEFT_ANALOG_TRIGGER, 2); mAxesMultiplier[2] = 0.5f; mAxesAdd[2] = 0.5f;
//setAxisMapping(RIGHT_ANALOG_TRIGGER, 5); mAxesMultiplier[5] = -0.5f; mAxesAdd[5] = 0.5f;
setAxisMapping(LEFT_ANALOG_STICK_X, 0); setAxisMapping(LEFT_ANALOG_STICK_X, 0);
setAxisMapping(LEFT_ANALOG_STICK_Y, 1); setAxisMapping(LEFT_ANALOG_STICK_Y, 1);
setAxisMapping(RIGHT_ANALOG_STICK_X, 3); mAxesMultiplier[3] = -1.0f; setAxisMapping(RIGHT_ANALOG_STICK_X, 3); mAxesMultiplier[3] = -1.0f;
...@@ -283,6 +281,14 @@ float GamePad::getAxisRaw( unsigned int _axis ) ...@@ -283,6 +281,14 @@ float GamePad::getAxisRaw( unsigned int _axis )
float GamePad::getAxis( GamePadAxis _axis ) float GamePad::getAxis( GamePadAxis _axis )
{ {
if (isXBox360OnWindows) {
if (_axis == GamePad::LEFT_ANALOG_TRIGGER) {
return std::max(getAxisRaw(2), 0.0f);
}
else if (_axis == GamePad::RIGHT_ANALOG_TRIGGER) {
return -std::min(getAxisRaw(2), 0.0f);
}
}
return getAxisRaw( mAxisMap[_axis] ); return getAxisRaw( mAxisMap[_axis] );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment