mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 03:47:07 -05:00
entry/x11: Fixed dpad.
This commit is contained in:
parent
9d8a0a1684
commit
1b7375df6c
1 changed files with 35 additions and 0 deletions
|
@ -61,6 +61,23 @@ namespace entry
|
|||
GamepadAxis::RightZ,
|
||||
};
|
||||
|
||||
struct AxisDpadRemap
|
||||
{
|
||||
Key::Enum first;
|
||||
Key::Enum second;
|
||||
};
|
||||
|
||||
static AxisDpadRemap s_axisDpad[] =
|
||||
{
|
||||
{ Key::GamepadLeft, Key::GamepadRight },
|
||||
{ Key::GamepadUp, Key::GamepadDown },
|
||||
{ Key::None, Key::None },
|
||||
{ Key::GamepadLeft, Key::GamepadRight },
|
||||
{ Key::GamepadUp, Key::GamepadDown },
|
||||
{ Key::None, Key::None },
|
||||
};
|
||||
BX_STATIC_ASSERT(BX_COUNTOF(s_translateAxis) == BX_COUNTOF(s_axisDpad) );
|
||||
|
||||
struct Joystick
|
||||
{
|
||||
Joystick()
|
||||
|
@ -135,6 +152,24 @@ namespace entry
|
|||
if (filter(axis, &value) )
|
||||
{
|
||||
_eventQueue.postAxisEvent(defaultWindow, handle, axis, value);
|
||||
|
||||
if (Key::None != s_axisDpad[axis].first)
|
||||
{
|
||||
if (m_value[axis] == 0)
|
||||
{
|
||||
_eventQueue.postKeyEvent(defaultWindow, s_axisDpad[axis].first, 0, false);
|
||||
_eventQueue.postKeyEvent(defaultWindow, s_axisDpad[axis].second, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventQueue.postKeyEvent(defaultWindow
|
||||
, 0 > m_value[axis] ? s_axisDpad[axis].first : s_axisDpad[axis].second
|
||||
, 0
|
||||
, true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue