diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-08-06 04:17:09 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-08-06 04:17:09 +0200 |
| commit | 8700a329d07bae49228f10b50999a161a235d140 (patch) | |
| tree | 020e41f757b7081114683da6ebb5505eb4ffc311 /Source/Pad.c | |
| parent | 153f078ec20cc442dd4dbe802dbd5fcb1748fcca (diff) | |
| download | airport-8700a329d07bae49228f10b50999a161a235d140.tar.gz | |
* Include directives are now moved to .c instead of .h, as it should really be...
* Makefile now rebuilds needed targets on modified header files.
* Some more work on GameEmergencyMode().
* Initial work on PSX mouse auto detection.
* Prototypes for RCNT2 I_MASK bit handling.
Diffstat (limited to 'Source/Pad.c')
| -rw-r--r-- | Source/Pad.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/Source/Pad.c b/Source/Pad.c index 9e892a6..8910298 100644 --- a/Source/Pad.c +++ b/Source/Pad.c @@ -3,6 +3,7 @@ * *************************************/ #include "Pad.h" +#include "System.h" /* ************************************* * Defines @@ -12,6 +13,7 @@ #define PAD_TWO 1 #define PAD_CHEAT_TIMEOUT 20 // 2 units * 100 ms/unit = 2000 ms #define PAD_MAX_CHEATS 16 +#define PAD_FLOATING_ID (unsigned char)0xFF /* ************************************** * Structs and enums * @@ -127,8 +129,10 @@ unsigned char PadTwoGetType(void) bool PadOneConnected(void) { psx_pad_state PadOne = PadOneGetState(); - - if(PadOne.status != PAD_STATUS_OK) + + if( (PadOne.status != PAD_STATUS_OK) + && + (PadOneGetID() == PAD_FLOATING_ID) ) { return false; } @@ -140,7 +144,9 @@ bool PadTwoConnected(void) { psx_pad_state PadTwo = PadTwoGetState(); - if(PadTwo.status != PAD_STATUS_OK) + if( (PadTwo.status != PAD_STATUS_OK) + && + (PadTwoGetID() == PAD_FLOATING_ID) ) { return false; } @@ -304,7 +310,10 @@ bool PadTwoIsVibrationEnabled(void) bool UpdatePads(void) { - PadOneVibrationHandler(); + unsigned short adc_mouse; + static unsigned short old_adc_mouse; + + PadOneVibrationHandler(); PadTwoVibrationHandler(); @@ -315,14 +324,33 @@ bool UpdatePads(void) // Get now-old pad data previous_pad1 = pad1; previous_pad2 = pad2; - - PSX_ReadPad(&pad1,&pad2); - + + if(PadOneGetType() == PADTYPE_MOUSE) + { + PSX_ReadMouse(&pad1, &adc_mouse); + + if(old_adc_mouse != adc_mouse) + { + Serial_printf("0%04X\n", adc_mouse); + } + + old_adc_mouse = adc_mouse; + } + else + { + PSX_ReadPad(&pad1,&pad2); + } + if(PadOneConnected() == false) { return false; } + if(PadTwoConnected() == false) + { + return false; + } + if(!(previous_pad1 & pad1) ) { pad1_last_key_single_pressed = pad1; @@ -569,3 +597,13 @@ unsigned short PadTwoGetLastKeySinglePressed(void) { return pad2_last_key_single_pressed; } + +unsigned short PadOneGetRawData(void) +{ + return pad1; +} + +unsigned short PadTwoGetRawData(void) +{ + return pad2; +} |
