0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMem/StructArrayHelpers.cs
mageven 2365ddfc36
HID SharedMem Rework (#1003)
* Delete old HLE.Input

* Add new HLE Input.

git shows Hid.cs as modified because of the same name. It is new.

* Change HID Service

* Change Ryujinx UI to reflect new Input

* Add basic ControllerApplet

* Add DebugPad

Should fix Kirby Star Allies

* Address Ac_K's comments

* Moved all of HLE.Input to Services.Hid
* Separated all structs and enums each to a file
* Removed vars
* Made some naming changes to align with switchbrew
* Added official joycon colors

As an aside, fixed a mistake in touchscreen headers and added checks to
important SharedMem structs at init time.

* Further address Ac_K's comments

* Addressed gdkchan's and some more Ac_K's comments

* Address AcK's review comments

* Address AcK's second review comments

* Replace missed Marshal.SizeOf and address gdkchan's comments
2020-04-03 11:10:02 +11:00

53 lines
No EOL
1.6 KiB
C#

using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid
{
struct Array2<T> where T : unmanaged
{
T e0, e1;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 2)[index];
public int Length => 2;
}
struct Array3<T> where T : unmanaged
{
T e0, e1, e2;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 3)[index];
public int Length => 3;
}
struct Array6<T> where T : unmanaged
{
T e0, e1, e2, e3, e4, e5;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 6)[index];
public int Length => 6;
}
struct Array7<T> where T : unmanaged
{
T e0, e1, e2, e3, e4, e5, e6;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 7)[index];
public int Length => 7;
}
struct Array10<T> where T : unmanaged
{
T e0, e1, e2, e3, e4, e5, e6, e7, e8, e9;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 10)[index];
public int Length => 10;
}
struct Array16<T> where T : unmanaged
{
T e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 16)[index];
public int Length => 16;
}
struct Array17<T> where T : unmanaged
{
T e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16;
public ref T this[int index] => ref MemoryMarshal.CreateSpan(ref e0, 17)[index];
public int Length => 17;
}
}