From 52c9fcc88f6a908c359afbf12f821602c25df123 Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Sat, 2 Jul 2016 13:57:35 +0200 Subject: [PATCH] Add dual shop request/response Add dualshock request/response to declare Analog pad correctly and retrieved the vibration information. --- include/psemu_plugin_defs.h | 4 +- libpcsxcore/plugins.c | 566 +++++++++++++++++++++++++----------- 2 files changed, 396 insertions(+), 174 deletions(-) diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 09e950ab..5c2fefe1 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -213,7 +213,9 @@ typedef struct unsigned char Vib[2]; unsigned char VibF[2]; - + + //configuration mode Request 0x43 + boolean configMode; unsigned char reserved[87]; } PadDataS; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index c9ccd2ae..64996b24 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -370,169 +370,411 @@ void *hPAD2Driver = NULL; static int multitap1 = -1; static int multitap2 = -1; +//Pad information, keystate, mode, config mode, vibration +static PadDataS pad[8]; + +static int reqPos, respSize, req, ledStateReq44; static unsigned char buf[256]; -unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff }; -unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - -static int bufcount, bufc; - -//PadDataS padd1, padd2; -unsigned char _PADstartPollMultitap(PadDataS padd[4]) { +unsigned char stdpar[8] = { 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +unsigned char multitappar[34] = { 0x80, 0x5a, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + +//response for request 44, 45, 46, 47, 4C, 4D +static unsigned char resp45[8] = {0xF3, 0x5A, 0x01, 0x02, 0x00, 0x02, 0x01, 0x00}; +static unsigned char resp46_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A}; +static unsigned char resp46_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x14}; +static unsigned char resp47[8] = {0xF3, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00}; +static unsigned char resp4C_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00}; +static unsigned char resp4C_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00}; +static unsigned char resp4D[8] = {0xF3, 0x5A, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF}; + +//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 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 +}; + +void initBufForRequest(int padIndex, char value){ + switch (value){ + //Pad keystate already in buffer + //case CMD_READ_DATA_AND_VIBRATE : + // break; + case CMD_CONFIG_MODE : + if(pad[padIndex].configMode == TRUE){ + buf[0] = 0xF3; + buf[1] = 0x53; + } + //else, not in config mode, pad keystate return (already in the buffer) + break; + case CMD_SET_MODE_AND_LOCK : + memcpy(buf, resp44, 8); + break; + case CMD_QUERY_MODEL_AND_MODE : + memcpy(buf, resp45, 8); + break; + case CMD_QUERY_ACT : + memcpy(buf, resp46_00, 8); + break; + case CMD_QUERY_COMB : + memcpy(buf, resp47, 8); + break; + case CMD_QUERY_MODE : + memcpy(buf, resp4C_00, 8); + break; + case CMD_VIBRATION_TOGGLE : + memcpy(buf, resp4D, 8); + break; + case REQ40 : + memcpy(buf, resp40, 8); + break; + case REQ41 : + memcpy(buf, resp41, 8); + break; + case REQ49 : + memcpy(buf, resp49, 8); + break; + case REQ4A : + memcpy(buf, resp4A, 8); + break; + case REQ4B : + memcpy(buf, resp4B, 8); + break; + case REQ4E : + memcpy(buf, resp4E, 8); + break; + case REQ4F : + memcpy(buf, resp4F, 8); + break; + } +} + +void reqIndex2Treatment(int padIndex, char value){ + switch (value){ + case CMD_CONFIG_MODE : + //0x43 + if(value == 0){ + pad[padIndex].configMode = FALSE; + }else{ + pad->configMode = TRUE; + } + break; + case CMD_SET_MODE_AND_LOCK : + //0x44 store the led state for change mode if the next value = 0x02 + //0x01 analog ON + //0x00 analog OFF + ledStateReq44 = value; + break; + case CMD_QUERY_ACT : + //0x46 + if(value==1){ + memcpy(buf, resp46_01, 8); + } + break; + + case CMD_QUERY_MODE : + if(value==1){ + memcpy(buf, resp4C_01, 8); + } + break; + case CMD_VIBRATION_TOGGLE : + //0x4D + memcpy(buf, resp4D, 8); + break; + case CMD_READ_DATA_AND_VIBRATE: + //mem the vibration value for small motor; + pad[padIndex].Vib[0] = value; + } +} + +void vibrate(int padIndex){ + if(pad[padIndex].Vib[0] != pad[padIndex].VibF[0] || pad[padIndex].Vib[1] != pad[padIndex].VibF[1]){ + //value is different update Value and call libretro for vibration + pad[padIndex].VibF[0] = pad[padIndex].Vib[0]; + pad[padIndex].VibF[1] = pad[padIndex].Vib[1]; + plat_trigger_vibrate(padIndex, pad[padIndex].VibF[0], pad[padIndex].VibF[1]); + printf("new value for vibration pad %i", padIndex); + } +} + + + +//Build response for 0x42 request Multitap in port +void _PADstartPollMultitap(PadDataS padd[4]) { int i = 0; int offset = 2; - bufc = 0; PadDataS pad; for(i = 0; i < 4; i++) { offset = 2 + (i * 8); pad = padd[i]; switch (pad.controllerType) { case PSE_PAD_TYPE_MOUSE: - multitappar[offset + 1] = 0x12; - multitappar[offset + 2] = 0x5a; - multitappar[offset + 3] = pad.buttonStatus & 0xff; - multitappar[offset + 4] = pad.buttonStatus >> 8; - multitappar[offset + 5] = pad.moveX; - multitappar[offset + 6] = pad.moveY; + multitappar[offset] = 0x12; + multitappar[offset + 1] = 0x5a; + multitappar[offset + 2] = pad.buttonStatus & 0xff; + multitappar[offset + 3] = pad.buttonStatus >> 8; + multitappar[offset + 4] = pad.moveX; + multitappar[offset + 5] = pad.moveY; break; case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069) - multitappar[offset + 1] = 0x23; - multitappar[offset + 2] = 0x5a; - multitappar[offset + 3] = pad.buttonStatus & 0xff; - multitappar[offset + 4] = pad.buttonStatus >> 8; - multitappar[offset + 5] = pad.rightJoyX; - multitappar[offset + 6] = pad.rightJoyY; - multitappar[offset + 7] = pad.leftJoyX; - multitappar[offset + 8] = pad.leftJoyY; + multitappar[offset] = 0x23; + multitappar[offset + 1] = 0x5a; + multitappar[offset + 2] = pad.buttonStatus & 0xff; + multitappar[offset + 3] = pad.buttonStatus >> 8; + multitappar[offset + 4] = pad.rightJoyX; + multitappar[offset + 5] = pad.rightJoyY; + multitappar[offset + 6] = pad.leftJoyX; + multitappar[offset + 7] = pad.leftJoyY; break; case PSE_PAD_TYPE_ANALOGPAD: // scph1150 - multitappar[offset + 1] = 0x73; - multitappar[offset + 2] = 0x5a; - multitappar[offset + 3] = pad.buttonStatus & 0xff; - multitappar[offset + 4] = pad.buttonStatus >> 8; - multitappar[offset + 5] = pad.rightJoyX; - multitappar[offset + 6] = pad.rightJoyY; - multitappar[offset + 7] = pad.leftJoyX; - multitappar[offset + 8] = pad.leftJoyY; + multitappar[offset] = 0x73; + multitappar[offset + 1] = 0x5a; + multitappar[offset + 2] = pad.buttonStatus & 0xff; + multitappar[offset + 3] = pad.buttonStatus >> 8; + multitappar[offset + 4] = pad.rightJoyX; + multitappar[offset + 5] = pad.rightJoyY; + multitappar[offset + 6] = pad.leftJoyX; + multitappar[offset + 7] = pad.leftJoyY; break; case PSE_PAD_TYPE_ANALOGJOY: // scph1110 - multitappar[offset + 1] = 0x53; - multitappar[offset + 2] = 0x5a; - multitappar[offset + 3] = pad.buttonStatus & 0xff; - multitappar[offset + 4] = pad.buttonStatus >> 8; - multitappar[offset + 5] = pad.rightJoyX; - multitappar[offset + 6] = pad.rightJoyY; - multitappar[offset + 7] = pad.leftJoyX; - multitappar[offset + 8] = pad.leftJoyY; + multitappar[offset] = 0x53; + multitappar[offset + 1] = 0x5a; + multitappar[offset + 2] = pad.buttonStatus & 0xff; + multitappar[offset + 3] = pad.buttonStatus >> 8; + multitappar[offset + 4] = pad.rightJoyX; + multitappar[offset + 5] = pad.rightJoyY; + multitappar[offset + 6] = pad.leftJoyX; + multitappar[offset + 7] = pad.leftJoyY; break; case PSE_PAD_TYPE_STANDARD: default: - multitappar[offset + 1] = 0x41; - multitappar[offset + 2] = 0x5a; - multitappar[offset + 3] = pad.buttonStatus & 0xff; - multitappar[offset + 4] = pad.buttonStatus >> 8; + multitappar[offset] = 0x41; + multitappar[offset + 1] = 0x5a; + multitappar[offset + 2] = pad.buttonStatus & 0xff; + multitappar[offset + 3] = pad.buttonStatus >> 8; } } - - memcpy(buf, multitappar, 35); - bufcount = 34; - - return buf[bufc++]; + memcpy(buf, multitappar, 34); + respSize = 34; } - -unsigned char _PADstartPoll(PadDataS *pad) { - - bufc = 0; - + +//Build response for 0x42 request Pad in port +void _PADstartPoll(PadDataS *pad) { switch (pad->controllerType) { case PSE_PAD_TYPE_MOUSE: - mousepar[3] = pad->buttonStatus & 0xff; - mousepar[4] = pad->buttonStatus >> 8; - mousepar[5] = pad->moveX; - mousepar[6] = pad->moveY; - - memcpy(buf, mousepar, 7); - bufcount = 6; + stdpar[0] = 0x12; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + stdpar[4] = pad->moveX; + stdpar[5] = pad->moveY; + memcpy(buf, stdpar, 6); + respSize = 6; break; case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069) - analogpar[1] = 0x23; - analogpar[3] = pad->buttonStatus & 0xff; - analogpar[4] = pad->buttonStatus >> 8; - analogpar[5] = pad->rightJoyX; - analogpar[6] = pad->rightJoyY; - analogpar[7] = pad->leftJoyX; - analogpar[8] = pad->leftJoyY; - - memcpy(buf, analogpar, 9); - bufcount = 8; + stdpar[0] = 0x23; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + stdpar[4] = pad->rightJoyX; + stdpar[5] = pad->rightJoyY; + stdpar[6] = pad->leftJoyX; + stdpar[7] = pad->leftJoyY; + memcpy(buf, stdpar, 8); + respSize = 8; break; case PSE_PAD_TYPE_ANALOGPAD: // scph1150 - analogpar[1] = 0x73; - analogpar[3] = pad->buttonStatus & 0xff; - analogpar[4] = pad->buttonStatus >> 8; - analogpar[5] = pad->rightJoyX; - analogpar[6] = pad->rightJoyY; - analogpar[7] = pad->leftJoyX; - analogpar[8] = pad->leftJoyY; - - memcpy(buf, analogpar, 9); - bufcount = 8; + stdpar[0] = 0x73; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + stdpar[4] = pad->rightJoyX; + stdpar[5] = pad->rightJoyY; + stdpar[6] = pad->leftJoyX; + stdpar[7] = pad->leftJoyY; + memcpy(buf, stdpar, 8); + respSize = 8; break; case PSE_PAD_TYPE_ANALOGJOY: // scph1110 - analogpar[1] = 0x53; - analogpar[3] = pad->buttonStatus & 0xff; - analogpar[4] = pad->buttonStatus >> 8; - analogpar[5] = pad->rightJoyX; - analogpar[6] = pad->rightJoyY; - analogpar[7] = pad->leftJoyX; - analogpar[8] = pad->leftJoyY; - - memcpy(buf, analogpar, 9); - bufcount = 8; + stdpar[0] = 0x53; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + stdpar[4] = pad->rightJoyX; + stdpar[5] = pad->rightJoyY; + stdpar[6] = pad->leftJoyX; + stdpar[7] = pad->leftJoyY; + memcpy(buf, stdpar, 8); + respSize = 8; break; case PSE_PAD_TYPE_STANDARD: default: - stdpar[3] = pad->buttonStatus & 0xff; - stdpar[4] = pad->buttonStatus >> 8; - memcpy(buf, stdpar, 5); - bufcount = 4; + stdpar[2] = pad->buttonStatus & 0xff; + stdpar[3] = pad->buttonStatus >> 8; + memcpy(buf, stdpar, 4); + respSize = 8; } - - return buf[bufc++]; } -unsigned char _PADpoll(unsigned char value) { - if (bufc > bufcount) return 0; - return buf[bufc++]; + + +unsigned char _PADpoll(int padIndex, unsigned char value) { + + //If no multitap on the port, we made the full implementation of dualshock protocol + if(multitap1 == 0){ + if(reqPos==0){ + //mem the request number + req = value; + //copy the default value of request response in buffer instead of the keystate + initBufForRequest(padIndex,value); + } + + //if no new request the pad return 0xff, for signaling connected + if ( reqPos >= respSize) return 0xff; + + switch(reqPos){ + case 2: + reqIndex2Treatment(padIndex, value); + break; + case 3: + switch(req) { + case CMD_SET_MODE_AND_LOCK : + //change mode on pad + break; + case CMD_READ_DATA_AND_VIBRATE: + //mem the vibration value for Large motor; + pad[padIndex].Vib[1] = value; + //vibration + vibrate(padIndex); + break; + + break; + } + } + } + return buf[reqPos++]; } // refresh the button state on port 1. // int pad is not needed. -unsigned char CALLBACK PAD1__startPoll(int pad) { +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) - { + 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) - { + if (multitap1 == 0){ PadDataS padd; padd.requestPadIndex = 0; PAD1_readPort1(&padd); - return _PADstartPoll(&padd); + _PADstartPoll(&padd); } else { // a multitap is plugged : refresh all pad. int i=0; @@ -540,27 +782,21 @@ unsigned char CALLBACK PAD1__startPoll(int pad) { for(i = 0; i < 4; i++) { padd[i].requestPadIndex = i; PAD1_readPort1(&padd[i]); - } - return _PADstartPollMultitap(padd); - } + } + _PADstartPollMultitap(padd); + } + printf("\n"); + return 0x00; } -unsigned char CALLBACK PAD1__poll(unsigned char value) { - if (multitap1 == 0) - { - return _PADpoll(value); - } else { - if(value == 42) { - unsigned char bufmultitap[256]; - memcpy(bufmultitap, multitappar, 3); - bufcount = 2; - return bufmultitap[bufc++]; - } else { - return _PADpoll(value); - } - } +unsigned char CALLBACK PAD1__poll(unsigned char value) { + char tmp = _PADpoll(0, value); + printf("%2x:%2x , ",value,tmp); + return tmp; + } + long CALLBACK PAD1__configure(void) { return 0; } void CALLBACK PAD1__about(void) {} long CALLBACK PAD1__test(void) { return 0; } @@ -603,60 +839,44 @@ static int LoadPAD1plugin(const char *PAD1dll) { return 0; } -unsigned char CALLBACK PAD2__startPoll(int pad) { - int pad_index = 0; - if(multitap1 == 1){ - pad_index+=4; - }else{ - pad_index=1; - } - //first call the pad provide if a multitap is connected between the psx and himself - if(multitap2 == -1){ +unsigned char CALLBACK PAD2__startPoll(int pad) { + reqPos = 0; + int pad_index = 0; + if(multitap1 == 1){ + pad_index+=4; + }else{ + pad_index=1; + } + //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 2 : NO MULTITAP - if (multitap2 == 0){ + padd.requestPadIndex = pad_index; + PAD2_readPort2(&padd); + multitap2 = padd.portMultitap; + } + + // just one pad is on port 1 : NO MULTITAP + if (multitap2 == 0){ PadDataS padd; - padd.requestPadIndex = pad_index; + padd.requestPadIndex = pad_index; PAD2_readPort2(&padd); - return _PADstartPoll(&padd); - }else{ - //a multitap is plugged : refresh all pad. - int i=0; - PadDataS padd[4]; + _PADstartPoll(&padd); + } else { + // a multitap is plugged : refresh all pad. + //a multitap is plugged : refresh all pad. + int i=0; + PadDataS padd[4]; for(i=0;i<4;i++){ - padd[i].requestPadIndex = i+pad_index; - PAD2_readPort2(&padd[i]); - } - return _PADstartPollMultitap(padd); - } + padd[i].requestPadIndex = i+pad_index; + PAD2_readPort2(&padd[i]); + } + _PADstartPollMultitap(padd); + } + return 0x00; } unsigned char CALLBACK PAD2__poll(unsigned char value) { -// if(value !=0){ -// int i; -// printf("%2x %c\n", value, value); -// for (i = 0; i < 35; i++) { -// printf("%2x", buf[i]); -// } -// printf("\n"); -// } - if(multitap2==0){ - return _PADpoll(value); - }else { - if(value==42){ - unsigned char bufmultitap[256]; - memcpy(bufmultitap, multitappar, 3); - bufcount = 2; - return bufmultitap[bufc++]; - }else{ - return _PADpoll(value); - } - } + return _PADpoll(1,value); } long CALLBACK PAD2__configure(void) { return 0; } -- 2.39.5