diff options
Diffstat (limited to 'app/mac/impl/input-device-gc-keyboard.hh')
| -rw-r--r-- | app/mac/impl/input-device-gc-keyboard.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/mac/impl/input-device-gc-keyboard.hh b/app/mac/impl/input-device-gc-keyboard.hh new file mode 100644 index 0000000..c879dcc --- /dev/null +++ b/app/mac/impl/input-device-gc-keyboard.hh @@ -0,0 +1,30 @@ +#pragma once + +#import "nes/app/input/input-device-keyboard.hh" +#import "nes/app/input/input-buffer.hh" +#import <optional> + +#import <GameController/GameController.h> + +namespace nes::app::mac +{ + /// Input device wrapping a GCKeyboard. + class input_device_gc_keyboard final : public input_device_keyboard + { + GCKeyboardInput* profile_{ nil }; + input_buffer buffer_; + + public: + explicit input_device_gc_keyboard(GCKeyboardInput* profile); + ~input_device_gc_keyboard() override; + + auto set_profile(GCKeyboardInput* profile) -> void; + + auto read_key(key const key) -> bool override { return buffer_.read_key(key); } + auto poll_event() -> input_event override { return buffer_.poll_event(); } + + private: + auto handle_key_changed(GCKeyCode key_code, BOOL pressed) -> void; + auto convert_key_code(GCKeyCode key_code) -> std::optional<key>; + }; +} // namespace nes::app::mac
\ No newline at end of file |
