3
0
Fork 0
forked from suyu/suyu

touchscreen: Make use of common point struct

This commit is contained in:
Lioncash 2021-05-28 07:58:55 -04:00
parent 8171ad65cd
commit 5554de3933
2 changed files with 10 additions and 10 deletions

View file

@ -74,8 +74,11 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
for (std::size_t id = 0; id < MAX_FINGERS; ++id) { for (std::size_t id = 0; id < MAX_FINGERS; ++id) {
auto& touch_entry = cur_entry.states[id]; auto& touch_entry = cur_entry.states[id];
if (id < active_fingers_count) { if (id < active_fingers_count) {
touch_entry.x = static_cast<u16>(active_fingers[id].x * Layout::ScreenUndocked::Width); const auto& [active_x, active_y] = active_fingers[id].position;
touch_entry.y = static_cast<u16>(active_fingers[id].y * Layout::ScreenUndocked::Height); touch_entry.position = {
.x = static_cast<u16>(active_x * Layout::ScreenUndocked::Width),
.y = static_cast<u16>(active_y * Layout::ScreenUndocked::Height),
};
touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; touch_entry.diameter_x = Settings::values.touchscreen.diameter_x;
touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; touch_entry.diameter_y = Settings::values.touchscreen.diameter_y;
touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle;
@ -86,8 +89,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
} else { } else {
// Clear touch entry // Clear touch entry
touch_entry.attribute.raw = 0; touch_entry.attribute.raw = 0;
touch_entry.x = 0; touch_entry.position = {};
touch_entry.y = 0;
touch_entry.diameter_x = 0; touch_entry.diameter_x = 0;
touch_entry.diameter_y = 0; touch_entry.diameter_y = 0;
touch_entry.rotation_angle = 0; touch_entry.rotation_angle = 0;
@ -140,8 +142,7 @@ std::size_t Controller_Touchscreen::UpdateTouchInputEvent(
fingers[finger_id].id = static_cast<u32_le>(finger_id); fingers[finger_id].id = static_cast<u32_le>(finger_id);
attribute.start_touch.Assign(1); attribute.start_touch.Assign(1);
} }
fingers[finger_id].x = x; fingers[finger_id].position = {x, y};
fingers[finger_id].y = y;
fingers[finger_id].attribute = attribute; fingers[finger_id].attribute = attribute;
return finger_id; return finger_id;
} }

View file

@ -7,6 +7,7 @@
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/point.h"
#include "common/swap.h" #include "common/swap.h"
#include "core/frontend/input.h" #include "core/frontend/input.h"
#include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/hid/controllers/controller_base.h"
@ -55,8 +56,7 @@ private:
u64_le delta_time; u64_le delta_time;
Attributes attribute; Attributes attribute;
u32_le finger; u32_le finger;
u32_le x; Common::Point<u32_le> position;
u32_le y;
u32_le diameter_x; u32_le diameter_x;
u32_le diameter_y; u32_le diameter_y;
u32_le rotation_angle; u32_le rotation_angle;
@ -81,8 +81,7 @@ private:
struct Finger { struct Finger {
u64_le last_touch{}; u64_le last_touch{};
float x{}; Common::Point<float> position;
float y{};
u32_le id{}; u32_le id{};
bool pressed{}; bool pressed{};
Attributes attribute; Attributes attribute;