public GameControllerSDL(InputSourceSDL source, int deviceIndex) { Source = source; joystick = SDL.SDL_JoystickOpen(deviceIndex); Id = Guid.NewGuid(); // Should be unique ProductId = SDL.SDL_JoystickGetGUID(joystick); // Will identify the type of controller Name = SDL.SDL_JoystickName(joystick); InstanceId = SDL.SDL_JoystickInstanceID(joystick); for (int i = 0; i < SDL.SDL_JoystickNumButtons(joystick); i++) { buttonInfos.Add(new GameControllerButtonInfo { Name = $"Button {i}" }); } for (int i = 0; i < SDL.SDL_JoystickNumAxes(joystick); i++) { axisInfos.Add(new GameControllerAxisInfo { Name = $"Axis {i}" }); } for (int i = 0; i < SDL.SDL_JoystickNumHats(joystick); i++) { povControllerInfos.Add(new GameControllerDirectionInfo { Name = $"Hat {i}" }); } InitializeButtonStates(); }
public GamePadSDL(InputSourceSDL source, InputManager inputManager, GameControllerSDL controller, GamePadLayout layout) : base(inputManager, controller, layout) { Source = source; Name = controller.Name; Id = controller.Id; ProductId = controller.ProductId; }
public KeyboardSDL(InputSourceSDL source, Window window) { Source = source; this.window = window; this.window.KeyDownActions += OnKeyEvent; this.window.KeyUpActions += OnKeyEvent; this.window.TextInputActions += OnTextInputActions; this.window.TextEditingActions += OnTextEditingActions; }
public MouseSDL(InputSourceSDL source, GameBase game, Window uiControl) { Source = source; this.game = game; this.uiControl = uiControl; uiControl.MouseMoveActions += OnMouseMoveEvent; uiControl.PointerButtonPressActions += OnMouseInputEvent; uiControl.PointerButtonReleaseActions += OnMouseInputEvent; uiControl.MouseWheelActions += OnMouseWheelEvent; uiControl.ResizeEndActions += OnSizeChanged; OnSizeChanged(new SDL.SDL_WindowEvent()); }
public PointerSDL(InputSourceSDL source, Window uiControl) { Source = source; this.uiControl = uiControl; // Disable Touch-Mouse synthesis SDL.SDL_SetHint(SDL.SDL_HINT_TOUCH_MOUSE_EVENTS, "false"); uiControl.FingerMoveActions += OnFingerMoveEvent; uiControl.FingerPressActions += OnFingerPressEvent; uiControl.FingerReleaseActions += OnFingerReleaseEvent; uiControl.ResizeEndActions += OnSizeChanged; OnSizeChanged(new SDL.SDL_WindowEvent()); }