//case CMD_READ_DATA_AND_VIBRATE :\r
// break;\r
case CMD_CONFIG_MODE :\r
- if(pad[padIndex].configMode == 1){\r
+ if (pad[padIndex].configMode == 1) {\r
memcpy(buf, resp43, 8);\r
break;\r
}\r
switch (req){\r
case CMD_CONFIG_MODE :\r
//0x43\r
- if(value == 0){\r
+ if (value == 0) {\r
pad[padIndex].configMode = 0;\r
- }else{\r
+ } else {\r
pad[padIndex].configMode = 1;\r
}\r
break;\r
break;\r
case CMD_QUERY_ACT :\r
//0x46\r
- if(value==1){\r
+ if (value == 1) {\r
memcpy(buf, resp46_01, 8);\r
}\r
break;\r
- \r
case CMD_QUERY_MODE :\r
- if(value==1){\r
+ if (value == 1) {\r
memcpy(buf, resp4C_01, 8);\r
}\r
break;\r
case CMD_READ_DATA_AND_VIBRATE:\r
//mem the vibration value for small motor;\r
pad[padIndex].Vib[0] = value;
+ break;
}\r
}\r
void vibrate(int padIndex){
- if(pad[padIndex].Vib[0] != pad[padIndex].VibF[0] || pad[padIndex].Vib[1] != pad[padIndex].VibF[1]){
+ 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];
//Build response for 0x42 request Multitap in port
//Response header for multitap : 0x80, 0x5A, (Pad information port 1-2A), (Pad information port 1-2B), (Pad information port 1-2C), (Pad information port 1-2D)\r
-void _PADstartPollMultitap(PadDataS padd[4]) {\r
- int i = 0;\r
- int offset = 2;\r
- PadDataS pad;\r
+void _PADstartPollMultitap(PadDataS* padd) {\r
+ int i, offset;\r
for(i = 0; i < 4; i++) {\r
offset = 2 + (i * 8);\r
- pad = padd[i];\r
- _PADstartPoll(&pad);
- memcpy(multitappar+offset, stdpar, 8);\r
+ _PADstartPoll(&padd[i]);
+ memcpy(multitappar+offset, stdpar, 8);\r
}\r
memcpy(bufMulti, multitappar, 34);\r
respSize = 34;\r
\r
\r
unsigned char _PADpoll(int port, unsigned char value) {
- if(reqPos==0){
+ if (reqPos == 0) {
//mem the request number
req = value;\r
//copy the default value of request response in buffer instead of the keystate\r
- initBufForRequest(port,value);
+ initBufForRequest(port, value);
}\r
\r
//if no new request the pad return 0xff, for signaling connected\r
- if ( reqPos >= respSize) return 0xff;\r
+ if (reqPos >= respSize) return 0xff;\r
\r
switch(reqPos){\r
case 2:\r
//vibration
vibrate(port);\r
break;\r
- \r
+ }\r
break;\r
- }\r
}\r
return buf[reqPos++];\r
}
unsigned char _PADpollMultitap(int port, unsigned char value) {
- if ( reqPos >= respSize) return 0xff;\r
+ if (reqPos >= respSize) return 0xff;\r
return bufMulti[reqPos++];\r
}
\r
unsigned char CALLBACK PAD1__startPoll(int pad) {
reqPos = 0;\r
// first call the pad provide if a multitap is connected between the psx and himself\r
- if(multitap1 == -1){\r
+ if (multitap1 == -1) {\r
PadDataS padd;
padd.requestPadIndex = 0;\r
PAD1_readPort1(&padd);\r
multitap1 = padd.portMultitap;\r
}\r
// just one pad is on port 1 : NO MULTITAP\r
- if (multitap1 == 0){\r
+ if (multitap1 == 0) {\r
PadDataS padd;
padd.requestPadIndex = 0;\r
PAD1_readPort1(&padd);\r
_PADstartPoll(&padd);\r
} else {\r
// a multitap is plugged : refresh all pad.\r
- int i=0;\r
+ int i;\r
PadDataS padd[4];\r
for(i = 0; i < 4; i++) {
padd[i].requestPadIndex = i;\r
\r
unsigned char CALLBACK PAD1__poll(unsigned char value) {
char tmp;
- if(multitap1 == 1){
+ if (multitap1 == 1) {
tmp = _PADpollMultitap(0, value);
- }else{
+ } else {
tmp = _PADpoll(0, value);
}
//printf("%2x:%2x, ",value,tmp);\r
}\r
\r
unsigned char CALLBACK PAD2__startPoll(int pad) {
+ int pad_index;
+
reqPos = 0;\r
- int pad_index = 0;
- if(multitap1 == 0 && multitap2 == 0){
- pad_index += 1;
- }else if(multitap1 == 1 && multitap2 == 0){
- pad_index += 4;
- }else if(multitap1 == 0 && multitap2 == 2){
- pad_index += 1;
- }else if(multitap1 == 1 && multitap2 == 2){
- pad_index += 4;
+ if (multitap1 == 0 && (multitap2 == 0 || multitap2 == 2)) {
+ pad_index = 1;
+ } else if(multitap1 == 1 && (multitap2 == 0 || multitap2 == 2)) {
+ pad_index = 4;
+ } else {
+ pad_index = 0;
}
//first call the pad provide if a multitap is connected between the psx and himself
- if(multitap2 == -1){
+ if (multitap2 == -1) {
PadDataS padd;
padd.requestPadIndex = pad_index;
PAD2_readPort2(&padd);
}
\r
// just one pad is on port 1 : NO MULTITAP\r
- if (multitap2 == 0){
+ if (multitap2 == 0) {
PadDataS padd;
padd.requestPadIndex = pad_index;
PAD2_readPort2(&padd);\r
_PADstartPoll(&padd);\r
} else {\r
// a multitap is plugged : refresh all pad.\r
- //a multitap is plugged : refresh all pad.
- int i=0;
+ int i;
PadDataS padd[4];
- for(i=0;i<4;i++){
+ for(i = 0; i < 4; i++) {
padd[i].requestPadIndex = i+pad_index;
PAD2_readPort2(&padd[i]);
}
\r
unsigned char CALLBACK PAD2__poll(unsigned char value) {\r
char tmp;
- if(multitap2 == 2){
+ if (multitap2 == 2) {
tmp = _PADpollMultitap(1, value);
- }else{
+ } else {
tmp = _PADpoll(1, value);
}
//printf("%2x:%2x, ",value,tmp);\r