Update to v106r53 release.

byuu says:

Okay, so the WIPs-within-WIPs thing wasn't achieving its desired effect,
and it ended up causing me to have to redo some work on hiro since my
last local snapshot was of r52. So, heck it. I'll just do mostly
non-functional WIPs for a bit, and worry about the fallout years later
when I'm trying to find an emulation regression and cursing that the
WIPs aren't compiling.

I ported all of the ruby input drivers to the new syntax, as well as the
OpenAL driver. If you patch the ruby drivers for Linux with this in
mind, bsnes should compile and run there again.

Also, the bsnes program icon has returned, now that the new hiro layout
code is mature enough and I can simply add and remove the icon as a
Canvas instead of having to try and render into a viewport. The icon
shows up instantly with the main window.
This commit is contained in:
Tim Allen
2018-08-01 19:07:28 +10:00
parent 2335bb0df8
commit 5d135b556d
25 changed files with 231 additions and 228 deletions

View File

@@ -1,11 +1,15 @@
#include "keyboard/carbon.cpp"
struct InputCarbon : Input {
InputCarbon() : _keyboard(*this) { initialize(); }
struct InputCarbon : InputDriver {
InputCarbon(Input& super) : InputDriver(super), keyboard(super) {}
~InputCarbon() { terminate(); }
auto create() -> bool override {
return initialize();
}
auto driver() -> string override { return "Carbon"; }
auto ready() -> bool override { return _ready; }
auto ready() -> bool override { return isReady; }
auto acquired() -> bool override { return false; }
auto acquire() -> bool override { return false; }
@@ -13,7 +17,7 @@ struct InputCarbon : Input {
auto poll() -> vector<shared_pointer<HID::Device>> override {
vector<shared_pointer<HID::Device>> devices;
_keyboard.poll(devices);
keyboard.poll(devices);
return devices;
}
@@ -24,16 +28,16 @@ struct InputCarbon : Input {
private:
auto initialize() -> bool {
terminate();
if(!_keyboard.initialize()) return false;
return _ready = true;
if(!keyboard.initialize()) return false;
return isReady = true;
}
auto terminate() -> void {
_ready = false;
_keyboard.terminate();
isReady = false;
keyboard.terminate();
}
bool _ready = false;
InputKeyboardCarbon _keyboard;
InputCarbon& self = *this;
bool isReady = false;
InputKeyboardCarbon keyboard;
};

View File

@@ -1,11 +1,15 @@
#include "keyboard/quartz.cpp"
struct InputQuartz : Input {
InputQuartz() : _keyboard(*this) { initialize(); }
struct InputQuartz : InputDriver {
InputQuartz(Input& super) : InputDriver(super), keyboard(super) {}
~InputQuartz() { terminate(); }
auto create() -> bool override {
return initialize();
}
auto driver() -> string override { return "Quartz"; }
auto ready() -> bool override { return _ready; }
auto ready() -> bool override { return isReady; }
auto acquired() -> bool override { return false; }
auto acquire() -> bool override { return false; }
@@ -13,7 +17,7 @@ struct InputQuartz : Input {
auto poll() -> vector<shared_pointer<HID::Device>> override {
vector<shared_pointer<HID::Device>> devices;
_keyboard.poll(devices);
keyboard.poll(devices);
return devices;
}
@@ -24,16 +28,16 @@ struct InputQuartz : Input {
private:
auto initialize() -> bool {
terminate();
if(!_keyboard.initialize()) return false;
if(!keyboard.initialize()) return false;
return _ready = true;
}
auto terminate() -> void {
_ready = false;
_keyboard.terminate();
isReady = false;
keyboard.terminate();
}
bool _ready = false;
InputKeyboardQuartz _keyboard;
InputQuartz& self = *this;
bool isReady = false;
InputKeyboardQuartz keyboard;
};

View File

@@ -7,12 +7,10 @@
#include "joypad/sdl.cpp"
struct InputSDL : InputDriver {
InputSDL& self;
InputSDL(Input& super) : InputDriver(super), self(*this), keyboard(super), mouse(super), joypad(super) {}
InputSDL(Input& super) : InputDriver(super), keyboard(super), mouse(super), joypad(super) {}
~InputSDL() { terminate(); }
auto create() -> bool {
auto create() -> bool override {
return initialize();
}
@@ -56,8 +54,8 @@ private:
joypad.terminate();
}
InputSDL& self = *this;
bool isReady = false;
InputKeyboardXlib keyboard;
InputMouseXlib mouse;
InputJoypadSDL joypad;

View File

@@ -12,65 +12,57 @@
#include "mouse/xlib.cpp"
#include "joypad/udev.cpp"
struct InputUdev : Input {
InputUdev() : _keyboard(*this), _mouse(*this), _joypad(*this) { initialize(); }
struct InputUdev : InputDriver {
InputUdev(Input& super) : InputDriver(super), keyboard(super), mouse(super), joypad(super) {}
~InputUdev() { terminate(); }
auto driver() -> string override { return "udev"; }
auto ready() -> bool { return _ready; }
auto hasContext() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
if(context == Input::context()) return true;
if(!Input::setContext(context)) return false;
auto create() -> bool override {
return initialize();
}
auto acquired() -> bool override {
return _mouse.acquired();
}
auto driver() -> string override { return "udev"; }
auto ready() -> bool { return isReady; }
auto acquire() -> bool override {
return _mouse.acquire();
}
auto hasContext() -> bool override { return true; }
auto release() -> bool override {
return _mouse.release();
}
auto setContext(uintptr context) -> bool override { return initialize(); }
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);
keyboard.poll(devices);
mouse.poll(devices);
joypad.poll(devices);
return devices;
}
auto rumble(uint64_t id, bool enable) -> bool override {
return _joypad.rumble(id, enable);
return joypad.rumble(id, enable);
}
private:
auto initialize() -> bool {
terminate();
if(!_context) return false;
if(!_keyboard.initialize()) return false;
if(!_mouse.initialize(_context)) return false;
if(!_joypad.initialize()) return false;
return _ready = true;
if(!self.context) return false;
if(!keyboard.initialize()) return false;
if(!mouse.initialize(self.context)) return false;
if(!joypad.initialize()) return false;
return isReady = true;
}
auto terminate() -> void {
_ready = false;
_keyboard.terminate();
_mouse.terminate();
_joypad.terminate();
isReady = false;
keyboard.terminate();
mouse.terminate();
joypad.terminate();
}
bool _ready = false;
InputKeyboardXlib _keyboard;
InputMouseXlib _mouse;
InputJoypadUdev _joypad;
InputUdev& self = *this;
bool isReady = false;
InputKeyboardXlib keyboard;
InputMouseXlib mouse;
InputJoypadUdev joypad;
};

View File

@@ -8,52 +8,44 @@
#include "joypad/xinput.cpp"
#include "joypad/directinput.cpp"
struct InputWindows : Input {
InputWindows() : _keyboard(*this), _mouse(*this), _joypadXInput(*this), _joypadDirectInput(*this) { initialize(); }
struct InputWindows : InputDriver {
InputWindows(Input& driver) : InputDriver(super), keyboard(super), mouse(super), joypadXInput(super), joypadDirectInput(super) {}
~InputWindows() { terminate(); }
auto driver() -> string override { return "Windows"; }
auto ready() -> bool override { return _ready; }
auto hasContext() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
if(context == Input::context()) return true;
if(!Input::setContext(context)) return false;
auto create() -> bool override {
return initialize();
}
auto acquired() -> bool override {
return _mouse.acquired();
}
auto driver() -> string override { return "Windows"; }
auto ready() -> bool override { return isReady; }
auto acquire() -> bool override {
return _mouse.acquire();
}
auto hasContext() -> bool override { return true; }
auto release() -> bool override {
return _mouse.release();
}
auto setContext(uintptr context) -> bool override { return initialize(); }
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);
_joypadXInput.poll(devices);
_joypadDirectInput.poll(devices);
keyboard.poll(devices);
mouse.poll(devices);
joypadXInput.poll(devices);
joypadDirectInput.poll(devices);
return devices;
}
auto rumble(uint64_t id, bool enable) -> bool override {
if(_joypadXInput.rumble(id, enable)) return true;
if(_joypadDirectInput.rumble(id, enable)) return true;
if(joypadXInput.rumble(id, enable)) return true;
if(joypadDirectInput.rumble(id, enable)) return true;
return false;
}
private:
auto initialize() -> bool {
terminate();
if(!_context) return false;
if(!self.context) return false;
if(!rawinput.initialized) {
rawinput.initialized = true;
@@ -67,35 +59,35 @@ private:
} while(!rawinput.ready);
}
DirectInput8Create(GetModuleHandle(0), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&_directInputContext, 0);
if(!_directInputContext) return false;
DirectInput8Create(GetModuleHandle(0), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&directInputContext, 0);
if(!directInputContext) return false;
if(!_keyboard.initialize()) return false;
if(!_mouse.initialize(_context)) return false;
if(!keyboard.initialize()) return false;
if(!mouse.initialize(_context)) return false;
bool xinputAvailable = _joypadXInput.initialize();
if(!_joypadDirectInput.initialize(_context, _directInputContext, xinputAvailable)) return false;
return _ready = true;
if(!joypadDirectInput.initialize(self.context, directInputContext, xinputAvailable)) return false;
return isReady = true;
}
auto terminate() -> void {
_ready = false;
isReady = false;
_keyboard.terminate();
_mouse.terminate();
_joypadXInput.terminate();
_joypadDirectInput.terminate();
keyboard.terminate();
mouse.terminate();
joypadXInput.terminate();
joypadDirectInput.terminate();
if(_directInputContext) {
_directInputContext->Release();
_directInputContext = nullptr;
if(directInputContext) {
directInputContext->Release();
directInputContext = nullptr;
}
}
bool _ready = false;
InputKeyboardRawInput _keyboard;
InputMouseRawInput _mouse;
InputJoypadXInput _joypadXInput;
InputJoypadDirectInput _joypadDirectInput;
LPDIRECTINPUT8 _directInputContext = nullptr;
InputWindows& self = *this;
bool isReady = false;
InputKeyboardRawInput keyboard;
InputMouseRawInput mouse;
InputJoypadXInput joypadXInput;
InputJoypadDirectInput joypadDirectInput;
LPDIRECTINPUT8 directInputContext = nullptr;
};

View File

@@ -7,37 +7,29 @@
#include "keyboard/xlib.cpp"
#include "mouse/xlib.cpp"
struct InputXlib : Input {
InputXlib() : _keyboard(*this), _mouse(*this) { initialize(); }
struct InputXlib : InputDriver {
InputXlib(Input& super) : InputDriver(super), keyboard(super), mouse(super) {}
~InputXlib() { terminate(); }
auto driver() -> string override { return "Xlib"; }
auto ready() -> bool override { return _ready; }
auto hasContext() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
if(context == Input::context()) return true;
if(!Input::setContext(context)) return false;
auto create() -> bool override {
return initialize();
}
auto acquired() -> bool override {
return _mouse.acquired();
}
auto driver() -> string override { return "Xlib"; }
auto ready() -> bool override { return isReady; }
auto acquire() -> bool override {
return _mouse.acquire();
}
auto hasContext() -> bool override { return true; }
auto release() -> bool override {
return _mouse.release();
}
auto setContext(uintptr context) -> bool override { return initialize(); }
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);
keyboard.poll(devices);
mouse.poll(devices);
return devices;
}
@@ -48,20 +40,20 @@ struct InputXlib : Input {
private:
auto initialize() -> bool {
terminate();
if(!_context) return false;
if(!_keyboard.initialize()) return false;
if(!_mouse.initialize(_context)) return false;
return _ready = true;
if(!self.context) return false;
if(!keyboard.initialize()) return false;
if(!mouse.initialize(self.context)) return false;
return isReady = true;
}
auto terminate() -> void {
_ready = false;
_keyboard.terminate();
_mouse.terminate();
isReady = false;
keyboard.terminate();
mouse.terminate();
}
bool _ready = false;
InputKeyboardXlib _keyboard;
InputMouseXlib _mouse;
InputXlib& self = *this;
bool isReady = false;
InputKeyboardXlib keyboard;
InputMouseXlib mouse;
};