HID Corrections

This commit is contained in:
AcK77 2018-02-18 00:25:03 +01:00
commit 8c6bca8f37
7 changed files with 170 additions and 154 deletions

View file

@ -35,6 +35,7 @@ namespace Ryujinx
private const int Hid_Num_Entries = 16; private const int Hid_Num_Entries = 16;
private Switch Ns; private Switch Ns;
private long SharedMemOffset;
public Hid(Switch Ns) public Hid(Switch Ns)
{ {
@ -50,9 +51,11 @@ namespace Ryujinx
return; return;
} }
SharedMemOffset = HidOffset;
uint InnerOffset = (uint)Marshal.SizeOf(typeof(HidSharedMemHeader)); uint InnerOffset = (uint)Marshal.SizeOf(typeof(HidSharedMemHeader));
IntPtr HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset); IntPtr HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
HidTouchScreen TouchScreen = new HidTouchScreen(); HidTouchScreen TouchScreen = new HidTouchScreen();
TouchScreen.Header.TimestampTicks = (ulong)Environment.TickCount; TouchScreen.Header.TimestampTicks = (ulong)Environment.TickCount;
@ -61,11 +64,11 @@ namespace Ryujinx
TouchScreen.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1; TouchScreen.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1;
TouchScreen.Header.Timestamp = (ulong)Environment.TickCount; TouchScreen.Header.Timestamp = (ulong)Environment.TickCount;
//Don't need to write it right now. //TODO: Write this structure when the input is implemented
//Marshal.StructureToPtr(TouchScreen, HidPtr, false); //Marshal.StructureToPtr(TouchScreen, HidPtr, false);
InnerOffset += (uint)Marshal.SizeOf(typeof(HidTouchScreen)); InnerOffset += (uint)Marshal.SizeOf(typeof(HidTouchScreen));
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset); HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
HidMouse Mouse = new HidMouse(); HidMouse Mouse = new HidMouse();
Mouse.Header.TimestampTicks = (ulong)Environment.TickCount; Mouse.Header.TimestampTicks = (ulong)Environment.TickCount;
@ -73,11 +76,11 @@ namespace Ryujinx
Mouse.Header.LatestEntry = 0; Mouse.Header.LatestEntry = 0;
Mouse.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1; Mouse.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1;
//Don't need to write it right now. //TODO: Write this structure when the input is implemented
//Marshal.StructureToPtr(Mouse, HidPtr, false); //Marshal.StructureToPtr(Mouse, HidPtr, false);
InnerOffset += (uint)Marshal.SizeOf(typeof(HidMouse)); InnerOffset += (uint)Marshal.SizeOf(typeof(HidMouse));
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset); HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
HidKeyboard Keyboard = new HidKeyboard(); HidKeyboard Keyboard = new HidKeyboard();
Keyboard.Header.TimestampTicks = (ulong)Environment.TickCount; Keyboard.Header.TimestampTicks = (ulong)Environment.TickCount;
@ -85,20 +88,24 @@ namespace Ryujinx
Keyboard.Header.LatestEntry = 0; Keyboard.Header.LatestEntry = 0;
Keyboard.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1; Keyboard.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1;
//Don't need to write it right now. //TODO: Write this structure when the input is implemented
//Marshal.StructureToPtr(Keyboard, HidPtr, false); //Marshal.StructureToPtr(Keyboard, HidPtr, false);
InnerOffset += (uint)Marshal.SizeOf(typeof(HidKeyboard)); InnerOffset += (uint)Marshal.SizeOf(typeof(HidKeyboard)) +
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection1)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection2)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection3)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection4)); (uint)Marshal.SizeOf(typeof(HidUnknownSection1)) +
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection5)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection6)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection7)); (uint)Marshal.SizeOf(typeof(HidUnknownSection2)) +
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection8)) + (uint)Marshal.SizeOf(typeof(HidControllerSerials)); (uint)Marshal.SizeOf(typeof(HidUnknownSection3)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection4)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection5)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection6)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection7)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection8)) +
(uint)Marshal.SizeOf(typeof(HidControllerSerials));
Console.WriteLine(InnerOffset); //Increase the loop to initialize more controller.
for (int i = 8; i < Enum.GetNames(typeof(HidControllerID)).Length - 1; i++)
//Increase the loop to Init more controller.
for (int i = 8; i < Enum.GetNames(typeof(HidControllerID)).Length - 2; i++)
{ {
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset + (uint)(Marshal.SizeOf(typeof(HidController)) * i)); HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset + (uint)(Marshal.SizeOf(typeof(HidController)) * i));
HidController Controller = new HidController(); HidController Controller = new HidController();
Controller.Header.Type = (uint)(HidControllerType.ControllerType_Handheld | HidControllerType.ControllerType_JoyconPair); Controller.Header.Type = (uint)(HidControllerType.ControllerType_Handheld | HidControllerType.ControllerType_JoyconPair);
@ -123,28 +130,30 @@ namespace Ryujinx
} }
} }
public void SendControllerButtons(HidControllerID ControllerId, HidControllerLayouts Layout, HidControllerKeys Buttons, JoystickPosition LeftJoystick, JoystickPosition RightJoystick) public void SendControllerButtons(HidControllerID ControllerId,
HidControllerLayouts Layout,
HidControllerKeys Buttons,
JoystickPosition LeftJoystick,
JoystickPosition RightJoystick)
{ {
unsafe uint InnerOffset = (uint)Marshal.SizeOf(typeof(HidSharedMemHeader)) +
{ (uint)Marshal.SizeOf(typeof(HidTouchScreen)) +
long HidOffset = Ns.Os.GetVirtHidOffset(); (uint)Marshal.SizeOf(typeof(HidMouse)) +
(uint)Marshal.SizeOf(typeof(HidKeyboard)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection1)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection2)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection3)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection4)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection5)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection6)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection7)) +
(uint)Marshal.SizeOf(typeof(HidUnknownSection8)) +
(uint)Marshal.SizeOf(typeof(HidControllerSerials)) +
((uint)(Marshal.SizeOf(typeof(HidController)) * (int)ControllerId)) +
(uint)Marshal.SizeOf(typeof(HidControllerHeader)) +
(uint)Layout * (uint)Marshal.SizeOf(typeof(HidControllerLayout));
if (HidOffset == 0 || HidOffset + Horizon.HidSize > uint.MaxValue) IntPtr HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
{
return;
}
uint InnerOffset = (uint)Marshal.SizeOf(typeof(HidSharedMemHeader));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidTouchScreen));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidMouse));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidKeyboard));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection1)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection2)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection3)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection4));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection5)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection6)) + (uint)Marshal.SizeOf(typeof(HidUnknownSection7));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidUnknownSection8)) + (uint)Marshal.SizeOf(typeof(HidControllerSerials));
InnerOffset += ((uint)(Marshal.SizeOf(typeof(HidController)) * (int)ControllerId));
InnerOffset += (uint)Marshal.SizeOf(typeof(HidControllerHeader));
InnerOffset += (uint)Layout * (uint)Marshal.SizeOf(typeof(HidControllerLayout));
IntPtr HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset);
HidControllerLayoutHeader OldControllerHeaderLayout = (HidControllerLayoutHeader)Marshal.PtrToStructure(HidPtr, typeof(HidControllerLayoutHeader)); HidControllerLayoutHeader OldControllerHeaderLayout = (HidControllerLayoutHeader)Marshal.PtrToStructure(HidPtr, typeof(HidControllerLayoutHeader));
@ -159,7 +168,7 @@ namespace Ryujinx
Marshal.StructureToPtr(ControllerLayoutHeader, HidPtr, false); Marshal.StructureToPtr(ControllerLayoutHeader, HidPtr, false);
InnerOffset += (uint)Marshal.SizeOf(typeof(HidControllerLayoutHeader)) + (uint)((uint)(ControllerLayoutHeader.LatestEntry) * Marshal.SizeOf(typeof(HidControllerInputEntry))); InnerOffset += (uint)Marshal.SizeOf(typeof(HidControllerLayoutHeader)) + (uint)((uint)(ControllerLayoutHeader.LatestEntry) * Marshal.SizeOf(typeof(HidControllerInputEntry)));
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset); HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
HidControllerInputEntry ControllerInputEntry = new HidControllerInputEntry(); HidControllerInputEntry ControllerInputEntry = new HidControllerInputEntry();
ControllerInputEntry.Timestamp = (ulong)Environment.TickCount; ControllerInputEntry.Timestamp = (ulong)Environment.TickCount;
@ -174,4 +183,3 @@ namespace Ryujinx
} }
} }
} }
}

View file

@ -4,32 +4,32 @@ namespace Ryujinx
{ {
public enum HidControllerKeys public enum HidControllerKeys
{ {
KEY_A = (1 << 0), //< A KEY_A = (1 << 0),
KEY_B = (1 << 1), //< B KEY_B = (1 << 1),
KEY_X = (1 << 2), //< X KEY_X = (1 << 2),
KEY_Y = (1 << 3), //< Y KEY_Y = (1 << 3),
KEY_LSTICK = (1 << 4), //< Left Stick Button KEY_LSTICK = (1 << 4),
KEY_RSTICK = (1 << 5), //< Right Stick Button KEY_RSTICK = (1 << 5),
KEY_L = (1 << 6), //< L KEY_L = (1 << 6),
KEY_R = (1 << 7), //< R KEY_R = (1 << 7),
KEY_ZL = (1 << 8), //< ZL KEY_ZL = (1 << 8),
KEY_ZR = (1 << 9), //< ZR KEY_ZR = (1 << 9),
KEY_PLUS = (1 << 10), //< Plus KEY_PLUS = (1 << 10),
KEY_MINUS = (1 << 11), //< Minus KEY_MINUS = (1 << 11),
KEY_DLEFT = (1 << 12), //< D-Pad Left KEY_DLEFT = (1 << 12),
KEY_DUP = (1 << 13), //< D-Pad Up KEY_DUP = (1 << 13),
KEY_DRIGHT = (1 << 14), //< D-Pad Right KEY_DRIGHT = (1 << 14),
KEY_DDOWN = (1 << 15), //< D-Pad Down KEY_DDOWN = (1 << 15),
KEY_LSTICK_LEFT = (1 << 16), //< Left Stick Left KEY_LSTICK_LEFT = (1 << 16),
KEY_LSTICK_UP = (1 << 17), //< Left Stick Up KEY_LSTICK_UP = (1 << 17),
KEY_LSTICK_RIGHT = (1 << 18), //< Left Stick Right KEY_LSTICK_RIGHT = (1 << 18),
KEY_LSTICK_DOWN = (1 << 19), //< Left Stick Down KEY_LSTICK_DOWN = (1 << 19),
KEY_RSTICK_LEFT = (1 << 20), //< Right Stick Left KEY_RSTICK_LEFT = (1 << 20),
KEY_RSTICK_UP = (1 << 21), //< Right Stick Up KEY_RSTICK_UP = (1 << 21),
KEY_RSTICK_RIGHT = (1 << 22), //< Right Stick Right KEY_RSTICK_RIGHT = (1 << 22),
KEY_RSTICK_DOWN = (1 << 23), //< Right Stick Down KEY_RSTICK_DOWN = (1 << 23),
KEY_SL = (1 << 24), //< SL KEY_SL = (1 << 24),
KEY_SR = (1 << 25), //< SR KEY_SR = (1 << 25),
// Pseudo-key for at least one finger on the touch screen // Pseudo-key for at least one finger on the touch screen
KEY_TOUCH = (1 << 26), KEY_TOUCH = (1 << 26),
@ -41,10 +41,10 @@ namespace Ryujinx
KEY_JOYCON_LEFT = (1 << 3), KEY_JOYCON_LEFT = (1 << 3),
// Generic catch-all directions, also works for single Joy-Con // Generic catch-all directions, also works for single Joy-Con
KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP, //< D-Pad Up or Sticks Up KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP,
KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN, //< D-Pad Down or Sticks Down KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN,
KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT, //< D-Pad Left or Sticks Left KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT,
KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT, //< D-Pad Right or Sticks Right KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT,
} }
public enum HidControllerID public enum HidControllerID
@ -58,8 +58,7 @@ namespace Ryujinx
CONTROLLER_PLAYER_7 = 6, CONTROLLER_PLAYER_7 = 6,
CONTROLLER_PLAYER_8 = 7, CONTROLLER_PLAYER_8 = 7,
CONTROLLER_HANDHELD = 8, CONTROLLER_HANDHELD = 8,
CONTROLLER_UNKNOWN = 9, CONTROLLER_UNKNOWN = 9
CONTROLLER_P1_AUTO = 10, //Not an actual HID-sysmodule ID. Only for hidKeys*(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
} }
public enum HidControllerJoystick public enum HidControllerJoystick
@ -82,32 +81,33 @@ namespace Ryujinx
public enum HidControllerConnectionState public enum HidControllerConnectionState
{ {
Controller_State_Connected = 1 << 0, Controller_State_Connected = (1 << 0),
Controller_State_Wired = 1 << 1 Controller_State_Wired = (1 << 1)
} }
public enum HidControllerType public enum HidControllerType
{ {
ControllerType_ProController = 1 << 0, ControllerType_ProController = (1 << 0),
ControllerType_Handheld = 1 << 1, ControllerType_Handheld = (1 << 1),
ControllerType_JoyconPair = 1 << 2, ControllerType_JoyconPair = (1 << 2),
ControllerType_JoyconLeft = 1 << 3, ControllerType_JoyconLeft = (1 << 3),
ControllerType_JoyconRight = 1 << 4 ControllerType_JoyconRight = (1 << 4)
} }
public enum HidControllerColorDescription public enum HidControllerColorDescription
{ {
ColorDesc_ColorsNonexistent = 1 << 1, ColorDesc_ColorsNonexistent = (1 << 1),
} }
public struct JoystickPosition //Size: 0x8 [StructLayout(LayoutKind.Sequential, Size = 0x8)]
public struct JoystickPosition
{ {
public int DX; public int DX;
public int DY; public int DY;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x20)]
public struct HidControllerMAC //Size: 0x20 public struct HidControllerMAC
{ {
public ulong Timestamp; public ulong Timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
@ -116,7 +116,8 @@ namespace Ryujinx
public ulong Timestamp_2; public ulong Timestamp_2;
} }
public struct HidControllerHeader //Size: 0x28 [StructLayout(LayoutKind.Sequential, Size = 0x28)]
public struct HidControllerHeader
{ {
public uint Type; public uint Type;
public uint IsHalf; public uint IsHalf;
@ -130,7 +131,8 @@ namespace Ryujinx
public uint RightColorButtons; public uint RightColorButtons;
} }
public struct HidControllerLayoutHeader //Size: 0x20 [StructLayout(LayoutKind.Sequential, Size = 0x20)]
public struct HidControllerLayoutHeader
{ {
public ulong TimestampTicks; public ulong TimestampTicks;
public ulong NumEntries; public ulong NumEntries;
@ -138,8 +140,8 @@ namespace Ryujinx
public ulong MaxEntryIndex; public ulong MaxEntryIndex;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x30)]
public struct HidControllerInputEntry //Size: 0x30 public struct HidControllerInputEntry
{ {
public ulong Timestamp; public ulong Timestamp;
public ulong Timestamp_2; public ulong Timestamp_2;
@ -149,16 +151,16 @@ namespace Ryujinx
public ulong ConnectionState; public ulong ConnectionState;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x350)]
public struct HidControllerLayout //Size: 0x350 public struct HidControllerLayout
{ {
public HidControllerLayoutHeader Header; public HidControllerLayoutHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
public HidControllerInputEntry[] Entries; public HidControllerInputEntry[] Entries;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x5000)]
public struct HidController //Size: 0x5000 public struct HidController
{ {
public HidControllerHeader Header; public HidControllerHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]

View file

@ -2,7 +2,8 @@
namespace Ryujinx namespace Ryujinx
{ {
public struct HidKeyboardHeader //Size: 0x20 [StructLayout(LayoutKind.Sequential, Size = 0x20)]
public struct HidKeyboardHeader
{ {
public ulong TimestampTicks; public ulong TimestampTicks;
public ulong NumEntries; public ulong NumEntries;
@ -10,8 +11,8 @@ namespace Ryujinx
public ulong MaxEntryIndex; public ulong MaxEntryIndex;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x38)]
public struct HidKeyboardEntry //Size: 0x38 public struct HidKeyboardEntry
{ {
public ulong Timestamp; public ulong Timestamp;
public ulong Timestamp_2; public ulong Timestamp_2;
@ -20,8 +21,8 @@ namespace Ryujinx
public uint[] Keys; public uint[] Keys;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidKeyboard //Size: 0x400 public struct HidKeyboard
{ {
public HidKeyboardHeader Header; public HidKeyboardHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]

View file

@ -2,7 +2,8 @@
namespace Ryujinx namespace Ryujinx
{ {
public struct HidMouseHeader //Size: 0x20 [StructLayout(LayoutKind.Sequential, Size = 0x20)]
public struct HidMouseHeader
{ {
public ulong TimestampTicks; public ulong TimestampTicks;
public ulong NumEntries; public ulong NumEntries;
@ -10,7 +11,8 @@ namespace Ryujinx
public ulong MaxEntryIndex; public ulong MaxEntryIndex;
} }
public struct HidMouseEntry //Size: 0x30 [StructLayout(LayoutKind.Sequential, Size = 0x30)]
public struct HidMouseEntry
{ {
public ulong Timestamp; public ulong Timestamp;
public ulong Timestamp_2; public ulong Timestamp_2;
@ -23,8 +25,8 @@ namespace Ryujinx
public ulong Buttons; public ulong Buttons;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidMouse //Size: 0x400 public struct HidMouse
{ {
public HidMouseHeader Header; public HidMouseHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]

View file

@ -2,7 +2,8 @@
namespace Ryujinx namespace Ryujinx
{ {
public struct HidTouchScreenHeader //Size: 0x28 [StructLayout(LayoutKind.Sequential, Size = 0x28)]
public struct HidTouchScreenHeader
{ {
public ulong TimestampTicks; public ulong TimestampTicks;
public ulong NumEntries; public ulong NumEntries;
@ -11,13 +12,15 @@ namespace Ryujinx
public ulong Timestamp; public ulong Timestamp;
} }
public struct HidTouchScreenEntryHeader //Size: 0x10 [StructLayout(LayoutKind.Sequential, Size = 0x10)]
public struct HidTouchScreenEntryHeader
{ {
public ulong Timestamp; public ulong Timestamp;
public ulong NumTouches; public ulong NumTouches;
} }
public struct HidTouchScreenEntryTouch //Size: 0x28 [StructLayout(LayoutKind.Sequential, Size = 0x28)]
public struct HidTouchScreenEntryTouch
{ {
public ulong Timestamp; public ulong Timestamp;
public uint Padding; public uint Padding;
@ -30,8 +33,8 @@ namespace Ryujinx
public uint Padding_2; public uint Padding_2;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x298)]
public struct HidTouchScreenEntry //Size: 0x298 public struct HidTouchScreenEntry
{ {
public HidTouchScreenEntryHeader Header; public HidTouchScreenEntryHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
@ -39,8 +42,8 @@ namespace Ryujinx
public ulong Unknown; public ulong Unknown;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x3000)]
public struct HidTouchScreen //Size: 0x3000 public struct HidTouchScreen
{ {
public HidTouchScreenHeader Header; public HidTouchScreenHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]

View file

@ -2,78 +2,78 @@
namespace Ryujinx namespace Ryujinx
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidSharedMemHeader //Size: 0x400 public struct HidSharedMemHeader
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidUnknownSection1 //Size: 0x400 public struct HidUnknownSection1
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidUnknownSection2 //Size: 0x400 public struct HidUnknownSection2
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidUnknownSection3 //Size: 0x400 public struct HidUnknownSection3
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x400)]
public struct HidUnknownSection4 //Size: 0x400 public struct HidUnknownSection4
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x200)]
public struct HidUnknownSection5 //Size: 0x200 public struct HidUnknownSection5
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x200)]
public struct HidUnknownSection6 //Size: 0x200 public struct HidUnknownSection6
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x200)]
public struct HidUnknownSection7 //Size: 0x200 public struct HidUnknownSection7
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x800)]
public struct HidUnknownSection8 //Size: 0x800 public struct HidUnknownSection8
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x800)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x800)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x4000)]
public struct HidControllerSerials //Size: 0x4000 public struct HidControllerSerials
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4000)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4000)]
public byte[] Padding; public byte[] Padding;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = 0x4600)]
public struct HidUnknownSection9 //Size: 0x4600 public struct HidUnknownSection9
{ {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4600)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4600)]
public byte[] Padding; public byte[] Padding;

View file

@ -330,7 +330,7 @@ void main(void) {
DY = RightJoystickDY DY = RightJoystickDY
}; };
//We just need one pair of JoyCon for because it's a faked one :P. //We just need one pair of JoyCon because it's emulate by the keyboard.
Ns.Hid.SendControllerButtons(HidControllerID.CONTROLLER_HANDHELD, HidControllerLayouts.Main, CurrentButton, LeftJoystick, RightJoystick); Ns.Hid.SendControllerButtons(HidControllerID.CONTROLLER_HANDHELD, HidControllerLayouts.Main, CurrentButton, LeftJoystick, RightJoystick);
} }