mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-19 06:45:39 +00:00
SDLControllerInterface: Pass player ID to hooks not joystick ID
Should fix controllers which show up as non-zero players.
This commit is contained in:
parent
3cfead36c4
commit
cae2e09957
|
@ -238,13 +238,13 @@ bool SDLControllerInterface::HandleControllerAxisEvent(const SDL_Event* ev)
|
||||||
const float value = static_cast<float>(ev->caxis.value) / (ev->caxis.value < 0 ? 32768.0f : 32767.0f);
|
const float value = static_cast<float>(ev->caxis.value) / (ev->caxis.value < 0 ? 32768.0f : 32767.0f);
|
||||||
Log_DebugPrintf("controller %d axis %d %d %f", ev->caxis.which, ev->caxis.axis, ev->caxis.value, value);
|
Log_DebugPrintf("controller %d axis %d %d %f", ev->caxis.which, ev->caxis.axis, ev->caxis.value, value);
|
||||||
|
|
||||||
if (DoEventHook(Hook::Type::Axis, ev->caxis.which, ev->caxis.axis, value))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
auto it = GetControllerDataForJoystickId(ev->caxis.which);
|
auto it = GetControllerDataForJoystickId(ev->caxis.which);
|
||||||
if (it == m_controllers.end())
|
if (it == m_controllers.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (DoEventHook(Hook::Type::Axis, it->player_id, ev->caxis.axis, value))
|
||||||
|
return true;
|
||||||
|
|
||||||
const AxisCallback& cb = it->axis_mapping[ev->caxis.axis];
|
const AxisCallback& cb = it->axis_mapping[ev->caxis.axis];
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
|
@ -280,14 +280,14 @@ bool SDLControllerInterface::HandleControllerButtonEvent(const SDL_Event* ev)
|
||||||
Log_DebugPrintf("controller %d button %d %s", ev->cbutton.which, ev->cbutton.button,
|
Log_DebugPrintf("controller %d button %d %s", ev->cbutton.which, ev->cbutton.button,
|
||||||
ev->cbutton.state == SDL_PRESSED ? "pressed" : "released");
|
ev->cbutton.state == SDL_PRESSED ? "pressed" : "released");
|
||||||
|
|
||||||
const bool pressed = (ev->cbutton.state == SDL_PRESSED);
|
|
||||||
if (DoEventHook(Hook::Type::Button, ev->cbutton.which, ev->cbutton.button, pressed ? 1.0f : 0.0f))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
auto it = GetControllerDataForJoystickId(ev->caxis.which);
|
auto it = GetControllerDataForJoystickId(ev->caxis.which);
|
||||||
if (it == m_controllers.end())
|
if (it == m_controllers.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const bool pressed = (ev->cbutton.state == SDL_PRESSED);
|
||||||
|
if (DoEventHook(Hook::Type::Button, it->player_id, ev->cbutton.button, pressed ? 1.0f : 0.0f))
|
||||||
|
return true;
|
||||||
|
|
||||||
const ButtonCallback& cb = it->button_mapping[ev->cbutton.button];
|
const ButtonCallback& cb = it->button_mapping[ev->cbutton.button];
|
||||||
if (!cb)
|
if (!cb)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue