Beispiel #1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();

                if (deviceNotification != null)
                {
                    deviceNotification.Dispose(); deviceNotification = null;
                }
#if USE_OLD_HID
                if (touchRawInputDevices != null)
                {
                    touchRawInputDevices.Dispose(); touchRawInputDevices = null;
                }
                if (HidReportsUpdateByWin32RawInput != null)
                {
                    HidReportsUpdateByWin32RawInput.Dispose(); HidReportsUpdateByWin32RawInput = null;
                }
#endif

                if (IsToUseActiveWindowHWnd)
                {
                    NativeMethods.SetWindowLong(hMainWindow, -4, oldWndProcPtr);
                    hMainWindow   = IntPtr.Zero;
                    oldWndProcPtr = IntPtr.Zero;
                    newWndProcPtr = IntPtr.Zero;
                    newWndProc    = null;
                }
            }
            base.Dispose(disposing);
        }
Beispiel #2
0
        internal IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            switch (msg)
            {
            case NativeMethods.WM_DEVICECHANGE:
                ProcessWindowMessageDeviceChange(hWnd, msg, wParam, lParam);
                break;

#if USE_OLD_HID
            case NativeMethods.WM_INPUT:
                // MUSTDO: TODO: Fix the spec and implementation.  It is difficult to use multiple devices by smart way in various situations.
                if (CurrentDevice != null)
                {
                    // NOTE (en): My idea was wrong, i.e. "m.LParam" cannot decide the EgsDevice object which should receive the messages.  So cast data by GetRawInputData(m.LParam) to a structure, and then rawInput.header.hDevice should be checked.  But the value can depend on the kind of Report, and the value cannot specify which device sends it, even though KeyboardDevice can (maybe) do it.
                    // NOTE (ja): m.LParamからメッセージを処理するべきEgsDeviceを決定できると思ったら根本的に間違いだった、m.LParamをGetRawInputDataに渡して得られるデータを構造体にキャストして、rawInput.header.hDeviceの値を見る必要がある。しかもその値はReportの種類ごとかもしれず、KeyboardDeviceのときのように、デバイスごとの値が来るわけではない。
                    if (false)
                    {
                        Debug.WriteLine(lParam);
                    }
                    HidReportsUpdateByWin32RawInput.ProcessRawInputData(lParam);
                }
                break;
#endif
            }
            if (IsToUseActiveWindowHWnd)
            {
                return(NativeMethods.CallWindowProc(oldWndProcPtr, hWnd, msg, wParam, lParam));
            }
            else
            {
                return(IntPtr.Zero);
            }
        }