Esempio n. 1
0
        public void StartMessageLoop(RawInputProcessor rawInputProcessor)
        {
            int bRet;
            MSG msg;
            int sqErr = 0;

            //hWnd zero for all windows (the mouse pointers are in this loop!)
            while ((bRet = WinApi.GetMessage(out msg, IntPtr.Zero, 0, 0)) != 0)
            {
                if (bRet == -1)
                {
                    if (sqErr++ > 10)
                    {
                        return;
                    }
                }
                else if (msg.message == 0x00FF)
                {
                    //Raw input
                    sqErr = 0;
                    rawInputProcessor.Process(msg.lParam);
                }
                else if (msg.message == 0x0400)
                {
                    //End split screen message.
                    Logger.WriteLine($"RawInputWindow received split screen end");
                    foreach (var window in RawInputManager.windows)
                    {
                        window.End();
                    }
                }
                else if (msg.message == 0x0400 + 1)
                {
                    //Create cursors
                    Logger.WriteLine($"RawInputWindow received create cursors message");

                    bool internalInputUpdate      = msg.wParam == (IntPtr)1;
                    bool drawCursorForControllers = msg.lParam == (IntPtr)1;

                    foreach (var window in RawInputManager.windows)
                    {
                        //Cursor needs to be created on the MainForm message loop so it can be accessed in the loop.
                        bool kbm = window.KeyboardAttached != (IntPtr)(-1) || window.MouseAttached != (IntPtr)(-1);
                        if (kbm || drawCursorForControllers)
                        {
                            window.CreateCursor(!kbm && internalInputUpdate);
                        }
                    }
                }
                else
                {
                    sqErr = 0;
                    WinApi.TranslateMessage(ref msg);
                    WinApi.DispatchMessage(ref msg);
                }
            }
        }
Esempio n. 2
0
        public static void RegisterRawInput(RawInputProcessor rawInputProcessor)
        {
            var windowThread = new Thread(WindowThread)
            {
                Priority     = ThreadPriority.AboveNormal,
                IsBackground = true
            };

            windowThread.Start(rawInputProcessor);
        }
Esempio n. 3
0
        public void StartMessageLoop(RawInputProcessor rawInputProcessor)
        {
            int bRet;
            MSG msg;
            int sqErr = 0;

            //hWnd zero for all windows (the mouse pointers are in this loop!)
            while ((bRet = WinApi.GetMessage(out msg, IntPtr.Zero, 0, 0)) != 0)
            {
                if (bRet == -1)
                {
                    if (sqErr++ > 10)
                    {
                        return;
                    }
                }
                else if (msg.message == 0x00FF)
                {
                    //Raw input
                    sqErr = 0;
                    rawInputProcessor.Process(msg.lParam);
                }
                else if (msg.message == 0x0400)
                {
                    //End split screen message.
                    Logger.WriteLine($"RawInputWindow received split screen end");
                    foreach (var window in RawInputManager.windows)
                    {
                        window.End();
                    }
                }
                else
                {
                    sqErr = 0;
                    WinApi.TranslateMessage(ref msg);
                    WinApi.DispatchMessage(ref msg);
                }
            }
        }