//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);
}
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);