internal unsafe JoystickState(IJoystick joystick) { Name = joystick.Name; Index = joystick.Index; IsConnected = joystick.IsConnected; var axes = joystick.Axes; var buttons = joystick.Buttons; var hats = joystick.Hats; _axes = (Axis *)Marshal.AllocHGlobal((_axisCount = axes.Count) * sizeof(Axis)); _buttons = (Button *)Marshal.AllocHGlobal((_buttonCount = buttons.Count) * sizeof(Button)); _hats = (Hat *)Marshal.AllocHGlobal((_hatCount = hats.Count) * sizeof(Hat)); for (var i = 0; i < _axisCount; i++) { _axes[i] = axes[i]; } for (var i = 0; i < _buttonCount; i++) { _buttons[i] = buttons[i]; } for (var i = 0; i < _hatCount; i++) { _hats[i] = hats[i]; } Deadzone = joystick.Deadzone; }
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; }