X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fplugins.c;h=13ab2972e91928b9fb89413dfe72a05b015b7da0;hb=384af87540d751ef274e5956d58f4bbc153a34a9;hp=87b574d442a7895dcf08ae3954ab412b28484496;hpb=4bbae293a879164d93d66580219f168540e9d251;p=pcsx_rearmed.git diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 87b574d4..13ab2972 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -371,8 +371,8 @@ extern int in_type[8]; void *hPAD1Driver = NULL; void *hPAD2Driver = NULL; -static int multitap1 = -1; -static int multitap2 = -1; +static int multitap1; +static int multitap2; //Pad information, keystate, mode, config mode, vibration static PadDataS pad[8]; @@ -650,7 +650,7 @@ void _PADstartPoll(PadDataS *pad) { memcpy(buf, stdpar, 8); respSize = 8; break; - case PSE_PAD_TYPE_GUNCON: // GUNCON - gun controller SLPH-00034 from Namco + case PSE_PAD_TYPE_GUNCON: // GUNCON - gun controller SLPH-00034 from Namco stdpar[0] = 0x63; stdpar[1] = 0x5a; stdpar[2] = pad->buttonStatus & 0xff; @@ -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); @@ -776,9 +765,8 @@ unsigned char _PADpoll(int port, unsigned char value) { } //if no new request the pad return 0xff, for signaling connected - if (reqPos >= respSize - && writeok - ) return 0xff; + if (reqPos >= respSize) + return 0xff; switch(reqPos){ case 2: @@ -817,12 +805,6 @@ unsigned char _PADpollMultitap(int port, unsigned char value) { unsigned char CALLBACK PAD1__startPoll(int pad) { reqPos = 0; // first call the pad provide if a multitap is connected between the psx and himself - if (multitap1 == -1) { - PadDataS padd; - padd.requestPadIndex = 0; - PAD1_readPort1(&padd); - multitap1 = padd.portMultitap; - } // just one pad is on port 1 : NO MULTITAP if (multitap1 == 0) { PadDataS padd; @@ -873,6 +855,7 @@ long CALLBACK PAD1__keypressed() { return 0; } if (PAD1_##dest == NULL) PAD1_##dest = (PAD##dest) PAD1__##dest; static int LoadPAD1plugin(const char *PAD1dll) { + PadDataS padd; void *drv; hPAD1Driver = SysLoadLibrary(PAD1dll); @@ -895,6 +878,10 @@ static int LoadPAD1plugin(const char *PAD1dll) { LoadPad1Sym0(poll, "PADpoll"); LoadPad1SymN(setSensitive, "PADsetSensitive"); + padd.requestPadIndex = 0; + PAD1_readPort1(&padd); + multitap1 = padd.portMultitap; + return 0; } @@ -910,14 +897,6 @@ unsigned char CALLBACK PAD2__startPoll(int pad) { pad_index = 0; } - //first call the pad provide if a multitap is connected between the psx and himself - if (multitap2 == -1) { - PadDataS padd; - padd.requestPadIndex = pad_index; - PAD2_readPort2(&padd); - multitap2 = padd.portMultitap; - } - // just one pad is on port 1 : NO MULTITAP if (multitap2 == 0) { PadDataS padd; @@ -966,6 +945,7 @@ long CALLBACK PAD2__keypressed() { return 0; } LoadSym(PAD2_##dest, PAD##dest, name, FALSE); static int LoadPAD2plugin(const char *PAD2dll) { + PadDataS padd; void *drv; hPAD2Driver = SysLoadLibrary(PAD2dll); @@ -988,6 +968,10 @@ static int LoadPAD2plugin(const char *PAD2dll) { LoadPad2Sym0(poll, "PADpoll"); LoadPad2SymN(setSensitive, "PADsetSensitive"); + padd.requestPadIndex = 0; + PAD2_readPort2(&padd); + multitap2 = padd.portMultitap; + return 0; }