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();
        }
示例#2
0
 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;
 }
示例#3
0
 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;
 }
示例#4
0
        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;

            Id = InputDeviceUtils.DeviceNameToGuid(window.SdlHandle.ToString() + Name);
        }
示例#5
0
        public MouseSDL(InputSourceSDL source, Window uiControl)
        {
            Source         = source;
            this.uiControl = uiControl;

            uiControl.MouseMoveActions            += OnMouseMoveEvent;
            uiControl.PointerButtonPressActions   += OnMouseInputEvent;
            uiControl.PointerButtonReleaseActions += OnMouseInputEvent;
            uiControl.MouseWheelActions           += OnMouseWheelEvent;
            uiControl.ResizeEndActions            += OnSizeChanged;
            OnSizeChanged(new SDL.SDL_WindowEvent());
        }
示例#6
0
        public MouseSDL(InputSourceSDL source, Window uiControl)
        {
            Source         = source;
            this.uiControl = uiControl;

            uiControl.MouseMoveActions            += OnMouseMoveEvent;
            uiControl.PointerButtonPressActions   += OnMouseInputEvent;
            uiControl.PointerButtonReleaseActions += OnMouseInputEvent;
            uiControl.MouseWheelActions           += OnMouseWheelEvent;
            uiControl.ResizeEndActions            += OnSizeChanged;
            OnSizeChanged(new SDL.SDL_WindowEvent());

            Id = InputDeviceUtils.DeviceNameToGuid(uiControl.SdlHandle.ToString() + Name);
        }
示例#7
0
        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());
        }
示例#8
0
        public PointerSDL(InputSourceSDL source, Window uiControl)
        {
            Source         = source;
            this.uiControl = uiControl;

            // Disable Touch-Mouse synthesis
            SDL.SetHint(Sdl.HintTouchMouseEvents, "false");

            uiControl.FingerMoveActions    += OnFingerMoveEvent;
            uiControl.FingerPressActions   += OnFingerPressEvent;
            uiControl.FingerReleaseActions += OnFingerReleaseEvent;

            uiControl.ResizeEndActions += OnSizeChanged;
            OnSizeChanged(new WindowEvent());

            Id = InputDeviceUtils.DeviceNameToGuid(uiControl.SdlHandle.ToString() + Name);
        }