mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-03 04:22:49 +02:00
Update to v094r28 release.
byuu says: This WIP substantially restructures the ruby API for the first time since that project started. It is my hope that with this restructuring, destruction of the ruby objects should now be deterministic, which should fix the crashing on closing the emulator on Linux. We'll see I guess ... either way, it removed two layers of wrappers from ruby, so it's a pretty nice code cleanup. It won't compile on Windows due to a few issues I didn't see until uploading the WIP, too lazy to upload another. But I fixed all the compilation issues locally, so it'll work on Windows again with the next WIP (unless I break something else.) (Kind of annoying that Linux defines glActiveTexture but Windows doesn't.)
This commit is contained in:
157
ruby/ruby.hpp
157
ruby/ruby.hpp
@@ -1,7 +1,7 @@
|
||||
/* ruby
|
||||
* author: byuu
|
||||
* license: ISC
|
||||
* version: 0.12 (2015-05-24)
|
||||
* version: 0.13 (2015-06-18)
|
||||
*
|
||||
* ruby is a cross-platform hardware abstraction layer
|
||||
* it provides a common interface to video, audio and input devices
|
||||
@@ -14,84 +14,97 @@
|
||||
|
||||
namespace ruby {
|
||||
|
||||
#include <ruby/video.hpp>
|
||||
#include <ruby/audio.hpp>
|
||||
#include <ruby/input.hpp>
|
||||
struct Video {
|
||||
static const nall::string Handle;
|
||||
static const nall::string Synchronize;
|
||||
static const nall::string Depth;
|
||||
static const nall::string Filter;
|
||||
static const nall::string Shader;
|
||||
|
||||
struct VideoInterface {
|
||||
~VideoInterface();
|
||||
static const unsigned FilterNearest;
|
||||
static const unsigned FilterLinear;
|
||||
|
||||
auto driver(nall::string driver = "") -> void;
|
||||
auto optimalDriver() -> nall::string;
|
||||
auto safestDriver() -> nall::string;
|
||||
auto availableDrivers() -> nall::string;
|
||||
auto init() -> bool;
|
||||
auto term() -> void;
|
||||
static auto create(const nall::string& driver = "") -> Video*;
|
||||
static auto optimalDriver() -> nall::string;
|
||||
static auto safestDriver() -> nall::string;
|
||||
static auto availableDrivers() -> nall::lstring;
|
||||
|
||||
auto cap(const nall::string& name) -> bool;
|
||||
auto get(const nall::string& name) -> nall::any;
|
||||
auto set(const nall::string& name, const nall::any& value) -> bool;
|
||||
virtual ~Video() = default;
|
||||
|
||||
auto lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) -> bool;
|
||||
auto unlock() -> void;
|
||||
auto clear() -> void;
|
||||
auto refresh() -> void;
|
||||
virtual auto cap(const nall::string& name) -> bool { return false; }
|
||||
virtual auto get(const nall::string& name) -> nall::any { return false; }
|
||||
virtual auto set(const nall::string& name, const nall::any& value) -> bool { return false; }
|
||||
|
||||
virtual auto lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) -> bool { return false; }
|
||||
virtual auto unlock() -> void {}
|
||||
virtual auto clear() -> void {}
|
||||
virtual auto refresh() -> void {}
|
||||
|
||||
virtual auto init() -> bool { return true; }
|
||||
virtual auto term() -> void {}
|
||||
};
|
||||
|
||||
struct Audio {
|
||||
static const nall::string Device;
|
||||
static const nall::string Handle;
|
||||
static const nall::string Synchronize;
|
||||
static const nall::string Frequency;
|
||||
static const nall::string Latency;
|
||||
|
||||
static auto create(const nall::string& driver = "") -> Audio*;
|
||||
static auto optimalDriver() -> nall::string;
|
||||
static auto safestDriver() -> nall::string;
|
||||
static auto availableDrivers() -> nall::lstring;
|
||||
|
||||
virtual ~Audio() = default;
|
||||
|
||||
virtual auto cap(const nall::string& name) -> bool { return false; }
|
||||
virtual auto get(const nall::string& name) -> nall::any { return false; }
|
||||
virtual auto set(const nall::string& name, const nall::any& value) -> bool { return false; }
|
||||
|
||||
virtual auto sample(uint16_t left, uint16_t right) -> void {}
|
||||
virtual auto clear() -> void {}
|
||||
|
||||
virtual auto init() -> bool { return true; }
|
||||
virtual auto term() -> void {}
|
||||
};
|
||||
|
||||
struct Input {
|
||||
static const nall::string Handle;
|
||||
static const nall::string KeyboardSupport;
|
||||
static const nall::string MouseSupport;
|
||||
static const nall::string JoypadSupport;
|
||||
static const nall::string JoypadRumbleSupport;
|
||||
|
||||
static auto create(const nall::string& driver = "") -> Input*;
|
||||
static auto optimalDriver() -> nall::string;
|
||||
static auto safestDriver() -> nall::string;
|
||||
static auto availableDrivers() -> nall::lstring;
|
||||
|
||||
virtual ~Input() = default;
|
||||
|
||||
virtual auto cap(const nall::string& name) -> bool { return false; }
|
||||
virtual auto get(const nall::string& name) -> nall::any { return false; }
|
||||
virtual auto set(const nall::string& name, const nall::any& value) -> bool { return false; }
|
||||
|
||||
virtual auto acquire() -> bool { return false; }
|
||||
virtual auto release() -> bool { return false; }
|
||||
virtual auto acquired() -> bool { return false; }
|
||||
virtual auto poll() -> nall::vector<nall::shared_pointer<nall::HID::Device>> { return {}; }
|
||||
virtual auto rumble(uint64_t id, bool enable) -> bool { return false; }
|
||||
|
||||
virtual auto init() -> bool { return true; }
|
||||
virtual auto term() -> void {}
|
||||
|
||||
auto onChange(const nall::function<void (nall::shared_pointer<nall::HID::Device>, unsigned, unsigned, int16_t, int16_t)>& callback) { _onChange = callback; }
|
||||
auto doChange(nall::shared_pointer<nall::HID::Device> device, unsigned group, unsigned input, int16_t oldValue, int16_t newValue) -> void {
|
||||
if(_onChange) _onChange(device, group, input, oldValue, newValue);
|
||||
}
|
||||
|
||||
private:
|
||||
Video* p = nullptr;
|
||||
nall::function<void (nall::shared_pointer<nall::HID::Device> device, unsigned group, unsigned input, int16_t oldValue, int16_t newValue)> _onChange;
|
||||
};
|
||||
|
||||
struct AudioInterface {
|
||||
~AudioInterface();
|
||||
|
||||
auto driver(nall::string driver = "") -> void;
|
||||
auto optimalDriver() -> nall::string;
|
||||
auto safestDriver() -> nall::string;
|
||||
auto availableDrivers() -> nall::string;
|
||||
auto init() -> bool;
|
||||
auto term() -> void;
|
||||
|
||||
auto cap(const nall::string& name) -> bool;
|
||||
auto get(const nall::string& name) -> nall::any;
|
||||
auto set(const nall::string& name, const nall::any& value) -> bool;
|
||||
|
||||
auto sample(uint16_t left, uint16_t right) -> void;
|
||||
auto clear() -> void;
|
||||
|
||||
private:
|
||||
Audio* p = nullptr;
|
||||
};
|
||||
|
||||
struct InputInterface {
|
||||
nall::function<void (nall::shared_pointer<nall::HID::Device> device, unsigned group, unsigned input, int16_t oldValue, int16_t newValue)> onChange;
|
||||
|
||||
~InputInterface();
|
||||
|
||||
auto driver(nall::string driver = "") -> void;
|
||||
auto optimalDriver() -> nall::string;
|
||||
auto safestDriver() -> nall::string;
|
||||
auto availableDrivers() -> nall::string;
|
||||
auto init() -> bool;
|
||||
auto term() -> void;
|
||||
|
||||
auto cap(const nall::string& name) -> bool;
|
||||
auto get(const nall::string& name) -> nall::any;
|
||||
auto set(const nall::string& name, const nall::any& value) -> bool;
|
||||
|
||||
auto acquire() -> bool;
|
||||
auto unacquire() -> bool;
|
||||
auto acquired() -> bool;
|
||||
auto poll() -> nall::vector<nall::shared_pointer<nall::HID::Device>>;
|
||||
auto rumble(uint64_t id, bool enable) -> bool;
|
||||
|
||||
private:
|
||||
Input* p = nullptr;
|
||||
};
|
||||
|
||||
extern VideoInterface video;
|
||||
extern AudioInterface audio;
|
||||
extern InputInterface input;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user