summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-03-08 21:21:25 -0400
committerGravatar bunnei2015-03-10 18:05:19 -0400
commite9b9f1842be5afa794f03e2a0fa29d49cfca2601 (patch)
tree6bec080a8cda579e28d32c77ad0d089aed8944ee /src
parentQt: Implemented EmuWindow touchpad support. (diff)
downloadyuzu-e9b9f1842be5afa794f03e2a0fa29d49cfca2601.tar.gz
yuzu-e9b9f1842be5afa794f03e2a0fa29d49cfca2601.tar.xz
yuzu-e9b9f1842be5afa794f03e2a0fa29d49cfca2601.zip
HID: Added static asserts to check register position in shared memory.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/hid/hid.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index f2affb5c5..e4665a43c 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -89,7 +89,7 @@ struct TouchDataEntry {
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 // Offset 0x0 : "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;
95 s64 index_reset_ticks_previous; 95 s64 index_reset_ticks_previous;
@@ -105,7 +105,7 @@ struct SharedMem {
105 std::array<PadDataEntry, 8> entries; // Pad state history 105 std::array<PadDataEntry, 8> entries; // Pad state history
106 } pad; 106 } pad;
107 107
108 // Offset 0xA8 : Touchpad data, this is used for touchpad input 108 // Touchpad data, this is used for touchpad input
109 struct { 109 struct {
110 s64 index_reset_ticks; 110 s64 index_reset_ticks;
111 s64 index_reset_ticks_previous; 111 s64 index_reset_ticks_previous;
@@ -117,6 +117,20 @@ struct SharedMem {
117 } touch; 117 } touch;
118}; 118};
119 119
120// TODO: MSVC does not support using offsetof() on non-static data members even though this
121// is technically allowed since C++11. This macro should be enabled once MSVC adds
122// support for that.
123#ifndef _MSC_VER
124#define ASSERT_REG_POSITION(field_name, position) \
125 static_assert(offsetof(SharedMem, field_name) == position * 4, \
126 "Field "#field_name" has invalid position")
127
128ASSERT_REG_POSITION(pad.index_reset_ticks, 0x0);
129ASSERT_REG_POSITION(touch.index_reset_ticks, 0x2A);
130
131#undef ASSERT_REG_POSITION
132#endif // !defined(_MSC_VER)
133
120// Pre-defined PadStates for single button presses 134// Pre-defined PadStates for single button presses
121const PadState PAD_NONE = {{0}}; 135const PadState PAD_NONE = {{0}};
122const PadState PAD_A = {{1u << 0}}; 136const PadState PAD_A = {{1u << 0}};