summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-11-15 04:56:54 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:28 +0100
commit42949738f2c01a4125a9a385c9100240181153ec (patch)
tree5de97be0bc08a1dd4ff5138196c08a6bf2e08e70 /src
parentcore/hid: Improve accuary of mouse implementation (diff)
downloadyuzu-42949738f2c01a4125a9a385c9100240181153ec.tar
yuzu-42949738f2c01a4125a9a385c9100240181153ec.tar.gz
yuzu-42949738f2c01a4125a9a385c9100240181153ec.tar.bz2
yuzu-42949738f2c01a4125a9a385c9100240181153ec.tar.lz
yuzu-42949738f2c01a4125a9a385c9100240181153ec.tar.xz
yuzu-42949738f2c01a4125a9a385c9100240181153ec.tar.zst
yuzu-42949738f2c01a4125a9a385c9100240181153ec.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hid/hid_types.h3
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp2
-rw-r--r--src/core/hle/service/hid/ring_lifo.h7
-rw-r--r--src/input_common/drivers/gc_adapter.cpp16
-rw-r--r--src/input_common/drivers/gc_adapter.h2
-rw-r--r--src/input_common/drivers/mouse.cpp2
-rw-r--r--src/input_common/drivers/mouse.h2
-rw-r--r--src/input_common/drivers/sdl_driver.cpp2
-rw-r--r--src/input_common/drivers/sdl_driver.h2
-rw-r--r--src/input_common/drivers/tas_input.cpp2
-rw-r--r--src/input_common/drivers/tas_input.h2
-rw-r--r--src/input_common/drivers/touch_screen.cpp2
-rw-r--r--src/input_common/drivers/touch_screen.h2
-rw-r--r--src/input_common/input_engine.cpp4
-rw-r--r--src/input_common/input_engine.h2
-rw-r--r--src/yuzu/bootmanager.cpp66
-rw-r--r--src/yuzu/bootmanager.h2
17 files changed, 54 insertions, 66 deletions
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index 8b12f63ad..3cbe16260 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -564,8 +564,9 @@ struct MouseState {
s32 y;
s32 delta_x;
s32 delta_y;
- s32 delta_wheel_x;
+ // Axis Order in HW is switched for the wheel
s32 delta_wheel_y;
+ s32 delta_wheel_x;
MouseButton button;
MouseAttribute attribute;
};
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index eaec79139..4b23230e1 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -345,7 +345,7 @@ void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
constexpr btn right_button_mask = btn::A | btn::B | btn::X | btn::Y | btn::StickR | btn::R |
btn::ZR | btn::Plus | btn::StickRLeft | btn::StickRUp |
btn::StickRRight | btn::StickRDown;
- pad_entry.npad_buttons.raw |= button_state.raw & right_button_mask;
+ pad_entry.npad_buttons.raw = button_state.raw & right_button_mask;
pad_entry.r_stick = stick_state.right;
}
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h
index 6209ed0d1..f0e0bab7f 100644
--- a/src/core/hle/service/hid/ring_lifo.h
+++ b/src/core/hle/service/hid/ring_lifo.h
@@ -7,7 +7,6 @@
#include <array>
#include "common/common_types.h"
-#include "common/swap.h"
namespace Service::HID {
constexpr std::size_t max_buffer_size = 17;
@@ -21,7 +20,7 @@ struct AtomicStorage {
template <typename State>
struct Lifo {
s64 timestamp{};
- s64 total_buffer_count = max_buffer_size;
+ s64 total_buffer_count = static_cast<s64>(max_buffer_size);
s64 buffer_tail{};
s64 buffer_count{};
std::array<AtomicStorage<State>, max_buffer_size> entries{};
@@ -35,11 +34,11 @@ struct Lifo {
}
std::size_t GetPreviousEntryIndex() const {
- return (buffer_tail + total_buffer_count - 1) % total_buffer_count;
+ return static_cast<size_t>((buffer_tail + total_buffer_count - 1) % total_buffer_count);
}
std::size_t GetNextEntryIndex() const {
- return (buffer_tail + 1) % total_buffer_count;
+ return static_cast<size_t>((buffer_tail + 1) % total_buffer_count);
}
void WriteNextEntry(const State& new_state) {
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp
index 2550f8cba..a1b9b6d98 100644
--- a/src/input_common/drivers/gc_adapter.cpp
+++ b/src/input_common/drivers/gc_adapter.cpp
@@ -69,7 +69,7 @@ private:
libusb_device_handle* handle{};
};
-GCAdapter::GCAdapter(const std::string input_engine_) : InputEngine(input_engine_) {
+GCAdapter::GCAdapter(const std::string& input_engine_) : InputEngine(input_engine_) {
if (usb_adapter_handle) {
return;
}
@@ -486,42 +486,30 @@ std::string GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const
switch (button) {
case PadButton::ButtonLeft:
return "left";
- break;
case PadButton::ButtonRight:
return "right";
- break;
case PadButton::ButtonDown:
return "down";
- break;
case PadButton::ButtonUp:
return "up";
- break;
case PadButton::TriggerZ:
return "Z";
- break;
case PadButton::TriggerR:
return "R";
- break;
case PadButton::TriggerL:
return "L";
- break;
case PadButton::ButtonA:
return "A";
- break;
case PadButton::ButtonB:
return "B";
- break;
case PadButton::ButtonX:
return "X";
- break;
case PadButton::ButtonY:
return "Y";
- break;
case PadButton::ButtonStart:
return "start";
- break;
default:
- return "Unkown GC";
+ return "Unknown GC";
}
}
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h
index fba90352e..3e4747040 100644
--- a/src/input_common/drivers/gc_adapter.h
+++ b/src/input_common/drivers/gc_adapter.h
@@ -24,7 +24,7 @@ class LibUSBDeviceHandle;
class GCAdapter : public InputCommon::InputEngine {
public:
- explicit GCAdapter(const std::string input_engine_);
+ explicit GCAdapter(const std::string& input_engine_);
~GCAdapter();
Common::Input::VibrationError SetRumble(
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp
index 05fd7f9c0..9a9a1987d 100644
--- a/src/input_common/drivers/mouse.cpp
+++ b/src/input_common/drivers/mouse.cpp
@@ -24,7 +24,7 @@ constexpr PadIdentifier identifier = {
.pad = 0,
};
-Mouse::Mouse(const std::string input_engine_) : InputEngine(input_engine_) {
+Mouse::Mouse(const std::string& input_engine_) : InputEngine(input_engine_) {
PreSetController(identifier);
PreSetAxis(identifier, mouse_axis_x);
PreSetAxis(identifier, mouse_axis_y);
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h
index f7e6db0b5..11dd76e14 100644
--- a/src/input_common/drivers/mouse.h
+++ b/src/input_common/drivers/mouse.h
@@ -29,7 +29,7 @@ enum class MouseButton {
*/
class Mouse final : public InputCommon::InputEngine {
public:
- explicit Mouse(const std::string input_engine_);
+ explicit Mouse(const std::string& input_engine_);
/**
* Signals that mouse has moved.
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 1e3741e0f..0b24f1858 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -929,7 +929,7 @@ std::string SDLDriver::GetHatButtonName(u8 direction_value) const {
}
}
-u8 SDLDriver::GetHatButtonId(const std::string direction_name) const {
+u8 SDLDriver::GetHatButtonId(const std::string& direction_name) const {
Uint8 direction;
if (direction_name == "up") {
direction = SDL_HAT_UP;
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h
index b879df8ab..3faaca984 100644
--- a/src/input_common/drivers/sdl_driver.h
+++ b/src/input_common/drivers/sdl_driver.h
@@ -56,7 +56,7 @@ public:
std::string GetUIName(const Common::ParamPackage& params) const override;
std::string GetHatButtonName(u8 direction_value) const override;
- u8 GetHatButtonId(const std::string direction_name) const override;
+ u8 GetHatButtonId(const std::string& direction_name) const override;
Common::Input::VibrationError SetRumble(
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp
index bb9c236ea..0e01fb0d9 100644
--- a/src/input_common/drivers/tas_input.cpp
+++ b/src/input_common/drivers/tas_input.cpp
@@ -47,7 +47,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_but
{"KEY_ZR", TasButton::TRIGGER_ZR},
};
-Tas::Tas(const std::string input_engine_) : InputCommon::InputEngine(input_engine_) {
+Tas::Tas(const std::string& input_engine_) : InputCommon::InputEngine(input_engine_) {
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
PadIdentifier identifier{
.guid = Common::UUID{},
diff --git a/src/input_common/drivers/tas_input.h b/src/input_common/drivers/tas_input.h
index bfb37a638..c95a130fc 100644
--- a/src/input_common/drivers/tas_input.h
+++ b/src/input_common/drivers/tas_input.h
@@ -83,7 +83,7 @@ enum class TasState {
class Tas final : public InputCommon::InputEngine {
public:
- explicit Tas(const std::string input_engine_);
+ explicit Tas(const std::string& input_engine_);
~Tas();
/**
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp
index 377c9ee2b..45b3086f6 100644
--- a/src/input_common/drivers/touch_screen.cpp
+++ b/src/input_common/drivers/touch_screen.cpp
@@ -13,7 +13,7 @@ constexpr PadIdentifier identifier = {
.pad = 0,
};
-TouchScreen::TouchScreen(const std::string input_engine_) : InputEngine(input_engine_) {
+TouchScreen::TouchScreen(const std::string& input_engine_) : InputEngine(input_engine_) {
PreSetController(identifier);
}
diff --git a/src/input_common/drivers/touch_screen.h b/src/input_common/drivers/touch_screen.h
index 0f4cd0e7a..25c11e8bf 100644
--- a/src/input_common/drivers/touch_screen.h
+++ b/src/input_common/drivers/touch_screen.h
@@ -14,7 +14,7 @@ namespace InputCommon {
*/
class TouchScreen final : public InputCommon::InputEngine {
public:
- explicit TouchScreen(const std::string input_engine_);
+ explicit TouchScreen(const std::string& input_engine_);
/**
* Signals that mouse has moved.
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp
index 139d8d2e6..2b2105376 100644
--- a/src/input_common/input_engine.cpp
+++ b/src/input_common/input_engine.cpp
@@ -300,8 +300,8 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot
if (!configuring || !mapping_callback.on_data) {
return;
}
- if (std::abs(value.gyro_x) < 1.0f && std::abs(value.gyro_y) < 1.0f &&
- std::abs(value.gyro_z) < 1.0f) {
+ if (std::abs(value.gyro_x) < 0.6f && std::abs(value.gyro_y) < 0.6f &&
+ std::abs(value.gyro_z) < 0.6f) {
return;
}
mapping_callback.on_data(MappingData{
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h
index 5430c0cf8..c621686e5 100644
--- a/src/input_common/input_engine.h
+++ b/src/input_common/input_engine.h
@@ -166,7 +166,7 @@ public:
};
/// Retrieves the index number of the given hat button direction
- virtual u8 GetHatButtonId([[maybe_unused]] const std::string direction_name) const {
+ virtual u8 GetHatButtonId([[maybe_unused]] const std::string& direction_name) const {
return 0;
};
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 2313a4189..7390fc5bd 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -613,56 +613,56 @@ int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) {
}
}
-int GRenderWindow::QtModifierToSwitchModdifier(quint32 qt_moddifiers) {
- int moddifier = 0;
+int GRenderWindow::QtModifierToSwitchModifier(quint32 qt_modifiers) {
+ int modifier = 0;
// The values are obtained through testing, Qt doesn't seem to provide a proper enum
- if ((qt_moddifiers & 0x1) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::LeftShift;
+ if ((qt_modifiers & 0x1) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::LeftShift;
}
- if ((qt_moddifiers & 0x2) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::LeftControl;
+ if ((qt_modifiers & 0x2) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::LeftControl;
}
- if ((qt_moddifiers & 0x4) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::LeftAlt;
+ if ((qt_modifiers & 0x4) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::LeftAlt;
}
- if ((qt_moddifiers & 0x08) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::LeftMeta;
+ if ((qt_modifiers & 0x08) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::LeftMeta;
}
- if ((qt_moddifiers & 0x10) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::RightShift;
+ if ((qt_modifiers & 0x10) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::RightShift;
}
- if ((qt_moddifiers & 0x20) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::RightControl;
+ if ((qt_modifiers & 0x20) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::RightControl;
}
- if ((qt_moddifiers & 0x40) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::RightAlt;
+ if ((qt_modifiers & 0x40) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::RightAlt;
}
- if ((qt_moddifiers & 0x80) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::RightMeta;
+ if ((qt_modifiers & 0x80) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::RightMeta;
}
- if ((qt_moddifiers & 0x100) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::CapsLock;
+ if ((qt_modifiers & 0x100) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::CapsLock;
}
- if ((qt_moddifiers & 0x200) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::NumLock;
+ if ((qt_modifiers & 0x200) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::NumLock;
}
// Verify the last two keys
- if ((qt_moddifiers & 0x400) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::Katakana;
+ if ((qt_modifiers & 0x400) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::Katakana;
}
- if ((qt_moddifiers & 0x800) != 0) {
- moddifier |= 1 << Settings::NativeKeyboard::Hiragana;
+ if ((qt_modifiers & 0x800) != 0) {
+ modifier |= 1 << Settings::NativeKeyboard::Hiragana;
}
- return moddifier;
+ return modifier;
}
void GRenderWindow::keyPressEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) {
- const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers());
+ const auto modifier = QtModifierToSwitchModifier(event->nativeModifiers());
// Replace event->key() with event->nativeVirtualKey() since the second one provides raw key
// buttons
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
- input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier);
+ input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier);
input_subsystem->GetKeyboard()->PressKeyboardKey(key);
// This is used for gamepads
input_subsystem->GetKeyboard()->PressKey(event->key());
@@ -671,9 +671,9 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event) {
void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) {
- const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers());
+ const auto modifier = QtModifierToSwitchModifier(event->nativeModifiers());
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
- input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier);
+ input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier);
input_subsystem->GetKeyboard()->ReleaseKeyboardKey(key);
// This is used for gamepads
input_subsystem->GetKeyboard()->ReleaseKey(event->key());
@@ -747,8 +747,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
}
void GRenderWindow::wheelEvent(QWheelEvent* event) {
- const int x = event->delta();
- const int y = 0;
+ const int x = event->angleDelta().x();
+ const int y = event->angleDelta().y();
input_subsystem->GetMouse()->MouseWheelChange(x, y);
}
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index d6b2ab5f3..81e3c4eb0 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -162,7 +162,7 @@ public:
static int QtKeyToSwitchKey(Qt::Key qt_keys);
/// Converts a Qt modifier keys into NativeKeyboard modifier keys
- static int QtModifierToSwitchModdifier(quint32 qt_moddifiers);
+ static int QtModifierToSwitchModifier(quint32 qt_modifiers);
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;