Esempio n. 1
0
        /// <summary>
        /// Handles EventController sent by DirectInputManager via EventBus<
        /// EventController> when any controller input occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            if (InvokeRequired && !IsDisposed)
            {
                OnEventControllerInvoker d = new OnEventControllerInvoker(OnEventController);
                this.Invoke(d, new object[] { sender, e });
                return;
            }

            EventController controllerEvent = e.BusEvent;

            switch (controllerEvent.Type)
            {
            case EventController.EventType.Button:
                textBoxControllerLog.AppendText(" " + controllerEvent.Joystick.Information.InstanceName +
                                                " (Button " + controllerEvent.Button + " " + controllerEvent.ButtonValue + ")\r\n");
                break;

            case EventController.EventType.POV:
                textBoxControllerLog.AppendText(" " + controllerEvent.Joystick.Information.InstanceName +
                                                " (POV " + controllerEvent.POVState + ")\r\n");
                break;

            // TODO do something with axis name and value
            case EventController.EventType.Axis:
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles EventController sent by DirectInputManager via EventBus<
        /// EventController> when any controller input occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(new OnEventControllerInvoker(OnEventController), sender, e);
                return;
            }

            EventController controllerEvent = e.BusEvent;

            switch (controllerEvent.Type)
            {
            case EventController.EventType.Button:
                ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName +
                                      " (Button " + controllerEvent.Button + " " + controllerEvent.ButtonValue + ")\r\n";
                break;

            case EventController.EventType.POV:
                ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName +
                                      " (POV " + controllerEvent.POVState + ")\r\n";
                break;

            // TODO do something with axis name and value
            case EventController.EventType.Axis:
                break;
            }
            ControllerLog.ScrollToEnd();
        }
Esempio n. 3
0
 private static void OnEventController(object sender, BusEventArgs <EventController> e)
 {
     if (e.BusEvent.Type != EventController.EventType.Axis)
     {
         LOGGER.Info(e.BusEvent.ToString());
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Handles EventControllersChanged sent by DirectInputManager via
        /// EventBus<EventControllersChanged> when list of connected
        /// controller devices is updated.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e)
        {
            if (InvokeRequired && !IsDisposed)
            {
                OnEventControllersChangedInvoker d = new OnEventControllersChangedInvoker(OnEventControllersChanged);
                this.Invoke(d, new object[] { sender, e });
                return;
            }

            UpdateConnectedDevices(e.BusEvent.ConnectedDeviceInfos);
        }
Esempio n. 5
0
        protected override void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            EventController eventController = e.BusEvent;

            if (eventController.Type == EventController.EventType.POV &&
                eventController.POVState == POVState &&
                eventController.Joystick.Information.InstanceName.Contains(NamePart))
            {
                Fire();
            }
        }
Esempio n. 6
0
        private void Bus_OnReceived(object sender, BusEventArgs e)
        {
            var data = System.Text.Json.JsonSerializer.Deserialize <IEnumerable <IOTData> >(e.Message);

            lock (Program.lockdb)
            {
                using (var litedb = new LitedbWapper(DBFile))
                {
                    litedb.Insert <IOTData>(data);
                }
            }
        }
 private void Bus_OnReceived(object sender, BusEventArgs e)
 {
     if (e.Topic == BusOption.CMD_INPUT)
     {
         //接收到了控制命令
         DriveControl Ctrl = JsonSerializer.Deserialize <DriveControl>(e.Message);
         if (Ctrl.Cmd == DriveControl.CMD_SHUTDOWN)
         {
             ISRun = false;
         }
     }
 }
Esempio n. 8
0
 private void Handle <TEnt>(BusEventArgs <TEnt> eventToHandle, ISubscriber <TEnt> subscriber)
 {
     try
     {
         this.OnSubscriberStarted(subscriber, eventToHandle.Data);
         subscriber.HandleEvent(eventToHandle.Data);
     }
     catch (Exception exc)
     {
         this.OnSubcriberExecutionException(subscriber, exc);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Handles EventControllersChanged sent by DirectInputManager via
        /// EventBus<EventControllersChanged> when list of connected
        /// controller devices is updated.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e)
        {
            // Events from DirectInputManager aren't on the UI thread, so
            // updates to window elements must be marshalled via Dispatcher.Invoke()
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(new OnEventControllersChangedInvoker(OnEventControllersChanged), sender, e);
                return;
            }

            UpdateConnectedDevices(e.BusEvent.ConnectedDeviceInfos);
        }
Esempio n. 10
0
        private void Bus_OnReceived(object sender, BusEventArgs e)
        {
            switch (e.Topic)
            {
            case BusOption.CTRL_START:           //启动消息
                StartDrive(e.Message);
                break;

            case BusOption.CTRL_STOP:           //关闭消息
                StopDrive(e.Message);
                break;
            }
        }
Esempio n. 11
0
        private void EventMouse_Received(object sender, BusEventArgs <EventMouse> e)
        {
            EventMouse eventMouse = e.BusEvent;

            // Always update status bar when mouse moves
            DisplayMouseMove(eventMouse.X, eventMouse.Y);

            if (LogInput &&
                eventMouse.MouseButton != MouseButtons.None &&
                eventMouse.ButtonState == ButtonStates.Press)
            {
                DisplayMouseClick(eventMouse.MouseButton, eventMouse.X, eventMouse.Y);
            }
        }
Esempio n. 12
0
        private void OnEventKeyboard(object sender, BusEventArgs <EventKeyboard> e)
        {
            EventKeyboard eventKeyboard = e.BusEvent;

            if (eventKeyboard.ButtonState == ButtonStates.Press)
            {
                keysPressed.Add(eventKeyboard.VirtualKeyCode);
            }
            else
            {
                keysPressed.Remove(eventKeyboard.VirtualKeyCode);
            }

            UpdateKeys();
        }
Esempio n. 13
0
        private void EventKeyboard_Recieved(object sender, BusEventArgs <EventKeyboard> e)
        {
            if (LogInput)
            {
                EventKeyboard eventKeyboard = e.BusEvent;

                if (eventKeyboard.ButtonState == ButtonStates.Press)
                {
                    DisplayKeyDown(eventKeyboard.VirtualKeyCode);
                }
                else
                {
                    DisplayKeyUp(eventKeyboard.VirtualKeyCode);
                }
            }
        }
Esempio n. 14
0
        private static void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            EventController controllerEvent = e.BusEvent;

            // Prevents spamming every time an axis is moved by writing that
            // information only when buttons are pressed
            if (controllerEvent.Type == EventController.EventType.Axis)
            {
                LastAxisEvent = e.BusEvent;
            }
            else
            {
                Console.WriteLine(controllerEvent.ToString());

                if (LastAxisEvent != null)
                {
                    Console.WriteLine(LastAxisEvent.ToString());
                }
            }
        }
Esempio n. 15
0
        protected override void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            EventController eventController = e.BusEvent;

            if (
                (EventController.EventType.Axis == eventController.Type) &&
                (Axis == (ControllerAxis)eventController.JoystickUpdate.Offset) &&
                (eventController.Joystick.Properties.InstanceName.Contains(NamePart))
                )
            {
                // LOGGER.Info(String.Format("{0} {1} {2:n0}", NamePart, axis, axisValue));
                int bandCurrent = GetBand(eventController.JoystickUpdate.Value);
                if (bandCurrent != this.bandPrevious)
                {
                    LOGGER.Info(
                        String.Format(
                            "{0} {1} Entered band [{2}] from band [{3}] position={4:n0}",
                            NamePart, axis, bandCurrent, bandPrevious, eventController.JoystickUpdate.Value));

                    // Activate keys for exited / entered bands
                    if (bandPrevious != -1 && Keys.None != KeyList[bandPrevious])
                    {
                        SimulateKey((int)KeyList[bandPrevious], ButtonStates.Release);
                    }
                    else if (bandCurrent != -1 && Keys.None != KeyList[bandCurrent])
                    {
                        SimulateKey((int)KeyList[bandCurrent], ButtonStates.Press);
                    }

                    // Fire macro for entered band
                    Fire(bandCurrent);

                    this.bandPrevious = bandCurrent;
                }
            }
        }
Esempio n. 16
0
 private void sub_EventReceived2(object sender, BusEventArgs <DefferMessage1> e)
 {
     Debug.WriteLine("Received " + sender.ToString());
     (sender as ISubscriber <DefferMessage1>).HandleEvent(e.Data);
 }
Esempio n. 17
0
 private void Bus_EventRecievedInt(object sender, BusEventArgs <int> e)
 {
     this.intReceived = e.BusEvent;
 }
Esempio n. 18
0
 void context_OnNewBusConstructed(object sender, BusEventArgs e)
 {
     _currentSystem.AddBus(e.Bus);
 }
Esempio n. 19
0
 private void EventController_Received(object sender, BusEventArgs <EventController> e)
 {
     DisplayControllerEvent(e.BusEvent);
 }
Esempio n. 20
0
 private void EventUserInfo_Received(object sender, BusEventArgs <EventUserInfo> e)
 {
     AppendText(" " + e.BusEvent.Message);
 }
Esempio n. 21
0
 private void sub_EventHandled2(object sender, BusEventArgs <DefferMessage1> e)
 {
     Debug.WriteLine("Handled " + sender.ToString());
     countEvent.Signal();
 }
Esempio n. 22
0
 private static void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e)
 {
     LOGGER.Info(e.BusEvent.ToString());
 }
Esempio n. 23
0
 private void OnControllerPlugEvent(object sender, BusEventArgs <EventControllersChanged> e)
 {
     connectedDeviceInfos = e.BusEvent.ConnectedDeviceInfos;
     UpdateListView();
 }
Esempio n. 24
0
        private void Bus_OnReceived(object sender, BusEventArgs e)
        {
            var data = System.Text.Json.JsonSerializer.Deserialize <IEnumerable <IOTData> >(e.Message);

            litedb.Insert <IOTData>(data);
        }
Esempio n. 25
0
 void Instance_BusCreated(object sender, BusEventArgs e)
 {
     this.Dispatcher.Invoke(new Action(() => this.RemoveBus(e.Bus)));
 }
Esempio n. 26
0
 private void Bus_OnReceived(object sender, BusEventArgs e)
 {
 }
Esempio n. 27
0
 protected abstract void OnEventController(object sender, BusEventArgs <EventController> e);
Esempio n. 28
0
 private static void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e)
 {
     Console.WriteLine("Controller un/plugged. New count: " + e.BusEvent.ConnectedDeviceInfos.Count);
 }
Esempio n. 29
0
 private void Bus_EventRecievedObject(object sender, BusEventArgs <object> e)
 {
     this.objectReceived = e.BusEvent;
 }