예제 #1
0
        public Sdl2InputDriver()
        {
            lock (SDL.Sync)
            {
                SDL.GameControllerEventState(EventState.Enable);
                SDL.JoystickEventState(EventState.Enable);

                EventFilterDelegate = Marshal.GetFunctionPointerForDelegate(EventFilterDelegate_GCUnsafe);
                driver_handle       = new IntPtr(count++);
                DriverHandles.Add(driver_handle, this);
                SDL.AddEventWatch(EventFilterDelegate, driver_handle);
                if (SDL.InitSubSystem(SystemFlags.JOYSTICK) < 0)
                {
                    Debug.Print("[SDL2] InputDriver failed to init Joystick subsystem. Error: {0}", SDL.GetError());
                }
                if (SDL.InitSubSystem(SystemFlags.GAMECONTROLLER) < 0)
                {
                    Debug.Print("[SDL2] InputDriver failed to init GameController subsystem. Error: {0}", SDL.GetError());
                }
            }
        }