summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2015-03-09 23:03:24 -0400
committerGravatar bunnei2015-03-10 23:58:13 -0400
commit85cbccb1d3110c934ccf0edddf86a03fa692f27b (patch)
treea504346ed7fad36c0a08e3aadb3391588a4f7339 /src/core/hle
parentHID: Complete refactor of pad/touch input to fix threading issues. (diff)
downloadyuzu-85cbccb1d3110c934ccf0edddf86a03fa692f27b.tar.gz
yuzu-85cbccb1d3110c934ccf0edddf86a03fa692f27b.tar.xz
yuzu-85cbccb1d3110c934ccf0edddf86a03fa692f27b.zip
HID: Added additional variable comments and some code cleanups.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/hid/hid.cpp8
-rw-r--r--src/core/hle/service/hid/hid.h41
2 files changed, 29 insertions, 20 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index baff92716..6aa8bfd1f 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -17,6 +17,8 @@
17namespace Service { 17namespace Service {
18namespace HID { 18namespace HID {
19 19
20static const int MAX_CIRCLEPAD_POS = 0x9C; ///< Max value for a circle pad position
21
20Kernel::SharedPtr<Kernel::SharedMemory> g_shared_mem = nullptr; 22Kernel::SharedPtr<Kernel::SharedMemory> g_shared_mem = nullptr;
21 23
22Kernel::SharedPtr<Kernel::Event> g_event_pad_or_touch_1; 24Kernel::SharedPtr<Kernel::Event> g_event_pad_or_touch_1;
@@ -78,8 +80,10 @@ void HIDUpdate() {
78 pad_entry->delta_removals.hex = changed.hex & old_state.hex;; 80 pad_entry->delta_removals.hex = changed.hex & old_state.hex;;
79 81
80 // Set circle Pad 82 // Set circle Pad
81 pad_entry->circle_pad_x = state.circle_left ? -0x9C : state.circle_right ? 0x9C : 0x0; 83 pad_entry->circle_pad_x = state.circle_left ? -MAX_CIRCLEPAD_POS :
82 pad_entry->circle_pad_y = state.circle_down ? -0x9C : state.circle_up ? 0x9C : 0x0; 84 state.circle_right ? MAX_CIRCLEPAD_POS : 0x0;
85 pad_entry->circle_pad_y = state.circle_down ? -MAX_CIRCLEPAD_POS :
86 state.circle_up ? MAX_CIRCLEPAD_POS : 0x0;
83 87
84 // If we just updated index 0, provide a new timestamp 88 // If we just updated index 0, provide a new timestamp
85 if (shared_mem->pad.index == 0) { 89 if (shared_mem->pad.index == 0) {
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index 063f06858..03971d3c7 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -80,40 +80,45 @@ struct PadDataEntry {
80 * Structure of a single entry of touch state history within HID shared memory 80 * Structure of a single entry of touch state history within HID shared memory
81 */ 81 */
82struct TouchDataEntry { 82struct TouchDataEntry {
83 u16 x; ///< Y-coordinate of a touchpad press on the lower screen 83 u16 x; ///< Y-coordinate of a touchpad press on the lower screen
84 u16 y; ///< X-coordinate of a touchpad press on the lower screen 84 u16 y; ///< X-coordinate of a touchpad press on the lower screen
85 BitField<0,7,u32> valid; ///< Set to 1 when this entry contains actual X/Y data, otherwise 0 85 BitField<0, 7, u32> valid; ///< Set to 1 when this entry contains actual X/Y data, otherwise 0
86}; 86};
87 87
88/** 88/**
89 * Structure of data stored in HID shared memory 89 * Structure of data stored in HID shared memory
90 */ 90 */
91struct SharedMem { 91struct SharedMem {
92 // "Pad data, this is used for buttons and the circle pad 92 /// Pad data, this is used for buttons and the circle pad
93 struct { 93 struct {
94 s64 index_reset_ticks; 94 s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
95 s64 index_reset_ticks_previous; 95 s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
96 u32 index; // Index of the last updated pad state history element 96 u32 index; ///< Index of the last updated pad state entry
97 97
98 INSERT_PADDING_BYTES(0x8); 98 INSERT_PADDING_WORDS(0x2);
99 99
100 PadState current_state; // Same as entries[index].current_state 100 PadState current_state; ///< Current state of the pad buttons
101 u32 raw_circle_pad_data;
102 101
103 INSERT_PADDING_BYTES(0x4); 102 // TODO(bunnei): Implement `raw_circle_pad_data` field
103 u32 raw_circle_pad_data; ///< Raw (analog) circle pad data, before being converted
104 104
105 std::array<PadDataEntry, 8> entries; // Pad state history 105 INSERT_PADDING_WORDS(0x1);
106
107 std::array<PadDataEntry, 8> entries; ///< Last 8 pad entries
106 } pad; 108 } pad;
107 109
108 // Touchpad data, this is used for touchpad input 110 /// Touchpad data, this is used for touchpad input
109 struct { 111 struct {
110 s64 index_reset_ticks; 112 s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
111 s64 index_reset_ticks_previous; 113 s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
112 u32 index; // Index of the last updated touch state history element 114 u32 index; ///< Index of the last updated touch entry
115
116 INSERT_PADDING_WORDS(0x1);
113 117
114 INSERT_PADDING_BYTES(0xC); 118 // TODO(bunnei): Implement `raw_entry` field
119 TouchDataEntry raw_entry; ///< Raw (analog) touch data, before being converted
115 120
116 std::array<TouchDataEntry, 8> entries; 121 std::array<TouchDataEntry, 8> entries; ///< Last 8 touch entries, in pixel coordinates
117 } touch; 122 } touch;
118}; 123};
119 124