| 114 | } |
| 115 | |
| 116 | static uint8_t PSXControllerRead() |
| 117 | { |
| 118 | /* |
| 119 | Communication Protocol |
| 120 | First three bytes - Header |
| 121 | Following bytes - Digital Mode (2 bytes) / Analog Mode (18 bytes) |
| 122 | |
| 123 | First byte |
| 124 | Command: 0x01 (indicates new packet) |
| 125 | Data: 0xFF |
| 126 | |
| 127 | Second byte |
| 128 | Command: Main command (poll or configure controller) |
| 129 | Polling: 0x42 |
| 130 | Data: Device Mode |
| 131 | Upper 4 bits: mode (4 = digital, 7 = analog, F = config) |
| 132 | Lower 4 bits: how many 16 bit words follow the header |
| 133 | |
| 134 | Third byte |
| 135 | Command : 0x00 |
| 136 | Data: 0x5A |
| 137 | */ |
| 138 | |
| 139 | // Button Mappings |
| 140 | /* |
| 141 | Digital Mode |
| 142 | 0 - Select |
| 143 | 1 - L3 |
| 144 | 2 - R3 |
| 145 | 3 - Start |
| 146 | 4 - Up |
| 147 | 5 - Right |
| 148 | 6 - Down |
| 149 | 7 - Left |
| 150 | 8 - L2 |
| 151 | 9 - R2 |
| 152 | 10 - L1 |
| 153 | 11 - R1 |
| 154 | 12 - Triangle |
| 155 | 13 - O |
| 156 | 14 - X |
| 157 | 15 - Square |
| 158 | |
| 159 | Analog Mode |
| 160 | - Analog sticks range 0x00 - 0xFF, 0x7F at rest |
| 161 | - Pressure buttons range 0x00 - 0xFF, 0xFF is fully pressed |
| 162 | 0-15 - Same as digital mode |
| 163 | Byte 2 - RX |
| 164 | Byte 3 - RY |
| 165 | Byte 4 - LX |
| 166 | Byte 5 - LY |
| 167 | Byte 6 - Right |
| 168 | Byte 7 - Left |
| 169 | Byte 8 - Up |
| 170 | Byte 9 - Down |
| 171 | Byte 10 - Triangle |
| 172 | Byte 11 - O |
| 173 | Byte 12 - X |
nothing calls this directly
no test coverage detected