Difference between revisions of "HID Shared Memory"

From 3dbrew
Jump to navigation Jump to search
Line 1: Line 1:
 
This page describes the format of the [[HID_Services|HID]] shared memory.
 
This page describes the format of the [[HID_Services|HID]] shared memory.
  
The data for each of the below entries(PAD state, circle-pad, touch-screen, etc) is originally read by the HID module at different times per frame.
+
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)
 
size: 0x2b0 (FIRM 4.4)
Line 9: Line 9:
 
|-
 
|-
 
!  Relative offset
 
!  Relative offset
 +
!  Size
 
!  Description
 
!  Description
 
|-
 
|-
 
| 0x1C
 
| 0x1C
 +
| 0x4
 
| [[PAD]] state. Bit set = button pressed, bit clear = button not pressed. Bit28-31 do not apply to this entry, but they apply to further PAD state entries. Bit28-31 are set when the corresponding circle pad coordinate is >=41 (or <=-41).
 
| [[PAD]] state. Bit set = button pressed, bit clear = button not pressed. Bit28-31 do not apply to this entry, but they apply to further PAD state entries. Bit28-31 are set when the corresponding circle pad coordinate is >=41 (or <=-41).
 
|-
 
|-
 
| 0x28
 
| 0x28
 +
| 0x4
 
| Second PAD state entry.
 
| Second PAD state entry.
 
|-
 
|-
 
| 0x34
 
| 0x34
 +
| 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 ~0 for these fields. The range for these fields is approximately: -0x9C(bottom/left) - 0x9C(top/right).
 
| This stores circle-pad info: the low s16 is the X coordinate, the high s16 is the Y coordinate. The circle-pad center is ~0 for these fields. The range for these fields is approximately: -0x9C(bottom/left) - 0x9C(top/right).
 
|-
 
|-
 
| 0x38
 
| 0x38
 +
| 0x4
 
| Third PAD state entry.
 
| Third PAD state entry.
 
|-
 
|-
 
| 0x44
 
| 0x44
 +
| 0x4
 
| Second circle-pad info entry.
 
| Second circle-pad info entry.
 
|-
 
|-
 
| 0x48
 
| 0x48
 +
| 0x4
 
| Fourth PAD state entry.
 
| Fourth PAD state entry.
 
|-
 
|-
 
| 0x54
 
| 0x54
 +
| 0x4
 
| Third circle-pad info entry.
 
| Third circle-pad info entry.
 
|-
 
|-
 
| 0x58
 
| 0x58
 +
| 0x4
 
| Fifth PAD state entry.
 
| Fifth PAD state entry.
 
|-
 
|-
 
| 0x64
 
| 0x64
 +
| 0x4
 
| Fourth circle-pad info entry.
 
| Fourth circle-pad info entry.
 
|-
 
|-
 
| 0x68
 
| 0x68
 +
| 0x4
 
| Sixth PAD state entry.
 
| Sixth PAD state entry.
 
|-
 
|-
 
| 0x74
 
| 0x74
 +
| 0x4
 
| Fifth circle-pad info entry.
 
| Fifth circle-pad info entry.
 
|-
 
|-
 
| 0x78
 
| 0x78
 +
| 0x4
 
| Seventh PAD state entry.
 
| Seventh PAD state entry.
 
|-
 
|-
 
| 0x84
 
| 0x84
 +
| 0x4
 
| Sixth circle-pad info entry.
 
| Sixth circle-pad info entry.
 
|-
 
|-
 
| 0x88
 
| 0x88
 +
| 0x4
 
| Eighth PAD state entry.
 
| Eighth PAD state entry.
 
|-
 
|-
 
| 0x94
 
| 0x94
 +
| 0x4
 
| Seventh circle-pad info entry.
 
| Seventh circle-pad info entry.
 
|-
 
|-
 
| 0x98
 
| 0x98
 +
| 0x4
 
| Ninth PAD state entry.
 
| Ninth PAD state entry.
 
|-
 
|-
 
| 0xA4
 
| 0xA4
 +
| 0x4
 
| Eighth circle-pad info entry.
 
| Eighth circle-pad info entry.
 +
|}
 +
 +
=Offset 0xA8=
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0xB8
+
!  Relative offset
| first used entry number in the touch-screen position info buffer?
+
!  Size
 +
!  Description
 +
|-
 +
| 0x10
 +
| 0x4
 +
| Index in the array at +0x20 which was last updated by HID module.
 +
|-
 +
| 0x18
 +
| 0x8
 +
| Touch-screen entry, which seems to contain raw coordinate data prior to being converted to pixel coordinates.
 +
|-
 +
| 0x20
 +
| 0x40
 +
| 8 touch-screen entries, containing pixel coordinates.
 
|}
 
|}
  
=Offset 0xC0=
+
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.
This 0x48-byte region stores entries for touch-screen position info. Each entry is 0x8-bytes, there's a total of 9 entries. When the touch-screen is not being touched, this region is all-zero.
 
  
The last 8 entries contain the pixel coordinates, while the first entry seems to contain the raw coordinate data prior to being converted to pixel coordinates.
+
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==
 
==Entry format==
Line 92: Line 126:
 
| 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.
 
| 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 probably contains the gyroscope and/or accelerometer state?
 +
 +
=Offset 0x158=
 +
The size of this region is 0xE0-bytes. Unknown, contains 0xFF/0x00 bytes?
 +
 +
=Offset 0x238=
 +
The size of this region is 0x78-bytes. Unknown, contains 0xFF/0x00 bytes?

Revision as of 02:33, 20 August 2014

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
0x1C 0x4 PAD state. Bit set = button pressed, bit clear = button not pressed. Bit28-31 do not apply to this entry, but they apply to further PAD state entries. Bit28-31 are set when the corresponding circle pad coordinate is >=41 (or <=-41).
0x28 0x4 Second PAD state entry.
0x34 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 ~0 for these fields. The range for these fields is approximately: -0x9C(bottom/left) - 0x9C(top/right).
0x38 0x4 Third PAD state entry.
0x44 0x4 Second circle-pad info entry.
0x48 0x4 Fourth PAD state entry.
0x54 0x4 Third circle-pad info entry.
0x58 0x4 Fifth PAD state entry.
0x64 0x4 Fourth circle-pad info entry.
0x68 0x4 Sixth PAD state entry.
0x74 0x4 Fifth circle-pad info entry.
0x78 0x4 Seventh PAD state entry.
0x84 0x4 Sixth circle-pad info entry.
0x88 0x4 Eighth PAD state entry.
0x94 0x4 Seventh circle-pad info entry.
0x98 0x4 Ninth PAD state entry.
0xA4 0x4 Eighth circle-pad info entry.

Offset 0xA8

Relative offset Size Description
0x10 0x4 Index in the array at +0x20 which was last updated by HID module.
0x18 0x8 Touch-screen entry, which seems to contain 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 probably contains the gyroscope and/or accelerometer state?

Offset 0x158

The size of this region is 0xE0-bytes. Unknown, contains 0xFF/0x00 bytes?

Offset 0x238

The size of this region is 0x78-bytes. Unknown, contains 0xFF/0x00 bytes?