Overview
Comment: | OFGameController: Handle D-Pad via ABS_HAT0[XY] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | gamecontroller |
Files: | files | file ages | folders |
SHA3-256: |
4fc79b14dbb53d6127b3345749430d7d |
User & Date: | js on 2024-05-09 15:13:43 |
Other Links: | branch diff | manifest | tags |
Context
2024-05-09
| ||
15:24 | OFGameController: Handle analog triggers on Linux check-in: 55a1492876 user: js tags: gamecontroller | |
15:13 | OFGameController: Handle D-Pad via ABS_HAT0[XY] check-in: 4fc79b14db user: js tags: gamecontroller | |
15:02 | Add interactive tests for OFGameController check-in: c31d8b6c37 user: js tags: gamecontroller | |
Changes
Modified src/platform/Linux/OFGameController.m from [ce46d32b19] to [f6f484278c].
︙ | ︙ | |||
282 283 284 285 286 287 288 289 290 291 292 293 294 295 | (float)event.value / (event.value < 0 ? -INT16_MIN : INT16_MAX); break; case ABS_RY: _analogStickPositions[1].y = (float)event.value / (event.value < 0 ? -INT16_MIN : INT16_MAX); break; } break; } } } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | (float)event.value / (event.value < 0 ? -INT16_MIN : INT16_MAX); break; case ABS_RY: _analogStickPositions[1].y = (float)event.value / (event.value < 0 ? -INT16_MIN : INT16_MAX); break; case ABS_HAT0X: if (event.value < 0) { [_pressedButtons addObject: @"D-Pad Left"]; [_pressedButtons removeObject: @"D-Pad Right"]; } else if (event.value > 0) { [_pressedButtons addObject: @"D-Pad Right"]; [_pressedButtons removeObject: @"D-Pad Left"]; } else { [_pressedButtons removeObject: @"D-Pad Left"]; [_pressedButtons removeObject: @"D-Pad Right"]; } break; case ABS_HAT0Y: if (event.value < 0) { [_pressedButtons addObject: @"D-Pad Up"]; [_pressedButtons removeObject: @"D-Pad Down"]; } else if (event.value > 0) { [_pressedButtons addObject: @"D-Pad Down"]; [_pressedButtons removeObject: @"D-Pad Up"]; } else { [_pressedButtons removeObject: @"D-Pad Up"]; [_pressedButtons removeObject: @"D-Pad Down"]; } break; } break; } } } |
︙ | ︙ |
Modified tests/gamecontroller/GameControllerTests.m from [ca4750fa5a] to [783f64a599].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | if (++i == 5) { [OFStdOut writeString: @"\n"]; i = 0; } else [OFStdOut writeString: @" "]; } [OFStdOut writeString: @"\n"]; for (i = 0; i < controller.numAnalogSticks; i++) { OFPoint position = [controller positionOfAnalogStickWithIndex: i]; [OFStdOut writeFormat: @"(%5.2f, %5.2f) ", position.x, position.y]; | > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | if (++i == 5) { [OFStdOut writeString: @"\n"]; i = 0; } else [OFStdOut writeString: @" "]; } [OFStdOut setForegroundColor: [OFColor gray]]; [OFStdOut writeString: @"\n"]; for (i = 0; i < controller.numAnalogSticks; i++) { OFPoint position = [controller positionOfAnalogStickWithIndex: i]; [OFStdOut writeFormat: @"(%5.2f, %5.2f) ", position.x, position.y]; |
︙ | ︙ |