private void showPSVRState(PSVRState state) { string str = ""; str += string.Format("Motion X1: {0,6}\r\n", state.sensor.MotionX1); str += string.Format("Motion Y1: {0,6}\r\n", state.sensor.MotionY1); str += string.Format("Motion Z1: {0,6}\r\n", state.sensor.MotionZ1); str += string.Format("Motion X2: {0,6}\r\n", state.sensor.MotionX2); str += string.Format("Motion Y2: {0,6}\r\n", state.sensor.MotionY2); str += string.Format("Motion Z2: {0,6}\r\n", state.sensor.MotionZ2); str += string.Format("Gyro Yaw1: {0,6}\r\n", state.sensor.GyroYaw1); str += string.Format("Gyro Pitch1: {0,6}\r\n", state.sensor.GyroPitch1); str += string.Format("Gyro Roll1: {0,6}\r\n", state.sensor.GyroRoll1); str += string.Format("Gyro Yaw2: {0,6}\r\n", state.sensor.GyroYaw2); str += string.Format("Gyro Pitch2: {0,6}\r\n", state.sensor.GyroPitch2); str += string.Format("Gyro Roll2: {0,6}\r\n", state.sensor.GyroRoll2); str += string.Format("Volume: {0}\r\n", state.sensor.volume); str += string.Format("Worn: {0}\r\n", state.sensor.isWorn); str += string.Format("Display: {0}\r\n", state.sensor.isDisplayActive); str += string.Format("Mute: {0}\r\n", state.sensor.isMute); str += string.Format("Earphone: {0}\r\n", state.sensor.isEarphoneConnected); trackBar1.Value = state.sensor.A; trackBar2.Value = state.sensor.B; trackBar3.Value = state.sensor.C; trackBar4.Value = state.sensor.D; trackBar5.Value = state.sensor.E; trackBar6.Value = state.sensor.F; trackBar7.Value = state.sensor.G; //trackBar8.Value = state.sensor.H; trackBar9.Value = state.sensor.I; trackBar10.Value = state.sensor.J; trackBar11.Value = state.sensor.K; trackBar12.Value = state.sensor.L; trackBar13.Value = state.sensor.M; trackBar14.Value = state.sensor.N; trackBar15.Value = state.sensor.O; //trackBar16.Value = state.sensor.MotionX1 - state.sensor.MotionX2; //trackBar17.Value = state.sensor.MotionY1 - state.sensor.MotionY2; //trackBar18.Value = state.sensor.MotionZ1 - state.sensor.MotionZ2; trackBar16.Value = state.sensor.GyroYaw1 - state.sensor.GyroYaw2; trackBar17.Value = state.sensor.GyroPitch1 - state.sensor.GyroPitch2; trackBar18.Value = state.sensor.GyroRoll1 - state.sensor.GyroRoll2; stateTextBox.Text = str; }
private void showPSVRState(PSVRState state) { string str = ""; /* * str += string.Format("Motion X: {0}\r\n", state.sensor.MotionX); * str += string.Format("Motion Y: {0}\r\n", state.sensor.MotionY); * str += string.Format("Motion Z: {0}\r\n", state.sensor.MotionZ); * * str += string.Format("Gyro Yaw: {0}\r\n", state.sensor.GyroYaw); * str += string.Format("Gyro Pitch: {0}\r\n", state.sensor.GyroPitch); * str += string.Format("Gyro Roll: {0}\r\n", state.sensor.GyroRoll); */ trackBar1.Value = state.sensor.A; trackBar2.Value = state.sensor.B; trackBar3.Value = state.sensor.C; trackBar4.Value = state.sensor.D; trackBar5.Value = state.sensor.E; trackBar6.Value = state.sensor.F; trackBar7.Value = state.sensor.G; //trackBar8.Value = state.sensor.H; trackBar9.Value = state.sensor.I; trackBar12.Value = state.sensor.J; trackBar11.Value = state.sensor.K; trackBar10.Value = state.sensor.L; trackBar13.Value = state.sensor.M; trackBar14.Value = state.sensor.N; trackBar15.Value = state.sensor.O; stateTextBox.Text = str; }
private void ProcessRawInput(ref Message m) { uint dwSize = 0; RawInput.GetRawInputData(m.LParam, (uint)RawInput.RID.INPUT, IntPtr.Zero, ref dwSize, (uint)Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER))); IntPtr buffer = Marshal.AllocHGlobal((int)dwSize); try { if (buffer == IntPtr.Zero) { return; } if ( RawInput.GetRawInputData(m.LParam, (uint)RawInput.RID.INPUT, buffer, ref dwSize, (uint)Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER))) != dwSize) { return; } } catch (Exception ex) { } RawInput.RAWINPUT raw = (RawInput.RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RawInput.RAWINPUT)); int offset = 0; byte[] bRawData; byte[] newArray; string RawCode; switch (raw.header.dwType) { case (int)RawInput.RawInputType.HID: RawInput.RAWHID hid = raw.hid; offset = Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER)) + Marshal.SizeOf(typeof(RawInput.RAWHID)); bRawData = new byte[offset + raw.hid.dwSizeHid]; Marshal.Copy(buffer, bRawData, 0, bRawData.Length); newArray = new byte[raw.hid.dwSizeHid]; Array.Copy(bRawData, offset, newArray, 0, newArray.Length); RawCode = BitConverter.ToString(newArray); if (false) { //this blocks UI... if (listBox1.Items.Count > 30) { listBox1.Items.RemoveAt(30); } listBox1.Items.Insert(0, string.Format("{0}\r\n", RawCode)); } else { Debug.WriteLine(RawCode); } //DS4State state = DS4.parse(newArray); PSVRState state = PSVR.parse(newArray); currentState = state; break; case (int)RawInput.RawInputType.Mouse: RawInput.RAWMOUSE mouse = raw.mouse; offset = Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER)) + Marshal.SizeOf(typeof(RawInput.RAWMOUSE)); bRawData = new byte[offset + Marshal.SizeOf(typeof(RawInput.RAWMOUSE))]; Marshal.Copy(buffer, bRawData, 0, bRawData.Length); newArray = new byte[Marshal.SizeOf(typeof(RawInput.RAWMOUSE))]; Array.Copy(bRawData, offset, newArray, 0, newArray.Length); RawCode = BitConverter.ToString(newArray); //textBox1.AppendText(string.Format("RAW HID DATA: {0}\r\n", RawCode)); if (listBox1.Items.Count > 30) { listBox1.Items.RemoveAt(30); } listBox1.Items.Insert(0, string.Format("{0}\r\n", RawCode)); break; case (int)RawInput.RawInputType.Keyboard: break; } }