yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

kraken: Address comments from review

Fix compiler bug
This commit is contained in:
german77 2021-11-14 21:56:54 -06:00 committed by Narr the Reg
parent f4e5f89e6f
commit 42949738f2
17 changed files with 54 additions and 66 deletions

View File

@ -564,8 +564,9 @@ struct MouseState {
s32 y; s32 y;
s32 delta_x; s32 delta_x;
s32 delta_y; s32 delta_y;
s32 delta_wheel_x; // Axis Order in HW is switched for the wheel
s32 delta_wheel_y; s32 delta_wheel_y;
s32 delta_wheel_x;
MouseButton button; MouseButton button;
MouseAttribute attribute; MouseAttribute attribute;
}; };

View File

@ -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 | 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::ZR | btn::Plus | btn::StickRLeft | btn::StickRUp |
btn::StickRRight | btn::StickRDown; 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; pad_entry.r_stick = stick_state.right;
} }

View File

@ -7,7 +7,6 @@
#include <array> #include <array>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
namespace Service::HID { namespace Service::HID {
constexpr std::size_t max_buffer_size = 17; constexpr std::size_t max_buffer_size = 17;
@ -21,7 +20,7 @@ struct AtomicStorage {
template <typename State> template <typename State>
struct Lifo { struct Lifo {
s64 timestamp{}; s64 timestamp{};
s64 total_buffer_count = max_buffer_size; s64 total_buffer_count = static_cast<s64>(max_buffer_size);
s64 buffer_tail{}; s64 buffer_tail{};
s64 buffer_count{}; s64 buffer_count{};
std::array<AtomicStorage<State>, max_buffer_size> entries{}; std::array<AtomicStorage<State>, max_buffer_size> entries{};
@ -35,11 +34,11 @@ struct Lifo {
} }
std::size_t GetPreviousEntryIndex() const { 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 { 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) { void WriteNextEntry(const State& new_state) {

View File

@ -69,7 +69,7 @@ private:
libusb_device_handle* handle{}; 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) { if (usb_adapter_handle) {
return; return;
} }
@ -486,42 +486,30 @@ std::string GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const
switch (button) { switch (button) {
case PadButton::ButtonLeft: case PadButton::ButtonLeft:
return "left"; return "left";
break;
case PadButton::ButtonRight: case PadButton::ButtonRight:
return "right"; return "right";
break;
case PadButton::ButtonDown: case PadButton::ButtonDown:
return "down"; return "down";
break;
case PadButton::ButtonUp: case PadButton::ButtonUp:
return "up"; return "up";
break;
case PadButton::TriggerZ: case PadButton::TriggerZ:
return "Z"; return "Z";
break;
case PadButton::TriggerR: case PadButton::TriggerR:
return "R"; return "R";
break;
case PadButton::TriggerL: case PadButton::TriggerL:
return "L"; return "L";
break;
case PadButton::ButtonA: case PadButton::ButtonA:
return "A"; return "A";
break;
case PadButton::ButtonB: case PadButton::ButtonB:
return "B"; return "B";
break;
case PadButton::ButtonX: case PadButton::ButtonX:
return "X"; return "X";
break;
case PadButton::ButtonY: case PadButton::ButtonY:
return "Y"; return "Y";
break;
case PadButton::ButtonStart: case PadButton::ButtonStart:
return "start"; return "start";
break;
default: default:
return "Unkown GC"; return "Unknown GC";
} }
} }

View File

@ -24,7 +24,7 @@ class LibUSBDeviceHandle;
class GCAdapter : public InputCommon::InputEngine { class GCAdapter : public InputCommon::InputEngine {
public: public:
explicit GCAdapter(const std::string input_engine_); explicit GCAdapter(const std::string& input_engine_);
~GCAdapter(); ~GCAdapter();
Common::Input::VibrationError SetRumble( Common::Input::VibrationError SetRumble(

View File

@ -24,7 +24,7 @@ constexpr PadIdentifier identifier = {
.pad = 0, .pad = 0,
}; };
Mouse::Mouse(const std::string input_engine_) : InputEngine(input_engine_) { Mouse::Mouse(const std::string& input_engine_) : InputEngine(input_engine_) {
PreSetController(identifier); PreSetController(identifier);
PreSetAxis(identifier, mouse_axis_x); PreSetAxis(identifier, mouse_axis_x);
PreSetAxis(identifier, mouse_axis_y); PreSetAxis(identifier, mouse_axis_y);

View File

@ -29,7 +29,7 @@ enum class MouseButton {
*/ */
class Mouse final : public InputCommon::InputEngine { class Mouse final : public InputCommon::InputEngine {
public: public:
explicit Mouse(const std::string input_engine_); explicit Mouse(const std::string& input_engine_);
/** /**
* Signals that mouse has moved. * Signals that mouse has moved.

View File

@ -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; Uint8 direction;
if (direction_name == "up") { if (direction_name == "up") {
direction = SDL_HAT_UP; direction = SDL_HAT_UP;

View File

@ -56,7 +56,7 @@ public:
std::string GetUIName(const Common::ParamPackage& params) const override; std::string GetUIName(const Common::ParamPackage& params) const override;
std::string GetHatButtonName(u8 direction_value) 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( Common::Input::VibrationError SetRumble(
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;

View File

@ -47,7 +47,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_but
{"KEY_ZR", TasButton::TRIGGER_ZR}, {"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++) { for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
PadIdentifier identifier{ PadIdentifier identifier{
.guid = Common::UUID{}, .guid = Common::UUID{},

View File

@ -83,7 +83,7 @@ enum class TasState {
class Tas final : public InputCommon::InputEngine { class Tas final : public InputCommon::InputEngine {
public: public:
explicit Tas(const std::string input_engine_); explicit Tas(const std::string& input_engine_);
~Tas(); ~Tas();
/** /**

View File

@ -13,7 +13,7 @@ constexpr PadIdentifier identifier = {
.pad = 0, .pad = 0,
}; };
TouchScreen::TouchScreen(const std::string input_engine_) : InputEngine(input_engine_) { TouchScreen::TouchScreen(const std::string& input_engine_) : InputEngine(input_engine_) {
PreSetController(identifier); PreSetController(identifier);
} }

View File

@ -14,7 +14,7 @@ namespace InputCommon {
*/ */
class TouchScreen final : public InputCommon::InputEngine { class TouchScreen final : public InputCommon::InputEngine {
public: public:
explicit TouchScreen(const std::string input_engine_); explicit TouchScreen(const std::string& input_engine_);
/** /**
* Signals that mouse has moved. * Signals that mouse has moved.

View File

@ -300,8 +300,8 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot
if (!configuring || !mapping_callback.on_data) { if (!configuring || !mapping_callback.on_data) {
return; return;
} }
if (std::abs(value.gyro_x) < 1.0f && std::abs(value.gyro_y) < 1.0f && if (std::abs(value.gyro_x) < 0.6f && std::abs(value.gyro_y) < 0.6f &&
std::abs(value.gyro_z) < 1.0f) { std::abs(value.gyro_z) < 0.6f) {
return; return;
} }
mapping_callback.on_data(MappingData{ mapping_callback.on_data(MappingData{

View File

@ -166,7 +166,7 @@ public:
}; };
/// Retrieves the index number of the given hat button direction /// 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; return 0;
}; };

View File

@ -613,56 +613,56 @@ int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) {
} }
} }
int GRenderWindow::QtModifierToSwitchModdifier(quint32 qt_moddifiers) { int GRenderWindow::QtModifierToSwitchModifier(quint32 qt_modifiers) {
int moddifier = 0; int modifier = 0;
// The values are obtained through testing, Qt doesn't seem to provide a proper enum // The values are obtained through testing, Qt doesn't seem to provide a proper enum
if ((qt_moddifiers & 0x1) != 0) { if ((qt_modifiers & 0x1) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::LeftShift; modifier |= 1 << Settings::NativeKeyboard::LeftShift;
} }
if ((qt_moddifiers & 0x2) != 0) { if ((qt_modifiers & 0x2) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::LeftControl; modifier |= 1 << Settings::NativeKeyboard::LeftControl;
} }
if ((qt_moddifiers & 0x4) != 0) { if ((qt_modifiers & 0x4) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::LeftAlt; modifier |= 1 << Settings::NativeKeyboard::LeftAlt;
} }
if ((qt_moddifiers & 0x08) != 0) { if ((qt_modifiers & 0x08) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::LeftMeta; modifier |= 1 << Settings::NativeKeyboard::LeftMeta;
} }
if ((qt_moddifiers & 0x10) != 0) { if ((qt_modifiers & 0x10) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::RightShift; modifier |= 1 << Settings::NativeKeyboard::RightShift;
} }
if ((qt_moddifiers & 0x20) != 0) { if ((qt_modifiers & 0x20) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::RightControl; modifier |= 1 << Settings::NativeKeyboard::RightControl;
} }
if ((qt_moddifiers & 0x40) != 0) { if ((qt_modifiers & 0x40) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::RightAlt; modifier |= 1 << Settings::NativeKeyboard::RightAlt;
} }
if ((qt_moddifiers & 0x80) != 0) { if ((qt_modifiers & 0x80) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::RightMeta; modifier |= 1 << Settings::NativeKeyboard::RightMeta;
} }
if ((qt_moddifiers & 0x100) != 0) { if ((qt_modifiers & 0x100) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::CapsLock; modifier |= 1 << Settings::NativeKeyboard::CapsLock;
} }
if ((qt_moddifiers & 0x200) != 0) { if ((qt_modifiers & 0x200) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::NumLock; modifier |= 1 << Settings::NativeKeyboard::NumLock;
} }
// Verify the last two keys // Verify the last two keys
if ((qt_moddifiers & 0x400) != 0) { if ((qt_modifiers & 0x400) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::Katakana; modifier |= 1 << Settings::NativeKeyboard::Katakana;
} }
if ((qt_moddifiers & 0x800) != 0) { if ((qt_modifiers & 0x800) != 0) {
moddifier |= 1 << Settings::NativeKeyboard::Hiragana; modifier |= 1 << Settings::NativeKeyboard::Hiragana;
} }
return moddifier; return modifier;
} }
void GRenderWindow::keyPressEvent(QKeyEvent* event) { void GRenderWindow::keyPressEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) { 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 // Replace event->key() with event->nativeVirtualKey() since the second one provides raw key
// buttons // buttons
const auto key = QtKeyToSwitchKey(Qt::Key(event->key())); const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier); input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier);
input_subsystem->GetKeyboard()->PressKeyboardKey(key); input_subsystem->GetKeyboard()->PressKeyboardKey(key);
// This is used for gamepads // This is used for gamepads
input_subsystem->GetKeyboard()->PressKey(event->key()); input_subsystem->GetKeyboard()->PressKey(event->key());
@ -671,9 +671,9 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event) {
void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) { if (!event->isAutoRepeat()) {
const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers()); const auto modifier = QtModifierToSwitchModifier(event->nativeModifiers());
const auto key = QtKeyToSwitchKey(Qt::Key(event->key())); const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier); input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier);
input_subsystem->GetKeyboard()->ReleaseKeyboardKey(key); input_subsystem->GetKeyboard()->ReleaseKeyboardKey(key);
// This is used for gamepads // This is used for gamepads
input_subsystem->GetKeyboard()->ReleaseKey(event->key()); input_subsystem->GetKeyboard()->ReleaseKey(event->key());
@ -747,8 +747,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
} }
void GRenderWindow::wheelEvent(QWheelEvent* event) { void GRenderWindow::wheelEvent(QWheelEvent* event) {
const int x = event->delta(); const int x = event->angleDelta().x();
const int y = 0; const int y = event->angleDelta().y();
input_subsystem->GetMouse()->MouseWheelChange(x, y); input_subsystem->GetMouse()->MouseWheelChange(x, y);
} }

View File

@ -162,7 +162,7 @@ public:
static int QtKeyToSwitchKey(Qt::Key qt_keys); static int QtKeyToSwitchKey(Qt::Key qt_keys);
/// Converts a Qt modifier keys into NativeKeyboard modifier 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 keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override;