mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 10:25:31 +00:00
Added GameControllerGetBind APIs
This commit is contained in:
parent
6fc679c4ba
commit
c51c4934df
|
@ -137,7 +137,28 @@ namespace OpenTK.Platform.SDL2
|
||||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetAxis", ExactSpelling = true)]
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetAxis", ExactSpelling = true)]
|
||||||
public static extern short GameControllerGetAxis(IntPtr gamecontroller, GameControllerAxis axis);
|
public static extern short GameControllerGetAxis(IntPtr gamecontroller, GameControllerAxis axis);
|
||||||
|
|
||||||
/// <summary>>
|
/// <summary>
|
||||||
|
/// Gets the SDL joystick layer binding for the specified game controller axis
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gamecontroller">Pointer to a game controller instance returned by <c>GameControllerOpen</c>.</param>
|
||||||
|
/// <param name="axis">A value from the <c>GameControllerAxis</c> enumeration</param>
|
||||||
|
/// <returns>A GameControllerButtonBind instance describing the specified binding</returns>
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetBindForAxis", ExactSpelling = true)]
|
||||||
|
public static extern GameControllerButtonBind GameControllerGetBindForAxis(IntPtr gamecontroller, GameControllerAxis axis);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the SDL joystick layer binding for the specified game controller button
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gamecontroller">Pointer to a game controller instance returned by <c>GameControllerOpen</c>.</param>
|
||||||
|
/// <param name="axis">A value from the <c>GameControllerButton</c> enumeration</param>
|
||||||
|
/// <returns>A GameControllerButtonBind instance describing the specified binding</returns>
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetBindForButton", ExactSpelling = true)]
|
||||||
|
public static extern GameControllerButtonBind GameControllerGetBindForButton(
|
||||||
|
IntPtr gamecontroller, GameControllerButton button);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
/// Gets the current state of a button on a game controller.
|
/// Gets the current state of a button on a game controller.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gamecontroller">A game controller handle previously opened with <c>GameControllerOpen</c>.</param>
|
/// <param name="gamecontroller">A game controller handle previously opened with <c>GameControllerOpen</c>.</param>
|
||||||
|
@ -147,6 +168,15 @@ namespace OpenTK.Platform.SDL2
|
||||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetButton", ExactSpelling = true)]
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetButton", ExactSpelling = true)]
|
||||||
public static extern bool GameControllerGetButton(IntPtr gamecontroller, GameControllerButton button);
|
public static extern bool GameControllerGetButton(IntPtr gamecontroller, GameControllerButton button);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve the joystick handle that corresponds to the specified game controller.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gamecontroller">A game controller handle previously opened with <c>GameControllerOpen</c>.</param>
|
||||||
|
/// <returns>A handle to a joystick, or IntPtr.Zero in case of error. The pointer is owned by the callee. Use <c>SDL.GetError</c> to retrieve error information</returns>
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GameControllerGetJoystick", ExactSpelling = true)]
|
||||||
|
public static extern IntPtr GameControllerGetJoystick(IntPtr gamecontroller);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens a game controller for use.
|
/// Opens a game controller for use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -587,6 +617,14 @@ namespace OpenTK.Platform.SDL2
|
||||||
Max
|
Max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum GameControllerBindType : byte
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Button,
|
||||||
|
Axis,
|
||||||
|
Hat
|
||||||
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
enum HatPosition : byte
|
enum HatPosition : byte
|
||||||
{
|
{
|
||||||
|
@ -1277,6 +1315,21 @@ namespace OpenTK.Platform.SDL2
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
struct GameControllerButtonBind
|
||||||
|
{
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public GameControllerBindType BindType;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public Button Button;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public GameControllerAxis Axis;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public int Hat;
|
||||||
|
[FieldOffset(8)]
|
||||||
|
public int HatMask;
|
||||||
|
}
|
||||||
|
|
||||||
struct JoyAxisEvent
|
struct JoyAxisEvent
|
||||||
{
|
{
|
||||||
public EventType Type;
|
public EventType Type;
|
||||||
|
|
Loading…
Reference in a new issue