HID Shared Memory: Difference between revisions

No edit summary
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
HID shared memory is a 0x40000 byte read-only segment of memory shared between applications for input. The segment contains structures for most if not all input methods available to applications.
HID shared memory is a 0x40000 byte read-only segment of memory shared between applications for input. The segment contains structures for most if not all input methods available to applications.
In sdknso this is "nn::hid::detail::SharedMemoryFormat".


= Memory Map =
= Memory Map =
Line 10: Line 12:
| 0x0
| 0x0
| 0x400
| 0x400
| DebugPad
| [[#DebugPad]]
|-
|-
| 0x400
| 0x400
Line 26: Line 28:
| 0x3C00
| 0x3C00
| 0x1000 (0x400 * 0x04)
| 0x1000 (0x400 * 0x04)
| BasicXpad
| [1.0.0-9.2.0] [[#BasicXpad]]
|-
| 0x3C00
|
| [10.0.0+] Digitizer
|-
|-
| 0x4C00
| 0x4C00
| 0x200
| 0x200
| HomeButton
| [[#HomeButton]]
|-
|-
| 0x4E00
| 0x4E00
| 0x200
| 0x200
| SleepButton
| [[#SleepButton]]
|-
|-
| 0x5000
| 0x5000
| 0x200
| 0x200
| CaptureButton
| [[#CaptureButton]]
|-
|-
| 0x5200
| 0x5200
| 0x800 (0x80 * 0x10)
| 0x800 (0x80 * 0x10)
| InputDetector
| [[#InputDetector]]
|-
|-
| 0x5A00
| 0x5A00
| 0x4000
| 0x4000 (0x400 * 0x10)
| Controller Serials?
| [1.0.0-4.1.0] [[#UniquePad]]
|-
|-
| 0x9A00
| 0x9A00
| 0x32000 (0x5000 * 0x0A)
| 0x32000 (0x5000 * 0x0A)
| Npad
| [[#Npad]]
|-
|-
| 0x3BA00
| 0x3BA00
| 0x800
| 0x800
| Gesture
| [[#Gesture]]
|-
|-
| 0x3C200
| 0x3C200
| 0x20
| 0x20
| [5.0.0+] ConsoleSixAxisSensor
| [5.0.0+] [[#ConsoleSixAxisSensor]]
|}
|}


== TouchScreen ==
== DebugPad ==
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 69: Line 75:
|-
|-
| 0x0
| 0x0
| 0x28
| 0x20
| [[#TouchScreenHeader]]
| [[#DebugPadHeader]]
|-
|-
| 0x28
| 0x20
| 0x298 * 17
| 0x28 * 17
| Array of [[#TouchScreenState]]
| Array of [[#DebugPadState]]
|}
|}


=== TouchScreenHeader ===
=== DebugPadHeader ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 86: Line 92:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in ticks?
| Timestamp in ticks
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Number of Entries, always 17
| Number of Entries (always 17)
|-
|-
| 0x10
| 0x10
Line 98: Line 104:
| 0x18
| 0x18
| 0x8
| 0x8
| Maximum Entry Index, always 16
| Maximum Entry Index (always 16)
|}
 
=== DebugPadState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
|-
| 0x8
| 0x20
| 0x20
| 0x8
|  
| Timestamp in samples
|}
 
== TouchScreen ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#TouchScreenHeader]]
|-
| 0x20
| 0x298 * 17
| Array of [[#TouchScreenState]]
|}
|}


=== TouchScreenState ===
=== TouchScreenHeader ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 113: Line 147:
|-
|-
| 0x0
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x10
| [[#TouchScreenStateHeader]]
| 0x8
| Latest Entry Index
|-
|-
| 0x10
| 0x18
| 0x28 * 16
| 0x8
| [[#TouchScreenStateData]]
| Maximum Entry Index (always 16)
|}
|}


==== TouchScreenStateHeader ====
=== TouchScreenState ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 129: Line 171:
|-
|-
| 0x0
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x8
| 0x8
| Timestamp in samples
| Timestamp in samples
|-
|-
| 0x8
| 0x10
| 0x8
| 0x8
| Touch count
| Touch count
|-
| 0x18
| 0x28 * 16
| [[#TouchScreenStateData]]
|}
|}


Line 206: Line 256:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in ticks?
| Timestamp in ticks
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Number of Entries, always 17
| Number of Entries (always 17)
|-
|-
| 0x10
| 0x10
Line 218: Line 268:
| 0x18
| 0x18
| 0x8
| 0x8
| Maximum Entry Index, always 16
| Maximum Entry Index (always 16)
|}
|}


Line 230: Line 280:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in samples
| Timestamp in samples (global)
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Timestamp in samples again?
| Timestamp in samples
|-
|-
| 0x10
| 0x10
Line 290: Line 340:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in ticks?
| Timestamp in ticks
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Number of Entries, always 17
| Number of Entries (always 17)
|-
|-
| 0x10
| 0x10
Line 302: Line 352:
| 0x18
| 0x18
| 0x8
| 0x8
| Maximum Entry Index, always 16
| Maximum Entry Index (always 16)
|}
|}


Line 314: Line 364:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in samples
| Timestamp in samples (global)
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Timestamp in samples again?
| Timestamp in samples
|-
|-
| 0x10
| 0x10
Line 329: Line 379:
|}
|}


== Controller Serials? ==
== BasicXpad ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#BasicXpadHeader]]
|-
| 0x20
| 0x28 * 17
| Array of [[#BasicXpadState]]
|}
 
=== BasicXpadHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
 
=== BasicXpadState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x20
|
|}
 
== HomeButton ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#HomeButtonHeader]]
|-
| 0x20
| 0x18 * 17
| Array of [[#HomeButtonState]]
|}
 
=== HomeButtonHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
 
=== HomeButtonState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x10
|
|}
 
== SleepButton ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#SleepButtonHeader]]
|-
| 0x20
| 0x18 * 17
| Array of [[#SleepButtonState]]
|}
 
=== SleepButtonHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
 
=== SleepButtonState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x10
|
|}
 
== CaptureButton ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#CaptureButtonHeader]]
|-
| 0x20
| 0x18 * 17
| Array of [[#CaptureButtonState]]
|}
 
=== CaptureButtonHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
 
=== CaptureButtonState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x10
|
|}
 
== InputDetector ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#InputDetectorHeader]]
|-
| 0x20
| 0x18 * 2
| Array of [[#InputDetectorState]]
|}
 
=== InputDetectorHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
 
=== InputDetectorState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x10
|
|}
 
== UniquePad ==
This section contains a series of 16 structures 0x400 bytes large.
This section contains a series of 16 structures 0x400 bytes large.
[5.0.0+] This section has been removed from SharedMemoryFormat. [[#UniquePad]] is now a specialization of [[#Npad]].


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
!   Offset
! Offset
!   Size in bytes
! Size
!   Description
! Description
|-
| 0x0
| 0x80
| [[#UniquePadConfig]]
|-
|-
| 0x30
| 0x80
| 0xE
| 0x70 * 2
| Controller Serial
| Array of [[#AnalogStickCalibration]]
|}
 
=== UniquePadConfig ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
|-
| 0x60
| 0x0
| 0xE
| 0x20
| Controller Serial
| [[#UniquePadConfigHeader]]
|-
|-
| 0x20
| 0x30 * 2
| Array of [[#UniquePadConfigState]]
|}
==== UniquePadConfigHeader ====
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
==== UniquePadConfigState ====
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x8
|
|-
| 0x10
| 0x20
| Controller Serial
|}
=== AnalogStickCalibration ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#AnalogStickCalibrationHeader]]
|-
| 0x20
| 0x28 * 2
| Array of [[#AnalogStickCalibrationState]]
|}
==== AnalogStickCalibrationHeader ====
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
==== AnalogStickCalibrationState ====
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x28
|
|}
|}


Line 363: Line 810:
|-
|-
| 9
| 9
| Unknown
| Other
|}
|}


=== NpadInternalState ===
=== NpadState ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 375: Line 822:
| 0x0
| 0x0
| 0x28
| 0x28
| [[#NpadInternalStateHeader]]
| [[#NpadStateHeader]]
|-
|-
| 0x28
| 0x28
Line 499: Line 946:
| 0x419C
| 0x419C
| 0x4
| 0x4
| PowerInfo0 battery state (must be 0-4)
| BatteryIndex0 state (must be 0-4)
|-
|-
| 0x41A0
| 0x41A0
| 0x4
| 0x4
| PowerInfo1 battery state (must be 0-4)
| BatteryIndex1 state (must be 0-4)
|-
|-
| 0x41A4
| 0x41A4
| 0x4
| 0x4
| PowerInfo2 battery state (must be 0-4)
| BatteryIndex2 state (must be 0-4)
|-
|-
| 0x41A8
| 0x41A8
Line 530: Line 977:
|}
|}


==== NpadInternalStateHeader ====
==== NpadStateHeader ====
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 587: Line 1,034:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in ticks?
| Timestamp in ticks
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Number of entries, always 17
| Number of entries (always 17)
|-
|-
| 0x10
| 0x10
Line 599: Line 1,046:
| 0x18
| 0x18
| 0x8
| 0x8
| Maximum Entry Index, always 16
| Maximum Entry Index (always 16)
|}
|}


Line 611: Line 1,058:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in samples
| Timestamp in samples (global)
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Timestamp in samples again
| Timestamp in samples
|-
|-
| 0x10
| 0x10
| 0x8
| 0x8
| [[#Button State]]
| [[#NpadButton]]
|-
|-
| 0x18
| 0x18
Line 642: Line 1,089:
|}
|}


===== Button State =====
===== NpadButton =====
This is the u64 bitmask for "nn::hid::NpadButton".
 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 736: Line 1,185:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in ticks?
| Timestamp in ticks
|-
|-
| 0x8
| 0x8
| 0x8
| 0x8
| Number of entries, always 17
| Number of entries (always 17)
|-
|-
| 0x10
| 0x10
Line 748: Line 1,197:
| 0x18
| 0x18
| 0x8
| 0x8
| Maximum Entry Index, up to 16
| Maximum Entry Index (up to 16)
|}
|}


Line 760: Line 1,209:
| 0x0
| 0x0
| 0x8
| 0x8
| Timestamp in samples
| Timestamp in samples (global)
|-
|-
| 0x8
| 0x8
Line 768: Line 1,217:
| 0x10
| 0x10
| 0x8
| 0x8
| Timestamp in samples again
| Timestamp in samples
|-
|-
| 0x1C
| 0x1C
Line 853: Line 1,302:
| 0
| 0
| UnintendedHomeButtonInputProtectionEnabled (if cleared)
| UnintendedHomeButtonInputProtectionEnabled (if cleared)
|}
== Gesture ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x20
| [[#GestureHeader]]
|-
| 0x20
| 0x68 * 17
| Array of [[#GestureState]]
|}
=== GestureHeader ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in ticks
|-
| 0x8
| 0x8
| Number of Entries (always 17)
|-
| 0x10
| 0x8
| Latest Entry Index
|-
| 0x18
| 0x8
| Maximum Entry Index (always 16)
|}
=== GestureState ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples (global)
|-
| 0x8
| 0x60
|
|}
== ConsoleSixAxisSensor ==
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| Timestamp in samples
|-
| 0x8
| 0x1
| IsSevenSixAxisSensorAtRest
|-
| 0x9
| 0x3
| Padding
|-
| 0xC
| 0x4
| VerticalizationError
|-
| 0x10
| 0xC
| GyroBias
|-
| 0x1C
| 0x4
| Padding
|}
|}