Refactor input_state_device - overlay code is not implemented

for every device - like MOUSE/POINTER
This commit is contained in:
twinaphex 2019-07-16 11:22:47 +02:00
parent 32add9c3c2
commit 724f623c8a
1 changed files with 170 additions and 198 deletions

View File

@ -7435,54 +7435,11 @@ static int16_t input_state_device(
{
int16_t res = 0;
settings_t *settings = configuration_settings;
#ifdef HAVE_OVERLAY
int16_t res_overlay = 0;
if (overlay_ptr && port == 0)
{
input_overlay_state_t *ol_state = &overlay_ptr->overlay_state;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (input_overlay_key_pressed(overlay_ptr, id))
res_overlay |= 1;
break;
case RETRO_DEVICE_KEYBOARD:
if (id < RETROK_LAST)
{
#if 0
RARCH_LOG("UDLR %u %u %u %u\n",
OVERLAY_GET_KEY(ol_state, RETROK_UP),
OVERLAY_GET_KEY(ol_state, RETROK_DOWN),
OVERLAY_GET_KEY(ol_state, RETROK_LEFT),
OVERLAY_GET_KEY(ol_state, RETROK_RIGHT)
);
#endif
if (OVERLAY_GET_KEY(ol_state, id))
res_overlay |= 1;
}
break;
case RETRO_DEVICE_ANALOG:
{
unsigned base = 0;
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
base = 2;
if (id == RETRO_DEVICE_ID_ANALOG_Y)
base += 1;
if (ol_state && ol_state->analog[base])
res_overlay = ol_state->analog[base];
}
break;
}
}
#endif
switch (device)
{
case RETRO_DEVICE_JOYPAD:
{
#ifdef HAVE_NETWORKGAMEPAD
if (input_driver_remote)
if (input_remote_key_pressed(id, port))
@ -7509,8 +7466,16 @@ static int16_t input_state_device(
res = ret;
#ifdef HAVE_OVERLAY
if (overlay_ptr && overlay_ptr->alive && port == 0)
{
int16_t res_overlay = 0;
if (overlay_ptr && port == 0 && overlay_ptr->alive)
{
if (input_overlay_key_pressed(overlay_ptr, id))
res_overlay |= 1;
if (overlay_ptr->alive)
res |= res_overlay;
}
}
#endif
}
}
@ -7543,13 +7508,11 @@ static int16_t input_state_device(
< settings->uints.input_turbo_duty_cycle);
}
}
}
break;
case RETRO_DEVICE_MOUSE:
{
if (id < RARCH_FIRST_META_KEY)
{
bool bind_valid = libretro_input_binds[port]
@ -7565,39 +7528,43 @@ static int16_t input_state_device(
}
else
res = ret;
#ifdef HAVE_OVERLAY
if (overlay_ptr && overlay_ptr->alive && port == 0)
res |= res_overlay;
#endif
}
}
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_state(input_driver_mapper,
&res, port, device, idx, id);
}
break;
case RETRO_DEVICE_KEYBOARD:
{
res = ret;
#ifdef HAVE_OVERLAY
if (overlay_ptr && overlay_ptr->alive && port == 0)
if (overlay_ptr && port == 0)
{
int16_t res_overlay = 0;
if (id < RETROK_LAST)
{
input_overlay_state_t *ol_state = &overlay_ptr->overlay_state;
if (OVERLAY_GET_KEY(ol_state, id))
res_overlay |= 1;
}
if (overlay_ptr->alive)
res |= res_overlay;
}
#endif
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_state(input_driver_mapper,
&res, port, device, idx, id);
}
break;
case RETRO_DEVICE_LIGHTGUN:
{
if (id < RARCH_FIRST_META_KEY)
{
bool bind_valid = libretro_input_binds[port]
@ -7613,23 +7580,34 @@ static int16_t input_state_device(
}
else
res = ret;
#ifdef HAVE_OVERLAY
if (overlay_ptr && overlay_ptr->alive && port == 0)
res |= res_overlay;
#endif
}
}
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_state(input_driver_mapper,
&res, port, device, idx, id);
}
break;
case RETRO_DEVICE_ANALOG:
{
#ifdef HAVE_OVERLAY
int16_t res_overlay = 0;
if (overlay_ptr && port == 0)
{
unsigned base = 0;
input_overlay_state_t *ol_state = &overlay_ptr->overlay_state;
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
base = 2;
if (id == RETRO_DEVICE_ID_ANALOG_Y)
base += 1;
if (ol_state && ol_state->analog[base])
res_overlay = ol_state->analog[base];
}
#endif
#ifdef HAVE_NETWORKGAMEPAD
if (input_driver_remote)
{
@ -7696,7 +7674,6 @@ static int16_t input_state_device(
case RETRO_DEVICE_POINTER:
{
if (id < RARCH_FIRST_META_KEY)
{
bool bind_valid = libretro_input_binds[port]
@ -7712,18 +7689,13 @@ static int16_t input_state_device(
}
else
res = ret;
#ifdef HAVE_OVERLAY
if (overlay_ptr && overlay_ptr->alive && port == 0)
res |= res_overlay;
#endif
}
}
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_state(input_driver_mapper,
&res, port, device, idx, id);
}
break;
}