public GlfwGamepad(int i) { var hasState = GlfwProvider.GLFW.Value.GetGamepadState(i, out var state); Index = i; _buttons = (Button *)Marshal.AllocHGlobal(GamepadButtonCount * sizeof(Button)); _thumbsticks = (Thumbstick *)Marshal.AllocHGlobal(GamepadThumbstickCount * sizeof(Thumbstick)); _triggers = (Trigger *)Marshal.AllocHGlobal(GamepadTriggerCount * sizeof(Trigger)); Buttons = new GlfwReadOnlyList <Button>(_buttons, GamepadButtonCount); Thumbsticks = new GlfwReadOnlyList <Thumbstick>(_thumbsticks, GamepadThumbstickCount); Triggers = new GlfwReadOnlyList <Trigger>(_triggers, GamepadTriggerCount); _connected = hasState; for (int j = 0; j < GamepadButtonCount; j++) { _buttons[j] = new Button((ButtonName)j, j, hasState && state.Buttons[j] == (int)InputAction.Press); } for (int j = 0; j < GamepadThumbstickCount; j++) { _thumbsticks[j] = new Thumbstick(j, 0, 0); } for (int j = 0; j < GamepadTriggerCount; j++) { _triggers[j] = new Trigger(j, 0); } }
public unsafe GlfwJoystick(int i) { Index = i; _axes = (Axis *)Marshal.AllocHGlobal(0); _buttons = (Button *)Marshal.AllocHGlobal(0); _hats = (Hat *)Marshal.AllocHGlobal(0); Axes = new GlfwReadOnlyList <Axis>(_axes, 0); Buttons = new GlfwReadOnlyList <Button>(_buttons, 0); Hats = new GlfwReadOnlyList <Hat>(_hats, 0); _connected = IsConnected; }
public unsafe GlfwMouse() { _scrollWheel = (ScrollWheel *)Marshal.AllocHGlobal(sizeof(ScrollWheel)); ScrollWheels = new GlfwReadOnlyList <ScrollWheel>(_scrollWheel, 1); }