summaryrefslogtreecommitdiff
path: root/src/input_common/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/gc_adapter.cpp2
-rw-r--r--src/input_common/drivers/joycon.cpp4
-rw-r--r--src/input_common/drivers/joycon.h2
-rw-r--r--src/input_common/drivers/keyboard.cpp2
-rw-r--r--src/input_common/drivers/mouse.cpp31
-rw-r--r--src/input_common/drivers/sdl_driver.cpp21
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp2
-rw-r--r--src/input_common/drivers/virtual_amiibo.h2
8 files changed, 45 insertions, 21 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