Dependency injection for apu/gpu/hid.
This commit is contained in:
@@ -13,54 +13,9 @@
|
||||
#include "xenia/hid/hid_flags.h"
|
||||
#include "xenia/hid/input_driver.h"
|
||||
|
||||
#include "xenia/hid/nop/nop_hid.h"
|
||||
#if XE_PLATFORM_WIN32
|
||||
#include "xenia/hid/winkey/winkey_hid.h"
|
||||
#include "xenia/hid/xinput/xinput_hid.h"
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
||||
namespace xe {
|
||||
namespace hid {
|
||||
|
||||
std::unique_ptr<InputSystem> InputSystem::Create(xe::ui::Window* window) {
|
||||
std::unique_ptr<InputSystem> input_system(new InputSystem(window));
|
||||
|
||||
if (FLAGS_hid.compare("nop") == 0) {
|
||||
input_system->AddDriver(xe::hid::nop::Create(input_system.get()));
|
||||
#if XE_PLATFORM_WIN32
|
||||
} else if (FLAGS_hid.compare("winkey") == 0) {
|
||||
input_system->AddDriver(xe::hid::winkey::Create(input_system.get()));
|
||||
} else if (FLAGS_hid.compare("xinput") == 0) {
|
||||
input_system->AddDriver(xe::hid::xinput::Create(input_system.get()));
|
||||
#endif // WIN32
|
||||
} else {
|
||||
// Create all available.
|
||||
bool any_created = false;
|
||||
|
||||
// NOTE: in any mode we create as many as we can, falling back to nop.
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
auto xinput_driver = xe::hid::xinput::Create(input_system.get());
|
||||
if (xinput_driver) {
|
||||
input_system->AddDriver(std::move(xinput_driver));
|
||||
any_created = true;
|
||||
}
|
||||
auto winkey_driver = xe::hid::winkey::Create(input_system.get());
|
||||
if (winkey_driver) {
|
||||
input_system->AddDriver(std::move(winkey_driver));
|
||||
any_created = true;
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
// Fallback to nop if none created.
|
||||
if (!any_created) {
|
||||
input_system->AddDriver(xe::hid::nop::Create(input_system.get()));
|
||||
}
|
||||
}
|
||||
|
||||
return input_system;
|
||||
}
|
||||
|
||||
InputSystem::InputSystem(xe::ui::Window* window) : window_(window) {}
|
||||
|
||||
InputSystem::~InputSystem() = default;
|
||||
|
||||
Reference in New Issue
Block a user