Fix input not responding
authornegativeExponent <negativeExponent@users.noreply.github.com>
Fri, 30 Oct 2020 11:33:23 +0000 (19:33 +0800)
committernegativeExponent <negativeExponent@users.noreply.github.com>
Fri, 30 Oct 2020 11:39:26 +0000 (19:39 +0800)
Pad mode set was missing that cause a few games which queries for an
analog-type controller to fail or causes no inputs at all.

This also change the "standard" input type to behave like one, which
means it does not have rumble or analog inputs. A required input type is
necessary to set the desired input effects.

Probably needs some cleanup but it works for now.

Fixes https://github.com/libretro/pcsx_rearmed/issues/161 and probably
other input related issues.

libpcsxcore/plugins.c

index 67fe835..8015232 100644 (file)
@@ -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
@@ -741,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
@@ -761,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;