private void VjoyDevice_StatusChanged(object sender, EventArgs e) { VjoyDevice vjoyDevice = (VjoyDevice)sender; uint id = vjoyDevice.GetVjoyDeviceId(); string status = GetJoystickStatus(vjoyDevice); string msg = string.Format("/set_var JOYSTICK_STATUS/{0} '{1}'\n", id, status); Send(msg); }
private void VjoyDevice_StatusChanged(object sender, EventArgs e) { VjoyDevice vjoyDevice = (VjoyDevice)sender; uint vjoyDeviceId = vjoyDevice.GetVjoyDeviceId(); string status = GetJoystickStatus(vjoyDevice); string msg = string.Format("vjoy_status {0} {1}\n", vjoyDeviceId, status); Send(msg); }
private void SetupThread() { if (!Connect(this.address, this.tcpPort)) { return; } this.controllerId = ((IPEndPoint)this.tcpClient.Client.LocalEndPoint).Port; byte[] vrcData; try { vrcData = File.ReadAllBytes(vrcFileName); } catch (Exception e) { Log(string.Format("Error reading {0}: {1}", vrcFileName, e.Message)); return; } string cmds = ""; VjoyDevice[] vjoyDevices = Program.VjoyInterface.GetDevices(); cmds += string.Format("/set_var SERVER_NAME '{0}'\n", Environment.MachineName); cmds += string.Format("/set_var CONTROLLER_ID '{0}'\n", GetControllerId()); cmds += string.Format("/set_var SEND_UPDATE_ADDR 'udp!$0!{0}'\n", Program.NetworkInterface.GetUdpPort()); cmds += string.Format("/set_var ACTIVE_JOYSTICK_ID '{0}'\n", 0); foreach (VjoyDevice vjoyDevice in vjoyDevices) { vjoyDevice.StatusChanged += VjoyDevice_StatusChanged; vjoyDevice.ExportedChanged += VjoyDevice_StatusChanged; uint id = vjoyDevice.GetVjoyDeviceId(); string status = GetJoystickStatus(vjoyDevice); cmds += string.Format("/set_var JOYSTICK_STATUS/{0} '{1}'\n", id, status); } cmds += string.Format("/load_vrc '{0}'\n", vrcData.Length); byte[] cmdsData = Encoding.UTF8.GetBytes(cmds); byte[] data = new byte[cmdsData.Length + vrcData.Length]; Array.Copy(cmdsData, data, cmdsData.Length); Array.Copy(vrcData, 0, data, cmdsData.Length, vrcData.Length); this.tcpClient.GetStream().Write(data, 0, data.Length); this.activeGui = Gui.OptionsScreen; this.receiverThread = new Thread(ReceiverThread); this.receiverThread.Start(); }