mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-01-17 20:58:28 +01:00
2335bb0df8
byuu says: I've completed moving all the class objects from `unique_pointer<T>` to just T. The one exception is the Emulator::Interface instance. I can absolutely make that a global object, but only in bsnes where there's just the one emulation core. I also moved all the SettingsWindow and ToolsWindow panels out to their own global objects, and fixed a very difficult bug with GTK TabFrame controls. The configuration settings panel is now the emulator settings panel. And I added some spacing between bold label sections on both the emulator and driver settings panels. I gave fixing ComboButtonItem my best shot, given I can't reproduce the crash. Probably won't work, though. Also made a very slight consistency improvement to ruby and renamed driverName() to driver(). ... An important change ... as a result of moving bsnes to global objects, this means that the constructors for all windows run before the presentation window is displayed. Before this change, only the presentation window was constructed first berore displaying it, followed by the construction of the rest of the GUI windows. The upside to this is that as soon as you see the main window, the GUI is ready to go without a period where it's unresponsive. The downside to this is it takes about 1.5 seconds to show the main window, compared to around 0.75 seconds before. I've no intention of changing that back. So if the startup time becomes a problem, then we'll just have to work on optimizing hiro, so that it can construct all the global Window objects quicker. The main way to do that would be to not do calls to the Layout::setGeometry functions for every widget added, and instead wait until the window is displayed. But I don't have an easy way to do that, because you want the widget geometry values to be sane even before the window is visible to help size certain things.
168 lines
3.2 KiB
C++
168 lines
3.2 KiB
C++
#if defined(INPUT_CARBON)
|
|
#include <ruby/input/carbon.cpp>
|
|
#endif
|
|
|
|
#if defined(INPUT_QUARTZ)
|
|
#include <ruby/input/quartz.cpp>
|
|
#endif
|
|
|
|
#if defined(INPUT_SDL)
|
|
#include <ruby/input/sdl.cpp>
|
|
#endif
|
|
|
|
#if defined(INPUT_UDEV)
|
|
#include <ruby/input/udev.cpp>
|
|
#endif
|
|
|
|
#if defined(INPUT_WINDOWS)
|
|
#include <ruby/input/windows.cpp>
|
|
#endif
|
|
|
|
#if defined(INPUT_XLIB)
|
|
#include <ruby/input/xlib.cpp>
|
|
#endif
|
|
|
|
namespace ruby {
|
|
|
|
auto Input::setContext(uintptr context) -> bool {
|
|
if(instance->context == context) return true;
|
|
if(!instance->hasContext()) return false;
|
|
if(!instance->setContext(instance->context = context)) return false;
|
|
return true;
|
|
}
|
|
|
|
//
|
|
|
|
auto Input::acquired() -> bool {
|
|
return instance->acquired();
|
|
}
|
|
|
|
auto Input::acquire() -> bool {
|
|
return instance->acquire();
|
|
}
|
|
|
|
auto Input::release() -> bool {
|
|
return instance->release();
|
|
}
|
|
|
|
auto Input::poll() -> vector<shared_pointer<nall::HID::Device>> {
|
|
return instance->poll();
|
|
}
|
|
|
|
auto Input::rumble(uint64_t id, bool enable) -> bool {
|
|
return instance->rumble(id, enable);
|
|
}
|
|
|
|
//
|
|
|
|
auto Input::onChange(const function<void (shared_pointer<HID::Device>, uint, uint, int16_t, int16_t)>& onChange) -> void {
|
|
change = onChange;
|
|
}
|
|
|
|
auto Input::doChange(shared_pointer<HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void {
|
|
if(change) change(device, group, input, oldValue, newValue);
|
|
}
|
|
|
|
//
|
|
|
|
auto Input::create(string driver) -> bool {
|
|
self.instance.reset();
|
|
if(!driver) driver = optimalDriver();
|
|
|
|
#if defined(INPUT_WINDOWS)
|
|
if(driver == "Windows") self.instance = new InputWindows(*this);
|
|
#endif
|
|
|
|
#if defined(INPUT_QUARTZ)
|
|
if(driver == "Quartz") self.instance = new InputQuartz(*this);
|
|
#endif
|
|
|
|
#if defined(INPUT_CARBON)
|
|
if(driver == "Carbon") self.instance = new InputCarbon(*this);
|
|
#endif
|
|
|
|
#if defined(INPUT_UDEV)
|
|
if(driver == "udev") self.instance = new InputUdev(*this);
|
|
#endif
|
|
|
|
#if defined(INPUT_SDL)
|
|
if(driver == "SDL") self.instance = new InputSDL(*this);
|
|
#endif
|
|
|
|
#if defined(INPUT_XLIB)
|
|
if(driver == "Xlib") self.instance = new InputXlib(*this);
|
|
#endif
|
|
|
|
if(!self.instance) self.instance = new InputDriver(*this);
|
|
|
|
return self.instance->create();
|
|
}
|
|
|
|
auto Input::hasDrivers() -> vector<string> {
|
|
return {
|
|
|
|
#if defined(INPUT_WINDOWS)
|
|
"Windows",
|
|
#endif
|
|
|
|
#if defined(INPUT_QUARTZ)
|
|
"Quartz",
|
|
#endif
|
|
|
|
#if defined(INPUT_CARBON)
|
|
"Carbon",
|
|
#endif
|
|
|
|
#if defined(INPUT_UDEV)
|
|
"udev",
|
|
#endif
|
|
|
|
#if defined(INPUT_SDL)
|
|
"SDL",
|
|
#endif
|
|
|
|
#if defined(INPUT_XLIB)
|
|
"Xlib",
|
|
#endif
|
|
|
|
"None"};
|
|
}
|
|
|
|
auto Input::optimalDriver() -> string {
|
|
#if defined(INPUT_WINDOWS)
|
|
return "Windows";
|
|
#elif defined(INPUT_QUARTZ)
|
|
return "Quartz";
|
|
#elif defined(INPUT_CARBON)
|
|
return "Carbon";
|
|
#elif defined(INPUT_UDEV)
|
|
return "udev";
|
|
#elif defined(INPUT_SDL)
|
|
return "SDL";
|
|
#elif defined(INPUT_XLIB)
|
|
return "Xlib";
|
|
#else
|
|
return "None";
|
|
#endif
|
|
}
|
|
|
|
auto Input::safestDriver() -> string {
|
|
#if defined(INPUT_WINDOWS)
|
|
return "Windows";
|
|
#elif defined(INPUT_QUARTZ)
|
|
return "Quartz";
|
|
#elif defined(INPUT_CARBON)
|
|
return "Carbon";
|
|
#elif defined(INPUT_UDEV)
|
|
return "udev";
|
|
#elif defined(INPUT_SDL)
|
|
return "SDL";
|
|
#elif defined(INPUT_XLIB)
|
|
return "Xlib";
|
|
#else
|
|
return "none";
|
|
#endif
|
|
}
|
|
|
|
}
|