private void joystickTest(VMulti vmulti) { double i = 0; bool running = true; while (running) { JoystickButtonState joyButtonState = new JoystickButtonState(); joyButtonState.A = false; joyButtonState.X = false; joyButtonState.Left = false; double x = Math.Sin(i); double y = Math.Cos(i); Console.WriteLine("x: " + x + " y: " + y); JoystickReport joystickReport = new JoystickReport(joyButtonState, x, y); Console.WriteLine("Update Joystick: " + vmulti.updateJoystick(joystickReport)); i += 0.1; System.Threading.Thread.Sleep(100); } }
static void Main(string[] args) { VMulti vmulti = new VMulti(); Console.WriteLine("Connect: " + vmulti.connect()); System.Threading.Thread.Sleep(3000); keyboardTest(vmulti); vmulti.disconnect(); }
static void Main(string[] args) { VMulti vmulti = new VMulti("D:\\Work\\CSharpWork\\VMultiDll-master\\VMultiDll-master\\Debug\\VMultiDll.dll"); Console.WriteLine("Connect: " + vmulti.connect()); System.Threading.Thread.Sleep(3000); keyboardTest(vmulti); vmulti.disconnect(); Console.ReadKey(); }
public void Initialize() { if (!this.isInitalized) { // VMulti Init this.vMulti = new VMulti(); if (!this.vMulti.connect()) { throw new Exception("Failed to connect to VMulti."); } // Kinect Init this.skeletons = new Skeleton[0]; handPixels = new bool[IMG_WIDTH, IMG_HEIGHT]; fingerPixels = new bool[IMG_WIDTH, IMG_HEIGHT]; contourPixels = new bool[IMG_WIDTH, IMG_HEIGHT]; // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser). foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.Sensor = potentialSensor; break; } } if (this.Sensor != null) { // Turn on the depth stream to receive depth frames this.Sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); // Add an event handler to be called whenever there is new depth frame data //this.Sensor.DepthFrameReady += this.SensorDepthFrameReady; this.Sensor.DepthStream.Range = DepthRange.Near; this.Sensor.SkeletonStream.EnableTrackingInNearRange = true; // enable returning skeletons while depth is in Near Range this.Sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; // Use seated tracking this.Sensor.SkeletonStream.Enable(); // Allocate space to put the depth pixels we'll receive this.depthPixels = new DepthImagePixel[this.Sensor.DepthStream.FramePixelDataLength]; } } this.isInitalized = true; }
private static void keyboardTest(VMulti vmulti) { System.Diagnostics.Process.Start("notepad.exe"); System.Threading.Thread.Sleep(3000); KeyboardReport report = new KeyboardReport(); report.keyDown(KeyboardKey.H); vmulti.updateKeyboard(report); report.keyUp(KeyboardKey.H); report.keyDown(KeyboardKey.E); vmulti.updateKeyboard(report); report.keyUp(KeyboardKey.E); report.keyDown(KeyboardKey.L); vmulti.updateKeyboard(report); report.keyUp(KeyboardKey.L); vmulti.updateKeyboard(report); report.keyDown(KeyboardKey.L); vmulti.updateKeyboard(report); report.keyUp(KeyboardKey.L); report.keyDown(KeyboardKey.O); vmulti.updateKeyboard(report); report.keyUp(KeyboardKey.O); report.keyDown(KeyboardModifier.LShift); report.keyDown(KeyboardKey.Number1); vmulti.updateKeyboard(report); report.keyUp(KeyboardModifier.LShift); report.keyUp(KeyboardKey.Number1); vmulti.updateKeyboard(report); System.Threading.Thread.Sleep(4000); report.keyDown(KeyboardModifier.LWin); report.keyDown(KeyboardKey.D); vmulti.updateKeyboard(report); report.keyUp(KeyboardModifier.LWin); report.keyUp(KeyboardKey.D); vmulti.updateKeyboard(report); }
private void multitouchTest(VMulti vmulti) { double x = 500; double y = 500; while (true) { List <MultitouchPointerInfo> touches = new List <MultitouchPointerInfo>(); bool spacePressed = Convert.ToBoolean(GetKeyState(0x20) & 0x8000); MultitouchPointerInfo pointer = new MultitouchPointerInfo(); bool rightPressed = Convert.ToBoolean(GetKeyState(0x27) & 0x8000); if (rightPressed) { x += 10; } bool downPressed = Convert.ToBoolean(GetKeyState(0x28) & 0x8000); if (downPressed) { y += 10; } bool leftPressed = Convert.ToBoolean(GetKeyState(0x25) & 0x8000); if (leftPressed) { x -= 10; } bool upPressed = Convert.ToBoolean(GetKeyState(0x26) & 0x8000); if (upPressed) { y -= 10; } if (spacePressed) { Console.WriteLine("pressed"); pointer.Down = true; } else { pointer.Down = false; } Point mousePos = Control.MousePosition; Console.WriteLine(mousePos); pointer.X = x / Screen.PrimaryScreen.Bounds.Width; pointer.Y = y / Screen.PrimaryScreen.Bounds.Height; Console.WriteLine("X: " + pointer.X); Console.WriteLine("Y: " + pointer.Y); touches.Add(pointer); MultitouchReport report = new MultitouchReport(touches); if (!vmulti.updateMultitouch(report)) { Console.WriteLine("fail"); } System.Threading.Thread.Sleep(10); } }