feat: Added wiimote support and cleaned up the project

This commit is contained in:
Gerard Gascón 2024-06-15 01:47:00 +02:00
parent 36574bdf46
commit baf15cdb0f
25 changed files with 263 additions and 69 deletions

10
Win32Api/HardwareInput.cs Normal file
View file

@ -0,0 +1,10 @@
using System.Runtime.InteropServices;
namespace Win32Api;
[StructLayout(LayoutKind.Sequential)]
public struct HardwareInput {
public uint uMsg;
public ushort wParamL;
public ushort wParamH;
}

9
Win32Api/Input.cs Normal file
View file

@ -0,0 +1,9 @@
using System.Runtime.InteropServices;
namespace Win32Api;
[StructLayout(LayoutKind.Sequential)]
public struct Input {
public uint type;
public InputUnion u;
}

10
Win32Api/InputUnion.cs Normal file
View file

@ -0,0 +1,10 @@
using System.Runtime.InteropServices;
namespace Win32Api;
[StructLayout(LayoutKind.Explicit)]
public struct InputUnion {
[FieldOffset(0)] public MouseInput mi;
[FieldOffset(0)] public KeyboardInput ki;
[FieldOffset(0)] public HardwareInput hi;
}

12
Win32Api/KeyboardInput.cs Normal file
View file

@ -0,0 +1,12 @@
using System.Runtime.InteropServices;
namespace Win32Api;
[StructLayout(LayoutKind.Sequential)]
public struct KeyboardInput {
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}

13
Win32Api/MouseInput.cs Normal file
View file

@ -0,0 +1,13 @@
using System.Runtime.InteropServices;
namespace Win32Api;
[StructLayout(LayoutKind.Sequential)]
public struct MouseInput {
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}

8
Win32Api/Win32Api.cs Normal file
View file

@ -0,0 +1,8 @@
using System.Runtime.InteropServices;
namespace Win32Api;
public static class Win32Api {
[DllImport("user32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, Input[] pInputs, int cbSize);
}

9
Win32Api/Win32Api.csproj Normal file
View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>