mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-29 14:38:25 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
73
brutal.sdl/Brutal.Sdl/Manual/SdlGamepadBinding.cs
Normal file
73
brutal.sdl/Brutal.Sdl/Manual/SdlGamepadBinding.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
namespace Brutal.SdlApi;
|
||||
|
||||
/// <summary>
|
||||
/// A mapping between one joystick input and a gamepad control (<c>SDL_GamepadBinding</c>).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Hand-written rather than generated: the native <c>SDL_GamepadBinding</c> struct contains two
|
||||
/// anonymous nested unions (<c>input</c>, <c>output</c>), which the generator's struct pass cannot
|
||||
/// mirror as a flat blittable type (see <c>Generated/SKIPPED.md</c>'s "Skipped struct types"
|
||||
/// section). This explicit-layout struct reproduces the native field offsets by hand instead, so
|
||||
/// Task 4's <see cref="Sdl.Gamepad.GetGamepadBindings"/> can copy the native bytes directly via a
|
||||
/// pointer cast.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Layout (verified against <c>SDL_gamepad.h</c>): <c>input_type</c> (4 bytes) at offset 0; the
|
||||
/// <c>input</c> union (its largest member, the axis triple of three <c>int</c>s, is 12 bytes) at
|
||||
/// offset 4; <c>output_type</c> (4 bytes) at offset 16; the <c>output</c> union (again a 12-byte
|
||||
/// axis triple at its largest) at offset 20. Total size 32 bytes, 4-byte aligned, no trailing
|
||||
/// padding needed.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 32)]
|
||||
public struct SdlGamepadBinding
|
||||
{
|
||||
/// <summary>Which kind of joystick input <see cref="InputButton"/>/<see cref="InputAxis"/>/<see cref="InputHat"/> describes.</summary>
|
||||
[FieldOffset(0)]
|
||||
public SdlGamepadBindingType InputType;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Button"/>.</summary>
|
||||
[FieldOffset(4)]
|
||||
public int InputButton;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(4)]
|
||||
public int InputAxis;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(8)]
|
||||
public int InputAxisMin;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(12)]
|
||||
public int InputAxisMax;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Hat"/>.</summary>
|
||||
[FieldOffset(4)]
|
||||
public int InputHat;
|
||||
|
||||
/// <summary>Valid when <see cref="InputType"/> is <see cref="SdlGamepadBindingType.Hat"/>.</summary>
|
||||
[FieldOffset(8)]
|
||||
public int InputHatMask;
|
||||
|
||||
/// <summary>Which kind of gamepad control <see cref="OutputButton"/>/<see cref="OutputAxis"/> describes.</summary>
|
||||
[FieldOffset(16)]
|
||||
public SdlGamepadBindingType OutputType;
|
||||
|
||||
/// <summary>Valid when <see cref="OutputType"/> is <see cref="SdlGamepadBindingType.Button"/>.</summary>
|
||||
[FieldOffset(20)]
|
||||
public SdlGamepadButton OutputButton;
|
||||
|
||||
/// <summary>Valid when <see cref="OutputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(20)]
|
||||
public SdlGamepadAxis OutputAxis;
|
||||
|
||||
/// <summary>Valid when <see cref="OutputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(24)]
|
||||
public int OutputAxisMin;
|
||||
|
||||
/// <summary>Valid when <see cref="OutputType"/> is <see cref="SdlGamepadBindingType.Axis"/>.</summary>
|
||||
[FieldOffset(28)]
|
||||
public int OutputAxisMax;
|
||||
}
|
||||
Loading…
Reference in a new issue