Index: src/platform/Linux/OFGameController.m ================================================================== --- src/platform/Linux/OFGameController.m +++ src/platform/Linux/OFGameController.m @@ -284,10 +284,46 @@ 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; } Index: tests/gamecontroller/GameControllerTests.m ================================================================== --- tests/gamecontroller/GameControllerTests.m +++ tests/gamecontroller/GameControllerTests.m @@ -63,10 +63,11 @@ [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];