From: StormedBubbles <80055191+StormedBubbles@users.noreply.github.com> Date: Tue, 6 Jun 2023 04:52:35 +0000 (-0400) Subject: Expand usable space for GunCon X-Git-Tag: r24l~319^2 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a901d51993abd8cbef621385b4298399455bff99;p=pcsx_rearmed.git Expand usable space for GunCon Expand range of allowed coordinates so that the whole game screen can be used when the coordinates are manually scaled via the core options. --- diff --git a/frontend/libretro.c b/frontend/libretro.c index 3e74b230..8434de0d 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2421,17 +2421,19 @@ static void update_input_guncon(int port, int ret) //Mouse range is -32767 -> 32767 //1% is about 655 //Use the left analog stick field to store the absolute coordinates - //Fix cursor to top-left when gun is detected as "offscreen" + + int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X); + int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y); + + //Have the Libretro API let /libpcsxcore/plugins.c know when the lightgun is pointed offscreen + //Offscreen value is chosen to be well out of range of any possible scaling done via core options if (input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN) || input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { - in_analog_left[port][0] = -32767; - in_analog_left[port][1] = -32767; + in_analog_left[port][0] = (65536 - 512) * 64; + in_analog_left[port][1] = (65536 - 512) * 64; } else { - int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X); - int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y); - in_analog_left[port][0] = (gunx * GunconAdjustRatioX) + (GunconAdjustX * 655); in_analog_left[port][1] = (guny * GunconAdjustRatioY) + (GunconAdjustY * 655); } diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index b143923b..13ab2972 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -664,28 +664,17 @@ void _PADstartPoll(PadDataS *pad) { int absX = (pad->absoluteX / 64) + 512; int absY = (pad->absoluteY / 64) + 512; - //Keep within limits - if (absX > 1023) absX = 1023; - if (absX < 0) absX = 0; - if (absY > 1023) absY = 1023; - if (absY < 0) absY = 0; - - stdpar[4] = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10); - stdpar[5] = (0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10)) >> 8; - stdpar[6] = 0x20 + (yres * absY >> 10); - stdpar[7] = (0x20 + (yres * absY >> 10)) >> 8; - - //Offscreen - Point at the side of the screen so PSX thinks you are pointing offscreen - //Required as a mouse can't be offscreen - //Coordinates X=0001h, Y=000Ah indicates "no light" - //This will mean you cannot shoot the very each of the screen - //ToDo read offscreen range from settings if useful to change - int OffscreenRange = 2; - if (absX < (OffscreenRange) || absX > (1023 - OffscreenRange) || absY < (OffscreenRange) || absY > (1023 - OffscreenRange)) { - stdpar[4] = 0x01; - stdpar[5] = 0x00; - stdpar[6] = 0x0A; - stdpar[7] = 0x00; + if (absX == 65536 || absY == 65536) { + stdpar[4] = 0x01; + stdpar[5] = 0x00; + stdpar[6] = 0x0A; + stdpar[7] = 0x00; + } + else { + stdpar[4] = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10); + stdpar[5] = (0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10)) >> 8; + stdpar[6] = 0x20 + (yres * absY >> 10); + stdpar[7] = (0x20 + (yres * absY >> 10)) >> 8; } memcpy(buf, stdpar, 8);