public AnalogRemote(string name, string addressServer = Network.UniVRPNityServerDefaultAddress, int port = Network.UniVRPNityServerDefaultPort) : base(name, addressServer, port) { AnalogChanged = new AnalogChangeEventHandler(Update); lastEvent = new AnalogEvent(); }
/* Analog event handler */ private void AnalogChanged(AnalogEvent e) { for (int i = 0; i < analogValues.Capacity; i++) { if(i < analog.LastEvent.getNumChannels()) analogValues[i] = (float)analog.LastEvent.Channel(i); } }
/* Analog event handler */ private void AnalogChanged(AnalogEvent e) { mouseLeft = button.GetButtonState(0); mouseMiddle = button.GetButtonState(1); mouseRight = button.GetButtonState(2); coordinates.x = (float)analog.LastEvent.Channel(0); coordinates.y = (float)analog.LastEvent.Channel(1); }
/* Analog event handler */ private void AnalogChanged(AnalogEvent e) { angleJoystick = analog.LastEvent.Channel(19); intensityJoystick = (float)analog.LastEvent.Channel(20); if (intensityJoystick < 0.05) intensityJoystick = 0; forward = button.GetButtonState((int)(object)forwardKey); backward = button.GetButtonState((int)(object)backwardKey); left = button.GetButtonState((int)(object)leftKey); right = button.GetButtonState((int)(object)rightKey); }
private void AnalogChangedMiddle(AnalogEvent e) { if (AnalogChanged != null) AnalogChanged(e); }
protected void deserializeEvent(StateObject state, int bytesRead) { //Receive message from the server formatter = new BinaryFormatter(); memStream = new MemoryStream(bytesRead - 1); memStream.Write(state.Buffer, 0, bytesRead - 1); memStream.Position = 0; UniVRPNity.Event event_deserialize = (UniVRPNity.Event)formatter.Deserialize(memStream); switch (event_deserialize.GetHandlerType()) { case UniVRPNity.Type.Analog: analogEvent = (AnalogEvent) event_deserialize; bufferEvent.Push(analogEvent); break; case UniVRPNity.Type.Button: buttonEvent = (ButtonEvent) event_deserialize; bufferEvent.Push(buttonEvent); break; case UniVRPNity.Type.Tracker: trackerEvent = (TrackerEvent) event_deserialize; bufferEvent.Push(trackerEvent); break; default: throw new Exception("Deserialization of the event failed.\n"); } }
/* Analog event handler */ private void AnalogChanged(object sender, AnalogChangeEventArgs e) { Vrpn.AnalogRemote analogSender = (Vrpn.AnalogRemote)sender; //sender.GetType() == Vrpn.AnalogRemote if (remotes.isPresent(analogSender)) { AnalogEvent analogEvent = new AnalogEvent(this.remotes[analogSender].Name); analogEvent.Channels = e.Channels.OfType<double>().ToList(); analogEvent.Time = e.Time; Console.WriteLine("Analog: " + analogEvent); this.SendEvent(analogSender, analogEvent); } else { analogSender.AnalogChanged -= new Vrpn.AnalogChangeEventHandler(this.AnalogChanged); } }
private void Update(AnalogEvent e) { lastEvent = e; }