X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fplugins.c;h=801523230500aa1dbe7969ac904d70707cfa5161;hb=8822f8b13ece6d070070aa5eef6d93d0340509a0;hp=afe3f3b8b97e06061aaf4cd7e7cc0f2592c76ad9;hpb=ff787a954fe4b7b2d50d0dddd1437eda75df0421;p=pcsx_rearmed.git diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index afe3f3b8..80152323 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -366,6 +366,8 @@ static int LoadSPUplugin(const char *SPUdll) { return 0; } +extern int in_type[8]; + void *hPAD1Driver = NULL; void *hPAD2Driver = NULL; @@ -376,6 +378,7 @@ static PadDataS pad[8]; static int reqPos, respSize, req; static int ledStateReq44[8]; +static int PadMode[8]; /* 0 : digital 1: analog */ static unsigned char buf[256]; static unsigned char bufMulti[34] = { 0x80, 0x5a, @@ -529,6 +532,7 @@ void initBufForRequest(int padIndex, char value){ break; case CMD_QUERY_MODEL_AND_MODE : memcpy(buf, resp45, 8); + buf[4] = PadMode[padIndex]; break; case CMD_QUERY_ACT : memcpy(buf, resp46_00, 8); @@ -584,6 +588,7 @@ void reqIndex2Treatment(int padIndex, char value){ //0x01 analog ON //0x00 analog OFF ledStateReq44[padIndex] = value; + PadMode[padIndex] = value; break; case CMD_QUERY_ACT : //0x46 @@ -640,6 +645,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; @@ -699,8 +746,16 @@ unsigned char _PADpoll(int port, unsigned char value) { if (reqPos == 0) { //mem the request number req = value; - //copy the default value of request response in buffer instead of the keystate - initBufForRequest(port, value); + + // Don't enable Analog/Vibration for a standard pad + if (in_type[port] == PSE_PAD_TYPE_STANDARD) { + ; // Pad keystate already in buffer + } + else + { + //copy the default value of request response in buffer instead of the keystate + initBufForRequest(port, value); + } } //if no new request the pad return 0xff, for signaling connected @@ -719,7 +774,8 @@ unsigned char _PADpoll(int port, unsigned char value) { //mem the vibration value for Large motor; pad[port].Vib[1] = value; //vibration - vibrate(port); + if (in_type[port] != PSE_PAD_TYPE_STANDARD) + vibrate(port); break; } break; @@ -1064,7 +1120,7 @@ void CALLBACK clearDynarec(void) { int LoadPlugins() { int ret; - char Plugin[MAXPATHLEN]; + char Plugin[MAXPATHLEN * 2]; ReleasePlugins(); SysLibError(); @@ -1141,11 +1197,11 @@ void ReleasePlugins() { if (Config.UseNet && hNETDriver != NULL) NET_shutdown(); - if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; - if (hGPUDriver != NULL) SysCloseLibrary(hGPUDriver); hGPUDriver = NULL; - if (hSPUDriver != NULL) SysCloseLibrary(hSPUDriver); hSPUDriver = NULL; - if (hPAD1Driver != NULL) SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL; - if (hPAD2Driver != NULL) SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL; + if (hCDRDriver != NULL) { SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; } + if (hGPUDriver != NULL) { SysCloseLibrary(hGPUDriver); hGPUDriver = NULL; } + if (hSPUDriver != NULL) { SysCloseLibrary(hSPUDriver); hSPUDriver = NULL; } + if (hPAD1Driver != NULL) { SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL; } + if (hPAD2Driver != NULL) { SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL; } if (Config.UseNet && hNETDriver != NULL) { SysCloseLibrary(hNETDriver); hNETDriver = NULL; @@ -1164,12 +1220,12 @@ void ReleasePlugins() { int ReloadCdromPlugin() { if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown(); - if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; + if (hCDRDriver != NULL) { SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; } 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 +1238,7 @@ void SetIsoFile(const char *filename) { IsoFile[0] = '\0'; return; } - strncpy(IsoFile, filename, MAXPATHLEN); + strncpy(IsoFile, filename, MAXPATHLEN - 1); } const char *GetIsoFile(void) {