mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-11 05:44:08 +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:
@@ -1,6 +1,6 @@
|
||||
namespace ruby {
|
||||
struct InputCarbon : Input {
|
||||
~InputCarbon() { term(); }
|
||||
|
||||
struct pInputCarbon {
|
||||
struct Key {
|
||||
uint8_t id;
|
||||
string name;
|
||||
@@ -25,7 +25,7 @@ struct pInputCarbon {
|
||||
}
|
||||
|
||||
auto acquire() -> bool { return false; }
|
||||
auto unacquire() -> bool { return false; }
|
||||
auto release() -> bool { return false; }
|
||||
auto acquired() -> bool { return false; }
|
||||
|
||||
auto assign(shared_pointer<HID::Device> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
@@ -179,7 +179,3 @@ struct pInputCarbon {
|
||||
auto term() -> void {
|
||||
}
|
||||
};
|
||||
|
||||
DeclareInput(Carbon)
|
||||
|
||||
};
|
||||
|
@@ -1,13 +1,14 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_DIRECTINPUT
|
||||
#define RUBY_INPUT_JOYPAD_DIRECTINPUT
|
||||
|
||||
namespace ruby {
|
||||
|
||||
auto CALLBACK DirectInput_EnumJoypadsCallback(const DIDEVICEINSTANCE* instance, void* p) -> BOOL;
|
||||
auto CALLBACK DirectInput_EnumJoypadAxesCallback(const DIDEVICEOBJECTINSTANCE* instance, void* p) -> BOOL;
|
||||
auto CALLBACK DirectInput_EnumJoypadEffectsCallback(const DIDEVICEOBJECTINSTANCE* instance, void* p) -> BOOL;
|
||||
|
||||
struct InputJoypadDirectInput {
|
||||
Input& input;
|
||||
InputJoypadDirectInput(Input& input) : input(input) {}
|
||||
|
||||
struct Joypad {
|
||||
shared_pointer<HID::Joypad> hid{new HID::Joypad};
|
||||
|
||||
@@ -30,7 +31,7 @@ struct InputJoypadDirectInput {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -213,6 +214,4 @@ auto CALLBACK DirectInput_EnumJoypadEffectsCallback(const DIDEVICEOBJECTINSTANCE
|
||||
return ((InputJoypadDirectInput*)p)->initEffect(instance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_SDL
|
||||
#define RUBY_INPUT_JOYPAD_SDL
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputJoypadSDL {
|
||||
Input& input;
|
||||
InputJoypadSDL(Input& input) : input(input) {}
|
||||
|
||||
struct Joypad {
|
||||
shared_pointer<HID::Joypad> hid{new HID::Joypad};
|
||||
|
||||
@@ -15,7 +16,7 @@ struct InputJoypadSDL {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -75,6 +76,4 @@ struct InputJoypadSDL {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_UDEV
|
||||
#define RUBY_INPUT_JOYPAD_UDEV
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputJoypadUdev {
|
||||
Input& input;
|
||||
InputJoypadUdev(Input& input) : input(input) {}
|
||||
|
||||
udev* context = nullptr;
|
||||
udev_monitor* monitor = nullptr;
|
||||
udev_enumerate* enumerator = nullptr;
|
||||
@@ -55,7 +56,7 @@ struct InputJoypadUdev {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -275,6 +276,4 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -19,9 +19,10 @@ typedef DWORD WINAPI (*pXInputPowerOffController)(DWORD dwUserIndex);
|
||||
|
||||
#define XINPUT_GAMEPAD_GUIDE 0x0400
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputJoypadXInput {
|
||||
Input& input;
|
||||
InputJoypadXInput(Input& input) : input(input) {}
|
||||
|
||||
HMODULE libxinput = nullptr;
|
||||
pXInputGetStateEx XInputGetStateEx = nullptr;
|
||||
pXInputSetState XInputSetState = nullptr;
|
||||
@@ -35,7 +36,7 @@ struct InputJoypadXInput {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -158,6 +159,4 @@ struct InputJoypadXInput {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_KEYBOARD_RAWINPUT
|
||||
#define RUBY_INPUT_KEYBOARD_RAWINPUT
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputKeyboardRawInput {
|
||||
Input& input;
|
||||
InputKeyboardRawInput(Input& input) : input(input) {}
|
||||
|
||||
struct Key {
|
||||
uint16_t code;
|
||||
uint16_t flag;
|
||||
@@ -29,7 +30,7 @@ struct InputKeyboardRawInput {
|
||||
auto assign(unsigned inputID, bool value) -> void {
|
||||
auto& group = kb.hid->buttons();
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(kb.hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(kb.hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -173,6 +174,4 @@ struct InputKeyboardRawInput {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_KEYBOARD_XLIB
|
||||
#define RUBY_INPUT_KEYBOARD_XLIB
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputKeyboardXlib {
|
||||
Input& input;
|
||||
InputKeyboardXlib(Input& input) : input(input) {}
|
||||
|
||||
shared_pointer<HID::Keyboard> hid{new HID::Keyboard};
|
||||
|
||||
Display* display = nullptr;
|
||||
@@ -18,7 +19,7 @@ struct InputKeyboardXlib {
|
||||
auto assign(unsigned inputID, bool value) -> void {
|
||||
auto& group = hid->buttons();
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -169,6 +170,4 @@ struct InputKeyboardXlib {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_MOUSE_RAWINPUT
|
||||
#define RUBY_INPUT_MOUSE_RAWINPUT
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputMouseRawInput {
|
||||
Input& input;
|
||||
InputMouseRawInput(Input& input) : input(input) {}
|
||||
|
||||
uintptr_t handle = 0;
|
||||
bool mouseAcquired = false;
|
||||
|
||||
@@ -24,7 +25,7 @@ struct InputMouseRawInput {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
auto release() -> bool {
|
||||
if(mouseAcquired == true) {
|
||||
mouseAcquired = false;
|
||||
ReleaseCapture();
|
||||
@@ -70,7 +71,7 @@ struct InputMouseRawInput {
|
||||
auto assign(unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = ms.hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(ms.hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(ms.hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -114,10 +115,8 @@ struct InputMouseRawInput {
|
||||
}
|
||||
|
||||
auto term() -> void {
|
||||
unacquire();
|
||||
release();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef RUBY_INPUT_MOUSE_XLIB
|
||||
#define RUBY_INPUT_MOUSE_XLIB
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct InputMouseXlib {
|
||||
Input& input;
|
||||
InputMouseXlib(Input& input) : input(input) {}
|
||||
|
||||
shared_pointer<HID::Mouse> hid{new HID::Mouse};
|
||||
|
||||
uintptr_t handle = 0;
|
||||
@@ -42,7 +43,7 @@ struct InputMouseXlib {
|
||||
}
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
auto release() -> bool {
|
||||
if(acquired()) {
|
||||
//restore cursor acceleration and release cursor
|
||||
XChangePointerControl(display, True, True, ms.numerator, ms.denominator, ms.threshold);
|
||||
@@ -59,7 +60,7 @@ struct InputMouseXlib {
|
||||
auto assign(unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
@@ -143,12 +144,10 @@ struct InputMouseXlib {
|
||||
}
|
||||
|
||||
auto term() -> void {
|
||||
unacquire();
|
||||
release();
|
||||
XFreeCursor(display, invisibleCursor);
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -6,12 +6,12 @@
|
||||
#include "mouse/xlib.cpp"
|
||||
#include "joypad/sdl.cpp"
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct pInputSDL {
|
||||
struct InputSDL : Input {
|
||||
InputKeyboardXlib xlibKeyboard;
|
||||
InputMouseXlib xlibMouse;
|
||||
InputJoypadSDL sdl;
|
||||
InputSDL() : xlibKeyboard(*this), xlibMouse(*this), sdl(*this) {}
|
||||
~InputSDL() { term(); }
|
||||
|
||||
struct Settings {
|
||||
uintptr_t handle = 0;
|
||||
@@ -43,8 +43,8 @@ struct pInputSDL {
|
||||
return xlibMouse.acquire();
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
return xlibMouse.unacquire();
|
||||
auto release() -> bool {
|
||||
return xlibMouse.release();
|
||||
}
|
||||
|
||||
auto acquired() -> bool {
|
||||
@@ -76,7 +76,3 @@ struct pInputSDL {
|
||||
sdl.term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareInput(SDL)
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
#ifndef RUBY_INPUT_SHARED_RAWINPUT
|
||||
#define RUBY_INPUT_SHARED_RAWINPUT
|
||||
|
||||
namespace ruby {
|
||||
|
||||
auto CALLBACK RawInputWindowProc(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
|
||||
|
||||
struct RawInput {
|
||||
Input& input;
|
||||
RawInput(Input& input) : input(input) {}
|
||||
|
||||
HANDLE mutex = nullptr;
|
||||
HWND hwnd = nullptr;
|
||||
bool ready = false;
|
||||
@@ -157,6 +158,4 @@ auto CALLBACK RawInputWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
|
||||
return rawinput.windowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -12,12 +12,12 @@
|
||||
#include "mouse/xlib.cpp"
|
||||
#include "joypad/udev.cpp"
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct pInputUdev {
|
||||
struct InputUdev : input {
|
||||
InputKeyboardXlib xlibKeyboard;
|
||||
InputMouseXlib xlibMouse;
|
||||
InputJoypadUdev udev;
|
||||
Input() : xlibKeyboard(*this), xlibMouse(*this), udev(*this) {}
|
||||
~Input() { term(); }
|
||||
|
||||
struct Settings {
|
||||
uintptr_t handle = 0;
|
||||
@@ -49,8 +49,8 @@ struct pInputUdev {
|
||||
return xlibMouse.acquire();
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
return xlibMouse.unacquire();
|
||||
auto release() -> bool {
|
||||
return xlibMouse.release();
|
||||
}
|
||||
|
||||
auto acquired() -> bool {
|
||||
@@ -82,7 +82,3 @@ struct pInputUdev {
|
||||
udev.term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareInput(Udev)
|
||||
|
||||
}
|
||||
|
@@ -8,13 +8,13 @@
|
||||
#include "joypad/xinput.cpp"
|
||||
#include "joypad/directinput.cpp"
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct pInputWindows {
|
||||
struct InputWindows : Input {
|
||||
InputKeyboardRawInput rawinputKeyboard;
|
||||
InputMouseRawInput rawinputMouse;
|
||||
InputJoypadXInput xinput;
|
||||
InputJoypadDirectInput directinput;
|
||||
InputWindows() : rawinputKeyboard(*this), rawinputMouse(*this), xinput(*this), directinput(*this) {}
|
||||
~InputWindows() { term(); }
|
||||
|
||||
LPDIRECTINPUT8 directinputContext = nullptr;
|
||||
|
||||
@@ -22,10 +22,6 @@ struct pInputWindows {
|
||||
uintptr_t handle = 0;
|
||||
} settings;
|
||||
|
||||
~pInputWindows() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Input::Handle) return true;
|
||||
if(name == Input::KeyboardSupport) return true;
|
||||
@@ -52,8 +48,8 @@ struct pInputWindows {
|
||||
return rawinputMouse.acquire();
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
return rawinputMouse.unacquire();
|
||||
auto release() -> bool {
|
||||
return rawinputMouse.release();
|
||||
}
|
||||
|
||||
auto acquired() -> bool {
|
||||
|
@@ -7,11 +7,11 @@
|
||||
#include "keyboard/xlib.cpp"
|
||||
#include "mouse/xlib.cpp"
|
||||
|
||||
namespace ruby {
|
||||
|
||||
struct pInputXlib {
|
||||
struct InputXlib : Input {
|
||||
InputKeyboardXlib xlibKeyboard;
|
||||
InputMouseXlib xlibMouse;
|
||||
InputXlib() : xlibKeyboard(*this), xlibMouse(*this) {}
|
||||
~InputXlib() { term(); }
|
||||
|
||||
struct Settings {
|
||||
uintptr_t handle = 0;
|
||||
@@ -41,8 +41,8 @@ struct pInputXlib {
|
||||
return xlibMouse.acquire();
|
||||
}
|
||||
|
||||
auto unacquire() -> bool {
|
||||
return xlibMouse.unacquire();
|
||||
auto release() -> bool {
|
||||
return xlibMouse.release();
|
||||
}
|
||||
|
||||
auto acquired() -> bool {
|
||||
@@ -71,7 +71,3 @@ struct pInputXlib {
|
||||
xlibMouse.term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareInput(Xlib)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user