summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/hid/controllers')
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.h2
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp47
-rw-r--r--src/core/hle/service/hid/controllers/gesture.h24
4 files changed, 41 insertions, 34 deletions
diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp
index 8091db9d7..9d1e6db6a 100644
--- a/src/core/hle/service/hid/controllers/controller_base.cpp
+++ b/src/core/hle/service/hid/controllers/controller_base.cpp
@@ -6,7 +6,7 @@
namespace Service::HID {
-ControllerBase::ControllerBase(Core::System& system) : system(system) {}
+ControllerBase::ControllerBase(Core::System& system_) : system(system_) {}
ControllerBase::~ControllerBase() = default;
void ControllerBase::ActivateController() {
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h
index f47a9e61c..1556fb08e 100644
--- a/src/core/hle/service/hid/controllers/controller_base.h
+++ b/src/core/hle/service/hid/controllers/controller_base.h
@@ -18,7 +18,7 @@ class System;
namespace Service::HID {
class ControllerBase {
public:
- explicit ControllerBase(Core::System& system);
+ explicit ControllerBase(Core::System& system_);
virtual ~ControllerBase();
// Called when the controller is initialized
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index 9e5df3bb7..d311f754b 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -23,7 +23,7 @@ constexpr f32 Square(s32 num) {
return static_cast<f32>(num * num);
}
-Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {}
+Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(system_) {}
Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit() {
@@ -211,15 +211,16 @@ void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, Touch
}
}
-void Controller_Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_gesture,
- TouchType& type, Attribute& attributes, f32 time_difference) {
+void Controller_Gesture::EndGesture(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ Attribute& attributes, f32 time_difference) {
const auto& last_entry =
shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
- if (last_gesture.active_points != 0) {
+ if (last_gesture_props.active_points != 0) {
switch (last_entry.type) {
case TouchType::Touch:
if (enable_press_and_tap) {
- SetTapEvent(gesture, last_gesture, type, attributes);
+ SetTapEvent(gesture, last_gesture_props, type, attributes);
return;
}
type = TouchType::Cancel;
@@ -234,7 +235,7 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie
force_update = true;
break;
case TouchType::Pan:
- EndPanEvent(gesture, last_gesture, type, time_difference);
+ EndPanEvent(gesture, last_gesture_props, type, time_difference);
break;
default:
break;
@@ -246,10 +247,11 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie
}
}
-void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture,
- TouchType& type, Attribute& attributes) {
+void Controller_Gesture::SetTapEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ Attribute& attributes) {
type = TouchType::Tap;
- gesture = last_gesture;
+ gesture = last_gesture_props;
force_update = true;
f32 tap_time_difference =
static_cast<f32>(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000);
@@ -259,8 +261,9 @@ void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperti
}
}
-void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture,
- TouchType& type, f32 time_difference) {
+void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ f32 time_difference) {
auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
const auto& last_entry =
shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
@@ -272,13 +275,14 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope
last_pan_time_difference = time_difference;
// Promote to pinch type
- if (std::abs(gesture.average_distance - last_gesture.average_distance) > pinch_threshold) {
+ if (std::abs(gesture.average_distance - last_gesture_props.average_distance) >
+ pinch_threshold) {
type = TouchType::Pinch;
- cur_entry.scale = gesture.average_distance / last_gesture.average_distance;
+ cur_entry.scale = gesture.average_distance / last_gesture_props.average_distance;
}
- const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture.angle) /
- (1 + (gesture.angle * last_gesture.angle)));
+ const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture_props.angle) /
+ (1 + (gesture.angle * last_gesture_props.angle)));
// Promote to rotate type
if (std::abs(angle_between_two_lines) > angle_threshold) {
type = TouchType::Rotate;
@@ -287,8 +291,9 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope
}
}
-void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture,
- TouchType& type, f32 time_difference) {
+void Controller_Gesture::EndPanEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ f32 time_difference) {
auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
const auto& last_entry =
shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
@@ -301,7 +306,7 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti
// Set swipe event with parameters
if (curr_vel > swipe_threshold) {
- SetSwipeEvent(gesture, last_gesture, type);
+ SetSwipeEvent(gesture, last_gesture_props, type);
return;
}
@@ -312,13 +317,13 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti
force_update = true;
}
-void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture,
- TouchType& type) {
+void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type) {
auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
const auto& last_entry =
shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
type = TouchType::Swipe;
- gesture = last_gesture;
+ gesture = last_gesture_props;
force_update = true;
cur_entry.delta_x = last_entry.delta_x;
cur_entry.delta_y = last_entry.delta_y;
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h
index 18110a6ad..f46e29411 100644
--- a/src/core/hle/service/hid/controllers/gesture.h
+++ b/src/core/hle/service/hid/controllers/gesture.h
@@ -128,32 +128,34 @@ private:
void UpdateExistingGesture(GestureProperties& gesture, TouchType& type, f32 time_difference);
// Terminates exiting gesture
- void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type,
- Attribute& attributes, f32 time_difference);
+ void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, Attribute& attributes, f32 time_difference);
// Set current event to a tap event
- void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type,
- Attribute& attributes);
+ void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, Attribute& attributes);
// Calculates and set the extra parameters related to a pan event
- void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture,
+ void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
TouchType& type, f32 time_difference);
// Terminates the pan event
- void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type,
- f32 time_difference);
+ void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, f32 time_difference);
// Set current event to a swipe event
- void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture,
+ void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
TouchType& type);
- // Returns an unused finger id, if there is no fingers avaliable MAX_FINGERS will be returned
+ // Returns an unused finger id, if there is no fingers available std::nullopt is returned.
std::optional<size_t> GetUnusedFingerID() const;
- /** If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no
+ /**
+ * If the touch is new it tries to assign a new finger id, if there is no fingers available no
* changes will be made. Updates the coordinates if the finger id it's already set. If the touch
* ends delays the output by one frame to set the end_touch flag before finally freeing the
- * finger id */
+ * finger id
+ */
size_t UpdateTouchInputEvent(const std::tuple<float, float, bool>& touch_input,
size_t finger_id);