|
|
@ -236,6 +236,7 @@ namespace olc { |
|
|
|
int axisCount = GP_AXIS_COUNT; |
|
|
|
int axisCount = GP_AXIS_COUNT; |
|
|
|
int buttonCount = GP_BUTTON_COUNT; |
|
|
|
int buttonCount = GP_BUTTON_COUNT; |
|
|
|
float axes[GP_AXIS_COUNT]{0}; |
|
|
|
float axes[GP_AXIS_COUNT]{0}; |
|
|
|
|
|
|
|
float prevAxes[GP_AXIS_COUNT]{0}; |
|
|
|
olc::HWButton buttons[GP_BUTTON_COUNT]; |
|
|
|
olc::HWButton buttons[GP_BUTTON_COUNT]; |
|
|
|
bool ff = false; |
|
|
|
bool ff = false; |
|
|
|
#ifdef __EMSCRIPTEN__ |
|
|
|
#ifdef __EMSCRIPTEN__ |
|
|
@ -1318,6 +1319,9 @@ olc::GamePad *olc::GamePad::selectWithAnyButton() { |
|
|
|
|
|
|
|
|
|
|
|
float olc::GamePad::getAxis(olc::GPAxes a) { |
|
|
|
float olc::GamePad::getAxis(olc::GPAxes a) { |
|
|
|
float axis = axes[static_cast<int>(a)]; |
|
|
|
float axis = axes[static_cast<int>(a)]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(prevAxes[static_cast<int>(a)]==0.f&&std::abs(prevAxes[static_cast<int>(a)]-axis)>0.9f)return 0.f; |
|
|
|
|
|
|
|
|
|
|
|
if (std::abs(axis) < deadZone) { |
|
|
|
if (std::abs(axis) < deadZone) { |
|
|
|
axis = 0; |
|
|
|
axis = 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -1329,6 +1333,9 @@ float olc::GamePad::getAxis(olc::GPAxes a) { |
|
|
|
if (!xInput && (a == GPAxes::TL || a == GPAxes::TR)) |
|
|
|
if (!xInput && (a == GPAxes::TL || a == GPAxes::TR)) |
|
|
|
return (axis + 1) / 2; |
|
|
|
return (axis + 1) / 2; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prevAxes[static_cast<int>(a)]=axis; |
|
|
|
|
|
|
|
|
|
|
|
return axis; |
|
|
|
return axis; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|