libtransistor
A userland library for the Nintendo Switch
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
hid.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include<libtransistor/types.h>
13 
17 typedef struct {
18  uint64_t timestamp;
19  uint32_t pad1;
20  uint32_t touch_idx;
21  uint32_t touch_x;
22  uint32_t touch_y;
23  uint32_t touch_diameter_x;
24  uint32_t touch_diameter_y;
25  uint32_t touch_angle;
26  uint32_t pad2;
28 
32 typedef struct {
33  uint64_t timestamp;
34  uint64_t num_touches;
35  hid_touch_data_entry_t touch_data[16];
36  uint64_t pad1;
38 
42 typedef struct {
43  uint64_t unknown1;
44  uint64_t num_entries;
45  uint64_t latest_idx;
46  uint64_t max_idx;
47  uint64_t timestamp;
48  hid_touch_entry_t touch_entry[17];
50 
56 typedef struct {
57  uint8_t data[0x400];
58 } hid_mouse_t;
59 
65 typedef struct {
66  uint8_t data[0x400];
68 
74 typedef struct {
75  uint8_t mac[0x10];
76 } hid_mac;
77 
82 typedef enum {
83  BUTTON_A = BIT(0),
84  BUTTON_B = BIT(1),
85  BUTTON_X = BIT(2),
86  BUTTON_Y = BIT(3),
87 
88  BUTTON_LSTICK = BIT(4), // Left stick pressed
89  BUTTON_RSTICK = BIT(5), // Right stick pressed
90 
91  BUTTON_L = BIT(6),
92  BUTTON_R = BIT(7),
93  BUTTON_ZL = BIT(8),
94  BUTTON_ZR = BIT(9),
95 
96  BUTTON_PLUS = BIT(10),
97  BUTTON_MINUS = BIT(11),
98 
99  BUTTON_LEFT = BIT(12),
100  BUTTON_UP = BIT(13),
101  BUTTON_RIGHT = BIT(14),
102  BUTTON_DOWN = BIT(15),
103 
104  BUTTON_LSTICK_LEFT = BIT(16),
105  BUTTON_LSTICK_UP = BIT(17),
106  BUTTON_LSTICK_DOWN = BIT(18),
107  BUTTON_LSTICK_RIGHT = BIT(19),
108 
109  BUTTON_RSTICK_LEFT = BIT(20),
110  BUTTON_RSTICK_UP = BIT(21),
111  BUTTON_RSTICK_DOWN = BIT(22),
112  BUTTON_RSTICK_RIGHT = BIT(23),
113 
114  BUTTON_SL = BIT(24),
115  BUTTON_SR = BIT(25),
117 
121 typedef struct {
122  uint64_t timestamp;
123  uint64_t timestamp2;
124  uint64_t button_state;
125  uint32_t left_stick_x;
126  uint32_t left_stick_y;
127  uint32_t right_stick_x;
128  uint32_t right_stick_y;
129  uint64_t controller_state;
131 
135 typedef struct {
136  uint64_t timestamp;
137  uint64_t num_entries;
138  uint64_t latest_idx;
139  uint64_t max_idx;
140  hid_controller_state_entry_t entries[17];
142 
146 typedef struct {
147  uint32_t body;
148  uint32_t buttons;
150 
154 typedef struct {
155  uint32_t status;
156  uint32_t is_joycon_half;
157  uint32_t unknown1;
158  hid_controller_color_t single_color;
159  uint32_t unknown2;
160  hid_controller_color_t right_color;
161  hid_controller_color_t left_color;
162 
163  hid_controller_state_t pro_controller;
164  hid_controller_state_t handheld_joined;
165  hid_controller_state_t joined;
168  hid_controller_state_t main_no_analog;
170 
171  uint8_t pad1[0x2a78];
172 
173  hid_mac mac[2];
174 
175  uint8_t pad2[0xe10];
177 
181 typedef struct {
182  uint8_t pad1[0x400];
183  hid_touchscreen_t touchscreen;
184  uint8_t pad2[0x3c0];
185  hid_mouse_t mouse;
186  hid_keyboard_t keyboard;
187  uint8_t unknown1[0x400];
188  uint8_t unknown2[0x400];
189  uint8_t unknown3[0x400];
190  uint8_t unknown4[0x400];
191  uint8_t unknown5[0x200];
192  uint8_t unknown6[0x200];
193  uint8_t unknown7[0x200];
194  uint8_t pad3[0x800];
195  uint8_t controller_serials[0x4000];
196  hid_controller_t controllers[10];
197  uint8_t unknown8[0x4600];
199 
204 
209 
214 
218 void hid_finalize();
219 
220 #ifdef __cplusplus
221 }
222 #endif
Definition: hid.h:65
uint32_t touch_y
Definition: hid.h:22
Various system types.
hid_controller_button_mask_t
Bitmasks for hid_controller_state_entry_t.button_state.
Definition: hid.h:82
Definition: hid.h:146
Definition: hid.h:17
bool hid_controller_buttons_down(hid_controller_t *c, hid_controller_button_mask_t m)
Detect if button(s) are pressed.
hid_shared_memory_t * hid_get_shared_memory()
Get HID shared memory.
void hid_finalize()
Finalize HID.
Definition: hid.h:56
uint32_t result_t
Function result.
Definition: types.h:51
uint32_t touch_x
Definition: hid.h:21
Definition: hid.h:154
Definition: hid.h:181
result_t hid_init()
Initialize input.
Definition: hid.h:74
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:57
Definition: hid.h:121
Definition: hid.h:42
Definition: hid.h:32
Definition: hid.h:135