diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 01:14:41 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 01:14:41 +0100 |
| commit | 1d32f7561305d6c86b1c80858bc73d55b1c6c402 (patch) | |
| tree | db4be090c2403a7e09dcd4eb116c3ec4bf5af926 /app/mac/controller-adapter-gamepad.mm | |
| parent | c1062208bb54cce8dffa04e9697ae124f271ecaf (diff) | |
(untested) game controller support
Diffstat (limited to 'app/mac/controller-adapter-gamepad.mm')
| -rw-r--r-- | app/mac/controller-adapter-gamepad.mm | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/app/mac/controller-adapter-gamepad.mm b/app/mac/controller-adapter-gamepad.mm index 132fa85..f1d8db8 100644 --- a/app/mac/controller-adapter-gamepad.mm +++ b/app/mac/controller-adapter-gamepad.mm @@ -1,5 +1,29 @@ -// -// Created by Hannes Schulze on 29.01.25. -// - #include "controller-adapter-gamepad.hh" + +@implementation ControllerAdapterGamepad + +- (instancetype)initWithProfile:(GCExtendedGamepad*)profile +{ + self = [super init]; + if (self) + { + _profile = profile; + } + return self; +} + +- (nes::button_mask)readPressedButtons +{ + auto res = nes::button_mask{}; + if ([[[_profile dpad] up] isPressed]) { res.add(nes::buttons::up); } + if ([[[_profile dpad] down] isPressed]) { res.add(nes::buttons::down); } + if ([[[_profile dpad] left] isPressed]) { res.add(nes::buttons::left); } + if ([[[_profile dpad] right] isPressed]) { res.add(nes::buttons::right); } + if ([[_profile buttonA] isPressed]) { res.add(nes::buttons::a); } + if ([[_profile buttonB] isPressed]) { res.add(nes::buttons::b); } + if ([[_profile leftTrigger] isPressed]) { res.add(nes::buttons::select); } + if ([[_profile rightTrigger] isPressed]) { res.add(nes::buttons::start); } + return res; +} + +@end
\ No newline at end of file |
