예제 #1
0
 /// <summary>
 /// Instructs this input provider to begin generating events.
 /// </summary>
 public void start()
 {
     Console.WriteLine("Start");
     TouchOutputFactory.getCurrentProviderHandler().connect();
     this.bRunning = true;
     wiimoteConnectorTimer.Change(0, Timeout.Infinite);
 }
예제 #2
0
        private List <IOutputHandler> createOutputHandlers(long id)
        {
            List <IOutputHandler> all             = new List <IOutputHandler>();
            IOutputHandler        keyboardHandler = VmultiDevice.Current.isAvailable() ? (IOutputHandler)(VmultiKeyboardHandler.Default) : (IOutputHandler)(new KeyboardHandler());

            all.Add(keyboardHandler);
            all.Add(new MouseHandler());
            all.Add(new XinputHandler(id));
            all.Add(new TouchHandler(TouchOutputFactory.getCurrentProviderHandler(), id));
            return(all);
        }
예제 #3
0
        /// <summary>
        /// Instructs this input provider to stop generating events.
        /// </summary>
        public void stop()
        {
            Console.WriteLine("stop");
            // Set the running flag.
            this.bRunning = false;

            this.wiimoteConnectorTimer.Change(Timeout.Infinite, Timeout.Infinite);

            this.teardownWiimoteConnections();
            if (Settings.Default.completelyDisconnect)
            {
                this.completelyDisconnectAll();
            }

            this.pWC.Clear();

            TouchOutputFactory.getCurrentProviderHandler().disconnect();
        }
예제 #4
0
        private void WiimoteHandlerWorker()
        {
            double   millisecondsForEachFrame = 1000 / Settings.Default.pointer_FPS;
            DateTime lastFrame = DateTime.Now;

            while (true)
            {
                double delay = DateTime.Now.Subtract(lastFrame).TotalMilliseconds;
                double wait  = millisecondsForEachFrame - delay;
                if (wait > 0)
                {
                    Thread.Sleep((int)wait);
                }

                lastFrame = DateTime.Now;

                if (bRunning)
                {
                    //DateTime now = DateTime.Now;

                    pDeviceMutex.WaitOne();

                    try
                    {
                        Queue <WiiContact> allContacts = new Queue <WiiContact>();

                        foreach (WiimoteControl control in pWiimoteMap.Values)
                        {
                            if (eventBuffer.ContainsKey(control.Wiimote.HIDDevicePath))
                            {
                                WiimoteChangedEventArgs e = eventBuffer[control.Wiimote.HIDDevicePath];

                                if (control.handleWiimoteChanged(this, e) && control.Status.InPowerSave)
                                {
                                    this.wakeFromPowerSave(control);
                                }

                                if (this.OnStatusUpdate != null)
                                {
                                    this.OnStatusUpdate(control.Status);
                                }
                            }
                        }

                        TouchOutputFactory.getCurrentProviderHandler().processEventFrame();

                        if (Settings.Default.pointer_customCursor)
                        {
                            D3DCursorWindow.Current.RefreshCursors();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error handling Wiimote: " + ex.Message);
                    }

                    pDeviceMutex.ReleaseMutex();

                    //Console.WriteLine("handle wiimote time : " + DateTime.Now.Subtract(now).TotalMilliseconds);
                }
            }
        }
예제 #5
0
        private void WiimoteHandlerWorker()
        {
            double   millisecondsForEachFrame = 1000 / Settings.Default.pointer_FPS;
            DateTime lastFrame = DateTime.Now;

            while (true)
            {
                double delay = DateTime.Now.Subtract(lastFrame).TotalMilliseconds;
                double wait  = millisecondsForEachFrame - delay;
                if (wait > 0)
                {
                    Thread.Sleep((int)wait);
                }

                lastFrame = DateTime.Now;

                if (bRunning)
                {
                    //DateTime now = DateTime.Now;

                    pDeviceMutex.WaitOne();

                    try
                    {
                        Queue <WiiContact> allContacts = new Queue <WiiContact>();

                        foreach (WiimoteControl control in pWiimoteMap.Values)
                        {
                            if (eventBuffer.ContainsKey(control.Wiimote.HIDDevicePath))
                            {
                                WiimoteChangedEventArgs e = eventBuffer[control.Wiimote.HIDDevicePath];

                                if (control.handleWiimoteChanged(this, e) && control.Status.InPowerSave)
                                {
                                    this.wakeFromPowerSave(control);
                                }

                                if (this.OnStatusUpdate != null)
                                {
                                    this.OnStatusUpdate(control.Status);
                                }

                                /*
                                 * if (control.FrameQueue.Count > 0)
                                 * {
                                 *  FrameEventArgs frame = control.FrameQueue.Dequeue();
                                 *
                                 *  ulong timeDelta = ((ulong)Stopwatch.GetTimestamp() / 10000) - (frame.Timestamp / 10000);
                                 *  if (timeDelta < OLD_FRAME_TIMEOUT) //Happens when the pointer is out of reach
                                 *  {
                                 *      foreach (WiiContact contact in frame.Contacts)
                                 *      {
                                 *          allContacts.Enqueue(contact);
                                 *      }
                                 *  }
                                 * }
                                 */
                            }
                        }

                        //FrameEventArgs newFrame = new FrameEventArgs((ulong)Stopwatch.GetTimestamp(), allContacts);

                        //this.OnNewFrame(this, newFrame);

                        TouchOutputFactory.getCurrentProviderHandler().processEventFrame();

                        if (Settings.Default.pointer_customCursor)
                        {
                            D3DCursorWindow.Current.RefreshCursors();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error handling Wiimote: " + ex.Message);
                    }

                    pDeviceMutex.ReleaseMutex();

                    //Console.WriteLine("handle wiimote time : " + DateTime.Now.Subtract(now).TotalMilliseconds);
                }
            }
        }