mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-22 18:51:34 +00:00
(Dinput joypad) Cleanup magic numbers mess surrounding
hat code
This commit is contained in:
parent
0893d6b7b1
commit
051fb92e83
@ -443,19 +443,43 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
|
|
||||||
pov = pad->joy_state.rgdwPOV[hat];
|
pov = pad->joy_state.rgdwPOV[hat];
|
||||||
|
|
||||||
/* Magic numbers I'm not sure where originate from. */
|
|
||||||
if (pov < 36000)
|
|
||||||
{
|
|
||||||
switch (hat_dir)
|
switch (hat_dir)
|
||||||
{
|
{
|
||||||
case HAT_UP_MASK:
|
case HAT_UP_MASK:
|
||||||
return (pov >= 31500) || (pov <= 4500);
|
{
|
||||||
|
static const unsigned check1 = (JOY_POVRIGHT/2);
|
||||||
|
static const unsigned check2 = (JOY_POVLEFT+JOY_POVRIGHT/2);
|
||||||
|
return
|
||||||
|
(pov == JOY_POVFORWARD) ||
|
||||||
|
(pov == check1) ||
|
||||||
|
(pov == check2);
|
||||||
|
}
|
||||||
case HAT_RIGHT_MASK:
|
case HAT_RIGHT_MASK:
|
||||||
return (pov >= 4500) && (pov <= 13500);
|
{
|
||||||
|
static const unsigned check1 = (JOY_POVRIGHT/2);
|
||||||
|
static const unsigned check2 = (JOY_POVRIGHT+JOY_POVRIGHT/2);
|
||||||
|
return
|
||||||
|
(pov == JOY_POVRIGHT) ||
|
||||||
|
(pov == check1) ||
|
||||||
|
(pov == check2);
|
||||||
|
}
|
||||||
case HAT_DOWN_MASK:
|
case HAT_DOWN_MASK:
|
||||||
return (pov >= 13500) && (pov <= 22500);
|
{
|
||||||
|
static const unsigned check1 = (JOY_POVRIGHT+JOY_POVRIGHT/2);
|
||||||
|
static const unsigned check2 = (JOY_POVBACKWARD+JOY_POVRIGHT/2);
|
||||||
|
return
|
||||||
|
(pov == JOY_POVBACKWARD) ||
|
||||||
|
(pov == check1) ||
|
||||||
|
(pov == check2);
|
||||||
|
}
|
||||||
case HAT_LEFT_MASK:
|
case HAT_LEFT_MASK:
|
||||||
return (pov >= 22500) && (pov <= 31500);
|
{
|
||||||
|
static const unsigned check1 = (JOY_POVBACKWARD+JOY_POVRIGHT/2);
|
||||||
|
static const unsigned check2 = (JOY_POVLEFT+JOY_POVRIGHT/2);
|
||||||
|
return
|
||||||
|
(pov == JOY_POVLEFT) ||
|
||||||
|
(pov == check1) ||
|
||||||
|
(pov == check2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user