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 */
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];
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;
}
#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 }};
void *hPAD1Driver = NULL;\r
void *hPAD2Driver = NULL;\r
\r
-static unsigned char buf[256];\r
+static int multitap1 = -1;\r
+static int multitap2 = -1;\r
+\r
+static unsigned char buf[512];\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
static int bufcount, bufc;\r
\r
//PadDataS padd1, padd2;\r
-unsigned char _PADstartPollPort1(PadDataS padd[4]) {\r
+unsigned char _PADstartPollMultitap(PadDataS padd[4]) {\r
int i=0;\r
int decallage=2;\r
bufc = 0;\r
// rafraichissement de l'état des boutons sur port 1,\r
// int pad dans le code d'origine ne sert a rien...\r
unsigned char CALLBACK PAD1__startPoll(int pad) {\r
- int i=0;\r
- PadDataS padd[4];\r
- for(i=0;i<4;i++){\r
- PAD1_readPort1(&padd[i],i);\r
+ //first call the pad provide if a multitap is connected between the psx and himself\r
+ if(multitap1 == -1){\r
+ PadDataS padd;\r
+ PAD1_readPort1(&padd,0);\r
+ multitap1 = padd.portMultitap;\r
+ }\r
+ // just one pad is on port 1 : NO MULTITAP\r
+ if (multitap1 == 0){\r
+ PadDataS padd;\r
+ PAD1_readPort1(&padd,0);\r
+ return _PADstartPoll(&padd);\r
+ }else{\r
+ //a multitap is plugged : refresh all pad.\r
+ int i=0;\r
+ PadDataS padd[4];\r
+ for(i=0;i<4;i++){\r
+ PAD1_readPort1(&padd[i],i);\r
+ }\r
+ return _PADstartPollMultitap(padd);\r
}\r
- return _PADstartPollPort1(padd);\r
}\r
\r
unsigned char CALLBACK PAD1__poll(unsigned char value) {\r
-\r
// if(value !=0){\r
// int i;\r
// printf("%2x %c\n", value, value);\r
// }\r
// printf("\n");\r
// }\r
-\r
- if(value==42){\r
- unsigned char bufmultitap[256];\r
- memcpy(bufmultitap, multitappar, 3);\r
- bufcount = 2;\r
- return bufmultitap[bufc++];\r
- }else{\r
+ if(multitap1==0){\r
return _PADpoll(value);\r
+ }else{\r
+ if(value==42){\r
+ unsigned char bufmultitap[256];\r
+ memcpy(bufmultitap, multitappar, 3);\r
+ bufcount = 2;\r
+ return bufmultitap[bufc++];\r
+ }else{\r
+ return _PADpoll(value);\r
+ }\r
}\r
}\r
\r
long CALLBACK PAD1__configure(void) { return 0; }\r
void CALLBACK PAD1__about(void) {}\r
long CALLBACK PAD1__test(void) { return 0; }\r
-long CALLBACK PAD1__query(void) {\r
- printf("PAD1__query");\r
- return 3; }\r
+long CALLBACK PAD1__query(void) { return 3; }\r
long CALLBACK PAD1__keypressed() { return 0; }\r
\r
#define LoadPad1Sym1(dest, name) \\r
}\r
\r
unsigned char CALLBACK PAD2__startPoll(int pad) {\r
- PadDataS padd;\r
+ int pad_index = 0;\r
+ if(multitap1 == 1){\r
+ pad_index+=4;\r
+ }else{\r
+ pad_index=1;\r
+ }\r
+ //first call the pad provide if a multitap is connected between the psx and himself\r
+ if(multitap2 == -1){\r
+ PadDataS padd;\r
+ PAD2_readPort2(&padd,pad_index);\r
+ multitap2 = padd.portMultitap;\r
+ }\r
\r
- PAD2_readPort2(&padd);\r
- \r
- return _PADstartPoll(&padd);\r
+ // just one pad is on port 2 : NO MULTITAP\r
+ if (multitap2 == 0){\r
+ PadDataS padd;\r
+ PAD2_readPort2(&padd,pad_index);\r
+ return _PADstartPoll(&padd);\r
+ }else{\r
+ //a multitap is plugged : refresh all pad.\r
+ int i=pad_index;\r
+ PadDataS padd[4];\r
+ for(i=0;i<4;i++){\r
+ PAD2_readPort2(&padd[i],i+pad_index);\r
+ }\r
+ return _PADstartPollMultitap(padd);\r
+ }\r
}\r
\r
unsigned char CALLBACK PAD2__poll(unsigned char value) {\r
- return _PADpoll(value);\r
+// if(value !=0){\r
+// int i;\r
+// printf("%2x %c\n", value, value);\r
+// for (i = 0; i < 35; i++) {\r
+// printf("%2x", buf[i]);\r
+// }\r
+// printf("\n");\r
+// }\r
+ if(multitap2==0){\r
+ return _PADpoll(value);\r
+ }else {\r
+ if(value==42){\r
+ unsigned char bufmultitap[256];\r
+ memcpy(bufmultitap, multitappar, 3);\r
+ bufcount = 2;\r
+ return bufmultitap[bufc++];\r
+ }else{\r
+ return _PADpoll(value);\r
+ }\r
+ }\r
}\r
\r
long CALLBACK PAD2__configure(void) { return 0; }\r