summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpsx/include/psx.h2
-rw-r--r--libpsx/src/psxsdk.c21
2 files changed, 23 insertions, 0 deletions
diff --git a/libpsx/include/psx.h b/libpsx/include/psx.h
index e972e0c..f1316d0 100644
--- a/libpsx/include/psx.h
+++ b/libpsx/include/psx.h
@@ -224,6 +224,8 @@ void PSX_InitEx(unsigned int flags);
*/
void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2);
+void PSX_ReadMouse(unsigned short* dig_pad1, unsigned short* adc_pad1);
+
void PSX_PollPad_Fast(int pad_num, psx_pad_state *pad_state);
void PSX_PollPad_Fast_Ex(const unsigned char* const arr, psx_pad_state* const pad_state);
diff --git a/libpsx/src/psxsdk.c b/libpsx/src/psxsdk.c
index 6fd97af..df623e2 100644
--- a/libpsx/src/psxsdk.c
+++ b/libpsx/src/psxsdk.c
@@ -141,6 +141,27 @@ void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2)
unsigned char psxsdkPadArr[PAD_READ_RAW_SIZE][2];
+void PSX_ReadMouse(unsigned short* dig_pad1, unsigned short* adc_pad1)
+{
+ unsigned char* arr = psxsdkPadArr[0];
+
+ const unsigned char pad_cmd[PAD_READ_RAW_SIZE] = {1,0x42,0,0,0,0,0}; // 2 extra bytes than digital pad
+
+ QueryPAD(0, pad_cmd, arr, sizeof(pad_cmd));
+
+ if(arr[2] == 0x5A)
+ {
+ *dig_pad1 = (arr[3]<<8)|arr[4];
+ *dig_pad1 = ~*dig_pad1;
+ *adc_pad1 = (arr[5]<<8)|arr[6];
+ }
+ else
+ {
+ *dig_pad1 = 0;
+ *adc_pad1 = 0;
+ }
+}
+
void PSX_PollPad_Fast_Ex(const unsigned char* const arr, psx_pad_state* const pad_state)
{
//Rely on pad_read_raw being called AFTER PSX_ReadPad(),