summaryrefslogtreecommitdiff
path: root/libpsx/src/pad.c
diff options
context:
space:
mode:
authorXavi Del Campo <xavi.dcr@tutanota.com>2020-01-31 13:13:14 +0100
committerXavi Del Campo <xavi.dcr@tutanota.com>2020-01-31 13:13:14 +0100
commit78128c8058e6f522c55e7945274926d33183634f (patch)
tree728add7839e1abc7c29e085e2076ae968e00b7bf /libpsx/src/pad.c
parent08ca71f289cd63090edea06ce9fe1803c20d799b (diff)
downloadpsxsdk-78128c8058e6f522c55e7945274926d33183634f.tar.gz
Added PSX_PollPad_Fast_Ex() from psxsdk-20150729 fork
Also, added extern "C" on some header files. Some are still missing.
Diffstat (limited to 'libpsx/src/pad.c')
-rw-r--r--libpsx/src/pad.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/libpsx/src/pad.c b/libpsx/src/pad.c
index ea3e20e..b3dd151 100644
--- a/libpsx/src/pad.c
+++ b/libpsx/src/pad.c
@@ -53,12 +53,12 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
int i;
unsigned char TempData;
int EmuFlag = 0;
-
+
PADSIO_MODE(0) = 0xD;
PADSIO_BAUD(0) = 0x88;
-
+
if(pad_n == 1) PADSIO_CTRL(0) = 0x3003; else PADSIO_CTRL(0) = 0x1003;
-
+
/*Get the initial command (usually 0x01 or 0x81)*/
TempData = *in;
@@ -75,7 +75,7 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
if(PADSIO_STATUS(0) & 4)break;
}
}
-
+
PADSIO_DATA(0) = *in;
in++;
@@ -90,48 +90,48 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
if(PADSIO_STATUS(0) & 128)break;
}
}
-
+
for(i=0;i<100;i++)
{
/*Read RX status flag, required for Xebra*/
if(PADSIO_STATUS(0) & 2)break;
}
}
-
+
*out = PADSIO_DATA(0);
-
+
/*This is emulator, valid data was received without ACK, ePSXe and PCSX*/
if(x == 0 && y > 1900 && *out != 0xFF)EmuFlag = 1;
-
+
out++;
}
-
+
PADSIO_CTRL(0) = 0;
}
void pad_read_raw(int pad_n, unsigned char *arr)
{
// arr must be at least 16 bytes long...
-
+
unsigned char pad_cmd[PAD_READ_RAW_SIZE] = {1,0x42,0,0,0};
-
+
pad_cmd[3] = readpad_vibrations[pad_n][0];
pad_cmd[4] = readpad_vibrations[pad_n][1];
-
+
QueryPAD(pad_n, pad_cmd, arr, sizeof(pad_cmd));
}
void pad_escape_mode(int pad_n, int enable)
{
unsigned char pad_cmd[] = {1,0x43,0,enable?1:0,0};
-
+
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
}
void pad_enable_vibration(int pad_n)
{
unsigned char pad_cmd[] = {1, 0x4d, 0, 0, 1, 0xff, 0xff, 0xff, 0xff};
-
+
pad_escape_mode(pad_n, 1); // Enter escape / configuration mode
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
pad_escape_mode(pad_n, 0); // Exit escape / configuration mode
@@ -154,10 +154,10 @@ void pad_set_analog(int pad_n, int lock)
{1, 0x44, 0, 1, lock?3:0, 0, 0, 0, 0};
unsigned char pad_cmd2[9] =
{1, 0x4f, 0, 0xff, 0xff, 3, 0, 0, 0};
-
+
pad_escape_mode(pad_n, 1);
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
- QueryPAD(pad_n, pad_cmd2, NULL, sizeof(pad_cmd));
+ QueryPAD(pad_n, pad_cmd2, NULL, sizeof(pad_cmd));
pad_escape_mode(pad_n, 0);
}*/