コード例 #1
0
        public override void Close()
        {
            lock (sync)
            {
                if (Exists && !must_destroy && !is_in_closing_event)
                {
                    Debug.Print("SDL2 closing window {0}", window.Handle);

                    Event e = new Event();
                    e.Type = EventType.WINDOWEVENT;
                    e.Window.Event = WindowEventID.CLOSE;
                    e.Window.WindowID = window_id;
                    lock (SDL.Sync)
                    {
                        SDL.PushEvent(ref e);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Sdl2.cs プロジェクト: PieterMarius/PhysicsEngine
 public static int PeepEvents(ref Event e, EventAction action, EventType min, EventType max)
 {
     unsafe
     {
         fixed (Event* pe = &e)
         {
             return PeepEvents(pe, 1, action, min, max);
         }
     }
 }
コード例 #3
0
        int ProcessEvent(ref Event ev)
        {
            bool processed = false;

            try
            {
                Sdl2NativeWindow window = null;

                switch (ev.Type)
                {
                    case EventType.WINDOWEVENT:
                        if (windows.TryGetValue(ev.Window.WindowID, out window))
                        {
                            ProcessWindowEvent(window, ev.Window);
                            processed = true;
                        }
                        break;

                    case EventType.TEXTINPUT:
                        if (windows.TryGetValue(ev.Text.WindowID, out window))
                        {
                            ProcessTextInputEvent(window, ev.Text);
                            processed = true;
                        }
                        break;

                    case EventType.KEYDOWN:
                    case EventType.KEYUP:
                        if (windows.TryGetValue(ev.Key.WindowID, out window))
                        {
                            ProcessKeyEvent(window, ev);
                            processed = true;
                        }
                        break;

                    case EventType.MOUSEBUTTONDOWN:
                    case EventType.MOUSEBUTTONUP:
                        if (windows.TryGetValue(ev.Button.WindowID, out window))
                        {
                            ProcessMouseButtonEvent(window, ev.Button);
                            processed = true;
                        }
                        break;

                    case EventType.MOUSEMOTION:
                        if (windows.TryGetValue(ev.Motion.WindowID, out window))
                        {
                            ProcessMouseMotionEvent(window, ev.Motion);
                            processed = true;
                        }
                        break;

                    case EventType.MOUSEWHEEL:
                        if (windows.TryGetValue(ev.Wheel.WindowID, out window))
                        {
                            ProcessMouseWheelEvent(window, ev.Wheel);
                            processed = true;
                        }
                        break;

                    case EventType.QUIT:
                        Debug.WriteLine("Sdl2 application quit");
                        break;
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.ToString());
            }

            return processed ? 0 : 1;
        }
コード例 #4
0
 static void ProcessKeyEvent(Sdl2NativeWindow window, Event ev)
 {
     bool key_pressed = ev.Key.State == State.Pressed;
     Key key = TranslateKey(ev.Key.Keysym.Scancode);
     if (key_pressed)
     {
         window.OnKeyDown(key, ev.Key.Repeat > 0);
     }
     else
     {
         window.OnKeyUp(key);
     }
 }
コード例 #5
0
        public void Close()
        {
            lock (sync)
            {
                if (Exists)
                {
                    Debug.Print("SDL2 destroying window {0}", window.Handle);

                    Event e = new Event();
                    e.Type = EventType.WINDOWEVENT;
                    e.Window.Event = WindowEventID.CLOSE;
                    e.Window.WindowID = window_id;
                    lock (SDL.Sync)
                    {
                        SDL.PushEvent(ref e);
                    }
                }
            }
        }
コード例 #6
0
ファイル: Sdl2NativeWindow.cs プロジェクト: raphaelts3/opentk
 static void ProcessWheelEvent(Sdl2NativeWindow window, Event ev)
 {
     //window.mouse.Wheel += ev.wheel.y;
 }
コード例 #7
0
ファイル: Sdl2NativeWindow.cs プロジェクト: raphaelts3/opentk
        static void ProcessButtonEvent(Sdl2NativeWindow window, Event ev)
        {
            bool button_pressed = ev.Button.State == State.Pressed;

            // We need MouseUp events to be reported even if they occur
            // outside the window. SetWindowGrab ensures we get them.
            if (window.CursorVisible)
            {
                SDL.SetWindowGrab(window.window.Handle,
                    button_pressed ? true : false);
            }
        }
コード例 #8
0
ファイル: Sdl2.cs プロジェクト: PieterMarius/PhysicsEngine
 public static extern int PollEvent(out Event e);
コード例 #9
0
ファイル: API.cs プロジェクト: sulix/opentk-sdl2
		extern public static int WaitEventTimeout(out Event _event, int timeout);
コード例 #10
0
ファイル: API.cs プロジェクト: sulix/opentk-sdl2
		extern public static int PushEvent(ref Event _event);
コード例 #11
0
ファイル: API.cs プロジェクト: sulix/opentk-sdl2
		extern public static int WaitEvent(out Event _event);
コード例 #12
0
ファイル: API.cs プロジェクト: sulix/opentk-sdl2
		extern public static int PollEvent(out Event _event);
コード例 #13
0
ファイル: Sdl2NativeWindow.cs プロジェクト: shahid-pk/opentk
 static void ProcessKeyEvent(Sdl2NativeWindow window, Event ev)
 {
     bool key_pressed = ev.Key.State == State.Pressed;
     var key = ev.Key.Keysym;
     var args = new KeyboardKeyEventArgs() 
     { 
         Key = TranslateKey(key.Scancode),
         ScanCode = (uint)key.Scancode
     };
     if (key_pressed)
         window.KeyDown(window, args);
     else
         window.KeyUp(window, args);
     //window.keyboard.SetKey(TranslateKey(key.scancode), (uint)key.scancode, key_pressed);
 }
コード例 #14
0
ファイル: Sdl2.cs プロジェクト: PieterMarius/PhysicsEngine
        public static int PeepEvents(Event[] e, int count, EventAction action, EventType min, EventType max)
        {
            if (e == null)
                throw new ArgumentNullException();
            if (count <= 0 || count > e.Length)
                throw new ArgumentOutOfRangeException();

            unsafe
            {
                fixed (Event *pe = e)
                {
                    return PeepEvents(pe, count, action, min, max);
                }
            }
        }
コード例 #15
0
ファイル: Sdl2NativeWindow.cs プロジェクト: raphaelts3/opentk
 static void ProcessKeyEvent(Sdl2NativeWindow window, Event ev)
 {
     bool key_pressed = ev.Key.State == State.Pressed;
     var key = ev.Key.Keysym;
     window.key_args.Key = TranslateKey(key.Scancode);
     window.key_args.ScanCode = (uint)key.Scancode;
     window.key_args.Modifiers = window.input_driver.Keyboard[0].GetModifiers();
     if (key_pressed)
     {
         window.KeyDown(window, window.key_args);
     }
     else
     {
         window.KeyUp(window, window.key_args);
     }
     //window.keyboard.SetKey(TranslateKey(key.scancode), (uint)key.scancode, key_pressed);
 }
コード例 #16
0
ファイル: Sdl2.cs プロジェクト: PieterMarius/PhysicsEngine
 unsafe static extern int PeepEvents(Event* e, int count, EventAction action, EventType min, EventType max);
コード例 #17
0
ファイル: Sdl2NativeWindow.cs プロジェクト: raphaelts3/opentk
 static void ProcessMotionEvent(Sdl2NativeWindow window, Event ev)
 {
     float scale = window.ClientSize.Width / (float)window.Size.Width;
     //window.mouse.Position = new Point(
     //    (int)(ev.motion.x * scale), (int)(ev.motion.y * scale));
 }
コード例 #18
0
ファイル: Sdl2.cs プロジェクト: PieterMarius/PhysicsEngine
 public static extern int PushEvent(ref Event @event);
コード例 #19
0
 static void ProcessKeyEvent(Sdl2NativeWindow window, Event ev)
 {
     bool key_pressed = ev.Key.State == State.Pressed;
     var key = ev.Key.Keysym;
     //window.keyboard.SetKey(TranslateKey(key.scancode), (uint)key.scancode, key_pressed);
 }