-\r
-static unsigned char buf[256];\r
-unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
-unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff };\r
-unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
-unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
-\r
-static int bufcount, bufc;\r
-\r
-//PadDataS padd1, padd2;\r
-unsigned char _PADstartPollMultitap(PadDataS padd[4]) {\r
- int i = 0;\r
- int offset = 2;\r
- bufc = 0;\r
- PadDataS pad;\r
- for(i = 0; i < 4; i++) {\r
- offset = 2 + (i * 8);\r
- pad = padd[i];\r
- switch (pad.controllerType) {\r
- case PSE_PAD_TYPE_MOUSE:\r
- multitappar[offset + 1] = 0x12;\r
- multitappar[offset + 2] = 0x5a;\r
- multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
- multitappar[offset + 4] = pad.buttonStatus >> 8;\r
- multitappar[offset + 5] = pad.moveX;\r
- multitappar[offset + 6] = pad.moveY;\r
-\r
- break;\r
- case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)\r
- multitappar[offset + 1] = 0x23;\r
- multitappar[offset + 2] = 0x5a;\r
- multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
- multitappar[offset + 4] = pad.buttonStatus >> 8;\r
- multitappar[offset + 5] = pad.rightJoyX;\r
- multitappar[offset + 6] = pad.rightJoyY;\r
- multitappar[offset + 7] = pad.leftJoyX;\r
- multitappar[offset + 8] = pad.leftJoyY;\r
-\r
- break;\r
- case PSE_PAD_TYPE_ANALOGPAD: // scph1150\r
- multitappar[offset + 1] = 0x73;\r
- multitappar[offset + 2] = 0x5a;\r
- multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
- multitappar[offset + 4] = pad.buttonStatus >> 8;\r
- multitappar[offset + 5] = pad.rightJoyX;\r
- multitappar[offset + 6] = pad.rightJoyY;\r
- multitappar[offset + 7] = pad.leftJoyX;\r
- multitappar[offset + 8] = pad.leftJoyY;\r
-\r
- break;\r
- case PSE_PAD_TYPE_ANALOGJOY: // scph1110\r
- multitappar[offset + 1] = 0x53;\r
- multitappar[offset + 2] = 0x5a;\r
- multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
- multitappar[offset + 4] = pad.buttonStatus >> 8;\r
- multitappar[offset + 5] = pad.rightJoyX;\r
- multitappar[offset + 6] = pad.rightJoyY;\r
- multitappar[offset + 7] = pad.leftJoyX;\r
- multitappar[offset + 8] = pad.leftJoyY;\r
-\r
+//Pad information, keystate, mode, config mode, vibration\r
+static PadDataS pad[8];
+
+static int reqPos, respSize, req;
+static int ledStateReq44[8];
+\r
+static unsigned char buf[256];
+static unsigned char bufMulti[34] = { 0x80, 0x5a,
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ \r
+unsigned char stdpar[8] = { 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
+unsigned char multitappar[34] = { 0x80, 0x5a,
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
+ \r
+//response for request 44, 45, 46, 47, 4C, 4D\r
+static unsigned char resp45[8] = {0xF3, 0x5A, 0x01, 0x02, 0x00, 0x02, 0x01, 0x00};\r
+static unsigned char resp46_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A};\r
+static unsigned char resp46_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x14};\r
+static unsigned char resp47[8] = {0xF3, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00};\r
+static unsigned char resp4C_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00};\r
+static unsigned char resp4C_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00};\r
+static unsigned char resp4D[8] = {0xF3, 0x5A, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF};\r
+
+//fixed reponse of request number 41, 48, 49, 4A, 4B, 4E, 4F
+static unsigned char resp40[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp41[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp43[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+static unsigned char resp44[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp49[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4A[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4B[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4E[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4F[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// Resquest of psx core
+enum {
+ // REQUEST
+ // first call of this request for the pad, the pad is configured as an digital pad.
+ // 0x0X, 0x42, 0x0Y, 0xZZ, 0xAA, 0x00, 0x00, 0x00, 0x00
+ // X pad number (used for the multitap, first request response 0x00, 0x80, 0x5A, (8 bytes pad A), (8 bytes pad B), (8 bytes pad C), (8 bytes pad D)
+ // Y if 1 : psx request the full length response for the multitap, 3 bytes header and 4 block of 8 bytes per pad
+ // Y if 0 : psx request a pad key state
+ // ZZ rumble small motor 00-> OFF, 01 -> ON
+ // AA rumble large motor speed 0x00 -> 0xFF
+ // RESPONSE
+ // header 3 Bytes
+ // 0x00
+ // PadId -> 0x41 for digital pas, 0x73 for analog pad
+ // 0x5A mode has not change (no press on analog button on the center of pad), 0x00 the analog button have been pressed and the mode switch
+ // 6 Bytes for keystates
+ CMD_READ_DATA_AND_VIBRATE = 0x42,
+
+ // REQUEST
+ // Header
+ // 0x0N, 0x43, 0x00, XX, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ // XX = 00 -> Normal mode : Seconde bytes of response = padId
+ // XX = 01 -> Configuration mode : Seconde bytes of response = 0xF3
+ // RESPONSE
+ // enter in config mode example :
+ // req : 01 43 00 01 00 00 00 00 00 00
+ // res : 00 41 5A buttons state, analog states
+ // exit config mode :
+ // req : 01 43 00 00 00 00 00 00 00 00
+ // res : 00 F3 5A buttons state, analog states
+ CMD_CONFIG_MODE = 0x43,
+
+ // Set led State
+ // REQUEST
+ // 0x0N, 0x44, 0x00, VAL, SEL, 0x00, 0x00, 0x00, 0x00
+ // If sel = 2 then
+ // VAL = 00 -> OFF
+ // VAL = 01 -> ON
+ // RESPONSE
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ CMD_SET_MODE_AND_LOCK = 0x44,
+
+ // Get Analog Led state
+ // REQUEST
+ // 0x0N, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ // RESPONSE
+ // 0x00, 0xF3, 0x5A, 0x01, 0x02, VAL, 0x02, 0x01, 0x00
+ // VAL = 00 Led OFF
+ // VAL = 01 Led ON
+ CMD_QUERY_MODEL_AND_MODE = 0x45,
+
+ //Get Variable A
+ // REQUEST
+ // 0x0N, 0x46, 0x00, 0xXX, 0x00, 0x00, 0x00, 0x00, 0x00
+ // RESPONSE
+ // XX=00
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A
+ // XX=01
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x14
+ CMD_QUERY_ACT = 0x46,
+
+ // REQUEST
+ // 0x0N, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ // RESPONSE
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00
+ CMD_QUERY_COMB = 0x47,
+
+ // REQUEST
+ // 0x0N, 0x4C, 0x00, 0xXX, 0x00, 0x00, 0x00, 0x00, 0x00
+ // RESPONSE
+ // XX = 0
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
+ // XX = 1
+ // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00
+ CMD_QUERY_MODE = 0x4C,
+
+ // REQUEST
+ // 0x0N, 0x4D, 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
+ // RESPONSE
+ // 0x00, 0xF3, 0x5A, old value or
+ // AA = 01 unlock large motor (and swap VAL1 and VAL2)
+ // BB = 01 unlock large motor (default)
+ // CC, DD, EE, FF = all FF -> unlock small motor
+ //
+ // default repsonse for analog pad with 2 motor : 0x00 0xF3 0x5A 0x00 0x01 0xFF 0xFF 0xFF 0xFF
+ //
+ CMD_VIBRATION_TOGGLE = 0x4D,
+ REQ40 = 0x40,
+ REQ41 = 0x41,
+ REQ49 = 0x49,
+ REQ4A = 0x4A,
+ REQ4B = 0x4B,
+ REQ4E = 0x4E,
+ REQ4F = 0x4F
+};
+
+
+
+
+//NO MULTITAP
+
+void initBufForRequest(int padIndex, char value){
+ switch (value){\r
+ //Pad keystate already in buffer\r
+ //case CMD_READ_DATA_AND_VIBRATE :\r
+ // break;\r
+ case CMD_CONFIG_MODE :\r
+ if (pad[padIndex].configMode == 1) {\r
+ memcpy(buf, resp43, 8);\r