Update to 20180730 release.

byuu says:

These WIPs-within-WIPs are getting more and more broken ... this isn't
going the way I wanted.

But ... this time around, I've revamped the entire ruby API again, to
solve a bunch of tough problems that have always made using ruby really
clunky.

But there are *so many* ruby drivers that it's going to take a long
time to work through them all. This WIP is only going to run bsnes, and
only on FreeBSD, and only with some drivers.

hiro's Application::initialize() now calls hiro::initialize(), which you
define inside of your hiro apps. This lets you call
Application::setName(...) before anything else in hiro runs. This is
essential on Xorg to set program icons, for instance.

With the ruby rewrite and the change to hiro, I can get away from the
need to make everything in bsnes/higan pointers to objects, and can now
just declare them as regular objects.
This commit is contained in:
Tim Allen
2018-07-31 12:23:12 +10:00
parent 5deba5cbc1
commit 212da0a966
39 changed files with 868 additions and 762 deletions

60
ruby/input/input.hpp Normal file
View File

@@ -0,0 +1,60 @@
struct Input;
struct InputDriver {
InputDriver(Input& super) : super(super) {}
virtual ~InputDriver() = default;
virtual auto create() -> bool { return true; }
virtual auto driverName() -> string { return "None"; }
virtual auto ready() -> bool { return true; }
virtual auto hasContext() -> bool { return false; }
virtual auto setContext(uintptr context) -> bool { return true; }
virtual auto acquired() -> bool { return false; }
virtual auto acquire() -> bool { return false; }
virtual auto release() -> bool { return false; }
virtual auto poll() -> vector<shared_pointer<nall::HID::Device>> { return {}; }
virtual auto rumble(uint64_t id, bool enable) -> bool { return false; }
protected:
Input& super;
friend class Input;
uintptr context = 0;
};
struct Input {
static auto hasDrivers() -> vector<string>;
static auto hasDriver(string driver) -> bool { return (bool)hasDrivers().find(driver); }
static auto optimalDriver() -> string;
static auto safestDriver() -> string;
Input() : self(*this) {}
explicit operator bool() const { return (bool)driver; }
auto reset() -> void { driver.reset(); }
auto create(string driver = "") -> bool;
auto driverName() -> string { return driver->driverName(); }
auto ready() -> bool { return driver->ready(); }
auto hasContext() -> bool { return driver->hasContext(); }
auto context() -> uintptr { return driver->context; }
auto setContext(uintptr context) -> bool;
auto acquired() -> bool;
auto acquire() -> bool;
auto release() -> bool;
auto poll() -> vector<shared_pointer<nall::HID::Device>>;
auto rumble(uint64_t id, bool enable) -> bool;
auto onChange(const function<void (shared_pointer<nall::HID::Device>, uint, uint, int16_t, int16_t)>&) -> void;
auto doChange(shared_pointer<nall::HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void;
protected:
Input& self;
unique_pointer<InputDriver> driver;
function<void (shared_pointer<nall::HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue)> change;
};