summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2021-03-25 16:58:50 +0100
committergerman77 <juangerman-13@hotmail.com>2021-03-26 18:13:18 +0100
commit7c26a9aefee00221df0d42d6cb753f4931473675 (patch)
treeed798a9da3238a8d6604494c4ef26e35b5eaa012
parentMerge pull request #6101 from ogniK5377/alloc-as-ex (diff)
downloadyuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar.gz
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar.bz2
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar.lz
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar.xz
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.tar.zst
yuzu-7c26a9aefee00221df0d42d6cb753f4931473675.zip
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp11
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp5
2 files changed, 13 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index e7063f8ef..93c43a203 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -4,6 +4,7 @@
#include <cstring>
#include "common/common_types.h"
+#include "common/logging/log.h"
#include "core/core_timing.h"
#include "core/frontend/emu_window.h"
#include "core/hle/service/hid/controllers/gesture.h"
@@ -19,9 +20,9 @@ Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit() {
for (std::size_t id = 0; id < MAX_FINGERS; ++id) {
- mouse_finger_id[id] = MAX_FINGERS;
- keyboard_finger_id[id] = MAX_FINGERS;
- udp_finger_id[id] = MAX_FINGERS;
+ mouse_finger_id[id] = MAX_POINTS;
+ keyboard_finger_id[id] = MAX_POINTS;
+ udp_finger_id[id] = MAX_POINTS;
}
}
@@ -142,6 +143,10 @@ std::optional<std::size_t> Controller_Gesture::GetUnusedFingerID() const {
std::size_t Controller_Gesture::UpdateTouchInputEvent(
const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) {
const auto& [x, y, pressed] = touch_input;
+ if (finger_id > MAX_POINTS) {
+ LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id);
+ return MAX_POINTS;
+ }
if (pressed) {
if (finger_id == MAX_POINTS) {
const auto first_free_id = GetUnusedFingerID();
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 5219f2dad..be60492a4 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -5,6 +5,7 @@
#include <algorithm>
#include <cstring>
#include "common/common_types.h"
+#include "common/logging/log.h"
#include "core/core_timing.h"
#include "core/frontend/emu_window.h"
#include "core/frontend/input.h"
@@ -118,6 +119,10 @@ std::optional<std::size_t> Controller_Touchscreen::GetUnusedFingerID() const {
std::size_t Controller_Touchscreen::UpdateTouchInputEvent(
const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) {
const auto& [x, y, pressed] = touch_input;
+ if (finger_id > MAX_FINGERS) {
+ LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id);
+ return MAX_FINGERS;
+ }
if (pressed) {
Attributes attribute{};
if (finger_id == MAX_FINGERS) {