libretro: lightgun with gamepad fixes. Lightgun with touchscreen support
Lightgun with gamepad: fix reload, fix trigger and buttons on AW Issue #881 Support for lr pointer device for lightgun with touchscreen. Issue #604
This commit is contained in:
parent
5e4e48fffe
commit
4514a4bfcc
|
@ -186,7 +186,6 @@ static retro_rumble_interface rumble;
|
|||
static void refresh_devices(bool first_startup);
|
||||
static void init_disk_control_interface();
|
||||
static bool read_m3u(const char *file);
|
||||
void UpdateInputState();
|
||||
void gui_display_notification(const char *msg, int duration);
|
||||
static void updateVibration(u32 port, float power, float inclination, u32 durationMs);
|
||||
|
||||
|
@ -280,13 +279,14 @@ void retro_set_environment(retro_environment_t cb)
|
|||
{ "Light Gun", RETRO_DEVICE_LIGHTGUN },
|
||||
{ "Twin Stick", RETRO_DEVICE_TWINSTICK },
|
||||
{ "Saturn Twin-Stick", RETRO_DEVICE_TWINSTICK_SATURN },
|
||||
{ "Pointer", RETRO_DEVICE_POINTER },
|
||||
{ 0 },
|
||||
};
|
||||
static const struct retro_controller_info ports[] = {
|
||||
{ ports_default, 7 },
|
||||
{ ports_default, 7 },
|
||||
{ ports_default, 7 },
|
||||
{ ports_default, 7 },
|
||||
{ ports_default, 8 },
|
||||
{ ports_default, 8 },
|
||||
{ ports_default, 8 },
|
||||
{ ports_default, 8 },
|
||||
{ 0 },
|
||||
};
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||
|
@ -1297,6 +1297,7 @@ static uint32_t map_gamepad_button(unsigned device, unsigned id)
|
|||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
case RETRO_DEVICE_POINTER:
|
||||
joymap = dc_joymap;
|
||||
joymap_size = ARRAY_SIZE(dc_joymap);
|
||||
break;
|
||||
|
@ -1314,6 +1315,7 @@ static uint32_t map_gamepad_button(unsigned device, unsigned id)
|
|||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
case RETRO_DEVICE_POINTER:
|
||||
joymap = nao_joymap;
|
||||
joymap_size = ARRAY_SIZE(nao_joymap);
|
||||
break;
|
||||
|
@ -1330,6 +1332,7 @@ static uint32_t map_gamepad_button(unsigned device, unsigned id)
|
|||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
case RETRO_DEVICE_POINTER:
|
||||
joymap = aw_joymap;
|
||||
joymap_size = ARRAY_SIZE(aw_joymap);
|
||||
break;
|
||||
|
@ -2191,6 +2194,7 @@ void retro_set_controller_port_device(unsigned in_port, unsigned device)
|
|||
}
|
||||
break;
|
||||
case RETRO_DEVICE_LIGHTGUN:
|
||||
case RETRO_DEVICE_POINTER:
|
||||
config::MapleMainDevices[in_port] = MDT_LightGun;
|
||||
if (settings.platform.isConsole()) {
|
||||
config::MapleExpansionDevices[in_port][0] = enable_purupuru ? MDT_PurupuruPack : MDT_SegaVMU;
|
||||
|
@ -2416,8 +2420,18 @@ static void updateMouseState(u32 port)
|
|||
|
||||
static void updateLightgunCoordinates(u32 port)
|
||||
{
|
||||
int x = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X);
|
||||
int y = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y);
|
||||
int x;
|
||||
int y;
|
||||
if (device_type[port] == RETRO_DEVICE_LIGHTGUN)
|
||||
{
|
||||
x = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X);
|
||||
y = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
|
||||
y = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
|
||||
}
|
||||
if (config::Widescreen && config::ScreenStretching == 100 && !config::EmulateFramebuffer)
|
||||
mo_x_abs[port] = 640.f * ((x + 0x8000) * 4.f / 3.f / 0x10000 - (4.f / 3.f - 1.f) / 2.f);
|
||||
else
|
||||
|
@ -2446,6 +2460,7 @@ static void UpdateInputStateNaomi(u32 port)
|
|||
switch (config::MapleMainDevices[port])
|
||||
{
|
||||
case MDT_LightGun:
|
||||
if (device_type[port] == RETRO_DEVICE_LIGHTGUN)
|
||||
{
|
||||
//
|
||||
// -- buttons
|
||||
|
@ -2488,6 +2503,44 @@ static void UpdateInputStateNaomi(u32 port)
|
|||
updateLightgunCoordinates(port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// RETRO_DEVICE_POINTER
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_B);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_START);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_UP);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
||||
|
||||
int pressed = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||
int count = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_COUNT);
|
||||
if (count > 1)
|
||||
{
|
||||
// reload
|
||||
mo_x_abs[port] = 0;
|
||||
mo_y_abs[port] = 0;
|
||||
lightgun_params[port].offscreen = true;
|
||||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
updateLightgunCoordinates(port);
|
||||
}
|
||||
if (pressed)
|
||||
{
|
||||
if (settings.platform.isAtomiswave())
|
||||
kcode[port] &= ~AWAVE_TRIGGER_KEY;
|
||||
else
|
||||
kcode[port] &= ~NAOMI_BTN0_KEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (settings.platform.isAtomiswave())
|
||||
kcode[port] |= AWAVE_TRIGGER_KEY;
|
||||
else
|
||||
kcode[port] |= NAOMI_BTN0_KEY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2577,7 +2630,35 @@ static void UpdateInputStateNaomi(u32 port)
|
|||
|
||||
// -- mouse, for rotary encoders
|
||||
updateMouseState(port);
|
||||
updateLightgunCoordinatesFromAnalogStick(port);
|
||||
// lightgun with analog stick
|
||||
if (settings.input.JammaSetup == JVS::LightGun || settings.input.JammaSetup == JVS::LightGunAsAnalog)
|
||||
{
|
||||
updateLightgunCoordinatesFromAnalogStick(port);
|
||||
if (input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD))
|
||||
{
|
||||
mo_x_abs[port] = 0;
|
||||
mo_y_abs[port] = 0;
|
||||
lightgun_params[port].offscreen = true;
|
||||
if (settings.platform.isAtomiswave())
|
||||
kcode[port] &= ~AWAVE_TRIGGER_KEY;
|
||||
else
|
||||
kcode[port] &= ~NAOMI_BTN0_KEY;
|
||||
}
|
||||
else if (settings.platform.isAtomiswave())
|
||||
{
|
||||
// map btn0 to trigger, btn1 to btn0, etc.
|
||||
u32 k = kcode[port] | (AWAVE_BTN0_KEY | AWAVE_BTN1_KEY | AWAVE_BTN2_KEY | AWAVE_BTN3_KEY | AWAVE_TRIGGER_KEY);
|
||||
if ((kcode[port] & AWAVE_BTN0_KEY) == 0)
|
||||
k &= ~AWAVE_TRIGGER_KEY;
|
||||
if ((kcode[port] & AWAVE_BTN1_KEY) == 0)
|
||||
k &= ~AWAVE_BTN0_KEY;
|
||||
if ((kcode[port] & AWAVE_BTN2_KEY) == 0)
|
||||
k &= ~AWAVE_BTN1_KEY;
|
||||
if ((kcode[port] & AWAVE_BTN3_KEY) == 0)
|
||||
k &= ~AWAVE_BTN2_KEY;
|
||||
kcode[port] = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2871,6 +2952,7 @@ static void UpdateInputState(u32 port)
|
|||
break;
|
||||
|
||||
case MDT_LightGun:
|
||||
if (device_type[port] == RETRO_DEVICE_LIGHTGUN)
|
||||
{
|
||||
//
|
||||
// -- buttons
|
||||
|
@ -2904,6 +2986,37 @@ static void UpdateInputState(u32 port)
|
|||
updateLightgunCoordinates(port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// RETRO_DEVICE_POINTER
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_B);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_START);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_UP);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
||||
setDeviceButtonState(port, RETRO_DEVICE_JOYPAD, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
||||
|
||||
int pressed = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||
int count = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_COUNT);
|
||||
if (count > 1)
|
||||
{
|
||||
// reload
|
||||
mo_x_abs[port] = -1000;
|
||||
mo_y_abs[port] = -1000;
|
||||
lightgun_params[port].offscreen = true;
|
||||
|
||||
lightgun_params[port].x = mo_x_abs[port];
|
||||
lightgun_params[port].y = mo_y_abs[port];
|
||||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
updateLightgunCoordinates(port);
|
||||
}
|
||||
if (pressed)
|
||||
kcode[port] &= ~DC_BTN_A;
|
||||
else
|
||||
kcode[port] |= DC_BTN_A;
|
||||
}
|
||||
break;
|
||||
|
||||
case MDT_Mouse:
|
||||
|
|
Loading…
Reference in New Issue