diff options
author | alexis-puska | 2016-05-12 01:45:26 +0200 |
---|---|---|
committer | cbransden | 2016-05-13 18:29:58 +0100 |
commit | 29f3675b9b2f24b8a16db73588b8b04d628eabd8 (patch) | |
tree | 026cbda2436e123ae3fabb6285e84ee3e753cc70 | |
parent | ace14ab3172ad90809a3cc5e8fe67d5cac9e294b (diff) | |
download | pcsx_rearmed-29f3675b9b2f24b8a16db73588b8b04d628eabd8.tar.gz pcsx_rearmed-29f3675b9b2f24b8a16db73588b8b04d628eabd8.tar.bz2 pcsx_rearmed-29f3675b9b2f24b8a16db73588b8b04d628eabd8.zip |
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
-rw-r--r-- | frontend/libretro.c | 4 | ||||
-rw-r--r-- | frontend/plugin.c | 30 | ||||
-rw-r--r-- | frontend/plugin_lib.c | 2 | ||||
-rw-r--r-- | frontend/plugin_lib.h | 4 | ||||
-rw-r--r-- | include/psemu_plugin_defs.h | 5 | ||||
-rw-r--r-- | libpcsxcore/plugins.c | 104 | ||||
-rw-r--r-- | libpcsxcore/plugins.h | 2 |
7 files changed, 113 insertions, 38 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c index 4486b95..361695c 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -58,8 +58,8 @@ int in_type[8]; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; unsigned short in_keystate[8]; -int multitap1; -int multitap2; +int multitap1 = 0; +int multitap2 = 0; int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ diff --git a/frontend/plugin.c b/frontend/plugin.c index d713452..cf93df8 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -49,10 +49,14 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int); extern int CALLBACK SPUplayCDDAchannel(short *, int); /* PAD */ -static long PADreadPort1(PadDataS *pad, int pad_index) -{ +static long PADreadPort1(PadDataS *pad, int pad_index) { pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; + if(multitap1==1){ + pad->portMultitap=1; + }else{ + pad->portMultitap=0; + } if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { pad->leftJoyX = in_analog_left[pad_index][0]; pad->leftJoyY = in_analog_left[pad_index][1]; @@ -62,15 +66,19 @@ static long PADreadPort1(PadDataS *pad, int pad_index) return 0; } -static long PADreadPort2(PadDataS *pad) -{ - pad->controllerType = in_type[4]; - pad->buttonStatus = ~in_keystate[4]; - if (in_type[4] == PSE_PAD_TYPE_ANALOGPAD || in_type[4] == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_analog_left[4][0]; - pad->leftJoyY = in_analog_left[4][1]; - pad->rightJoyX = in_analog_right[4][0]; - pad->rightJoyY = in_analog_right[4][1]; +static long PADreadPort2(PadDataS *pad, int pad_index) { + pad->controllerType = in_type[pad_index]; + pad->buttonStatus = ~in_keystate[pad_index]; + if(multitap2==1){ + pad->portMultitap=2; + }else{ + pad->portMultitap=0; + } + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[pad_index][0]; + pad->leftJoyY = in_analog_left[pad_index][1]; + pad->rightJoyX = in_analog_right[pad_index][0]; + pad->rightJoyY = in_analog_right[pad_index][1]; } return 0; } diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index ff3518e..ad2f49b 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -37,6 +37,8 @@ #define HUD_HEIGHT 10 int in_type[8]; +int multitap1; +int multitap2; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }}; diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 50fcf9e..ad27fc2 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -17,8 +17,10 @@ enum { DKEY_CROSS, DKEY_SQUARE, }; -extern int in_state_gun; +extern int in_state_gun; extern int in_type[8]; +extern int multitap1; +extern int multitap2; extern int in_analog_left[8][2]; extern int in_analog_right[8][2]; unsigned short in_keystate[8]; diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 9986654..7232d03 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -194,6 +194,11 @@ typedef struct // controler type - fill it withe predefined values above unsigned char controllerType; + //0 : No multitap between psx and pad + //1 : multitap between psx and pad on port 1 + //2 : multitap between psx and pad on port 2 + int portMultitap; + // status of buttons - every controller fills this field unsigned short buttonStatus; 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);
|