public unsafe Sdl2ControllerTracker(int index) { _controller = SDL_GameControllerOpen(index); SDL_Joystick joystick = SDL_GameControllerGetJoystick(_controller); _controllerIndex = SDL_JoystickInstanceID(joystick); ControllerName = Marshal.PtrToStringUTF8((IntPtr)SDL_GameControllerName(_controller)); Sdl2Events.Subscribe(ProcessEvent); }
public GameController(string name, SDL_GameController controller, SDL_Joystick joystick) { Name = name; Controller = controller; Joystick = joystick; _buttonsDown = new Dictionary <GamepadButton, float>(); _buttonsDownThisFrame = new HashSet <GamepadButton>(); _buttonsUpThisFrame = new Dictionary <GamepadButton, float>(); _axes = new Dictionary <GamepadAxis, float>(); foreach (GamepadAxis axis in Enum.GetValues(typeof(GamepadAxis))) { _axes.Add(axis, 0.0f); } }