Remove button float value from gamepad plus(+) binds since basegame doesnt make use of it

This commit is contained in:
Jan 2021-08-24 12:04:34 +02:00
parent edf060bd4a
commit fea24a509a
2 changed files with 14 additions and 29 deletions

View File

@ -650,20 +650,20 @@ namespace Components
if (gamePad.stickDown[stickIndex][Game::GPAD_STICK_POS]) if (gamePad.stickDown[stickIndex][Game::GPAD_STICK_POS])
{ {
const Game::GamePadButtonEvent event = gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_POS] ? Game::GPAD_BUTTON_UPDATE : Game::GPAD_BUTTON_PRESSED; const Game::GamePadButtonEvent event = gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_POS] ? Game::GPAD_BUTTON_UPDATE : Game::GPAD_BUTTON_PRESSED;
CL_GamepadButtonEvent(gamePadIndex, mapping.posCode, event, time, Game::GPAD_NONE); CL_GamepadButtonEvent(gamePadIndex, mapping.posCode, event, time);
} }
else if (gamePad.stickDown[stickIndex][Game::GPAD_STICK_NEG]) else if (gamePad.stickDown[stickIndex][Game::GPAD_STICK_NEG])
{ {
const Game::GamePadButtonEvent event = gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_NEG] ? Game::GPAD_BUTTON_UPDATE : Game::GPAD_BUTTON_PRESSED; const Game::GamePadButtonEvent event = gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_NEG] ? Game::GPAD_BUTTON_UPDATE : Game::GPAD_BUTTON_PRESSED;
CL_GamepadButtonEvent(gamePadIndex, mapping.negCode, event, time, Game::GPAD_NONE); CL_GamepadButtonEvent(gamePadIndex, mapping.negCode, event, time);
} }
else if (gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_POS]) else if (gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_POS])
{ {
CL_GamepadButtonEvent(gamePadIndex, mapping.posCode, Game::GPAD_BUTTON_RELEASED, time, Game::GPAD_NONE); CL_GamepadButtonEvent(gamePadIndex, mapping.posCode, Game::GPAD_BUTTON_RELEASED, time);
} }
else if (gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_NEG]) else if (gamePad.stickDownLast[stickIndex][Game::GPAD_STICK_NEG])
{ {
CL_GamepadButtonEvent(gamePadIndex, mapping.negCode, Game::GPAD_BUTTON_RELEASED, time, Game::GPAD_NONE); CL_GamepadButtonEvent(gamePadIndex, mapping.negCode, Game::GPAD_BUTTON_RELEASED, time);
} }
} }
} }
@ -734,7 +734,7 @@ namespace Components
return repeatCount > 1; return repeatCount > 1;
} }
void Gamepad::CL_GamepadButtonEvent(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time, const Game::GamePadButton button) void Gamepad::CL_GamepadButtonEvent(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time)
{ {
assert(gamePadIndex < Game::MAX_GAMEPADS); assert(gamePadIndex < Game::MAX_GAMEPADS);
@ -789,13 +789,7 @@ namespace Components
{ {
if (keyBinding[0] == '+') if (keyBinding[0] == '+')
{ {
float floatValue; sprintf_s(cmd, "%s %i %i\n", keyBinding, key, time);
if (button)
floatValue = GPad_GetButton(gamePadIndex, button);
else
floatValue = 0.0f;
sprintf_s(cmd, "%s %i %i %0.3f\n", keyBinding, key, time, floatValue);
Game::Cbuf_AddText(gamePadIndex, cmd); Game::Cbuf_AddText(gamePadIndex, cmd);
} }
else else
@ -809,13 +803,7 @@ namespace Components
{ {
if (keyBinding && keyBinding[0] == '+') if (keyBinding && keyBinding[0] == '+')
{ {
float floatValue; sprintf_s(cmd, "-%s %i %i\n", &keyBinding[1], key, time);
if (button)
floatValue = GPad_GetButton(gamePadIndex, button);
else
floatValue = 0.0f;
sprintf_s(cmd, "-%s %i %i %0.3f\n", &keyBinding[1], key, time, floatValue);
Game::Cbuf_AddText(gamePadIndex, cmd); Game::Cbuf_AddText(gamePadIndex, cmd);
} }
@ -826,7 +814,7 @@ namespace Components
} }
} }
void Gamepad::CL_GamepadButtonEventForPort(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time, const Game::GamePadButton button) void Gamepad::CL_GamepadButtonEventForPort(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time)
{ {
assert(gamePadIndex < Game::MAX_GAMEPADS); assert(gamePadIndex < Game::MAX_GAMEPADS);
auto& gamePad = gamePads[gamePadIndex]; auto& gamePad = gamePads[gamePadIndex];
@ -838,7 +826,7 @@ namespace Components
CL_GamepadResetMenuScrollTime(gamePadIndex, key, buttonEvent == Game::GPAD_BUTTON_PRESSED, time); CL_GamepadResetMenuScrollTime(gamePadIndex, key, buttonEvent == Game::GPAD_BUTTON_PRESSED, time);
CL_GamepadButtonEvent(gamePadIndex, key, buttonEvent, time, button); CL_GamepadButtonEvent(gamePadIndex, key, buttonEvent, time);
} }
void Gamepad::GPad_ConvertStickToFloat(const short x, const short y, float& outX, float& outY) void Gamepad::GPad_ConvertStickToFloat(const short x, const short y, float& outX, float& outY)
@ -1131,8 +1119,7 @@ namespace Components
gamePadIndex, gamePadIndex,
buttonMapping.code, buttonMapping.code,
Game::GPAD_BUTTON_PRESSED, Game::GPAD_BUTTON_PRESSED,
time, time);
buttonMapping.padButton);
} }
else if (GPad_ButtonRequiresUpdates(gamePadIndex, buttonMapping.padButton)) else if (GPad_ButtonRequiresUpdates(gamePadIndex, buttonMapping.padButton))
{ {
@ -1140,8 +1127,7 @@ namespace Components
gamePadIndex, gamePadIndex,
buttonMapping.code, buttonMapping.code,
Game::GPAD_BUTTON_UPDATE, Game::GPAD_BUTTON_UPDATE,
time, time);
buttonMapping.padButton);
} }
else if (GPad_IsButtonReleased(gamePadIndex, buttonMapping.padButton)) else if (GPad_IsButtonReleased(gamePadIndex, buttonMapping.padButton))
{ {
@ -1149,8 +1135,7 @@ namespace Components
gamePadIndex, gamePadIndex,
buttonMapping.code, buttonMapping.code,
Game::GPAD_BUTTON_RELEASED, Game::GPAD_BUTTON_RELEASED,
time, time);
buttonMapping.padButton);
} }
} }
} }

View File

@ -306,8 +306,8 @@ namespace Components
static void UI_GamepadKeyEvent(int gamePadIndex, int key, bool down); static void UI_GamepadKeyEvent(int gamePadIndex, int key, bool down);
static void CL_GamepadGenerateAPad(int gamePadIndex, Game::GamepadPhysicalAxis physicalAxis, unsigned time); static void CL_GamepadGenerateAPad(int gamePadIndex, Game::GamepadPhysicalAxis physicalAxis, unsigned time);
static void CL_GamepadEvent(int gamePadIndex, Game::GamepadPhysicalAxis physicalAxis, float value, unsigned time); static void CL_GamepadEvent(int gamePadIndex, Game::GamepadPhysicalAxis physicalAxis, float value, unsigned time);
static void CL_GamepadButtonEvent(int gamePadIndex, int key, Game::GamePadButtonEvent buttonEvent, unsigned time, Game::GamePadButton button); static void CL_GamepadButtonEvent(int gamePadIndex, int key, Game::GamePadButtonEvent buttonEvent, unsigned time);
static void CL_GamepadButtonEventForPort(int gamePadIndex, int key, Game::GamePadButtonEvent buttonEvent, unsigned int time, Game::GamePadButton button); static void CL_GamepadButtonEventForPort(int gamePadIndex, int key, Game::GamePadButtonEvent buttonEvent, unsigned int time);
static void GPad_ConvertStickToFloat(short x, short y, float& outX, float& outY); static void GPad_ConvertStickToFloat(short x, short y, float& outX, float& outY);
static float GPad_GetStick(int gamePadIndex, Game::GamePadStick stick); static float GPad_GetStick(int gamePadIndex, Game::GamePadStick stick);