libretro: add a few options for the analog combo
[pcsx_rearmed.git] / libpcsxcore / plugins.c
index a617187..75e1f5f 100644 (file)
@@ -490,15 +490,8 @@ static void initBufForRequest(int padIndex, char value) {
                return;
        }
 
-       // switch to analog mode automatically after the game finishes init
-       if (value == 0x42 && pads[padIndex].ds.padMode == 0)
-               pads[padIndex].ds.digitalModeFrames++;
-       if (pads[padIndex].ds.digitalModeFrames == 60*4) {
-               pads[padIndex].ds.padMode = 1;
-               pads[padIndex].ds.digitalModeFrames = 0;
-       }
-
-       if ((u32)(frame_counter - pads[padIndex].ds.lastUseFrame) > 60u)
+       if ((u32)(frame_counter - pads[padIndex].ds.lastUseFrame) > 60u
+           && !Config.hacks.dualshock_init_analog)
                pads[padIndex].ds.padMode = 0; // according to nocash
        pads[padIndex].ds.lastUseFrame = frame_counter;
 
@@ -626,8 +619,9 @@ static void adjust_analog(unsigned char *b)
 {
        // ff8 hates 0x80 for whatever reason (broken in 2d area menus),
        // or is this caused by something else we do wrong??
-       if (b[6] == 0x80)
-               b[6] = 0x7f;
+       // Also S.C.A.R.S. treats 0x7f as turning left.
+       if (b[6] == 0x7f || b[6] == 0x80)
+               b[6] = 0x81;
 }
 
 // Build response for 0x42 request Pad in port
@@ -990,6 +984,15 @@ int padFreeze(void *f, int Mode) {
        return 0;
 }
 
+int padToggleAnalog(unsigned int index)
+{
+       int r = -1;
+
+       if (index < sizeof(pads) / sizeof(pads[0]))
+               r = (pads[index].ds.padMode ^= 1);
+       return r;
+}
+
 
 void *hNETDriver = NULL;