Beispiel #1
0
 public InputManagerComponent()
 {
     //Informs SDL that this Subsystem is Active.
     SDL2.SDL.SDL_InitSubSystem((uint)SDL_INIT_FLAGS.SDL_INIT_EVENTS);
     myFilterBase = new SDL_EventFilter(InputFilter);
     SDL_SetEventFilter(myFilterBase, IntPtr.Zero);
 }
Beispiel #2
0
        protected override void Initialize()
        {
            Log.Trace("Setup GraphicDeviceManager");

            _graphicDeviceManager.PreparingDeviceSettings += (sender, e) => e.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.DiscardContents;
            if (_graphicDeviceManager.GraphicsDevice.Adapter.IsProfileSupported(GraphicsProfile.HiDef))
            {
                _graphicDeviceManager.GraphicsProfile = GraphicsProfile.HiDef;
            }

            _graphicDeviceManager.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            _graphicDeviceManager.SynchronizeWithVerticalRetrace = false; // TODO: V-Sync option
            _graphicDeviceManager.ApplyChanges();

            Window.ClientSizeChanged += WindowOnClientSizeChanged;
            Window.AllowUserResizing  = true;
            Window.Title              = $"ClassicUO - {CUOEnviroment.Version}";
            IsMouseVisible            = Settings.GlobalSettings.RunMouseInASeparateThread;

            IsFixedTimeStep   = false; // Settings.GlobalSettings.FixedTimeStep;
            TargetElapsedTime = TimeSpan.FromMilliseconds(1000.0f / 250);

            SetRefreshRate(Settings.GlobalSettings.FPS);
            _uoSpriteBatch = new UltimaBatcher2D(GraphicsDevice);

            _filter = new SDL_EventFilter(HandleSDLEvent);
            SDL.SDL_AddEventWatch(_filter, IntPtr.Zero);

            base.Initialize();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SDL2UltravioletContext"/> class.
 /// </summary>
 /// <param name="host">The object that is hosting the Ultraviolet context.</param>
 /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
 protected unsafe SDL2UltravioletContext(IUltravioletHost host, UltravioletConfiguration configuration)
     : base(host, configuration)
 {
     eventFilter    = new SDL_EventFilter(SDLEventFilter);
     eventFilterPtr = Marshal.GetFunctionPointerForDelegate(eventFilter);
     SDL_SetEventFilter(eventFilterPtr, IntPtr.Zero);
 }
Beispiel #4
0
        protected override void Initialize()
        {
            // if (_graphicDeviceManager.GraphicsDevice.Adapter.IsProfileSupported(GraphicsProfile.HiDef))
            //     _graphicDeviceManager.GraphicsProfile = GraphicsProfile.HiDef;
            _graphicDeviceManager.ApplyChanges();

            SetRefreshRate(Settings.GlobalSettings.FPS);
            _uoSpriteBatch = new UltimaBatcher2D(GraphicsDevice);

            _filter = new SDL_EventFilter(HandleSDLEvent);
            SDL.SDL_AddEventWatch(_filter, IntPtr.Zero);

            base.Initialize();
        }
Beispiel #5
0
        //private readonly Queue<InputEvent> _nextEvents = new Queue<InputEvent>();
        //private SDL_Keycode _lastKey;
        //private InputMouseEvent _lastMouseDown, _lastMouseClick;
        //private float _lastMouseDownTime, _lastMouseClickTime;
        //private bool _leftButtonPressed;
        //private bool _mouseIsDragging;
        //private float _time = -1f;

        public InputManager()
        {
            _hookDel = HookFunc;

            //IntPtr surface = SDL_LoadBMP(Path.Combine(Bootstrap.ExeDirectory, "cursor.bmp"));
            //_cursorPtr = SDL_CreateColorCursor(surface, 0, 0);
            //SDL_ShowCursor(1);
            //SDL_SetCursor(_cursorPtr);

            //_hitTestDel = Callback;
            //SDL_SetWindowHitTest(Microsoft.Xna.Framework.Input.Mouse.WindowHandle, _hitTestDel, IntPtr.Zero);

            SDL_AddEventWatch(_hookDel, IntPtr.Zero);
            //SDL_SetEventFilter(_hookDel, IntPtr.Zero);
        }
Beispiel #6
0
 public WatchReg(EventWatcher func)
 {
     this.func = func;
     del = (IntPtr ud, ref Event v) =>
     {
         try
         {
             func(ref v);
         }
         catch (Exception e)
         {
             SDL.OnUnhandledException(e, true);
         }
         return 1;
     };
     fp = Marshal.GetFunctionPointerForDelegate(del);
 }
Beispiel #7
0
        /// <summary>
        /// TODO: Move out of interface
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="userdata"></param>
        /// <returns></returns>
        public static SDL_BOOL SDL_GetEventFilter(out SDL_EventFilter filter, out IntPtr userdata)
        {
            IntPtr   result = IntPtr.Zero;
            SDL_BOOL retval = SDL_GetEventFilter(out result, out userdata);

            if (result != IntPtr.Zero)
            {
                filter = (SDL_EventFilter)Marshal.GetDelegateForFunctionPointer(
                    result,
                    typeof(SDL_EventFilter)
                    );
            }
            else
            {
                filter = null;
            }

            return(retval);
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SDL2UltravioletContext"/> class.
        /// </summary>
        /// <param name="host">The object that is hosting the Ultraviolet context.</param>
        /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
        public unsafe SDL2UltravioletContext(IUltravioletHost host, SDL2UltravioletConfiguration configuration)
            : base(host, configuration)
        {
            Contract.Require(configuration, nameof(configuration));

            if (!InitSDL(configuration))
            {
                throw new SDL2Exception();
            }

            this.onWindowDrawing = (context, time, window) =>
                                   ((SDL2UltravioletContext)context).OnWindowDrawing(time, window);
            this.onWindowDrawn = (context, time, window) =>
                                 ((SDL2UltravioletContext)context).OnWindowDrawn(time, window);

            eventFilter    = new SDL_EventFilter(SDLEventFilter);
            eventFilterPtr = Marshal.GetFunctionPointerForDelegate(eventFilter);
            SDL_SetEventFilter(eventFilterPtr, IntPtr.Zero);

            LoadSubsystemAssemblies(configuration);
            this.swapChainManager = IsRunningInServiceMode ? new DummySwapChainManager(this) : SwapChainManager.Create();

            this.platform = InitializePlatformSubsystem(configuration);
            this.graphics = InitializeGraphicsSubsystem(configuration);

            if (!this.platform.IsPrimaryWindowInitialized)
            {
                throw new InvalidOperationException(UltravioletStrings.PrimaryWindowMustBeInitialized);
            }

            this.audio   = InitializeAudioSubsystem(configuration);
            this.input   = InitializeInputSubsystem();
            this.content = InitializeContentSubsystem();
            this.ui      = InitializeUISubsystem(configuration);

            PumpEvents();

            InitializeContext();
            InitializeViewProvider(configuration);
            InitializePlugins(configuration);
        }
Beispiel #9
0
		public extern static SDL_EventFilter SDL_SetEventFilter(SDL_EventFilter filter);
Beispiel #10
0
 public static void Initialize()
 {
     _hookDel = HookFunc;
     SDL_AddEventWatch(_hookDel, IntPtr.Zero);
 }
Beispiel #11
0
 public static void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) => s_sdl_filterEvents(filter, userdata);
Beispiel #12
0
 public static void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) => s_sdl_setEventFilter(filter, userdata);
Beispiel #13
0
 public static void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) => s_sdl_addEventWatch(filter, userdata);
Beispiel #14
0
 public static extern void SDL_SetEventFilter(SDL_EventFilter filter);
Beispiel #15
0
 public extern static SDL_EventFilter SDL_SetEventFilter(SDL_EventFilter filter);
Beispiel #16
0
 public InputManager()
 {
     _hookDel = HookFunc;
     SDL_AddEventWatch(_hookDel, IntPtr.Zero);
 }
Beispiel #17
0
 internal static extern void SDL_FilterEvents(SDL_EventFilter filter, IntPtr userdata);
Beispiel #18
0
 internal static extern void SDL_DelEventWatch(SDL_EventFilter filter, IntPtr userdata);
Beispiel #19
0
 internal static extern void SDL_SetEventFilter(SDL_EventFilter filter, IntPtr userdata);
Beispiel #20
0
 public void RegisterEventFilter(SDL_EventFilter mouseInputFilter)
 {
     myFilter += mouseInputFilter;
 }