mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-10 09:44:13 +02:00
ruby/input: Add macOS mouse support
While keyboard and joypad input had already been present for some time, mouse input for macOS remained unimplemented in ruby. Until now, that is.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "keyboard/quartz.cpp"
|
||||
#include "mouse/quartz.cpp"
|
||||
#include "joypad/iokit.cpp"
|
||||
|
||||
struct InputQuartz : InputDriver {
|
||||
InputQuartz& self = *this;
|
||||
InputQuartz(Input& super) : InputDriver(super), keyboard(super), joypad(super) {}
|
||||
InputQuartz(Input& super) : InputDriver(super), keyboard(super), mouse(super), joypad(super) {}
|
||||
~InputQuartz() { terminate(); }
|
||||
|
||||
auto create() -> bool override {
|
||||
@@ -13,13 +14,14 @@ struct InputQuartz : InputDriver {
|
||||
auto driver() -> string override { return "Quartz"; }
|
||||
auto ready() -> bool override { return isReady; }
|
||||
|
||||
auto acquired() -> bool override { return false; }
|
||||
auto acquire() -> bool override { return false; }
|
||||
auto release() -> bool override { return false; }
|
||||
auto acquired() -> bool override { return mouse.acquired(); }
|
||||
auto acquire() -> bool override { return mouse.acquire(); }
|
||||
auto release() -> bool override { return mouse.release(); }
|
||||
|
||||
auto poll() -> vector<shared_pointer<HID::Device>> override {
|
||||
vector<shared_pointer<HID::Device>> devices;
|
||||
keyboard.poll(devices);
|
||||
mouse.poll(devices);
|
||||
joypad.poll(devices);
|
||||
return devices;
|
||||
}
|
||||
@@ -32,6 +34,7 @@ private:
|
||||
auto initialize() -> bool {
|
||||
terminate();
|
||||
if(!keyboard.initialize()) return false;
|
||||
if(!mouse.initialize()) return false;
|
||||
if(!joypad.initialize()) return false;
|
||||
return isReady = true;
|
||||
}
|
||||
@@ -39,10 +42,12 @@ private:
|
||||
auto terminate() -> void {
|
||||
isReady = false;
|
||||
keyboard.terminate();
|
||||
mouse.terminate();
|
||||
joypad.terminate();
|
||||
}
|
||||
|
||||
bool isReady = false;
|
||||
InputKeyboardQuartz keyboard;
|
||||
InputMouseQuartz mouse;
|
||||
InputJoypadIOKit joypad;
|
||||
};
|
||||
|
Reference in New Issue
Block a user