X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fplugins.c;h=67fe83525f4a7eaf085bd4b3dad6830443069495;hb=2e6a3b0ee60c654873ca836d3f18ba9f57880fb4;hp=4f52ed2cebef41f21d0b837f8c6c34a4938886a2;hpb=cf4334ed9741d6247673fefa057b71926b2e1cfe;p=pcsx_rearmed.git diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 4f52ed2c..67fe8352 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -640,6 +640,48 @@ void _PADstartPoll(PadDataS *pad) { stdpar[5] = pad->rightJoyY; stdpar[6] = pad->leftJoyX; stdpar[7] = pad->leftJoyY; + memcpy(buf, stdpar, 8); + respSize = 8; + break; + case PSE_PAD_TYPE_GUNCON: // GUNCON - gun controller SLPH-00034 from Namco + stdpar[0] = 0x63; + stdpar[1] = 0x5a; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + + //This code assumes an X resolution of 256 and a Y resolution of 240 + int xres = 256; + int yres = 240; + + //The code wants an input range for x and y of 0-1023 we passed in -32767 -> 32767 + 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; + } + memcpy(buf, stdpar, 8); respSize = 8; break; @@ -1064,7 +1106,7 @@ void CALLBACK clearDynarec(void) { int LoadPlugins() { int ret; - char Plugin[MAXPATHLEN]; + char Plugin[MAXPATHLEN * 2]; ReleasePlugins(); SysLibError(); @@ -1169,7 +1211,7 @@ int ReloadCdromPlugin() if (UsingIso()) { LoadCDRplugin(NULL); } else { - char Plugin[MAXPATHLEN]; + char Plugin[MAXPATHLEN * 2]; sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr); if (LoadCDRplugin(Plugin) == -1) return -1; } @@ -1182,7 +1224,7 @@ void SetIsoFile(const char *filename) { IsoFile[0] = '\0'; return; } - strncpy(IsoFile, filename, MAXPATHLEN); + strncpy(IsoFile, filename, MAXPATHLEN - 1); } const char *GetIsoFile(void) {