summaryrefslogtreecommitdiffstats
path: root/src/core/hid
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_console.cpp4
-rw-r--r--src/core/hid/emulated_console.h10
-rw-r--r--src/core/hid/emulated_controller.cpp6
-rw-r--r--src/core/hid/emulated_controller.h22
-rw-r--r--src/core/hid/emulated_devices.cpp4
-rw-r--r--src/core/hid/hid_core.cpp8
-rw-r--r--src/core/hid/hid_types.h48
-rw-r--r--src/core/hid/input_converter.cpp12
8 files changed, 57 insertions, 57 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index 540fd107b..d1d4a5355 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -6,7 +6,7 @@
#include "core/hid/input_converter.h"
namespace Core::HID {
-EmulatedConsole::EmulatedConsole() {}
+EmulatedConsole::EmulatedConsole() = default;
EmulatedConsole::~EmulatedConsole() = default;
@@ -191,7 +191,7 @@ TouchFingerState EmulatedConsole::GetTouch() const {
}
void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) {
- for (const std::pair<int, ConsoleUpdateCallback> poller_pair : callback_list) {
+ for (const auto& poller_pair : callback_list) {
const ConsoleUpdateCallback& poller = poller_pair.second;
if (poller.on_change) {
poller.on_change(type);
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h
index c48d25794..f26f24f2e 100644
--- a/src/core/hid/emulated_console.h
+++ b/src/core/hid/emulated_console.h
@@ -20,7 +20,7 @@
namespace Core::HID {
struct ConsoleMotionInfo {
- Input::MotionStatus raw_status;
+ Input::MotionStatus raw_status{};
MotionInput emulated{};
};
@@ -34,21 +34,21 @@ using ConsoleMotionValues = ConsoleMotionInfo;
using TouchValues = std::array<Input::TouchStatus, 16>;
struct TouchFinger {
- u64_le last_touch{};
+ u64 last_touch{};
Common::Point<float> position{};
- u32_le id{};
- bool pressed{};
+ u32 id{};
TouchAttribute attribute{};
+ bool pressed{};
};
// Contains all motion related data that is used on the services
struct ConsoleMotion {
- bool is_at_rest{};
Common::Vec3f accel{};
Common::Vec3f gyro{};
Common::Vec3f rotation{};
std::array<Common::Vec3f, 3> orientation{};
Common::Quaternion<f32> quaternion{};
+ bool is_at_rest{};
};
using TouchFingerState = std::array<TouchFinger, 16>;
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index d59758e99..228f80183 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -865,10 +865,10 @@ BatteryLevelState EmulatedController::GetBattery() const {
return controller.battery_state;
}
-void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_service_update) {
- for (const std::pair<int, ControllerUpdateCallback> poller_pair : callback_list) {
+void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) {
+ for (const auto& poller_pair : callback_list) {
const ControllerUpdateCallback& poller = poller_pair.second;
- if (!is_service_update && poller.is_service) {
+ if (!is_npad_service_update && poller.is_npad_service) {
continue;
}
if (poller.on_change) {
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index 50f21ccd9..d66768549 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -20,7 +20,7 @@
namespace Core::HID {
struct ControllerMotionInfo {
- Input::MotionStatus raw_status;
+ Input::MotionStatus raw_status{};
MotionInput emulated{};
};
@@ -51,28 +51,28 @@ using BatteryValues = std::array<Input::BatteryStatus, 3>;
using VibrationValues = std::array<Input::VibrationStatus, 2>;
struct AnalogSticks {
- AnalogStickState left;
- AnalogStickState right;
+ AnalogStickState left{};
+ AnalogStickState right{};
};
struct ControllerColors {
- NpadControllerColor fullkey;
- NpadControllerColor left;
- NpadControllerColor right;
+ NpadControllerColor fullkey{};
+ NpadControllerColor left{};
+ NpadControllerColor right{};
};
struct BatteryLevelState {
- NpadPowerInfo dual;
- NpadPowerInfo left;
- NpadPowerInfo right;
+ NpadPowerInfo dual{};
+ NpadPowerInfo left{};
+ NpadPowerInfo right{};
};
struct ControllerMotion {
- bool is_at_rest;
Common::Vec3f accel{};
Common::Vec3f gyro{};
Common::Vec3f rotation{};
std::array<Common::Vec3f, 3> orientation{};
+ bool is_at_rest{};
};
using MotionState = std::array<ControllerMotion, 2>;
@@ -113,7 +113,7 @@ enum class ControllerTriggerType {
struct ControllerUpdateCallback {
std::function<void(ControllerTriggerType)> on_change;
- bool is_service;
+ bool is_npad_service;
};
class EmulatedController {
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index 54a753d8a..1c4065cd8 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -9,7 +9,7 @@
namespace Core::HID {
-EmulatedDevices::EmulatedDevices() {}
+EmulatedDevices::EmulatedDevices() = default;
EmulatedDevices::~EmulatedDevices() = default;
@@ -332,7 +332,7 @@ MousePosition EmulatedDevices::GetMousePosition() const {
}
void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) {
- for (const std::pair<int, InterfaceUpdateCallback> poller_pair : callback_list) {
+ for (const auto& poller_pair : callback_list) {
const InterfaceUpdateCallback& poller = poller_pair.second;
if (poller.on_change) {
poller.on_change(type);
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp
index cc1b3c295..3cb26e1e7 100644
--- a/src/core/hid/hid_core.cpp
+++ b/src/core/hid/hid_core.cpp
@@ -113,8 +113,8 @@ NpadStyleTag HIDCore::GetSupportedStyleTag() const {
s8 HIDCore::GetPlayerCount() const {
s8 active_players = 0;
- for (std::size_t player_index = 0; player_index < available_controllers -2; player_index++) {
- const auto* controller = GetEmulatedControllerByIndex(player_index);
+ for (std::size_t player_index = 0; player_index < available_controllers - 2; ++player_index) {
+ const auto* const controller = GetEmulatedControllerByIndex(player_index);
if (controller->IsConnected()) {
active_players++;
}
@@ -123,8 +123,8 @@ s8 HIDCore::GetPlayerCount() const {
}
NpadIdType HIDCore::GetFirstNpadId() const {
- for (std::size_t player_index = 0; player_index < available_controllers; player_index++) {
- const auto* controller = GetEmulatedControllerByIndex(player_index);
+ for (std::size_t player_index = 0; player_index < available_controllers; ++player_index) {
+ const auto* const controller = GetEmulatedControllerByIndex(player_index);
if (controller->IsConnected()) {
return controller->GetNpadIdType();
}
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index 539436283..59ec593b8 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -100,7 +100,7 @@ enum class NpadType : u8 {
// This is nn::hid::NpadStyleTag
struct NpadStyleTag {
union {
- u32_le raw{};
+ u32 raw{};
BitField<0, 1, u32> fullkey;
BitField<1, 1, u32> handheld;
@@ -132,35 +132,35 @@ static_assert(sizeof(TouchAttribute) == 0x4, "TouchAttribute is an invalid size"
// This is nn::hid::TouchState
struct TouchState {
- u64_le delta_time;
+ u64 delta_time;
TouchAttribute attribute;
- u32_le finger;
- Common::Point<u32_le> position;
- u32_le diameter_x;
- u32_le diameter_y;
- u32_le rotation_angle;
+ u32 finger;
+ Common::Point<u32> position;
+ u32 diameter_x;
+ u32 diameter_y;
+ u32 rotation_angle;
};
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
// This is nn::hid::NpadControllerColor
struct NpadControllerColor {
- u32_le body;
- u32_le button;
+ u32 body;
+ u32 button;
};
static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size");
// This is nn::hid::AnalogStickState
struct AnalogStickState {
- s32_le x;
- s32_le y;
+ s32 x;
+ s32 y;
};
static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size");
// This is nn::hid::server::NpadGcTriggerState
struct NpadGcTriggerState {
- s64_le sampling_number{};
- s32_le left{};
- s32_le right{};
+ s64 sampling_number{};
+ s32 left{};
+ s32 right{};
};
static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size");
@@ -286,7 +286,7 @@ static_assert(sizeof(NpadButtonState) == 0x8, "NpadButtonState has incorrect siz
// This is nn::hid::DebugPadButton
struct DebugPadButton {
union {
- u32_le raw{};
+ u32 raw{};
BitField<0, 1, u32> a;
BitField<1, 1, u32> b;
BitField<2, 1, u32> x;
@@ -345,7 +345,7 @@ static_assert(sizeof(VibrationDeviceInfo) == 0x8, "VibrationDeviceInfo has incor
// This is nn::hid::KeyboardModifier
struct KeyboardModifier {
union {
- u32_le raw{};
+ u32 raw{};
BitField<0, 1, u32> control;
BitField<1, 1, u32> shift;
BitField<2, 1, u32> left_alt;
@@ -383,7 +383,7 @@ static_assert(sizeof(MouseButton) == 0x4, "MouseButton is an invalid size");
// This is nn::hid::MouseAttribute
struct MouseAttribute {
union {
- u32_le raw{};
+ u32 raw{};
BitField<0, 1, u32> transferable;
BitField<1, 1, u32> is_connected;
};
@@ -392,13 +392,13 @@ static_assert(sizeof(MouseAttribute) == 0x4, "MouseAttribute is an invalid size"
// This is nn::hid::detail::MouseState
struct MouseState {
- s64_le sampling_number;
- s32_le x;
- s32_le y;
- s32_le delta_x;
- s32_le delta_y;
- s32_le delta_wheel_x;
- s32_le delta_wheel_y;
+ s64 sampling_number;
+ s32 x;
+ s32 y;
+ s32 delta_x;
+ s32 delta_y;
+ s32 delta_wheel_x;
+ s32 delta_wheel_y;
MouseButton button;
MouseAttribute attribute;
};
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp
index 128a48ec9..b3c8913ce 100644
--- a/src/core/hid/input_converter.cpp
+++ b/src/core/hid/input_converter.cpp
@@ -142,8 +142,8 @@ Input::StickStatus TransformToStick(const Input::CallbackStatus& callback) {
}
SanitizeStick(status.x, status.y, true);
- const Input::AnalogProperties& properties_x = status.x.properties;
- const Input::AnalogProperties& properties_y = status.y.properties;
+ const auto& properties_x = status.x.properties;
+ const auto& properties_y = status.y.properties;
const float x = status.x.value;
const float y = status.y.value;
@@ -213,7 +213,7 @@ Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) {
}
SanitizeAnalog(status.analog, true);
- const Input::AnalogProperties& properties = status.analog.properties;
+ const auto& properties = status.analog.properties;
float& value = status.analog.value;
// Set button status
@@ -231,7 +231,7 @@ Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) {
}
void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) {
- const Input::AnalogProperties& properties = analog.properties;
+ const auto& properties = analog.properties;
float& raw_value = analog.raw_value;
float& value = analog.value;
@@ -271,8 +271,8 @@ void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) {
}
void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value) {
- const Input::AnalogProperties& properties_x = analog_x.properties;
- const Input::AnalogProperties& properties_y = analog_y.properties;
+ const auto& properties_x = analog_x.properties;
+ const auto& properties_y = analog_y.properties;
float& raw_x = analog_x.raw_value;
float& raw_y = analog_y.raw_value;
float& x = analog_x.value;