diff options
Diffstat (limited to 'src/input_common')
-rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 2 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.cpp | 4 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.h | 2 | ||||
-rw-r--r-- | src/input_common/drivers/keyboard.cpp | 2 | ||||
-rw-r--r-- | src/input_common/drivers/mouse.cpp | 31 | ||||
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 21 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 2 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.h | 2 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 6 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_driver.h | 6 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_protocol/common_protocol.h | 4 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_protocol/joycon_types.h | 14 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_protocol/poller.cpp | 107 | ||||
-rw-r--r-- | src/input_common/helpers/joycon_protocol/poller.h | 15 | ||||
-rw-r--r-- | src/input_common/helpers/udp_protocol.cpp | 2 | ||||
-rw-r--r-- | src/input_common/input_mapping.cpp | 1 | ||||
-rw-r--r-- | src/input_common/main.h | 2 |
17 files changed, 150 insertions, 73 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index d09ff178b..3ad34884d 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp @@ -344,7 +344,7 @@ bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identif void GCAdapter::UpdateVibrations() { // Use 8 states to keep the switching between on/off fast enough for - // a human to feel different vibration strenght + // a human to feel different vibration strength // More states == more rumble strengths == slower update time constexpr u8 vibration_states = 8; diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index b4cd39a20..8b57ebe07 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -307,8 +307,8 @@ Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identif switch (polling_mode) { case Common::Input::PollingMode::Active: return static_cast<Common::Input::DriverResult>(handle->SetActiveMode()); - case Common::Input::PollingMode::Pasive: - return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode()); + case Common::Input::PollingMode::Passive: + return static_cast<Common::Input::DriverResult>(handle->SetPassiveMode()); case Common::Input::PollingMode::IR: return static_cast<Common::Input::DriverResult>(handle->SetIrMode()); case Common::Input::PollingMode::NFC: diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 473ba1b9e..5b40817e2 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -62,7 +62,7 @@ private: /// Registers controllers, clears all data and starts the scan thread void Setup(); - /// Actively searchs for new devices + /// Actively searches for new devices void ScanThread(std::stop_token stop_token); /// Returns true if device is valid and not registered diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp index 71e612fbf..2567df9af 100644 --- a/src/input_common/drivers/keyboard.cpp +++ b/src/input_common/drivers/keyboard.cpp @@ -24,7 +24,7 @@ constexpr PadIdentifier keyboard_modifier_identifier = { }; Keyboard::Keyboard(std::string input_engine_) : InputEngine(std::move(input_engine_)) { - // Keyboard is broken into 3 diferent sets: + // Keyboard is broken into 3 different 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 diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 8b7f9aee9..4fb2a6cfa 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -3,6 +3,7 @@ #include <thread> #include <fmt/format.h> +#include <math.h> #include "common/param_package.h" #include "common/settings.h" @@ -11,8 +12,9 @@ namespace InputCommon { constexpr int update_time = 10; -constexpr float default_stick_sensitivity = 0.022f; -constexpr float default_motion_sensitivity = 0.008f; +constexpr float default_stick_sensitivity = 0.0044f; +constexpr float default_motion_sensitivity = 0.0003f; +constexpr float maximum_rotation_speed = 2.0f; constexpr int mouse_axis_x = 0; constexpr int mouse_axis_y = 1; constexpr int wheel_axis_x = 2; @@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() { const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; - // Slow movement by 7% - if (Settings::values.mouse_panning) { - last_motion_change *= 0.93f; - } else { - last_motion_change.z *= 0.93f; + const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + + last_motion_change.y * last_motion_change.y); + + if (rotation_velocity > maximum_rotation_speed / sensitivity) { + const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity; + last_motion_change.x = last_motion_change.x * multiplier; + last_motion_change.y = last_motion_change.y * multiplier; } const BasicMotion motion_data{ @@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() { .delta_timestamp = update_time * 1000, }; + if (Settings::values.mouse_panning) { + last_motion_change.x = 0; + last_motion_change.y = 0; + } + last_motion_change.z = 0; + SetMotion(motion_identifier, 0, motion_data); } @@ -125,14 +135,14 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { auto mouse_change = (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); - Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z}; + last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z}; const auto move_distance = mouse_change.Length(); if (move_distance == 0) { return; } - // Make slow movements at least 3 units on lenght + // Make slow movements at least 3 units on length if (move_distance < 3.0f) { // Normalize value mouse_change /= move_distance; @@ -141,11 +151,10 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { // Average mouse movements last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); - last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f); const auto last_move_distance = last_mouse_change.Length(); - // Make fast movements clamp to 8 units on lenght + // Make fast movements clamp to 8 units on length if (last_move_distance > 8.0f) { // Normalize value last_mouse_change /= last_move_distance; diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 5c20b3426..7f9e8dbb9 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -652,12 +652,27 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) { } void SDLDriver::SendVibrations() { + std::vector<VibrationRequest> filtered_vibrations{}; while (!vibration_queue.Empty()) { VibrationRequest request; vibration_queue.Pop(request); const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(), static_cast<int>(request.identifier.port)); - joystick->RumblePlay(request.vibration); + const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(), + [request](VibrationRequest vibration) { + return vibration.identifier == request.identifier; + }); + if (it == filtered_vibrations.end()) { + filtered_vibrations.push_back(std::move(request)); + continue; + } + *it = request; + } + + for (const auto& vibration : filtered_vibrations) { + const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(), + static_cast<int>(vibration.identifier.port)); + joystick->RumblePlay(vibration.vibration); } } @@ -748,7 +763,7 @@ ButtonMapping SDLDriver::GetButtonMappingForDevice(const Common::ParamPackage& p // This list is missing ZL/ZR since those are not considered buttons in SDL GameController. // We will add those afterwards - // This list also excludes Screenshot since theres not really a mapping for that + // This list also excludes Screenshot since there's not really a mapping for that ButtonBindings switch_to_sdl_button; if (SDL_GameControllerGetType(controller) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) { @@ -1007,7 +1022,7 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const { if (params.Has("button")) { - // TODO(German77): Find how to substitue the values for real button names + // TODO(German77): Find how to substitute the values for real button names return Common::Input::ButtonNames::Value; } if (params.Has("hat")) { diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 4a0268a4d..304f4c70b 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp @@ -57,7 +57,7 @@ Common::Input::NfcState VirtualAmiibo::WriteNfcData( } if (!nfc_file.Write(data)) { - LOG_ERROR(Service_NFP, "Error writting to file"); + LOG_ERROR(Service_NFP, "Error writing to file"); return Common::Input::NfcState::WriteFailed; } diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 13cacfc0a..488d00b31 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h @@ -60,6 +60,6 @@ private: std::string file_path{}; State state{State::Initialized}; std::vector<u8> nfc_data; - Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive}; + Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Passive}; }; } // namespace InputCommon diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index e65b6b845..83429a336 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -164,8 +164,8 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { void JoyconDriver::OnNewData(std::span<u8> buffer) { const auto report_mode = static_cast<ReportMode>(buffer[0]); - // Packages can be a litte bit inconsistent. Average the delta time to provide a smoother motion - // experience + // Packages can be a little bit inconsistent. Average the delta time to provide a smoother + // motion experience switch (report_mode) { case ReportMode::STANDARD_FULL_60HZ: case ReportMode::NFC_IR_MODE_60HZ: @@ -410,7 +410,7 @@ DriverResult JoyconDriver::SetIrsConfig(IrsMode mode_, IrsResolution format_) { return result; } -DriverResult JoyconDriver::SetPasiveMode() { +DriverResult JoyconDriver::SetPassiveMode() { std::scoped_lock lock{mutex}; motion_enabled = false; hidbus_enabled = false; diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index c1e189fa5..72a9e71dc 100644 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h @@ -44,7 +44,7 @@ public: DriverResult SetVibration(const VibrationValue& vibration); DriverResult SetLedConfig(u8 led_pattern); DriverResult SetIrsConfig(IrsMode mode_, IrsResolution format_); - DriverResult SetPasiveMode(); + DriverResult SetPassiveMode(); DriverResult SetActiveMode(); DriverResult SetIrMode(); DriverResult SetNfcMode(); @@ -73,7 +73,7 @@ private: /// Main thread, actively request new data from the handle void InputThread(std::stop_token stop_token); - /// Called everytime a valid package arrives + /// Called every time a valid package arrives void OnNewData(std::span<u8> buffer); /// Updates device configuration to enable or disable features @@ -110,7 +110,7 @@ private: bool amiibo_detected{}; bool is_ring_disabled_by_irs{}; - // Harware configuration + // Hardware configuration u8 leds{}; ReportMode mode{}; bool passive_enabled{}; // Low power mode, Ideal for multiple controllers at the same time diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.h b/src/input_common/helpers/joycon_protocol/common_protocol.h index f44f73ba4..62cae739a 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.h +++ b/src/input_common/helpers/joycon_protocol/common_protocol.h @@ -68,7 +68,7 @@ public: } /** - * Waits for incoming data of the joycon device that matchs the subcommand + * Waits for incoming data of the joycon device that matches the subcommand * @param sub_command type of data to be returned * @returns a buffer containing the response */ @@ -137,7 +137,7 @@ public: DriverResult EnableMCU(bool enable); /** - * Configures the MCU to the correspoinding mode + * Configures the MCU to the corresponding mode * @param MCUConfig configuration */ DriverResult ConfigureMCU(const MCUConfig& config); diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index b91934990..dcac0e422 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -78,7 +78,7 @@ enum class PadButton : u32 { Capture = 0x200000, }; -enum class PasivePadButton : u32 { +enum class PassivePadButton : u32 { Down_A = 0x0001, Right_X = 0x0002, Left_B = 0x0004, @@ -95,6 +95,18 @@ enum class PasivePadButton : u32 { ZL_ZR = 0x8000, }; +enum class PassivePadStick : u8 { + Right = 0x00, + RightDown = 0x01, + Down = 0x02, + DownLeft = 0x03, + Left = 0x04, + LeftUp = 0x05, + Up = 0x06, + UpRight = 0x07, + Neutral = 0x08, +}; + enum class OutputReport : u8 { RUMBLE_AND_SUBCMD = 0x01, FW_UPDATE_PKT = 0x03, diff --git a/src/input_common/helpers/joycon_protocol/poller.cpp b/src/input_common/helpers/joycon_protocol/poller.cpp index 9bb15e935..dca797f7a 100644 --- a/src/input_common/helpers/joycon_protocol/poller.cpp +++ b/src/input_common/helpers/joycon_protocol/poller.cpp @@ -12,7 +12,7 @@ JoyconPoller::JoyconPoller(ControllerType device_type_, JoyStickCalibration left : device_type{device_type_}, left_stick_calibration{left_stick_calibration_}, right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {} -void JoyconPoller::SetCallbacks(const Joycon::JoyconCallbacks& callbacks_) { +void JoyconPoller::SetCallbacks(const JoyconCallbacks& callbacks_) { callbacks = std::move(callbacks_); } @@ -22,13 +22,13 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti memcpy(&data, buffer.data(), sizeof(InputReportActive)); switch (device_type) { - case Joycon::ControllerType::Left: + case ControllerType::Left: UpdateActiveLeftPadInput(data, motion_status); break; - case Joycon::ControllerType::Right: + case ControllerType::Right: UpdateActiveRightPadInput(data, motion_status); break; - case Joycon::ControllerType::Pro: + case ControllerType::Pro: UpdateActiveProPadInput(data, motion_status); break; default: @@ -47,14 +47,14 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) { memcpy(&data, buffer.data(), sizeof(InputReportPassive)); switch (device_type) { - case Joycon::ControllerType::Left: - UpdatePasiveLeftPadInput(data); + case ControllerType::Left: + UpdatePassiveLeftPadInput(data); break; - case Joycon::ControllerType::Right: - UpdatePasiveRightPadInput(data); + case ControllerType::Right: + UpdatePassiveRightPadInput(data); break; - case Joycon::ControllerType::Pro: - UpdatePasiveProPadInput(data); + case ControllerType::Pro: + UpdatePassiveProPadInput(data); break; default: break; @@ -210,14 +210,12 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input, } } -void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 11> left_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Capture, - Joycon::PasivePadButton::StickL, +void JoyconPoller::UpdatePassiveLeftPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 11> left_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Capture, PassivePadButton::StickL, }; for (auto left_button : left_buttons) { @@ -225,16 +223,19 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { const int button = static_cast<int>(left_button); callbacks.on_button_data(button, button_status); } + + const auto [left_axis_x, left_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state)); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); } -void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 11> right_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Plus, Joycon::PasivePadButton::Home, - Joycon::PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveRightPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 11> right_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Plus, + PassivePadButton::Home, PassivePadButton::StickR, }; for (auto right_button : right_buttons) { @@ -242,17 +243,20 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { const int button = static_cast<int>(right_button); callbacks.on_button_data(button, button_status); } + + const auto [right_axis_x, right_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state)); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); } -void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 14> pro_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Plus, - Joycon::PasivePadButton::Capture, Joycon::PasivePadButton::Home, - Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveProPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 14> pro_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Plus, PassivePadButton::Capture, PassivePadButton::Home, + PassivePadButton::StickL, PassivePadButton::StickR, }; for (auto pro_button : pro_buttons) { @@ -260,6 +264,15 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { const int button = static_cast<int>(pro_button); callbacks.on_button_data(button, button_status); } + + const auto [left_axis_x, left_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state & 0xf)); + const auto [right_axis_x, right_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state >> 4)); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); } f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const { @@ -270,6 +283,30 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca return value / calibration.min; } +std::pair<f32, f32> JoyconPoller::GetPassiveAxisValue(PassivePadStick raw_value) const { + switch (raw_value) { + case PassivePadStick::Right: + return {1.0f, 0.0f}; + case PassivePadStick::RightDown: + return {1.0f, -1.0f}; + case PassivePadStick::Down: + return {0.0f, -1.0f}; + case PassivePadStick::DownLeft: + return {-1.0f, -1.0f}; + case PassivePadStick::Left: + return {-1.0f, 0.0f}; + case PassivePadStick::LeftUp: + return {-1.0f, 1.0f}; + case PassivePadStick::Up: + return {0.0f, 1.0f}; + case PassivePadStick::UpRight: + return {1.0f, 1.0f}; + case PassivePadStick::Neutral: + default: + return {0.0f, 0.0f}; + } +} + f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, AccelerometerSensitivity sensitivity) const { const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4; diff --git a/src/input_common/helpers/joycon_protocol/poller.h b/src/input_common/helpers/joycon_protocol/poller.h index 354d41dad..0fa72c6db 100644 --- a/src/input_common/helpers/joycon_protocol/poller.h +++ b/src/input_common/helpers/joycon_protocol/poller.h @@ -22,7 +22,7 @@ public: JoyStickCalibration right_stick_calibration_, MotionCalibration motion_calibration_); - void SetCallbacks(const Joycon::JoyconCallbacks& callbacks_); + void SetCallbacks(const JoyconCallbacks& callbacks_); /// Handles data from passive packages void ReadPassiveMode(std::span<u8> buffer); @@ -46,12 +46,15 @@ private: const MotionStatus& motion_status); void UpdateActiveProPadInput(const InputReportActive& input, const MotionStatus& motion_status); - void UpdatePasiveLeftPadInput(const InputReportPassive& buffer); - void UpdatePasiveRightPadInput(const InputReportPassive& buffer); - void UpdatePasiveProPadInput(const InputReportPassive& buffer); + void UpdatePassiveLeftPadInput(const InputReportPassive& buffer); + void UpdatePassiveRightPadInput(const InputReportPassive& buffer); + void UpdatePassiveProPadInput(const InputReportPassive& buffer); /// Returns a calibrated joystick axis from raw axis data - f32 GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const; + f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const; + + /// Returns a digital joystick axis from passive axis data + std::pair<f32, f32> GetPassiveAxisValue(PassivePadStick raw_value) const; /// Returns a calibrated accelerometer axis from raw motion data f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, @@ -75,7 +78,7 @@ private: JoyStickCalibration right_stick_calibration{}; MotionCalibration motion_calibration{}; - Joycon::JoyconCallbacks callbacks{}; + JoyconCallbacks callbacks{}; }; } // namespace InputCommon::Joycon diff --git a/src/input_common/helpers/udp_protocol.cpp b/src/input_common/helpers/udp_protocol.cpp index 994380d21..e54a8fce1 100644 --- a/src/input_common/helpers/udp_protocol.cpp +++ b/src/input_common/helpers/udp_protocol.cpp @@ -25,7 +25,7 @@ namespace Response { /** * Returns Type if the packet is valid, else none * - * Note: Modifies the buffer to zero out the crc (since thats the easiest way to check without + * Note: Modifies the buffer to zero out the crc (since that's the easiest way to check without * copying the buffer) */ std::optional<Type> Validate(u8* data, std::size_t size) { diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 2ff480ff9..9361b00c5 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp @@ -146,6 +146,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) { if (data.engine == "mouse") { new_input.Set("motion", 0); new_input.Set("pad", 1); + new_input.Set("threshold", 0.001f); input_queue.Push(new_input); return; } diff --git a/src/input_common/main.h b/src/input_common/main.h index 1207d786c..d64a6cb4c 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h @@ -132,7 +132,7 @@ public: /// Retrieves the motion mappings for the given device. [[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const; - /// Returns an enum contaning the name to be displayed from the input engine. + /// Returns an enum containing the name to be displayed from the input engine. [[nodiscard]] Common::Input::ButtonNames GetButtonName( const Common::ParamPackage& params) const; |