mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
kraken: Address comments from review
Fix compiler bug
This commit is contained in:
parent
f4e5f89e6f
commit
42949738f2
17 changed files with 54 additions and 66 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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{},
|
||||
|
|
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue