HID Corrections
This commit is contained in:
parent
8ab1b693fb
commit
8c6bca8f37
7 changed files with 170 additions and 154 deletions
124
Ryujinx/Hid.cs
124
Ryujinx/Hid.cs
|
@ -35,6 +35,7 @@ namespace Ryujinx
|
|||
|
||||
private const int Hid_Num_Entries = 16;
|
||||
private Switch Ns;
|
||||
private long SharedMemOffset;
|
||||
|
||||
public Hid(Switch Ns)
|
||||
{
|
||||
|
@ -50,9 +51,11 @@ namespace Ryujinx
|
|||
return;
|
||||
}
|
||||
|
||||
SharedMemOffset = HidOffset;
|
||||
|
||||
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();
|
||||
TouchScreen.Header.TimestampTicks = (ulong)Environment.TickCount;
|
||||
|
@ -61,11 +64,11 @@ namespace Ryujinx
|
|||
TouchScreen.Header.MaxEntryIndex = (ulong)Hid_Num_Entries - 1;
|
||||
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);
|
||||
|
||||
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();
|
||||
Mouse.Header.TimestampTicks = (ulong)Environment.TickCount;
|
||||
|
@ -73,11 +76,11 @@ namespace Ryujinx
|
|||
Mouse.Header.LatestEntry = 0;
|
||||
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);
|
||||
|
||||
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();
|
||||
Keyboard.Header.TimestampTicks = (ulong)Environment.TickCount;
|
||||
|
@ -85,20 +88,24 @@ namespace Ryujinx
|
|||
Keyboard.Header.LatestEntry = 0;
|
||||
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);
|
||||
|
||||
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(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));
|
||||
|
||||
Console.WriteLine(InnerOffset);
|
||||
|
||||
//Increase the loop to Init more controller.
|
||||
for (int i = 8; i < Enum.GetNames(typeof(HidControllerID)).Length - 2; i++)
|
||||
//Increase the loop to initialize more controller.
|
||||
for (int i = 8; i < Enum.GetNames(typeof(HidControllerID)).Length - 1; 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();
|
||||
Controller.Header.Type = (uint)(HidControllerType.ControllerType_Handheld | HidControllerType.ControllerType_JoyconPair);
|
||||
|
@ -123,55 +130,56 @@ 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)) +
|
||||
(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));
|
||||
|
||||
IntPtr HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
|
||||
|
||||
HidControllerLayoutHeader OldControllerHeaderLayout = (HidControllerLayoutHeader)Marshal.PtrToStructure(HidPtr, typeof(HidControllerLayoutHeader));
|
||||
|
||||
HidControllerLayoutHeader ControllerLayoutHeader = new HidControllerLayoutHeader
|
||||
{
|
||||
long HidOffset = Ns.Os.GetVirtHidOffset();
|
||||
TimestampTicks = (ulong)Environment.TickCount,
|
||||
NumEntries = (ulong)Hid_Num_Entries,
|
||||
MaxEntryIndex = (ulong)Hid_Num_Entries - 1,
|
||||
LatestEntry = (OldControllerHeaderLayout.LatestEntry < (ulong)Hid_Num_Entries ? OldControllerHeaderLayout.LatestEntry + 1 : 0)
|
||||
};
|
||||
|
||||
if (HidOffset == 0 || HidOffset + Horizon.HidSize > uint.MaxValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Marshal.StructureToPtr(ControllerLayoutHeader, HidPtr, false);
|
||||
|
||||
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);
|
||||
InnerOffset += (uint)Marshal.SizeOf(typeof(HidControllerLayoutHeader)) + (uint)((uint)(ControllerLayoutHeader.LatestEntry) * Marshal.SizeOf(typeof(HidControllerInputEntry)));
|
||||
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset);
|
||||
|
||||
HidControllerLayoutHeader OldControllerHeaderLayout = (HidControllerLayoutHeader)Marshal.PtrToStructure(HidPtr, typeof(HidControllerLayoutHeader));
|
||||
HidControllerInputEntry ControllerInputEntry = new HidControllerInputEntry();
|
||||
ControllerInputEntry.Timestamp = (ulong)Environment.TickCount;
|
||||
ControllerInputEntry.Timestamp_2 = (ulong)Environment.TickCount;
|
||||
ControllerInputEntry.Buttons = (ulong)Buttons;
|
||||
ControllerInputEntry.Joysticks = new JoystickPosition[(int)HidControllerJoystick.Joystick_Num_Sticks];
|
||||
ControllerInputEntry.Joysticks[(int)HidControllerJoystick.Joystick_Left] = LeftJoystick;
|
||||
ControllerInputEntry.Joysticks[(int)HidControllerJoystick.Joystick_Right] = RightJoystick;
|
||||
ControllerInputEntry.ConnectionState = (ulong)(HidControllerConnectionState.Controller_State_Connected | HidControllerConnectionState.Controller_State_Wired);
|
||||
|
||||
HidControllerLayoutHeader ControllerLayoutHeader = new HidControllerLayoutHeader
|
||||
{
|
||||
TimestampTicks = (ulong)Environment.TickCount,
|
||||
NumEntries = (ulong)Hid_Num_Entries,
|
||||
MaxEntryIndex = (ulong)Hid_Num_Entries - 1,
|
||||
LatestEntry = (OldControllerHeaderLayout.LatestEntry < (ulong)Hid_Num_Entries ? OldControllerHeaderLayout.LatestEntry + 1 : 0)
|
||||
};
|
||||
|
||||
Marshal.StructureToPtr(ControllerLayoutHeader, HidPtr, false);
|
||||
|
||||
InnerOffset += (uint)Marshal.SizeOf(typeof(HidControllerLayoutHeader)) + (uint)((uint)(ControllerLayoutHeader.LatestEntry) * Marshal.SizeOf(typeof(HidControllerInputEntry)));
|
||||
HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)HidOffset + InnerOffset);
|
||||
|
||||
HidControllerInputEntry ControllerInputEntry = new HidControllerInputEntry();
|
||||
ControllerInputEntry.Timestamp = (ulong)Environment.TickCount;
|
||||
ControllerInputEntry.Timestamp_2 = (ulong)Environment.TickCount;
|
||||
ControllerInputEntry.Buttons = (ulong)Buttons;
|
||||
ControllerInputEntry.Joysticks = new JoystickPosition[(int)HidControllerJoystick.Joystick_Num_Sticks];
|
||||
ControllerInputEntry.Joysticks[(int)HidControllerJoystick.Joystick_Left] = LeftJoystick;
|
||||
ControllerInputEntry.Joysticks[(int)HidControllerJoystick.Joystick_Right] = RightJoystick;
|
||||
ControllerInputEntry.ConnectionState = (ulong)(HidControllerConnectionState.Controller_State_Connected | HidControllerConnectionState.Controller_State_Wired);
|
||||
|
||||
Marshal.StructureToPtr(ControllerInputEntry, HidPtr, false);
|
||||
}
|
||||
Marshal.StructureToPtr(ControllerInputEntry, HidPtr, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,47 +4,47 @@ namespace Ryujinx
|
|||
{
|
||||
public enum HidControllerKeys
|
||||
{
|
||||
KEY_A = (1 << 0), //< A
|
||||
KEY_B = (1 << 1), //< B
|
||||
KEY_X = (1 << 2), //< X
|
||||
KEY_Y = (1 << 3), //< Y
|
||||
KEY_LSTICK = (1 << 4), //< Left Stick Button
|
||||
KEY_RSTICK = (1 << 5), //< Right Stick Button
|
||||
KEY_L = (1 << 6), //< L
|
||||
KEY_R = (1 << 7), //< R
|
||||
KEY_ZL = (1 << 8), //< ZL
|
||||
KEY_ZR = (1 << 9), //< ZR
|
||||
KEY_PLUS = (1 << 10), //< Plus
|
||||
KEY_MINUS = (1 << 11), //< Minus
|
||||
KEY_DLEFT = (1 << 12), //< D-Pad Left
|
||||
KEY_DUP = (1 << 13), //< D-Pad Up
|
||||
KEY_DRIGHT = (1 << 14), //< D-Pad Right
|
||||
KEY_DDOWN = (1 << 15), //< D-Pad Down
|
||||
KEY_LSTICK_LEFT = (1 << 16), //< Left Stick Left
|
||||
KEY_LSTICK_UP = (1 << 17), //< Left Stick Up
|
||||
KEY_LSTICK_RIGHT = (1 << 18), //< Left Stick Right
|
||||
KEY_LSTICK_DOWN = (1 << 19), //< Left Stick Down
|
||||
KEY_RSTICK_LEFT = (1 << 20), //< Right Stick Left
|
||||
KEY_RSTICK_UP = (1 << 21), //< Right Stick Up
|
||||
KEY_RSTICK_RIGHT = (1 << 22), //< Right Stick Right
|
||||
KEY_RSTICK_DOWN = (1 << 23), //< Right Stick Down
|
||||
KEY_SL = (1 << 24), //< SL
|
||||
KEY_SR = (1 << 25), //< SR
|
||||
KEY_A = (1 << 0),
|
||||
KEY_B = (1 << 1),
|
||||
KEY_X = (1 << 2),
|
||||
KEY_Y = (1 << 3),
|
||||
KEY_LSTICK = (1 << 4),
|
||||
KEY_RSTICK = (1 << 5),
|
||||
KEY_L = (1 << 6),
|
||||
KEY_R = (1 << 7),
|
||||
KEY_ZL = (1 << 8),
|
||||
KEY_ZR = (1 << 9),
|
||||
KEY_PLUS = (1 << 10),
|
||||
KEY_MINUS = (1 << 11),
|
||||
KEY_DLEFT = (1 << 12),
|
||||
KEY_DUP = (1 << 13),
|
||||
KEY_DRIGHT = (1 << 14),
|
||||
KEY_DDOWN = (1 << 15),
|
||||
KEY_LSTICK_LEFT = (1 << 16),
|
||||
KEY_LSTICK_UP = (1 << 17),
|
||||
KEY_LSTICK_RIGHT = (1 << 18),
|
||||
KEY_LSTICK_DOWN = (1 << 19),
|
||||
KEY_RSTICK_LEFT = (1 << 20),
|
||||
KEY_RSTICK_UP = (1 << 21),
|
||||
KEY_RSTICK_RIGHT = (1 << 22),
|
||||
KEY_RSTICK_DOWN = (1 << 23),
|
||||
KEY_SL = (1 << 24),
|
||||
KEY_SR = (1 << 25),
|
||||
|
||||
// Pseudo-key for at least one finger on the touch screen
|
||||
KEY_TOUCH = (1 << 26),
|
||||
KEY_TOUCH = (1 << 26),
|
||||
|
||||
// Buttons by orientation (for single Joy-Con), also works with Joy-Con pairs, Pro Controller
|
||||
KEY_JOYCON_RIGHT = (1 << 0),
|
||||
KEY_JOYCON_DOWN = (1 << 1),
|
||||
KEY_JOYCON_UP = (1 << 2),
|
||||
KEY_JOYCON_LEFT = (1 << 3),
|
||||
KEY_JOYCON_DOWN = (1 << 1),
|
||||
KEY_JOYCON_UP = (1 << 2),
|
||||
KEY_JOYCON_LEFT = (1 << 3),
|
||||
|
||||
// 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_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN, //< D-Pad Down or Sticks Down
|
||||
KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT, //< D-Pad Left or Sticks Left
|
||||
KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT, //< D-Pad Right or Sticks Right
|
||||
KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP,
|
||||
KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN,
|
||||
KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT,
|
||||
KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT,
|
||||
}
|
||||
|
||||
public enum HidControllerID
|
||||
|
@ -58,14 +58,13 @@ namespace Ryujinx
|
|||
CONTROLLER_PLAYER_7 = 6,
|
||||
CONTROLLER_PLAYER_8 = 7,
|
||||
CONTROLLER_HANDHELD = 8,
|
||||
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.
|
||||
CONTROLLER_UNKNOWN = 9
|
||||
}
|
||||
|
||||
public enum HidControllerJoystick
|
||||
{
|
||||
Joystick_Left = 0,
|
||||
Joystick_Right = 1,
|
||||
Joystick_Left = 0,
|
||||
Joystick_Right = 1,
|
||||
Joystick_Num_Sticks = 2
|
||||
}
|
||||
|
||||
|
@ -82,32 +81,33 @@ namespace Ryujinx
|
|||
|
||||
public enum HidControllerConnectionState
|
||||
{
|
||||
Controller_State_Connected = 1 << 0,
|
||||
Controller_State_Wired = 1 << 1
|
||||
Controller_State_Connected = (1 << 0),
|
||||
Controller_State_Wired = (1 << 1)
|
||||
}
|
||||
|
||||
public enum HidControllerType
|
||||
{
|
||||
ControllerType_ProController = 1 << 0,
|
||||
ControllerType_Handheld = 1 << 1,
|
||||
ControllerType_JoyconPair = 1 << 2,
|
||||
ControllerType_JoyconLeft = 1 << 3,
|
||||
ControllerType_JoyconRight = 1 << 4
|
||||
ControllerType_ProController = (1 << 0),
|
||||
ControllerType_Handheld = (1 << 1),
|
||||
ControllerType_JoyconPair = (1 << 2),
|
||||
ControllerType_JoyconLeft = (1 << 3),
|
||||
ControllerType_JoyconRight = (1 << 4)
|
||||
}
|
||||
|
||||
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 DY;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidControllerMAC //Size: 0x20
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
public struct HidControllerMAC
|
||||
{
|
||||
public ulong Timestamp;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
|
@ -116,7 +116,8 @@ namespace Ryujinx
|
|||
public ulong Timestamp_2;
|
||||
}
|
||||
|
||||
public struct HidControllerHeader //Size: 0x28
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x28)]
|
||||
public struct HidControllerHeader
|
||||
{
|
||||
public uint Type;
|
||||
public uint IsHalf;
|
||||
|
@ -130,7 +131,8 @@ namespace Ryujinx
|
|||
public uint RightColorButtons;
|
||||
}
|
||||
|
||||
public struct HidControllerLayoutHeader //Size: 0x20
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
public struct HidControllerLayoutHeader
|
||||
{
|
||||
public ulong TimestampTicks;
|
||||
public ulong NumEntries;
|
||||
|
@ -138,8 +140,8 @@ namespace Ryujinx
|
|||
public ulong MaxEntryIndex;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidControllerInputEntry //Size: 0x30
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x30)]
|
||||
public struct HidControllerInputEntry
|
||||
{
|
||||
public ulong Timestamp;
|
||||
public ulong Timestamp_2;
|
||||
|
@ -149,16 +151,16 @@ namespace Ryujinx
|
|||
public ulong ConnectionState;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidControllerLayout //Size: 0x350
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x350)]
|
||||
public struct HidControllerLayout
|
||||
{
|
||||
public HidControllerLayoutHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
|
||||
public HidControllerInputEntry[] Entries;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidController //Size: 0x5000
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x5000)]
|
||||
public struct HidController
|
||||
{
|
||||
public HidControllerHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace Ryujinx
|
||||
{
|
||||
public struct HidKeyboardHeader //Size: 0x20
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
public struct HidKeyboardHeader
|
||||
{
|
||||
public ulong TimestampTicks;
|
||||
public ulong NumEntries;
|
||||
|
@ -10,8 +11,8 @@ namespace Ryujinx
|
|||
public ulong MaxEntryIndex;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidKeyboardEntry //Size: 0x38
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x38)]
|
||||
public struct HidKeyboardEntry
|
||||
{
|
||||
public ulong Timestamp;
|
||||
public ulong Timestamp_2;
|
||||
|
@ -20,8 +21,8 @@ namespace Ryujinx
|
|||
public uint[] Keys;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidKeyboard //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidKeyboard
|
||||
{
|
||||
public HidKeyboardHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace Ryujinx
|
||||
{
|
||||
public struct HidMouseHeader //Size: 0x20
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
public struct HidMouseHeader
|
||||
{
|
||||
public ulong TimestampTicks;
|
||||
public ulong NumEntries;
|
||||
|
@ -10,7 +11,8 @@ namespace Ryujinx
|
|||
public ulong MaxEntryIndex;
|
||||
}
|
||||
|
||||
public struct HidMouseEntry //Size: 0x30
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x30)]
|
||||
public struct HidMouseEntry
|
||||
{
|
||||
public ulong Timestamp;
|
||||
public ulong Timestamp_2;
|
||||
|
@ -23,8 +25,8 @@ namespace Ryujinx
|
|||
public ulong Buttons;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidMouse //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidMouse
|
||||
{
|
||||
public HidMouseHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace Ryujinx
|
||||
{
|
||||
public struct HidTouchScreenHeader //Size: 0x28
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x28)]
|
||||
public struct HidTouchScreenHeader
|
||||
{
|
||||
public ulong TimestampTicks;
|
||||
public ulong NumEntries;
|
||||
|
@ -11,13 +12,15 @@ namespace Ryujinx
|
|||
public ulong Timestamp;
|
||||
}
|
||||
|
||||
public struct HidTouchScreenEntryHeader //Size: 0x10
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct HidTouchScreenEntryHeader
|
||||
{
|
||||
public ulong Timestamp;
|
||||
public ulong NumTouches;
|
||||
}
|
||||
|
||||
public struct HidTouchScreenEntryTouch //Size: 0x28
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x28)]
|
||||
public struct HidTouchScreenEntryTouch
|
||||
{
|
||||
public ulong Timestamp;
|
||||
public uint Padding;
|
||||
|
@ -30,8 +33,8 @@ namespace Ryujinx
|
|||
public uint Padding_2;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidTouchScreenEntry //Size: 0x298
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x298)]
|
||||
public struct HidTouchScreenEntry
|
||||
{
|
||||
public HidTouchScreenEntryHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
|
@ -39,8 +42,8 @@ namespace Ryujinx
|
|||
public ulong Unknown;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidTouchScreen //Size: 0x3000
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x3000)]
|
||||
public struct HidTouchScreen
|
||||
{
|
||||
public HidTouchScreenHeader Header;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
|
||||
|
|
|
@ -2,78 +2,78 @@
|
|||
|
||||
namespace Ryujinx
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidSharedMemHeader //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidSharedMemHeader
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection1 //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidUnknownSection1
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection2 //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidUnknownSection2
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection3 //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidUnknownSection3
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection4 //Size: 0x400
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x400)]
|
||||
public struct HidUnknownSection4
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection5 //Size: 0x200
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
public struct HidUnknownSection5
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection6 //Size: 0x200
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
public struct HidUnknownSection6
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection7 //Size: 0x200
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
public struct HidUnknownSection7
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x200)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection8 //Size: 0x800
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x800)]
|
||||
public struct HidUnknownSection8
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x800)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidControllerSerials //Size: 0x4000
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x4000)]
|
||||
public struct HidControllerSerials
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4000)]
|
||||
public byte[] Padding;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HidUnknownSection9 //Size: 0x4600
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x4600)]
|
||||
public struct HidUnknownSection9
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4600)]
|
||||
public byte[] Padding;
|
||||
|
|
|
@ -330,7 +330,7 @@ void main(void) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue