early-access version 2201
This commit is contained in:
@@ -1,36 +1,32 @@
|
||||
add_library(input_common STATIC
|
||||
analog_from_button.cpp
|
||||
analog_from_button.h
|
||||
keyboard.cpp
|
||||
keyboard.h
|
||||
drivers/gc_adapter.cpp
|
||||
drivers/gc_adapter.h
|
||||
drivers/keyboard.cpp
|
||||
drivers/keyboard.h
|
||||
drivers/mouse.cpp
|
||||
drivers/mouse.h
|
||||
drivers/sdl_driver.cpp
|
||||
drivers/sdl_driver.h
|
||||
drivers/tas_input.cpp
|
||||
drivers/tas_input.h
|
||||
drivers/touch_screen.cpp
|
||||
drivers/touch_screen.h
|
||||
drivers/udp_client.cpp
|
||||
drivers/udp_client.h
|
||||
helpers/stick_from_buttons.cpp
|
||||
helpers/stick_from_buttons.h
|
||||
helpers/touch_from_buttons.cpp
|
||||
helpers/touch_from_buttons.h
|
||||
helpers/udp_protocol.cpp
|
||||
helpers/udp_protocol.h
|
||||
input_engine.cpp
|
||||
input_engine.h
|
||||
input_mapping.cpp
|
||||
input_mapping.h
|
||||
input_poller.cpp
|
||||
input_poller.h
|
||||
main.cpp
|
||||
main.h
|
||||
motion_from_button.cpp
|
||||
motion_from_button.h
|
||||
motion_input.cpp
|
||||
motion_input.h
|
||||
touch_from_button.cpp
|
||||
touch_from_button.h
|
||||
gcadapter/gc_adapter.cpp
|
||||
gcadapter/gc_adapter.h
|
||||
gcadapter/gc_poller.cpp
|
||||
gcadapter/gc_poller.h
|
||||
mouse/mouse_input.cpp
|
||||
mouse/mouse_input.h
|
||||
mouse/mouse_poller.cpp
|
||||
mouse/mouse_poller.h
|
||||
sdl/sdl.cpp
|
||||
sdl/sdl.h
|
||||
tas/tas_input.cpp
|
||||
tas/tas_input.h
|
||||
tas/tas_poller.cpp
|
||||
tas/tas_poller.h
|
||||
udp/client.cpp
|
||||
udp/client.h
|
||||
udp/protocol.cpp
|
||||
udp/protocol.h
|
||||
udp/udp.cpp
|
||||
udp/udp.h
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
@@ -57,8 +53,8 @@ endif()
|
||||
|
||||
if (ENABLE_SDL2)
|
||||
target_sources(input_common PRIVATE
|
||||
sdl/sdl_impl.cpp
|
||||
sdl/sdl_impl.h
|
||||
drivers/sdl_driver.cpp
|
||||
drivers/sdl_driver.h
|
||||
)
|
||||
target_link_libraries(input_common PRIVATE SDL2)
|
||||
target_compile_definitions(input_common PRIVATE HAVE_SDL2)
|
||||
|
@@ -13,15 +13,26 @@ constexpr PadIdentifier key_identifier = {
|
||||
.port = 0,
|
||||
.pad = 0,
|
||||
};
|
||||
constexpr PadIdentifier modifier_identifier = {
|
||||
constexpr PadIdentifier keyboard_key_identifier = {
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = 0,
|
||||
.port = 1,
|
||||
.pad = 0,
|
||||
};
|
||||
constexpr PadIdentifier keyboard_modifier_identifier = {
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = 1,
|
||||
.pad = 1,
|
||||
};
|
||||
|
||||
Keyboard::Keyboard(const std::string& input_engine_) : InputEngine(input_engine_) {
|
||||
// Keyboard is broken into 3 diferent sets:
|
||||
// key: Unfiltered intended for controllers.
|
||||
// keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation.
|
||||
// keyboard_modifier: Allows only Settings::NativeKeyboard::Modifiers intended for keyboard
|
||||
// emulation.
|
||||
PreSetController(key_identifier);
|
||||
PreSetController(modifier_identifier);
|
||||
PreSetController(keyboard_key_identifier);
|
||||
PreSetController(keyboard_modifier_identifier);
|
||||
}
|
||||
|
||||
void Keyboard::PressKey(int key_code) {
|
||||
@@ -32,35 +43,50 @@ void Keyboard::ReleaseKey(int key_code) {
|
||||
SetButton(key_identifier, key_code, false);
|
||||
}
|
||||
|
||||
void Keyboard::SetModifiers(int key_modifiers) {
|
||||
void Keyboard::PressKeyboardKey(int key_index) {
|
||||
if (key_index == Settings::NativeKeyboard::None) {
|
||||
return;
|
||||
}
|
||||
SetButton(keyboard_key_identifier, key_index, true);
|
||||
}
|
||||
|
||||
void Keyboard::ReleaseKeyboardKey(int key_index) {
|
||||
if (key_index == Settings::NativeKeyboard::None) {
|
||||
return;
|
||||
}
|
||||
SetButton(keyboard_key_identifier, key_index, false);
|
||||
}
|
||||
|
||||
void Keyboard::SetKeyboardModifiers(int key_modifiers) {
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
bool key_value = ((key_modifiers >> i) & 0x1) != 0;
|
||||
SetButton(modifier_identifier, i, key_value);
|
||||
SetButton(keyboard_modifier_identifier, i, key_value);
|
||||
// Use the modifier to press the key button equivalent
|
||||
switch (i) {
|
||||
case Settings::NativeKeyboard::LeftControl:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::LeftControlKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::LeftControlKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::LeftShift:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::LeftShiftKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::LeftShiftKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::LeftAlt:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::LeftAltKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::LeftAltKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::LeftMeta:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::LeftMetaKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::LeftMetaKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::RightControl:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::RightControlKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::RightControlKey,
|
||||
key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::RightShift:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::RightShiftKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::RightShiftKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::RightAlt:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::RightAltKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::RightAltKey, key_value);
|
||||
break;
|
||||
case Settings::NativeKeyboard::RightMeta:
|
||||
SetButton(key_identifier, Settings::NativeKeyboard::RightMetaKey, key_value);
|
||||
SetButton(keyboard_key_identifier, Settings::NativeKeyboard::RightMetaKey, key_value);
|
||||
break;
|
||||
default:
|
||||
// Other modifier keys should be pressed with PressKey since they stay enabled until
|
||||
|
@@ -28,11 +28,23 @@ public:
|
||||
*/
|
||||
void ReleaseKey(int key_code);
|
||||
|
||||
/**
|
||||
* Sets the status of the keyboard key to pressed
|
||||
* @param key_index index of the key to press
|
||||
*/
|
||||
void PressKeyboardKey(int key_index);
|
||||
|
||||
/**
|
||||
* Sets the status of the keyboard key to released
|
||||
* @param key_index index of the key to release
|
||||
*/
|
||||
void ReleaseKeyboardKey(int key_index);
|
||||
|
||||
/**
|
||||
* Sets the status of all keyboard modifier keys
|
||||
* @param key_modifiers the code of the key to release
|
||||
*/
|
||||
void SetModifiers(int key_modifiers);
|
||||
void SetKeyboardModifiers(int key_modifiers);
|
||||
|
||||
/// Sets all keys to the non pressed state
|
||||
void ReleaseAllKeys();
|
||||
|
@@ -12,6 +12,10 @@
|
||||
#include "input_common/drivers/mouse.h"
|
||||
|
||||
namespace InputCommon {
|
||||
constexpr int mouse_axis_x = 0;
|
||||
constexpr int mouse_axis_y = 1;
|
||||
constexpr int wheel_axis_x = 2;
|
||||
constexpr int wheel_axis_y = 3;
|
||||
constexpr int touch_axis_x = 10;
|
||||
constexpr int touch_axis_y = 11;
|
||||
constexpr PadIdentifier identifier = {
|
||||
@@ -34,14 +38,18 @@ void Mouse::UpdateThread(std::stop_token stop_token) {
|
||||
last_mouse_change *= 0.96f;
|
||||
const float sensitivity =
|
||||
Settings::values.mouse_panning_sensitivity.GetValue() * 0.022f;
|
||||
SetAxis(identifier, 0, last_mouse_change.x * sensitivity);
|
||||
SetAxis(identifier, 1, -last_mouse_change.y * sensitivity);
|
||||
SetAxis(identifier, mouse_axis_x, last_mouse_change.x * sensitivity);
|
||||
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
|
||||
}
|
||||
|
||||
if (mouse_panning_timout++ > 20) {
|
||||
StopPanning();
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(update_time));
|
||||
|
||||
// Reset wheel position
|
||||
SetAxis(identifier, wheel_axis_x, 0);
|
||||
SetAxis(identifier, wheel_axis_y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +97,8 @@ void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int
|
||||
if (button_pressed) {
|
||||
const auto mouse_move = Common::MakeVec<int>(x, y) - mouse_origin;
|
||||
const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f;
|
||||
SetAxis(identifier, 0, static_cast<float>(mouse_move.x) * sensitivity);
|
||||
SetAxis(identifier, 1, static_cast<float>(-mouse_move.y) * sensitivity);
|
||||
SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * sensitivity);
|
||||
SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * sensitivity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +116,17 @@ void Mouse::ReleaseButton(MouseButton button) {
|
||||
SetButton(identifier, static_cast<int>(button), false);
|
||||
|
||||
if (!Settings::values.mouse_panning) {
|
||||
SetAxis(identifier, 0, 0);
|
||||
SetAxis(identifier, 1, 0);
|
||||
SetAxis(identifier, mouse_axis_x, 0);
|
||||
SetAxis(identifier, mouse_axis_y, 0);
|
||||
}
|
||||
button_pressed = false;
|
||||
}
|
||||
|
||||
void Mouse::MouseWheelChange(int x, int y) {
|
||||
SetAxis(identifier, wheel_axis_x, static_cast<f32>(x));
|
||||
SetAxis(identifier, wheel_axis_y, static_cast<f32>(y));
|
||||
}
|
||||
|
||||
void Mouse::ReleaseAllButtons() {
|
||||
ResetButtonState();
|
||||
button_pressed = false;
|
||||
|
@@ -52,6 +52,13 @@ public:
|
||||
*/
|
||||
void ReleaseButton(MouseButton button);
|
||||
|
||||
/**
|
||||
* Sets the status of the mouse wheel
|
||||
* @param x delta movement in the x direction
|
||||
* @param y delta movement in the y direction
|
||||
*/
|
||||
void MouseWheelChange(int x, int y);
|
||||
|
||||
void ReleaseAllButtons();
|
||||
|
||||
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
||||
|
@@ -28,6 +28,10 @@ void MappingFactory::RegisterInput(const MappingData& data) {
|
||||
if (!is_enabled) {
|
||||
return;
|
||||
}
|
||||
if (!IsDriverValid(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (input_type) {
|
||||
case Polling::InputType::Button:
|
||||
RegisterButton(data);
|
||||
@@ -168,4 +172,25 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
|
||||
input_queue.Push(new_input);
|
||||
}
|
||||
|
||||
bool MappingFactory::IsDriverValid(const MappingData& data) const {
|
||||
// Only port 0 can be mapped on the keyboard
|
||||
if (data.engine == "keyboard" && data.pad.port != 0) {
|
||||
return false;
|
||||
}
|
||||
// The following drivers don't need to be mapped
|
||||
if (data.engine == "tas") {
|
||||
return false;
|
||||
}
|
||||
if (data.engine == "touch") {
|
||||
return false;
|
||||
}
|
||||
if (data.engine == "touch_from_button") {
|
||||
return false;
|
||||
}
|
||||
if (data.engine == "analog_from_button") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace InputCommon
|
||||
|
@@ -66,6 +66,13 @@ private:
|
||||
*/
|
||||
void RegisterMotion(const MappingData& data);
|
||||
|
||||
/**
|
||||
* Returns true if driver can be mapped
|
||||
* @param "data": An struct containing all the information needed to create a proper
|
||||
* ParamPackage
|
||||
*/
|
||||
bool IsDriverValid(const MappingData& data) const;
|
||||
|
||||
Common::SPSCQueue<Common::ParamPackage> input_queue;
|
||||
Polling::InputType input_type{Polling::InputType::None};
|
||||
bool is_enabled{};
|
||||
|
@@ -4,146 +4,164 @@
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include "common/input.h"
|
||||
#include "common/param_package.h"
|
||||
#include "common/settings.h"
|
||||
#include "input_common/analog_from_button.h"
|
||||
#include "input_common/gcadapter/gc_adapter.h"
|
||||
#include "input_common/gcadapter/gc_poller.h"
|
||||
#include "input_common/keyboard.h"
|
||||
#include "input_common/drivers/gc_adapter.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "input_common/drivers/mouse.h"
|
||||
#include "input_common/drivers/tas_input.h"
|
||||
#include "input_common/drivers/touch_screen.h"
|
||||
#include "input_common/drivers/udp_client.h"
|
||||
#include "input_common/helpers/stick_from_buttons.h"
|
||||
#include "input_common/helpers/touch_from_buttons.h"
|
||||
#include "input_common/input_engine.h"
|
||||
#include "input_common/input_mapping.h"
|
||||
#include "input_common/input_poller.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/motion_from_button.h"
|
||||
#include "input_common/mouse/mouse_input.h"
|
||||
#include "input_common/mouse/mouse_poller.h"
|
||||
#include "input_common/tas/tas_input.h"
|
||||
#include "input_common/tas/tas_poller.h"
|
||||
#include "input_common/touch_from_button.h"
|
||||
#include "input_common/udp/client.h"
|
||||
#include "input_common/udp/udp.h"
|
||||
#ifdef HAVE_SDL2
|
||||
#include "input_common/sdl/sdl.h"
|
||||
#include "input_common/drivers/sdl_driver.h"
|
||||
#endif
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
struct InputSubsystem::Impl {
|
||||
void Initialize() {
|
||||
gcadapter = std::make_shared<GCAdapter::Adapter>();
|
||||
gcbuttons = std::make_shared<GCButtonFactory>(gcadapter);
|
||||
Input::RegisterFactory<Input::ButtonDevice>("gcpad", gcbuttons);
|
||||
gcanalog = std::make_shared<GCAnalogFactory>(gcadapter);
|
||||
Input::RegisterFactory<Input::AnalogDevice>("gcpad", gcanalog);
|
||||
gcvibration = std::make_shared<GCVibrationFactory>(gcadapter);
|
||||
Input::RegisterFactory<Input::VibrationDevice>("gcpad", gcvibration);
|
||||
mapping_factory = std::make_shared<MappingFactory>();
|
||||
MappingCallback mapping_callback{[this](MappingData data) { RegisterInput(data); }};
|
||||
|
||||
keyboard = std::make_shared<Keyboard>();
|
||||
Input::RegisterFactory<Input::ButtonDevice>("keyboard", keyboard);
|
||||
Input::RegisterFactory<Input::AnalogDevice>("analog_from_button",
|
||||
std::make_shared<AnalogFromButton>());
|
||||
Input::RegisterFactory<Input::MotionDevice>("keyboard",
|
||||
std::make_shared<MotionFromButton>());
|
||||
Input::RegisterFactory<Input::TouchDevice>("touch_from_button",
|
||||
std::make_shared<TouchFromButtonFactory>());
|
||||
keyboard = std::make_shared<Keyboard>("keyboard");
|
||||
keyboard->SetMappingCallback(mapping_callback);
|
||||
keyboard_factory = std::make_shared<InputFactory>(keyboard);
|
||||
keyboard_output_factory = std::make_shared<OutputFactory>(keyboard);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(),
|
||||
keyboard_factory);
|
||||
Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(),
|
||||
keyboard_output_factory);
|
||||
|
||||
mouse = std::make_shared<Mouse>("mouse");
|
||||
mouse->SetMappingCallback(mapping_callback);
|
||||
mouse_factory = std::make_shared<InputFactory>(mouse);
|
||||
mouse_output_factory = std::make_shared<OutputFactory>(mouse);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(),
|
||||
mouse_factory);
|
||||
Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(),
|
||||
mouse_output_factory);
|
||||
|
||||
touch_screen = std::make_shared<TouchScreen>("touch");
|
||||
touch_screen_factory = std::make_shared<InputFactory>(touch_screen);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(),
|
||||
touch_screen_factory);
|
||||
|
||||
gcadapter = std::make_shared<GCAdapter>("gcpad");
|
||||
gcadapter->SetMappingCallback(mapping_callback);
|
||||
gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter);
|
||||
gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(),
|
||||
gcadapter_input_factory);
|
||||
Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(),
|
||||
gcadapter_output_factory);
|
||||
|
||||
udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp");
|
||||
udp_client->SetMappingCallback(mapping_callback);
|
||||
udp_client_factory = std::make_shared<InputFactory>(udp_client);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(),
|
||||
udp_client_factory);
|
||||
|
||||
tas_input = std::make_shared<TasInput::Tas>("tas");
|
||||
tas_input->SetMappingCallback(mapping_callback);
|
||||
tas_input_factory = std::make_shared<InputFactory>(tas_input);
|
||||
tas_output_factory = std::make_shared<OutputFactory>(tas_input);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(),
|
||||
tas_input_factory);
|
||||
Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(),
|
||||
tas_output_factory);
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
sdl = SDL::Init();
|
||||
sdl = std::make_shared<SDLDriver>("sdl");
|
||||
sdl->SetMappingCallback(mapping_callback);
|
||||
sdl_input_factory = std::make_shared<InputFactory>(sdl);
|
||||
sdl_output_factory = std::make_shared<OutputFactory>(sdl);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(),
|
||||
sdl_input_factory);
|
||||
Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(),
|
||||
sdl_output_factory);
|
||||
#endif
|
||||
|
||||
udp = std::make_shared<InputCommon::CemuhookUDP::Client>();
|
||||
udpmotion = std::make_shared<UDPMotionFactory>(udp);
|
||||
Input::RegisterFactory<Input::MotionDevice>("cemuhookudp", udpmotion);
|
||||
udptouch = std::make_shared<UDPTouchFactory>(udp);
|
||||
Input::RegisterFactory<Input::TouchDevice>("cemuhookudp", udptouch);
|
||||
|
||||
mouse = std::make_shared<MouseInput::Mouse>();
|
||||
mousebuttons = std::make_shared<MouseButtonFactory>(mouse);
|
||||
Input::RegisterFactory<Input::ButtonDevice>("mouse", mousebuttons);
|
||||
mouseanalog = std::make_shared<MouseAnalogFactory>(mouse);
|
||||
Input::RegisterFactory<Input::AnalogDevice>("mouse", mouseanalog);
|
||||
mousemotion = std::make_shared<MouseMotionFactory>(mouse);
|
||||
Input::RegisterFactory<Input::MotionDevice>("mouse", mousemotion);
|
||||
mousetouch = std::make_shared<MouseTouchFactory>(mouse);
|
||||
Input::RegisterFactory<Input::TouchDevice>("mouse", mousetouch);
|
||||
|
||||
tas = std::make_shared<TasInput::Tas>();
|
||||
tasbuttons = std::make_shared<TasButtonFactory>(tas);
|
||||
Input::RegisterFactory<Input::ButtonDevice>("tas", tasbuttons);
|
||||
tasanalog = std::make_shared<TasAnalogFactory>(tas);
|
||||
Input::RegisterFactory<Input::AnalogDevice>("tas", tasanalog);
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(
|
||||
"touch_from_button", std::make_shared<TouchFromButton>());
|
||||
Common::Input::RegisterFactory<Common::Input::InputDevice>(
|
||||
"analog_from_button", std::make_shared<StickFromButton>());
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
Input::UnregisterFactory<Input::ButtonDevice>("keyboard");
|
||||
Input::UnregisterFactory<Input::MotionDevice>("keyboard");
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName());
|
||||
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName());
|
||||
keyboard.reset();
|
||||
Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button");
|
||||
Input::UnregisterFactory<Input::TouchDevice>("touch_from_button");
|
||||
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName());
|
||||
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName());
|
||||
mouse.reset();
|
||||
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName());
|
||||
touch_screen.reset();
|
||||
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName());
|
||||
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName());
|
||||
gcadapter.reset();
|
||||
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName());
|
||||
udp_client.reset();
|
||||
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName());
|
||||
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName());
|
||||
tas_input.reset();
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName());
|
||||
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName());
|
||||
sdl.reset();
|
||||
#endif
|
||||
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
|
||||
Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
|
||||
Input::UnregisterFactory<Input::VibrationDevice>("gcpad");
|
||||
|
||||
gcbuttons.reset();
|
||||
gcanalog.reset();
|
||||
gcvibration.reset();
|
||||
|
||||
Input::UnregisterFactory<Input::MotionDevice>("cemuhookudp");
|
||||
Input::UnregisterFactory<Input::TouchDevice>("cemuhookudp");
|
||||
|
||||
udpmotion.reset();
|
||||
udptouch.reset();
|
||||
|
||||
Input::UnregisterFactory<Input::ButtonDevice>("mouse");
|
||||
Input::UnregisterFactory<Input::AnalogDevice>("mouse");
|
||||
Input::UnregisterFactory<Input::MotionDevice>("mouse");
|
||||
Input::UnregisterFactory<Input::TouchDevice>("mouse");
|
||||
|
||||
mousebuttons.reset();
|
||||
mouseanalog.reset();
|
||||
mousemotion.reset();
|
||||
mousetouch.reset();
|
||||
|
||||
Input::UnregisterFactory<Input::ButtonDevice>("tas");
|
||||
Input::UnregisterFactory<Input::AnalogDevice>("tas");
|
||||
|
||||
tasbuttons.reset();
|
||||
tasanalog.reset();
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button");
|
||||
Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button");
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
|
||||
std::vector<Common::ParamPackage> devices = {
|
||||
Common::ParamPackage{{"display", "Any"}, {"class", "any"}},
|
||||
Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "keyboard"}},
|
||||
Common::ParamPackage{{"display", "Any"}, {"engine", "any"}},
|
||||
};
|
||||
if (Settings::values.tas_enable) {
|
||||
devices.emplace_back(
|
||||
Common::ParamPackage{{"display", "TAS Controller"}, {"class", "tas"}});
|
||||
}
|
||||
|
||||
auto keyboard_devices = keyboard->GetInputDevices();
|
||||
devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end());
|
||||
auto mouse_devices = mouse->GetInputDevices();
|
||||
devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end());
|
||||
auto gcadapter_devices = gcadapter->GetInputDevices();
|
||||
devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end());
|
||||
#ifdef HAVE_SDL2
|
||||
auto sdl_devices = sdl->GetInputDevices();
|
||||
devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end());
|
||||
#endif
|
||||
auto udp_devices = udp->GetInputDevices();
|
||||
devices.insert(devices.end(), udp_devices.begin(), udp_devices.end());
|
||||
auto gcpad_devices = gcadapter->GetInputDevices();
|
||||
devices.insert(devices.end(), gcpad_devices.begin(), gcpad_devices.end());
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
[[nodiscard]] AnalogMapping GetAnalogMappingForDevice(
|
||||
const Common::ParamPackage& params) const {
|
||||
if (!params.Has("class") || params.Get("class", "") == "any") {
|
||||
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
||||
return {};
|
||||
}
|
||||
if (params.Get("class", "") == "gcpad") {
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == mouse->GetEngineName()) {
|
||||
return mouse->GetAnalogMappingForDevice(params);
|
||||
}
|
||||
if (engine == gcadapter->GetEngineName()) {
|
||||
return gcadapter->GetAnalogMappingForDevice(params);
|
||||
}
|
||||
if (params.Get("class", "") == "tas") {
|
||||
return tas->GetAnalogMappingForDevice(params);
|
||||
if (engine == tas_input->GetEngineName()) {
|
||||
return tas_input->GetAnalogMappingForDevice(params);
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
if (params.Get("class", "") == "sdl") {
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return sdl->GetAnalogMappingForDevice(params);
|
||||
}
|
||||
#endif
|
||||
@@ -152,17 +170,18 @@ struct InputSubsystem::Impl {
|
||||
|
||||
[[nodiscard]] ButtonMapping GetButtonMappingForDevice(
|
||||
const Common::ParamPackage& params) const {
|
||||
if (!params.Has("class") || params.Get("class", "") == "any") {
|
||||
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
||||
return {};
|
||||
}
|
||||
if (params.Get("class", "") == "gcpad") {
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == gcadapter->GetEngineName()) {
|
||||
return gcadapter->GetButtonMappingForDevice(params);
|
||||
}
|
||||
if (params.Get("class", "") == "tas") {
|
||||
return tas->GetButtonMappingForDevice(params);
|
||||
if (engine == tas_input->GetEngineName()) {
|
||||
return tas_input->GetButtonMappingForDevice(params);
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
if (params.Get("class", "") == "sdl") {
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return sdl->GetButtonMappingForDevice(params);
|
||||
}
|
||||
#endif
|
||||
@@ -171,40 +190,115 @@ struct InputSubsystem::Impl {
|
||||
|
||||
[[nodiscard]] MotionMapping GetMotionMappingForDevice(
|
||||
const Common::ParamPackage& params) const {
|
||||
if (!params.Has("class") || params.Get("class", "") == "any") {
|
||||
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
||||
return {};
|
||||
}
|
||||
if (params.Get("class", "") == "cemuhookudp") {
|
||||
// TODO return the correct motion device
|
||||
return {};
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == gcadapter->GetEngineName()) {
|
||||
return gcadapter->GetMotionMappingForDevice(params);
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
if (params.Get("class", "") == "sdl") {
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return sdl->GetMotionMappingForDevice(params);
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<Keyboard> keyboard;
|
||||
std::string GetButtonName(const Common::ParamPackage& params) const {
|
||||
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
||||
return "Unknown";
|
||||
}
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == mouse->GetEngineName()) {
|
||||
return mouse->GetUIName(params);
|
||||
}
|
||||
if (engine == gcadapter->GetEngineName()) {
|
||||
return gcadapter->GetUIName(params);
|
||||
}
|
||||
if (engine == udp_client->GetEngineName()) {
|
||||
return udp_client->GetUIName(params);
|
||||
}
|
||||
if (engine == tas_input->GetEngineName()) {
|
||||
return tas_input->GetUIName(params);
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
std::unique_ptr<SDL::State> sdl;
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return sdl->GetUIName(params);
|
||||
}
|
||||
#endif
|
||||
return "Bad engine";
|
||||
}
|
||||
|
||||
bool IsController(const Common::ParamPackage& params) {
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == mouse->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
if (engine == gcadapter->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
if (engine == tas_input->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
if (engine == sdl->GetEngineName()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void BeginConfiguration() {
|
||||
keyboard->BeginConfiguration();
|
||||
mouse->BeginConfiguration();
|
||||
gcadapter->BeginConfiguration();
|
||||
udp_client->BeginConfiguration();
|
||||
#ifdef HAVE_SDL2
|
||||
sdl->BeginConfiguration();
|
||||
#endif
|
||||
}
|
||||
|
||||
void EndConfiguration() {
|
||||
keyboard->EndConfiguration();
|
||||
mouse->EndConfiguration();
|
||||
gcadapter->EndConfiguration();
|
||||
udp_client->EndConfiguration();
|
||||
#ifdef HAVE_SDL2
|
||||
sdl->EndConfiguration();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RegisterInput(MappingData data) {
|
||||
mapping_factory->RegisterInput(data);
|
||||
}
|
||||
|
||||
std::shared_ptr<MappingFactory> mapping_factory;
|
||||
|
||||
std::shared_ptr<Keyboard> keyboard;
|
||||
std::shared_ptr<Mouse> mouse;
|
||||
std::shared_ptr<GCAdapter> gcadapter;
|
||||
std::shared_ptr<TouchScreen> touch_screen;
|
||||
std::shared_ptr<TasInput::Tas> tas_input;
|
||||
std::shared_ptr<CemuhookUDP::UDPClient> udp_client;
|
||||
|
||||
std::shared_ptr<InputFactory> keyboard_factory;
|
||||
std::shared_ptr<InputFactory> mouse_factory;
|
||||
std::shared_ptr<InputFactory> gcadapter_input_factory;
|
||||
std::shared_ptr<InputFactory> touch_screen_factory;
|
||||
std::shared_ptr<InputFactory> udp_client_factory;
|
||||
std::shared_ptr<InputFactory> tas_input_factory;
|
||||
|
||||
std::shared_ptr<OutputFactory> keyboard_output_factory;
|
||||
std::shared_ptr<OutputFactory> mouse_output_factory;
|
||||
std::shared_ptr<OutputFactory> gcadapter_output_factory;
|
||||
std::shared_ptr<OutputFactory> tas_output_factory;
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
std::shared_ptr<SDLDriver> sdl;
|
||||
std::shared_ptr<InputFactory> sdl_input_factory;
|
||||
std::shared_ptr<OutputFactory> sdl_output_factory;
|
||||
#endif
|
||||
std::shared_ptr<GCButtonFactory> gcbuttons;
|
||||
std::shared_ptr<GCAnalogFactory> gcanalog;
|
||||
std::shared_ptr<GCVibrationFactory> gcvibration;
|
||||
std::shared_ptr<UDPMotionFactory> udpmotion;
|
||||
std::shared_ptr<UDPTouchFactory> udptouch;
|
||||
std::shared_ptr<MouseButtonFactory> mousebuttons;
|
||||
std::shared_ptr<MouseAnalogFactory> mouseanalog;
|
||||
std::shared_ptr<MouseMotionFactory> mousemotion;
|
||||
std::shared_ptr<MouseTouchFactory> mousetouch;
|
||||
std::shared_ptr<TasButtonFactory> tasbuttons;
|
||||
std::shared_ptr<TasAnalogFactory> tasanalog;
|
||||
std::shared_ptr<CemuhookUDP::Client> udp;
|
||||
std::shared_ptr<GCAdapter::Adapter> gcadapter;
|
||||
std::shared_ptr<MouseInput::Mouse> mouse;
|
||||
std::shared_ptr<TasInput::Tas> tas;
|
||||
};
|
||||
|
||||
InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}
|
||||
@@ -227,20 +321,28 @@ const Keyboard* InputSubsystem::GetKeyboard() const {
|
||||
return impl->keyboard.get();
|
||||
}
|
||||
|
||||
MouseInput::Mouse* InputSubsystem::GetMouse() {
|
||||
Mouse* InputSubsystem::GetMouse() {
|
||||
return impl->mouse.get();
|
||||
}
|
||||
|
||||
const MouseInput::Mouse* InputSubsystem::GetMouse() const {
|
||||
const Mouse* InputSubsystem::GetMouse() const {
|
||||
return impl->mouse.get();
|
||||
}
|
||||
|
||||
TouchScreen* InputSubsystem::GetTouchScreen() {
|
||||
return impl->touch_screen.get();
|
||||
}
|
||||
|
||||
const TouchScreen* InputSubsystem::GetTouchScreen() const {
|
||||
return impl->touch_screen.get();
|
||||
}
|
||||
|
||||
TasInput::Tas* InputSubsystem::GetTas() {
|
||||
return impl->tas.get();
|
||||
return impl->tas_input.get();
|
||||
}
|
||||
|
||||
const TasInput::Tas* InputSubsystem::GetTas() const {
|
||||
return impl->tas.get();
|
||||
return impl->tas_input.get();
|
||||
}
|
||||
|
||||
std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const {
|
||||
@@ -259,100 +361,37 @@ MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPacka
|
||||
return impl->GetMotionMappingForDevice(device);
|
||||
}
|
||||
|
||||
GCAnalogFactory* InputSubsystem::GetGCAnalogs() {
|
||||
return impl->gcanalog.get();
|
||||
std::string InputSubsystem::GetButtonName(const Common::ParamPackage& params) const {
|
||||
const std::string toggle = params.Get("toggle", false) ? "~" : "";
|
||||
const std::string inverted = params.Get("inverted", false) ? "!" : "";
|
||||
const std::string button_name = impl->GetButtonName(params);
|
||||
std::string axis_direction = "";
|
||||
if (params.Has("axis")) {
|
||||
axis_direction = params.Get("invert", "+");
|
||||
}
|
||||
return fmt::format("{}{}{}{}", toggle, inverted, button_name, axis_direction);
|
||||
}
|
||||
|
||||
const GCAnalogFactory* InputSubsystem::GetGCAnalogs() const {
|
||||
return impl->gcanalog.get();
|
||||
}
|
||||
|
||||
GCButtonFactory* InputSubsystem::GetGCButtons() {
|
||||
return impl->gcbuttons.get();
|
||||
}
|
||||
|
||||
const GCButtonFactory* InputSubsystem::GetGCButtons() const {
|
||||
return impl->gcbuttons.get();
|
||||
}
|
||||
|
||||
UDPMotionFactory* InputSubsystem::GetUDPMotions() {
|
||||
return impl->udpmotion.get();
|
||||
}
|
||||
|
||||
const UDPMotionFactory* InputSubsystem::GetUDPMotions() const {
|
||||
return impl->udpmotion.get();
|
||||
}
|
||||
|
||||
UDPTouchFactory* InputSubsystem::GetUDPTouch() {
|
||||
return impl->udptouch.get();
|
||||
}
|
||||
|
||||
const UDPTouchFactory* InputSubsystem::GetUDPTouch() const {
|
||||
return impl->udptouch.get();
|
||||
}
|
||||
|
||||
MouseButtonFactory* InputSubsystem::GetMouseButtons() {
|
||||
return impl->mousebuttons.get();
|
||||
}
|
||||
|
||||
const MouseButtonFactory* InputSubsystem::GetMouseButtons() const {
|
||||
return impl->mousebuttons.get();
|
||||
}
|
||||
|
||||
MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() {
|
||||
return impl->mouseanalog.get();
|
||||
}
|
||||
|
||||
const MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() const {
|
||||
return impl->mouseanalog.get();
|
||||
}
|
||||
|
||||
MouseMotionFactory* InputSubsystem::GetMouseMotions() {
|
||||
return impl->mousemotion.get();
|
||||
}
|
||||
|
||||
const MouseMotionFactory* InputSubsystem::GetMouseMotions() const {
|
||||
return impl->mousemotion.get();
|
||||
}
|
||||
|
||||
MouseTouchFactory* InputSubsystem::GetMouseTouch() {
|
||||
return impl->mousetouch.get();
|
||||
}
|
||||
|
||||
const MouseTouchFactory* InputSubsystem::GetMouseTouch() const {
|
||||
return impl->mousetouch.get();
|
||||
}
|
||||
|
||||
TasButtonFactory* InputSubsystem::GetTasButtons() {
|
||||
return impl->tasbuttons.get();
|
||||
}
|
||||
|
||||
const TasButtonFactory* InputSubsystem::GetTasButtons() const {
|
||||
return impl->tasbuttons.get();
|
||||
}
|
||||
|
||||
TasAnalogFactory* InputSubsystem::GetTasAnalogs() {
|
||||
return impl->tasanalog.get();
|
||||
}
|
||||
|
||||
const TasAnalogFactory* InputSubsystem::GetTasAnalogs() const {
|
||||
return impl->tasanalog.get();
|
||||
bool InputSubsystem::IsController(const Common::ParamPackage& params) const {
|
||||
return impl->IsController(params);
|
||||
}
|
||||
|
||||
void InputSubsystem::ReloadInputDevices() {
|
||||
if (!impl->udp) {
|
||||
return;
|
||||
}
|
||||
impl->udp->ReloadSockets();
|
||||
impl->udp_client.get()->ReloadSockets();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers(
|
||||
[[maybe_unused]] Polling::DeviceType type) const {
|
||||
#ifdef HAVE_SDL2
|
||||
return impl->sdl->GetPollers(type);
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
void InputSubsystem::BeginMapping(Polling::InputType type) {
|
||||
impl->BeginConfiguration();
|
||||
impl->mapping_factory->BeginMapping(type);
|
||||
}
|
||||
|
||||
const Common::ParamPackage InputSubsystem::GetNextInput() const {
|
||||
return impl->mapping_factory->GetNextInput();
|
||||
}
|
||||
|
||||
void InputSubsystem::StopMapping() const {
|
||||
impl->EndConfiguration();
|
||||
impl->mapping_factory->StopMapping();
|
||||
}
|
||||
|
||||
std::string GenerateKeyboardParam(int key_code) {
|
||||
|
@@ -25,56 +25,26 @@ namespace Settings::NativeMotion {
|
||||
enum Values : int;
|
||||
}
|
||||
|
||||
namespace MouseInput {
|
||||
namespace InputCommon {
|
||||
class Keyboard;
|
||||
class Mouse;
|
||||
}
|
||||
class TouchScreen;
|
||||
struct MappingData;
|
||||
} // namespace InputCommon
|
||||
|
||||
namespace TasInput {
|
||||
namespace InputCommon::TasInput {
|
||||
class Tas;
|
||||
}
|
||||
} // namespace InputCommon::TasInput
|
||||
|
||||
namespace InputCommon {
|
||||
namespace Polling {
|
||||
|
||||
enum class DeviceType { Button, AnalogPreferred, Motion };
|
||||
|
||||
/**
|
||||
* A class that can be used to get inputs from an input device like controllers without having to
|
||||
* poll the device's status yourself
|
||||
*/
|
||||
class DevicePoller {
|
||||
public:
|
||||
virtual ~DevicePoller() = default;
|
||||
/// Setup and start polling for inputs, should be called before GetNextInput
|
||||
/// If a device_id is provided, events should be filtered to only include events from this
|
||||
/// device id
|
||||
virtual void Start(const std::string& device_id = "") = 0;
|
||||
/// Stop polling
|
||||
virtual void Stop() = 0;
|
||||
/**
|
||||
* Every call to this function returns the next input recorded since calling Start
|
||||
* @return A ParamPackage of the recorded input, which can be used to create an InputDevice.
|
||||
* If there has been no input, the package is empty
|
||||
*/
|
||||
virtual Common::ParamPackage GetNextInput() = 0;
|
||||
};
|
||||
/// Type of input desired for mapping purposes
|
||||
enum class InputType { None, Button, Stick, Motion, Touch };
|
||||
} // namespace Polling
|
||||
|
||||
class GCAnalogFactory;
|
||||
class GCButtonFactory;
|
||||
class UDPMotionFactory;
|
||||
class UDPTouchFactory;
|
||||
class MouseButtonFactory;
|
||||
class MouseAnalogFactory;
|
||||
class MouseMotionFactory;
|
||||
class MouseTouchFactory;
|
||||
class TasButtonFactory;
|
||||
class TasAnalogFactory;
|
||||
class Keyboard;
|
||||
|
||||
/**
|
||||
* Given a ParamPackage for a Device returned from `GetInputDevices`, attempt to get the default
|
||||
* mapping for the device. This is currently only implemented for the SDL backend devices.
|
||||
* mapping for the device.
|
||||
*/
|
||||
using AnalogMapping = std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage>;
|
||||
using ButtonMapping = std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage>;
|
||||
@@ -104,20 +74,27 @@ public:
|
||||
[[nodiscard]] const Keyboard* GetKeyboard() const;
|
||||
|
||||
/// Retrieves the underlying mouse device.
|
||||
[[nodiscard]] MouseInput::Mouse* GetMouse();
|
||||
[[nodiscard]] Mouse* GetMouse();
|
||||
|
||||
/// Retrieves the underlying mouse device.
|
||||
[[nodiscard]] const MouseInput::Mouse* GetMouse() const;
|
||||
[[nodiscard]] const Mouse* GetMouse() const;
|
||||
|
||||
/// Retrieves the underlying tas device.
|
||||
/// Retrieves the underlying touch screen device.
|
||||
[[nodiscard]] TouchScreen* GetTouchScreen();
|
||||
|
||||
/// Retrieves the underlying touch screen device.
|
||||
[[nodiscard]] const TouchScreen* GetTouchScreen() const;
|
||||
|
||||
/// Retrieves the underlying tas input device.
|
||||
[[nodiscard]] TasInput::Tas* GetTas();
|
||||
|
||||
/// Retrieves the underlying tas device.
|
||||
/// Retrieves the underlying tas input device.
|
||||
[[nodiscard]] const TasInput::Tas* GetTas() const;
|
||||
|
||||
/**
|
||||
* Returns all available input devices that this Factory can create a new device with.
|
||||
* Each returned ParamPackage should have a `display` field used for display, a class field for
|
||||
* backends to determine if this backend is meant to service the request and any other
|
||||
* Each returned ParamPackage should have a `display` field used for display, a `engine` field
|
||||
* for backends to determine if this backend is meant to service the request and any other
|
||||
* information needed to identify this in the backend later.
|
||||
*/
|
||||
[[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const;
|
||||
@@ -131,83 +108,33 @@ public:
|
||||
/// Retrieves the motion mappings for the given device.
|
||||
[[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const;
|
||||
|
||||
/// Retrieves the underlying GameCube analog handler.
|
||||
[[nodiscard]] GCAnalogFactory* GetGCAnalogs();
|
||||
/// Returns a string contaning the name of the button from the input engine.
|
||||
[[nodiscard]] std::string GetButtonName(const Common::ParamPackage& params) const;
|
||||
|
||||
/// Retrieves the underlying GameCube analog handler.
|
||||
[[nodiscard]] const GCAnalogFactory* GetGCAnalogs() const;
|
||||
/// Returns true if device is a controller.
|
||||
[[nodiscard]] bool IsController(const Common::ParamPackage& params) const;
|
||||
|
||||
/// Retrieves the underlying GameCube button handler.
|
||||
[[nodiscard]] GCButtonFactory* GetGCButtons();
|
||||
|
||||
/// Retrieves the underlying GameCube button handler.
|
||||
[[nodiscard]] const GCButtonFactory* GetGCButtons() const;
|
||||
|
||||
/// Retrieves the underlying udp motion handler.
|
||||
[[nodiscard]] UDPMotionFactory* GetUDPMotions();
|
||||
|
||||
/// Retrieves the underlying udp motion handler.
|
||||
[[nodiscard]] const UDPMotionFactory* GetUDPMotions() const;
|
||||
|
||||
/// Retrieves the underlying udp touch handler.
|
||||
[[nodiscard]] UDPTouchFactory* GetUDPTouch();
|
||||
|
||||
/// Retrieves the underlying udp touch handler.
|
||||
[[nodiscard]] const UDPTouchFactory* GetUDPTouch() const;
|
||||
|
||||
/// Retrieves the underlying mouse button handler.
|
||||
[[nodiscard]] MouseButtonFactory* GetMouseButtons();
|
||||
|
||||
/// Retrieves the underlying mouse button handler.
|
||||
[[nodiscard]] const MouseButtonFactory* GetMouseButtons() const;
|
||||
|
||||
/// Retrieves the underlying mouse analog handler.
|
||||
[[nodiscard]] MouseAnalogFactory* GetMouseAnalogs();
|
||||
|
||||
/// Retrieves the underlying mouse analog handler.
|
||||
[[nodiscard]] const MouseAnalogFactory* GetMouseAnalogs() const;
|
||||
|
||||
/// Retrieves the underlying mouse motion handler.
|
||||
[[nodiscard]] MouseMotionFactory* GetMouseMotions();
|
||||
|
||||
/// Retrieves the underlying mouse motion handler.
|
||||
[[nodiscard]] const MouseMotionFactory* GetMouseMotions() const;
|
||||
|
||||
/// Retrieves the underlying mouse touch handler.
|
||||
[[nodiscard]] MouseTouchFactory* GetMouseTouch();
|
||||
|
||||
/// Retrieves the underlying mouse touch handler.
|
||||
[[nodiscard]] const MouseTouchFactory* GetMouseTouch() const;
|
||||
|
||||
/// Retrieves the underlying tas button handler.
|
||||
[[nodiscard]] TasButtonFactory* GetTasButtons();
|
||||
|
||||
/// Retrieves the underlying tas button handler.
|
||||
[[nodiscard]] const TasButtonFactory* GetTasButtons() const;
|
||||
|
||||
/// Retrieves the underlying tas analogs handler.
|
||||
[[nodiscard]] TasAnalogFactory* GetTasAnalogs();
|
||||
|
||||
/// Retrieves the underlying tas analogs handler.
|
||||
[[nodiscard]] const TasAnalogFactory* GetTasAnalogs() const;
|
||||
|
||||
/// Reloads the input devices
|
||||
/// Reloads the input devices.
|
||||
void ReloadInputDevices();
|
||||
|
||||
/// Get all DevicePoller from all backends for a specific device type
|
||||
[[nodiscard]] std::vector<std::unique_ptr<Polling::DevicePoller>> GetPollers(
|
||||
Polling::DeviceType type) const;
|
||||
/// Start polling from all backends for a desired input type.
|
||||
void BeginMapping(Polling::InputType type);
|
||||
|
||||
/// Returns an input event with mapping information.
|
||||
[[nodiscard]] const Common::ParamPackage GetNextInput() const;
|
||||
|
||||
/// Stop polling from all backends.
|
||||
void StopMapping() const;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
/// Generates a serialized param package for creating a keyboard button device
|
||||
/// Generates a serialized param package for creating a keyboard button device.
|
||||
std::string GenerateKeyboardParam(int key_code);
|
||||
|
||||
/// Generates a serialized param package for creating an analog device taking input from keyboard
|
||||
/// Generates a serialized param package for creating an analog device taking input from keyboard.
|
||||
std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right,
|
||||
int key_modifier, float modifier_scale);
|
||||
|
||||
} // namespace InputCommon
|
||||
|
Reference in New Issue
Block a user