summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-28 01:06:13 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:26 +0100
commit2d3a63b28969089746e43ed232dc74630fbfc3b2 (patch)
treef75d3245b6e23815611796c85b96fa4c7674c3e2 /src/core/hle/service/hid
parentcore/hid: Add TAS input (diff)
downloadyuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.gz
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.bz2
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.lz
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.xz
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.zst
yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.zip
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/controllers/debug_pad.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp8
-rw-r--r--src/core/hle/service/hid/controllers/keyboard.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/mouse.cpp6
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp15
-rw-r--r--src/core/hle/service/hid/controllers/npad.h60
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/xpad.cpp4
-rw-r--r--src/core/hle/service/hid/ring_lifo.h26
9 files changed, 89 insertions, 42 deletions
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp
index 5b1946f13..345134357 100644
--- a/src/core/hle/service/hid/controllers/debug_pad.cpp
+++ b/src/core/hle/service/hid/controllers/debug_pad.cpp
@@ -30,8 +30,8 @@ void Controller_DebugPad::OnRelease() {}
void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
if (!IsControllerActivated()) {
- debug_pad_lifo.entry_count = 0;
- debug_pad_lifo.last_entry_index = 0;
+ debug_pad_lifo.buffer_count = 0;
+ debug_pad_lifo.buffer_tail = 0;
std::memcpy(data + SHARED_MEMORY_OFFSET, &debug_pad_lifo, sizeof(debug_pad_lifo));
return;
}
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index 47760b4f8..00df50f32 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -31,8 +31,8 @@ Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(s
Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit() {
- gesture_lifo.entry_count = 0;
- gesture_lifo.last_entry_index = 0;
+ gesture_lifo.buffer_count = 0;
+ gesture_lifo.buffer_tail = 0;
force_update = true;
}
@@ -41,8 +41,8 @@ void Controller_Gesture::OnRelease() {}
void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
if (!IsControllerActivated()) {
- gesture_lifo.entry_count = 0;
- gesture_lifo.last_entry_index = 0;
+ gesture_lifo.buffer_count = 0;
+ gesture_lifo.buffer_tail = 0;
std::memcpy(data + SHARED_MEMORY_OFFSET, &gesture_lifo, sizeof(gesture_lifo));
return;
}
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp
index 632679a17..f4d49965f 100644
--- a/src/core/hle/service/hid/controllers/keyboard.cpp
+++ b/src/core/hle/service/hid/controllers/keyboard.cpp
@@ -27,8 +27,8 @@ void Controller_Keyboard::OnRelease() {}
void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
if (!IsControllerActivated()) {
- keyboard_lifo.entry_count = 0;
- keyboard_lifo.last_entry_index = 0;
+ keyboard_lifo.buffer_count = 0;
+ keyboard_lifo.buffer_tail = 0;
std::memcpy(data + SHARED_MEMORY_OFFSET, &keyboard_lifo, sizeof(keyboard_lifo));
return;
}
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp
index 6d3bd0a2b..7ec75e8c8 100644
--- a/src/core/hle/service/hid/controllers/mouse.cpp
+++ b/src/core/hle/service/hid/controllers/mouse.cpp
@@ -24,11 +24,9 @@ void Controller_Mouse::OnRelease() {}
void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
- mouse_lifo.timestamp = core_timing.GetCPUTicks();
-
if (!IsControllerActivated()) {
- mouse_lifo.entry_count = 0;
- mouse_lifo.last_entry_index = 0;
+ mouse_lifo.buffer_count = 0;
+ mouse_lifo.buffer_tail = 0;
std::memcpy(data + SHARED_MEMORY_OFFSET, &mouse_lifo, sizeof(mouse_lifo));
return;
}
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index 9f84e20c2..9f82f872a 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -101,7 +101,8 @@ Controller_NPad::Controller_NPad(Core::System& system_,
for (std::size_t i = 0; i < controller_data.size(); ++i) {
auto& controller = controller_data[i];
controller.device = system.HIDCore().GetEmulatedControllerByIndex(i);
- controller.vibration[Core::HID::DeviceIndex::LeftIndex].latest_vibration_value = DEFAULT_VIBRATION_VALUE;
+ controller.vibration[Core::HID::DeviceIndex::LeftIndex].latest_vibration_value =
+ DEFAULT_VIBRATION_VALUE;
controller.vibration[Core::HID::DeviceIndex::RightIndex].latest_vibration_value =
DEFAULT_VIBRATION_VALUE;
Core::HID::ControllerUpdateCallback engine_callback{
@@ -178,7 +179,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.system_properties.use_plus.Assign(1);
shared_memory.system_properties.use_minus.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
- shared_memory.footer_type = AppletFooterUiType::SwitchProController;
+ shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController;
break;
case Core::HID::NpadType::Handheld:
shared_memory.style_set.handheld.Assign(1);
@@ -188,7 +189,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.system_properties.use_plus.Assign(1);
shared_memory.system_properties.use_minus.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual;
- shared_memory.footer_type = AppletFooterUiType::HandheldJoyConLeftJoyConRight;
+ shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight;
break;
case Core::HID::NpadType::JoyconDual:
shared_memory.style_set.joycon_dual.Assign(1);
@@ -198,7 +199,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.system_properties.use_plus.Assign(1);
shared_memory.system_properties.use_minus.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual;
- shared_memory.footer_type = AppletFooterUiType::JoyDual;
+ shared_memory.applet_footer.type = AppletFooterUiType::JoyDual;
break;
case Core::HID::NpadType::JoyconLeft:
shared_memory.style_set.joycon_left.Assign(1);
@@ -206,7 +207,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.system_properties.is_horizontal.Assign(1);
shared_memory.system_properties.use_minus.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
- shared_memory.footer_type = AppletFooterUiType::JoyLeftHorizontal;
+ shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal;
break;
case Core::HID::NpadType::JoyconRight:
shared_memory.style_set.joycon_right.Assign(1);
@@ -214,7 +215,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.system_properties.is_horizontal.Assign(1);
shared_memory.system_properties.use_plus.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
- shared_memory.footer_type = AppletFooterUiType::JoyRightHorizontal;
+ shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal;
break;
case Core::HID::NpadType::GameCube:
shared_memory.style_set.gamecube.Assign(1);
@@ -919,7 +920,7 @@ void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) {
.right = {},
};
shared_memory_entry.assignment_mode = NpadJoyAssignmentMode::Dual;
- shared_memory_entry.footer_type = AppletFooterUiType::None;
+ shared_memory_entry.applet_footer.type = AppletFooterUiType::None;
controller.is_connected = false;
controller.device->Disconnect();
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 0a2dc6992..af4934c55 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -330,10 +330,43 @@ private:
BitField<13, 1, s32> handheld_lark_nes_left;
BitField<14, 1, s32> handheld_lark_nes_right;
BitField<15, 1, s32> lucia;
+ BitField<16, 1, s32> lagon;
+ BitField<17, 1, s32> lager;
BitField<31, 1, s32> system;
};
};
+ // This is nn::hid::detail::NfcXcdDeviceHandleStateImpl
+ struct NfcXcdDeviceHandleStateImpl {
+ u64 handle;
+ bool is_available;
+ bool is_activated;
+ INSERT_PADDING_BYTES(0x6); // Reserved
+ u64 sampling_number;
+ };
+ static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
+ "NfcXcdDeviceHandleStateImpl is an invalid size");
+
+ // nn::hid::detail::NfcXcdDeviceHandleStateImplAtomicStorage
+ struct NfcXcdDeviceHandleStateImplAtomicStorage {
+ u64 sampling_number;
+ NfcXcdDeviceHandleStateImpl nfc_xcd_device_handle_state;
+ };
+ static_assert(sizeof(NfcXcdDeviceHandleStateImplAtomicStorage) == 0x20,
+ "NfcXcdDeviceHandleStateImplAtomicStorage is an invalid size");
+
+ // This is nn::hid::detail::NfcXcdDeviceHandleState
+ struct NfcXcdDeviceHandleState {
+ // TODO(german77): Make this struct a ring lifo object
+ INSERT_PADDING_BYTES(0x8); // Unused
+ s64 total_buffer_count = max_buffer_size;
+ s64 buffer_tail{};
+ s64 buffer_count{};
+ std::array<NfcXcdDeviceHandleStateImplAtomicStorage, 2> nfc_xcd_device_handle_storage;
+ };
+ static_assert(sizeof(NfcXcdDeviceHandleState) == 0x60,
+ "NfcXcdDeviceHandleState is an invalid size");
+
// This is nn::hid::system::AppletFooterUiAttributesSet
struct AppletFooterUiAttributes {
INSERT_PADDING_BYTES(0x4);
@@ -365,6 +398,14 @@ private:
Lagon = 21,
};
+ struct AppletFooterUi {
+ AppletFooterUiAttributes attributes;
+ AppletFooterUiType type;
+ INSERT_PADDING_BYTES(0x5B); // Reserved
+ };
+ static_assert(sizeof(AppletFooterUi) == 0x60,
+ "AppletFooterUi is an invalid size");
+
// This is nn::hid::NpadLarkType
enum class NpadLarkType : u32 {
Invalid,
@@ -382,6 +423,11 @@ private:
U,
};
+ // This is nn::hid::NpadLagonType
+ enum class NpadLagonType : u32 {
+ Invalid,
+ };
+
// This is nn::hid::NpadLagerType
enum class NpadLagerType : u32 {
Invalid,
@@ -416,17 +462,19 @@ private:
Core::HID::BatteryLevel battery_level_dual;
Core::HID::BatteryLevel battery_level_left;
Core::HID::BatteryLevel battery_level_right;
- AppletFooterUiAttributes footer_attributes;
- AppletFooterUiType footer_type;
- // GetXcdHandleForNpadWithNfc needs to be checked switchbrew doesn't match with HW
- INSERT_PADDING_BYTES(0x78); // Unknown
+ union {
+ NfcXcdDeviceHandleState nfc_xcd_device_handle;
+ AppletFooterUi applet_footer;
+ };
+ INSERT_PADDING_BYTES(0x20); // Unknown
Lifo<NpadGcTriggerState> gc_trigger_lifo;
- NpadLarkType lark_type_l;
+ NpadLarkType lark_type_l_and_main;
NpadLarkType lark_type_r;
NpadLuciaType lucia_type;
+ NpadLagonType lagon_type;
NpadLagerType lager_type;
INSERT_PADDING_BYTES(
- 0x8); // FW 13.x Investigate there is some sort of bitflag related to joycons
+ 0x4); // FW 13.x Investigate there is some sort of bitflag related to joycons
INSERT_PADDING_BYTES(0xc08); // Unknown
};
static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size");
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 5ba8d96a8..9ae2bf2b1 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -30,8 +30,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
touch_screen_lifo.timestamp = core_timing.GetCPUTicks();
if (!IsControllerActivated()) {
- touch_screen_lifo.entry_count = 0;
- touch_screen_lifo.last_entry_index = 0;
+ touch_screen_lifo.buffer_count = 0;
+ touch_screen_lifo.buffer_tail = 0;
std::memcpy(data, &touch_screen_lifo, sizeof(touch_screen_lifo));
return;
}
diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp
index aa9f044f1..a2ed1e7c2 100644
--- a/src/core/hle/service/hid/controllers/xpad.cpp
+++ b/src/core/hle/service/hid/controllers/xpad.cpp
@@ -20,8 +20,8 @@ void Controller_XPad::OnRelease() {}
void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
if (!IsControllerActivated()) {
- basic_xpad_lifo.entry_count = 0;
- basic_xpad_lifo.last_entry_index = 0;
+ basic_xpad_lifo.buffer_count = 0;
+ basic_xpad_lifo.buffer_tail = 0;
std::memcpy(data + SHARED_MEMORY_OFFSET, &basic_xpad_lifo, sizeof(basic_xpad_lifo));
return;
}
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h
index f68d82762..382350a2d 100644
--- a/src/core/hle/service/hid/ring_lifo.h
+++ b/src/core/hle/service/hid/ring_lifo.h
@@ -8,7 +8,7 @@
#include "common/swap.h"
namespace Service::HID {
-constexpr std::size_t max_entry_size = 17;
+constexpr std::size_t max_buffer_size = 17;
template <typename State>
struct AtomicStorage {
@@ -19,13 +19,13 @@ struct AtomicStorage {
template <typename State>
struct Lifo {
s64 timestamp{};
- s64 total_entry_count = max_entry_size;
- s64 last_entry_index{};
- s64 entry_count{};
- std::array<AtomicStorage<State>, max_entry_size> entries{};
+ s64 total_buffer_count = max_buffer_size;
+ s64 buffer_tail{};
+ s64 buffer_count{};
+ std::array<AtomicStorage<State>, max_buffer_size> entries{};
const AtomicStorage<State>& ReadCurrentEntry() const {
- return entries[last_entry_index];
+ return entries[buffer_tail];
}
const AtomicStorage<State>& ReadPreviousEntry() const {
@@ -33,21 +33,21 @@ struct Lifo {
}
std::size_t GetPreviuousEntryIndex() const {
- return (last_entry_index + total_entry_count - 1) % total_entry_count;
+ return (buffer_tail + total_buffer_count - 1) % total_buffer_count;
}
std::size_t GetNextEntryIndex() const {
- return (last_entry_index + 1) % total_entry_count;
+ return (buffer_tail + 1) % total_buffer_count;
}
void WriteNextEntry(const State& new_state) {
- if (entry_count < total_entry_count - 1) {
- entry_count++;
+ if (buffer_count < total_buffer_count - 1) {
+ buffer_count++;
}
- last_entry_index = GetNextEntryIndex();
+ buffer_tail = GetNextEntryIndex();
const auto& previous_entry = ReadPreviousEntry();
- entries[last_entry_index].sampling_number = previous_entry.sampling_number + 1;
- entries[last_entry_index].state = new_state;
+ entries[buffer_tail].sampling_number = previous_entry.sampling_number + 1;
+ entries[buffer_tail].state = new_state;
}
};