HID Shared Memory

Revision as of 16:51, 20 August 2014 by Yellows8 (talk | contribs)

This page describes the format of the HID shared memory.

The data for each of the below entries(PAD state, circle-pad, touch-screen, etc) is originally written by the HID module at different times per frame.

size: 0x2b0 (FIRM 4.4)

Offset 0x0

Relative offset Size Description
0x0 0x8 svcGetSystemTick tick-count output, for when HID module updates entry index0 in the below array.
0x8 0x8 Before the above tick-count field is updated, that value is copied into this field. Therefore, this contains the tick-count for the previous time that entry index0 in the below array was updated by HID module.
0x10 0x4 Index in the following array which was last updated by HID module.
0x1C 0x4 Current PAD state.
0x20 0x4 Raw circle-pad info.
0x28 0x80 Array of 8 entries, where each entry(see below) is 0x10-bytes.

HID module first updates index0, then index1, and so on. When updating the array when the index is already 7, the index is reset to 0.

PAD State

Bit Description
0 A
1 B
2 Select
3 Start
4 Right
5 Left
6 Up
7 Down
8 R
9 L
10 X
11 Y
28 Circle pad left (X <= -41)
29 Circle pad right (X >= 41)
30 Circle pad up (Y >= 41)
31 Circle pad down (Y <= -41)

Bit set = button pressed, bit clear = button not pressed. Bit28-31 only apply to the PAD fields in the array entries. Bit28-31 are set by HID module depending on data from a GPIO command, these are not included with the PAD register itself.

Entry format

Relative offset Size Description
0x0 0x4 Current PAD state.
0x4 0x4 PAD state for buttons which were pressed(bitmasks which changed from value 0 to value 1) since the last HID update.
0x8 0x4 PAD state for buttons which were released(bitmasks which changed from value 1 to value 0) since the last HID update.
0xC 0x4 This stores circle-pad info: the low s16 is the X coordinate, the high s16 is the Y coordinate. The circle-pad center is approximately 0 for these fields. The range for these fields is approximately: -0x9C(bottom/left) - 0x9C(top/right).

Offset 0xA8

Relative offset Size Description
0x0 0x8 svcGetSystemTick tick-count output, for when HID module updates entry index0 in the below array.
0x8 0x8 Before the above tick-count field is updated, that value is copied into this field. Therefore, this contains the tick-count for the previous time that entry index0 in the below array was updated by HID module.
0x10 0x4 Index in the following array which was last updated by HID module.
0x18 0x8 Touch-screen entry, which contains the raw coordinate data prior to being converted to pixel coordinates.
0x20 0x40 8 Touch-screen entries, containing pixel coordinates.

This 0x60-byte region stores state for touch-screen related info. Each touch-screen entry is all-zero when the touch-screen is not being touched.

HID module first updates index0, then index1, and so on. When updating the array when the index is already 7, the index is reset to 0.

Entry format

Relative offset Size Description
0x0 0x2 X coordinate.
0x2 0x2 Y coordinate.
0x4 0x4 The u8 at +0 here is 0x0 when this entry doesn't contain any actual data, value 0x1 indicates that this entry contains actual data.

Offset 0x108

The size of this region is 0x50-bytes. This contains the accelerometer state.

Offset 0x158

Relative offset Size Description
0x0 0x8 svcGetSystemTick tick-count output, for when HID module updates entry index0 in the below array.
0x8 0x8 Before the above tick-count field is updated, that value is copied into this field. Therefore, this contains the tick-count for the previous time that entry index0 in the below array was updated by HID module.
0x10 0x4 Index in the following array which was last updated by HID module.
0x18 0x6 Current gyroscope state entry.
0x20 0xC0 Array containing 32 gyroscrope entries.

The size of this region is 0xE0-bytes. Initially this contains 0xFF/0x00 bytes. This contains the gyroscope state.

HID module first updates index0, then index1, and so on. When updating the array when the index is already 31, the index is reset to 0.

Entry format

Relative offset Size Description
0x0 0x2 Unknown s16.
0x2 0x2 Unknown s16.
0x2 0x2 Unknown s16.

Offset 0x238

The size of this region is 0x78-bytes. Initially this contains 0xFF/0x00 bytes.