// controller type - fill it withe predefined values above
unsigned char controllerType;
+ unsigned char padding;
+ unsigned short saveSize;
+
int portMultitap;
int requestPadIndex;
// values are in range -128 - 127
unsigned char moveX, moveY;
+ // Lightgun values
+ int absoluteX, absoluteY;
+
unsigned char Vib[2];
unsigned char VibF[2];
- //configuration mode Request 0x43
- int configMode;
-
- unsigned char txData[34];
-
+ struct {
+ unsigned char configMode;
+ unsigned char padMode; // 0 : digital 1: analog
+ unsigned char cmd4dConfig[6];
+ unsigned int lastUseFrame;
+ unsigned int digitalModeFrames;
+ } ds;
unsigned char multitapLongModeEnabled;
- unsigned char PadMode; // 0 : digital 1: analog
- unsigned char cmd4dConfig[6];
- unsigned char reserved[46];
-
- //Lightgun values
- int absoluteX,absoluteY;
+ unsigned char padding2;
+ unsigned char txData[34];
+ unsigned char reserved[26];
} PadDataS;
/* NET PlugIn v2 */
#include "plugins.h"
#include "cdriso.h"
+#include "psxcounters.h"
static char IsoFile[MAXPATHLEN] = "";
static s64 cdOpenCaseTime = 0;
static void initBufForRequest(int padIndex, char value) {
- if (pads[padIndex].configMode) {
+ if (pads[padIndex].ds.configMode) {
buf[0] = 0xf3; buf[1] = 0x5a;
respSize = 8;
}
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)
+ pads[padIndex].ds.padMode = 0; // according to nocash
+ pads[padIndex].ds.lastUseFrame = frame_counter;
+
switch (value) {
// keystate already in buffer, set by PADstartPoll_()
//case CMD_READ_DATA_AND_VIBRATE :
// break;
case CMD_CONFIG_MODE :
- if (pads[padIndex].configMode) {
+ if (pads[padIndex].ds.configMode) {
memcpy(buf, resp43, 8);
break;
}
break;
case CMD_QUERY_MODEL_AND_MODE :
memcpy(buf, resp45, 8);
- buf[4] = pads[padIndex].PadMode;
+ buf[4] = pads[padIndex].ds.padMode;
break;
case CMD_QUERY_ACT :
memcpy(buf, resp46_00, 8);
memcpy(buf, resp4C_00, 8);
break;
case CMD_VIBRATION_TOGGLE: // 4d
- memcpy(buf + 2, pads[padIndex].cmd4dConfig, 6);
+ memcpy(buf + 2, pads[padIndex].ds.cmd4dConfig, 6);
break;
case REQ40 :
memcpy(buf, resp40, 8);
case CMD_CONFIG_MODE :
//0x43
if (value == 0) {
- pads[padIndex].configMode = 0;
+ pads[padIndex].ds.configMode = 0;
} else {
- pads[padIndex].configMode = 1;
+ pads[padIndex].ds.configMode = 1;
}
break;
case CMD_SET_MODE_AND_LOCK :
//0x01 analog ON
//0x00 analog OFF
if ((value & ~1) == 0)
- pads[padIndex].PadMode = value;
+ pads[padIndex].ds.padMode = value;
break;
case CMD_QUERY_ACT :
//0x46
pad->VibF[0] = pad->Vib[0];
pad->VibF[1] = pad->Vib[1];
plat_trigger_vibrate(padIndex, pad->VibF[0], pad->VibF[1]);
- //printf("vibration pad %i\n", padIndex);
+ //printf("vib%i %02x %02x\n", padIndex, pad->VibF[0], pad->VibF[1]);
}
}
respSize = 4;
break;
case PSE_PAD_TYPE_ANALOGPAD: // scph1150
- if (pad->PadMode == 0)
+ if (pad->ds.padMode == 0)
goto standard;
stdpar[0] = 0x73;
stdpar[1] = 0x5a;
break;
case 7:
if (pads[port].txData[0] == CMD_VIBRATION_TOGGLE)
- memcpy(pads[port].cmd4dConfig, pads[port].txData + 2, 6);
+ memcpy(pads[port].ds.cmd4dConfig, pads[port].txData + 2, 6);
break;
}
}
memset(pads, 0, sizeof(pads));
for (p = 0; p < sizeof(pads) / sizeof(pads[0]); p++) {
- memset(pads[p].cmd4dConfig, 0xff, sizeof(pads[p].cmd4dConfig));
+ memset(pads[p].ds.cmd4dConfig, 0xff, sizeof(pads[p].ds.cmd4dConfig));
}
return 0;
return 0;
}
+int padFreeze(void *f, int Mode) {
+ size_t i;
+
+ for (i = 0; i < sizeof(pads) / sizeof(pads[0]); i++) {
+ pads[i].saveSize = sizeof(pads[i]);
+ gzfreeze(&pads[i], sizeof(pads[i]));
+ if (Mode == 0 && pads[i].saveSize != sizeof(pads[i]))
+ SaveFuncs.seek(f, pads[i].saveSize - sizeof(pads[i]), SEEK_CUR);
+ }
+
+ return 0;
+}
+
+
void *hNETDriver = NULL;
void CALLBACK NET__setInfo(netInfo *info) {}