コード例 #1
0
        public override void Start()
        {
            foreach (RawDevice device in RawDevice.GetRawDevices())
            {
                if (device.RawType == RawType.Mouse)
                {
                    deviceList.Add(device.Handle, new CursorData());
                }
            }

            Thread t = new Thread((ThreadStart) delegate
            {
                RawDevice.RegisterRawDevices(0x01, 0x02,
                                             InputMode.BackgroundMode | InputMode.SuppressMessages);
                RawDevice.RawInput += RawDevice_RawInput;
                lowLevelMouseHook   = new LowLevelMouseHook(MouseHookCallback);
                System.Windows.Forms.Application.Run();
            });

            t.IsBackground = true;
            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            timer          = new Timer(10);
            timer.Elapsed += timer_Elapsed;
            timer.Start();

            Mouse.OverrideCursor = Cursors.None;

            isRunning = true;
        }
コード例 #2
0
        public RawDevicesManager(InputProvider inputProvider)
        {
            virtualScreen = SystemInformation.VirtualScreen;

            this.inputProvider = inputProvider;
            mouseSpeed         = SystemInformation.MouseSpeed * 0.15;

            devices  = new DeviceCollection();
            contacts = new ContactCollection();

            IEnumerable <RawDevice> rawDevices = from device in RawDevice.GetRawDevices()
                                                 where (device.RawType == RawType.Device &&
                                                        device.GetRawInfo().UsagePage == HID_USAGE_PAGE_DIGITIZER &&
                                                        device.GetRawInfo().Usage == HID_USAGE_DIGITIZER_PEN) ||
                                                 device.RawType == RawType.Mouse
                                                 select device;


            foreach (RawDevice mouseDevice in rawDevices)
            {
                devices.Add(new DeviceStatus(mouseDevice));
            }

            Thread inputThread = new Thread(InputWorker);

            inputThread.IsBackground = true;
            inputThread.SetApartmentState(ApartmentState.STA);
            inputThread.Name = "MultipleMice thread";
            inputThread.Start();

            this.inputProvider.IsRunning = true;
        }