From 29f3675b9b2f24b8a16db73588b8b04d628eabd8 Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Thu, 12 May 2016 01:45:26 +0200 Subject: second implementation of multitap add game/core option to enabled or disabled multitap. Test with micro machine V3 and 5 devices, 2 multitap enabled, all device react good i can’t test the 6 7 8 select player but i can select 8 gamer. The 2 multitap works fine. i detect a bug, when we change the game pad type to analog, the library crash, see it next time --- libpcsxcore/plugins.c | 104 +++++++++++++++++++++++++++++++++++++++----------- libpcsxcore/plugins.h | 2 +- 2 files changed, 82 insertions(+), 24 deletions(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 372fdd0..3d0ed3c 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -368,7 +368,10 @@ static int LoadSPUplugin(const char *SPUdll) { void *hPAD1Driver = NULL; void *hPAD2Driver = NULL; -static unsigned char buf[256]; +static int multitap1 = -1; +static int multitap2 = -1; + +static unsigned char buf[512]; 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 }; @@ -380,7 +383,7 @@ unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff static int bufcount, bufc; //PadDataS padd1, padd2; -unsigned char _PADstartPollPort1(PadDataS padd[4]) { +unsigned char _PADstartPollMultitap(PadDataS padd[4]) { int i=0; int decallage=2; bufc = 0; @@ -515,16 +518,29 @@ unsigned char _PADpoll(unsigned char value) { // rafraichissement de l'état des boutons sur port 1, // int pad dans le code d'origine ne sert a rien... unsigned char CALLBACK PAD1__startPoll(int pad) { - int i=0; - PadDataS padd[4]; - for(i=0;i<4;i++){ - PAD1_readPort1(&padd[i],i); + //first call the pad provide if a multitap is connected between the psx and himself + if(multitap1 == -1){ + PadDataS padd; + PAD1_readPort1(&padd,0); + multitap1 = padd.portMultitap; + } + // just one pad is on port 1 : NO MULTITAP + if (multitap1 == 0){ + PadDataS padd; + PAD1_readPort1(&padd,0); + return _PADstartPoll(&padd); + }else{ + //a multitap is plugged : refresh all pad. + int i=0; + PadDataS padd[4]; + for(i=0;i<4;i++){ + PAD1_readPort1(&padd[i],i); + } + return _PADstartPollMultitap(padd); } - return _PADstartPollPort1(padd); } unsigned char CALLBACK PAD1__poll(unsigned char value) { - // if(value !=0){ // int i; // printf("%2x %c\n", value, value); @@ -533,23 +549,24 @@ unsigned char CALLBACK PAD1__poll(unsigned char value) { // } // printf("\n"); // } - - if(value==42){ - unsigned char bufmultitap[256]; - memcpy(bufmultitap, multitappar, 3); - bufcount = 2; - return bufmultitap[bufc++]; - }else{ + 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); + } } } long CALLBACK PAD1__configure(void) { return 0; } void CALLBACK PAD1__about(void) {} long CALLBACK PAD1__test(void) { return 0; } -long CALLBACK PAD1__query(void) { - printf("PAD1__query"); - return 3; } +long CALLBACK PAD1__query(void) { return 3; } long CALLBACK PAD1__keypressed() { return 0; } #define LoadPad1Sym1(dest, name) \ @@ -589,15 +606,56 @@ static int LoadPAD1plugin(const char *PAD1dll) { } unsigned char CALLBACK PAD2__startPoll(int pad) { - PadDataS padd; + 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; + PAD2_readPort2(&padd,pad_index); + multitap2 = padd.portMultitap; + } - PAD2_readPort2(&padd); - - return _PADstartPoll(&padd); + // just one pad is on port 2 : NO MULTITAP + if (multitap2 == 0){ + PadDataS padd; + PAD2_readPort2(&padd,pad_index); + return _PADstartPoll(&padd); + }else{ + //a multitap is plugged : refresh all pad. + int i=pad_index; + PadDataS padd[4]; + for(i=0;i<4;i++){ + PAD2_readPort2(&padd[i],i+pad_index); + } + return _PADstartPollMultitap(padd); + } } unsigned char CALLBACK PAD2__poll(unsigned char value) { - return _PADpoll(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); + } + } } long CALLBACK PAD2__configure(void) { return 0; } diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index 4f0c4fa..626939b 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -235,7 +235,7 @@ typedef long (CALLBACK* PADtest)(void); typedef long (CALLBACK* PADclose)(void); typedef long (CALLBACK* PADquery)(void); typedef long (CALLBACK* PADreadPort1)(PadDataS*, int pad_index); -typedef long (CALLBACK* PADreadPort2)(PadDataS*); +typedef long (CALLBACK* PADreadPort2)(PadDataS*, int pad_index); typedef long (CALLBACK* PADkeypressed)(void); typedef unsigned char (CALLBACK* PADstartPoll)(int); typedef unsigned char (CALLBACK* PADpoll)(unsigned char); -- cgit v1.2.3