예제 #1
0
        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 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());
        }