| 164 | return ret; |
| 165 | } |
| 166 | void PSXController::processData(bool ack, bool timeout) |
| 167 | { |
| 168 | // if the controller sends an ack after we are done, ignore it! |
| 169 | if (done && ack) |
| 170 | { |
| 171 | return; |
| 172 | } |
| 173 | cancel_alarm(timeout_alarm_id); |
| 174 | if (done) |
| 175 | { |
| 176 | switch (status) |
| 177 | { |
| 178 | case DISCONNECTED: |
| 179 | if (valid) |
| 180 | { |
| 181 | status = CONNECTION_DELAY; |
| 182 | timeout_alarm_id = add_alarm_in_ms(100, restart_handler, this, true); |
| 183 | return; |
| 184 | } |
| 185 | break; |
| 186 | case CONNECTION_DELAY: |
| 187 | status = FIRST_INPUTS; |
| 188 | autoShiftData(commandPollInput, sizeof(commandPollInput)); |
| 189 | return; |
| 190 | case FIRST_INPUTS: |
| 191 | if (isConfigReply(ps2Data)) |
| 192 | { |
| 193 | status = ENABLE_ANALOG_MODE; |
| 194 | autoShiftData(commandSetMode, sizeof(commandSetMode)); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | status = ENTER_CONFIG; |
| 199 | autoShiftData(commandEnterConfig, sizeof(commandEnterConfig)); |
| 200 | } |
| 201 | return; |
| 202 | case ENTER_CONFIG: |
| 203 | if (valid) |
| 204 | { |
| 205 | // poll the controller so we know it has entered config mode before we send config commands |
| 206 | status = FIRST_INPUTS; |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | // config mode not supported |
| 211 | status = SECOND_INPUTS; |
| 212 | } |
| 213 | autoShiftData(commandPollInput, sizeof(commandPollInput)); |
| 214 | return; |
| 215 | case ENABLE_ANALOG_MODE: |
| 216 | status = ENABLE_PRESSURES; |
| 217 | autoShiftData(commandSetPressures, sizeof(commandSetPressures)); |
| 218 | return; |
| 219 | case ENABLE_PRESSURES: |
| 220 | status = ENABLE_PRESSURES_2; |
| 221 | autoShiftData(commandSetPressures, sizeof(commandSetPressures)); |
| 222 | return; |
| 223 | case ENABLE_PRESSURES_2: |
no test coverage detected