From 307e07d6513f9524b7fcab5134494bd175465cd1 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Thu, 30 Jan 2025 16:43:06 +0100 Subject: handle input devices in the c++ application --- app/mac/controller-adapter-keyboard.mm | 44 ---------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 app/mac/controller-adapter-keyboard.mm (limited to 'app/mac/controller-adapter-keyboard.mm') diff --git a/app/mac/controller-adapter-keyboard.mm b/app/mac/controller-adapter-keyboard.mm deleted file mode 100644 index ad3dda8..0000000 --- a/app/mac/controller-adapter-keyboard.mm +++ /dev/null @@ -1,44 +0,0 @@ -#import "controller-adapter-keyboard.hh" - -@implementation ControllerAdapterKeyboard - -- (instancetype)init -{ - self = [super init]; - if (self) - { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleKeyboardConnected:) - name:GCKeyboardDidConnectNotification - object:nil]; - } - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)handleKeyboardConnected:(NSNotification*)notification -{ - _keyboard = [GCKeyboard coalescedKeyboard]; -} - -- (nes::button_mask)readPressedButtons -{ - auto profile = [[self keyboard] keyboardInput]; - - auto res = nes::button_mask{}; - if ([[profile buttonForKeyCode:GCKeyCodeUpArrow] isPressed]) { res.add(nes::buttons::up); } - if ([[profile buttonForKeyCode:GCKeyCodeDownArrow] isPressed]) { res.add(nes::buttons::down); } - if ([[profile buttonForKeyCode:GCKeyCodeLeftArrow] isPressed]) { res.add(nes::buttons::left); } - if ([[profile buttonForKeyCode:GCKeyCodeRightArrow] isPressed]) { res.add(nes::buttons::right); } - if ([[profile buttonForKeyCode:GCKeyCodeKeyZ] isPressed]) { res.add(nes::buttons::a); } - if ([[profile buttonForKeyCode:GCKeyCodeKeyX] isPressed]) { res.add(nes::buttons::b); } - if ([[profile buttonForKeyCode:GCKeyCodeReturnOrEnter] isPressed]) { res.add(nes::buttons::start); } - if ([[profile buttonForKeyCode:GCKeyCodeSpacebar] isPressed]) { res.add(nes::buttons::select); } - return res; -} - -@end \ No newline at end of file -- cgit v1.3.1