private void DrawAndPressButton_KeyDown(object sender, EventArgs e) { if (!_MouseMoving) { return; } Pen = true; KeyboardServiceWrapper.UpdateMouseStatus(0, 0); }
protected override void Setup() { var bluetoothManager = DependencyService.Get <IManagerManager>().BluetoothManager; var deviceInfomationService = new DeviceInfomationServiceBuilder(bluetoothManager).Build(); SensorSpeed speed = SensorSpeed.Game; Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(speed); bluetoothManager.GattSever.AddService(new DeviceInfomationServiceBuilder(bluetoothManager).Build()); bluetoothManager.GattSever.AddService(new RfcommServerServiceWrapper(bluetoothManager).GattServerService); KeyboardServiceWrapper = new KeyboardServiceWrapper(bluetoothManager); bluetoothManager.GattSever.AddService(KeyboardServiceWrapper.GattServerService); bluetoothManager.GattSever.StartAdvertising(); var createServiceProviderTask = bluetoothManager.CreateRfcommServiceProviderAsync(MouseServiceWrapper.ServiceId); createServiceProviderTask.Wait(); var mouseServiceProvider = createServiceProviderTask.Result; mouseServiceProvider.OnConnectionReceived += MouseServiceProvider_OnConnectionReceived;; mouseServiceProvider.StartAdvertising(); var keyManager = DependencyService.Get <IManagerManager>().KeyManager; keyManager.VolumnDownKeyDown += KeyManager_VolumnDownKeyDown; keyManager.VolumnDownKeyUp += KeyManager_VolumnDownKeyUp; keyManager.VolumnUpKeyDown += KeyManager_VolumnUpKeyDown; keyManager.VolumnUpKeyUp += KeyManager_VolumnUpKeyUp; ButtonStick = Sketch.SketchEngine.Instantiate <LineAreaJoystick <VirtualKeyCode> >(); ButtonStick.OnAreaStatusChanged += Stick_OnAreaStatusChanged; ButtonStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.LSHIFT, -60, 60, 0, float.PositiveInfinity)); ButtonStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_V, 30, 150, 0, float.PositiveInfinity)); ButtonStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_R, 120, 240, 0, float.PositiveInfinity)); ButtonStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.SPACE, 210, 330, 0, float.PositiveInfinity)); ButtonStick.RectTransform.AnchorMax = new Vector2(0f, 1f); ButtonStick.RectTransform.AnchorMin = new Vector2(0f, 1f); ButtonStick.RectTransform.OffsetMin = new Vector2(1178.8f, -428f); ButtonStick.RectTransform.OffsetMax = new Vector2(1528.8f, -78f); LeftStick = Sketch.SketchEngine.Instantiate <LineAreaJoystick <VirtualKeyCode> >(); LeftStick.OnAreaStatusChanged += Stick_OnAreaStatusChanged; LeftStick.MaxLength = 120; LeftStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_D, -60, 60, 0.3f, float.PositiveInfinity)); LeftStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_W, 30, 150, 0.3f, float.PositiveInfinity)); LeftStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_A, 120, 240, 0.3f, float.PositiveInfinity)); LeftStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_S, 210, 330, 0.3f, float.PositiveInfinity)); LeftStick.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.LCONTROL, 0, 360, 1f, 1.2f)); LeftStick.RectTransform.AnchorMax = new Vector2(0f, 1f); LeftStick.RectTransform.AnchorMin = new Vector2(0f, 1f); LeftStick.RectTransform.OffsetMin = new Vector2(26f, -457f); LeftStick.RectTransform.OffsetMax = new Vector2(376f, -107f); LeftStick.Level = 3; DirectionPad = Sketch.SketchEngine.Instantiate <LineAreaJoystick <VirtualKeyCode> >(); DirectionPad.OnAreaStatusChanged += Stick_OnAreaStatusChanged; DirectionPad.MaxLength = 100; DirectionPad.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_Z, -60, 60, 0, float.PositiveInfinity)); DirectionPad.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_Q, 30, 150, 0, float.PositiveInfinity)); DirectionPad.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_E, 120, 240, 0, float.PositiveInfinity)); DirectionPad.AddArea(AreaJoystick <VirtualKeyCode> .Area <VirtualKeyCode> .CreateFromAngle(VirtualKeyCode.VK_N, 210, 330, 0, float.PositiveInfinity)); DirectionPad.RectTransform.AnchorMax = new Vector2(0f, 1f); DirectionPad.RectTransform.AnchorMin = new Vector2(0f, 1f); DirectionPad.RectTransform.OffsetMin = new Vector2(26f, -807f); DirectionPad.RectTransform.OffsetMax = new Vector2(376f, -457f); RightStick = Sketch.SketchEngine.Instantiate <TouchpadJoystick>(); RightStick.OnMove += RightStick_OnMove; RightStick.RectTransform.AnchorMax = new Vector2(0f, 1f); RightStick.RectTransform.AnchorMin = new Vector2(0f, 1f); RightStick.RectTransform.OffsetMin = new Vector2(1178.8f, -778f); RightStick.RectTransform.OffsetMax = new Vector2(1528.8f, -428f); RightStick.Level = 3; Sketch.SketchEngine.Instantiate <SketchBorderRenderer>(); Sketch.SketchEngine.Instantiate <RectTransformFrameRenderer>(); }
private void Stick_OnAreaStatusChanged(object sender, AreaJoystick <VirtualKeyCode> .AreaStatusChangeEventArgs <VirtualKeyCode> e) { KeyboardServiceWrapper.UpdateKeyStatus(e.Area.AreaIdentifier, (KeyStatus)e.NewStatus); }
private void KeyManager_VolumnDownKeyDown(object sender, KeyEventArgs e) { KeyboardServiceWrapper.UpdateMouseStatus(1, 0); e.Handle = true; }
private void KeyManager_VolumnUpKeyUp(object sender, KeyEventArgs e) { KeyboardServiceWrapper.UpdateMouseStatus(0, 1); e.Handle = true; }
protected override void Setup() { base.Setup(); var bluetoothManager = DependencyService.Get <IManagerManager>().BluetoothManager; var deviceInfomationService = new DeviceInfomationServiceBuilder(bluetoothManager).Build(); SensorSpeed speed = SensorSpeed.Game; Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(speed); OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged; OrientationSensor.Start(speed); bluetoothManager.GattSever.AddService(new DeviceInfomationServiceBuilder(bluetoothManager).Build()); bluetoothManager.GattSever.AddService(new RfcommServerServiceWrapper(bluetoothManager).GattServerService); KeyboardServiceWrapper = new KeyboardServiceWrapper(bluetoothManager); bluetoothManager.GattSever.AddService(KeyboardServiceWrapper.GattServerService); bluetoothManager.GattSever.StartAdvertising(); var createServiceProviderTask = bluetoothManager.CreateRfcommServiceProviderAsync(MouseServiceWrapper.ServiceId); createServiceProviderTask.Wait(); var mouseServiceProvider = createServiceProviderTask.Result; mouseServiceProvider.OnConnectionReceived += MouseServiceProvider_OnConnectionReceived;; mouseServiceProvider.StartAdvertising(); var keyManager = DependencyService.Get <IManagerManager>().KeyManager; keyManager.VolumnDownKeyDown += KeyManager_VolumnDownKeyDown; keyManager.VolumnDownKeyUp += KeyManager_VolumnDownKeyUp; keyManager.VolumnUpKeyDown += KeyManager_VolumnUpKeyDown; keyManager.VolumnUpKeyUp += KeyManager_VolumnUpKeyUp; LeftMouseButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); LeftMouseButton.RectTransform.AnchorMax = new Vector2(0f, 1f); LeftMouseButton.RectTransform.AnchorMin = new Vector2(0f, 1f); LeftMouseButton.RectTransform.OffsetMin = new Vector2(53f, -1157f); LeftMouseButton.RectTransform.OffsetMax = new Vector2(403f, -807f); LeftMouseButton.KeyDown += LeftMouseButton_KeyDown; LeftMouseButton.KeyUp += LeftMouseButton_KeyUp; RightMouseButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); RightMouseButton.RectTransform.AnchorMax = new Vector2(0f, 1f); RightMouseButton.RectTransform.AnchorMin = new Vector2(0f, 1f); RightMouseButton.RectTransform.OffsetMin = new Vector2(53f, -1552f); RightMouseButton.RectTransform.OffsetMax = new Vector2(403f, -1202f); RightMouseButton.KeyDown += RightMouseButton_KeyDown; RightMouseButton.KeyUp += RightMouseButton_KeyUp; StopMouseButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); StopMouseButton.RectTransform.AnchorMax = new Vector2(0f, 1f); StopMouseButton.RectTransform.AnchorMin = new Vector2(0f, 1f); StopMouseButton.RectTransform.OffsetMin = new Vector2(53f, -778f); StopMouseButton.RectTransform.OffsetMax = new Vector2(214.6f, -616.4f); StopMouseButton.KeyDown += StopMouseButton_KeyDown; StopMouseButton.KeyUp += StopMouseButton_KeyUp; DrawAndPressButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); DrawAndPressButton.RectTransform.AnchorMax = new Vector2(0f, 1f); DrawAndPressButton.RectTransform.AnchorMin = new Vector2(0f, 1f); DrawAndPressButton.RectTransform.OffsetMin = new Vector2(688.4f, -778f); DrawAndPressButton.RectTransform.OffsetMax = new Vector2(850f, -616.4f); DrawAndPressButton.KeyDown += DrawAndPressButton_KeyDown; DrawAndPressButton.KeyUp += DrawAndPressButton_KeyUp; MouseStick = Sketch.SketchEngine.Instantiate <TouchpadJoystick>(); MouseStick.RectTransform.AnchorMax = new Vector2(0f, 1f); MouseStick.RectTransform.AnchorMin = new Vector2(0f, 1f); MouseStick.RectTransform.OffsetMin = new Vector2(500f, -1359f); MouseStick.RectTransform.OffsetMax = new Vector2(850f, -1009f); MouseStick.OnMove += MouseStick_OnMove; OpenLazerButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); OpenLazerButton.RectTransform.AnchorMax = new Vector2(0f, 1f); OpenLazerButton.RectTransform.AnchorMin = new Vector2(0f, 1f); OpenLazerButton.RectTransform.OffsetMin = new Vector2(86f, -286.2f); OpenLazerButton.RectTransform.OffsetMax = new Vector2(436f, -78.00001f); OpenLazerButton.KeyDown += OpenLazerButton_KeyDown; OpenLazerButton.KeyUp += OpenLazerButton_KeyUp; Sketch.SketchEngine.Instantiate <SketchBorderRenderer>(); Sketch.SketchEngine.Instantiate <RectTransformFrameRenderer>(); _MouseMoving = false; }
private void KeyManager_VolumnDownKeyDown(object sender, KeyEventArgs e) { KeyboardServiceWrapper.UpdateKeyStatus(VirtualKeyCode.NEXT, KeyStatus.Pressed); e.Handle = true; }
private void KeyManager_VolumnUpKeyUp(object sender, KeyEventArgs e) { KeyboardServiceWrapper.UpdateKeyStatus(VirtualKeyCode.PRIOR, KeyStatus.Released); e.Handle = true; }
private void LeftMouseButton_KeyDown(object sender, EventArgs e) { KeyboardServiceWrapper.UpdateMouseStatus(0, 0); }
private void RightMouseButton_KeyUp(object sender, EventArgs e) { KeyboardServiceWrapper.UpdateMouseStatus(1, 1); }
private void OpenLazerButton_KeyDown(object sender, EventArgs e) { KeyboardServiceWrapper.UpdateKeyStatus(VirtualKeyCode.LCONTROL, KeyStatus.Pressed); KeyboardServiceWrapper.UpdateKeyStatus(VirtualKeyCode.VK_L, KeyStatus.Pressed); }
private void DrawAndPressButton_KeyUp(object sender, EventArgs e) { Pen = false; Laser = true; KeyboardServiceWrapper.UpdateMouseStatus(0, 1); }
public MainPage() { InitializeComponent(); //AbsoluteLayout.SetLayoutFlags(CanvasView, AbsoluteLayoutFlags.All); //AbsoluteLayout.SetLayoutBounds(CanvasView, new Rectangle(0, 0, 1, 1)); var bluetoothManager = DependencyService.Get <IManagerManager>().BluetoothManager; var deviceInfomationService = new DeviceInfomationServiceBuilder(bluetoothManager).Build(); bluetoothManager.GattSever.AddService(new DeviceInfomationServiceBuilder(bluetoothManager).Build()); //bluetoothManager.GattSever.AddService(new BatteryServiceWrapper(bluetoothManager).GattServerService); bluetoothManager.GattSever.AddService(new RfcommServerServiceWrapper(bluetoothManager).GattServerService); KeyboardServiceWrapper = new KeyboardServiceWrapper(bluetoothManager); bluetoothManager.GattSever.AddService(KeyboardServiceWrapper.GattServerService); bluetoothManager.GattSever.StartAdvertising(); var createServiceProviderTask = bluetoothManager.CreateRfcommServiceProviderAsync(GyroscopeRfcommServiceConnectionWrapper.RfcommServiceId); createServiceProviderTask.Wait(); var gyroRfcommServiceProvider = createServiceProviderTask.Result; gyroRfcommServiceProvider.OnConnectionReceived += GyroRfcommServiceProvider_OnConnectionReceived; gyroRfcommServiceProvider.StartAdvertising(); Sketch = new Sketch(); Sketch.SkiaManager.Init(CanvasView.InvalidateSurface, SKMatrix.MakeScale(1, -1)); Sketch.SketchEngine.Instantiate <GridRenderer>(); Sketch.SketchEngine.Instantiate <PointerInfoBoard>(); Sketch.SkiaManager.BeforePaint += SkiaManager_BeforePaint; ManagerManager = DependencyService.Get <IManagerManager>(); SketchInputManager = Sketch.SketchEngine.Instantiate <SketchInputManager>(); Sketch.Start(); SketchInputManager.Init(ManagerManager.InputManager); /* * var joystick = Sketch.SketchEngine.Instantiate<ColorJoystick>(); * joystick.RectTransform.AnchorMax = new Vector2(1, 1); * joystick.RectTransform.AnchorMin = new Vector2(0, 0); * joystick.RectTransform.OffsetMax = new Vector2(-800, -800); * joystick.RectTransform.OffsetMin = new Vector2(10, 10); * joystick.Level = 2; */ var joystick2 = Sketch.SketchEngine.Instantiate <LineAreaJoystick <byte> >(); joystick2.RectTransform.AnchorMax = new Vector2(0, 0); joystick2.RectTransform.AnchorMin = new Vector2(0, 0); joystick2.RectTransform.OffsetMax = new Vector2(600, 600); joystick2.RectTransform.OffsetMin = new Vector2(500, 500); joystick2.Level = 3; joystick2.AddArea(AreaJoystick <byte> .Area <byte> .CreateFromAngle((byte)VirtualKeyCode.VK_D, -60, 60, 0, float.PositiveInfinity)); joystick2.AddArea(AreaJoystick <byte> .Area <byte> .CreateFromAngle((byte)VirtualKeyCode.VK_W, 30, 150, 0, float.PositiveInfinity)); joystick2.AddArea(AreaJoystick <byte> .Area <byte> .CreateFromAngle((byte)VirtualKeyCode.VK_A, 120, 240, 0, float.PositiveInfinity)); joystick2.AddArea(AreaJoystick <byte> .Area <byte> .CreateFromAngle((byte)VirtualKeyCode.VK_S, 210, 330, 0, float.PositiveInfinity)); joystick2.AddArea(AreaJoystick <byte> .Area <byte> .CreateFromAngle((byte)VirtualKeyCode.LSHIFT, 0, 360, 0.7f, float.PositiveInfinity)); joystick2.OnAreaStatusChanged += Joystick2_OnAreaStatusChanged; var keyboardButton = Sketch.SketchEngine.Instantiate <KeyboardKeyButton>(); keyboardButton.RectTransform.AnchorMax = new Vector2(0, 0); keyboardButton.RectTransform.AnchorMin = new Vector2(0, 0); keyboardButton.RectTransform.OffsetMin = new Vector2(50, 50); keyboardButton.RectTransform.OffsetMax = new Vector2(150, 150); keyboardButton.Level = 2; ExampleSketchObject = Sketch.SketchEngine.Instantiate <ExampleSketchObject>(); Sketch.SketchEngine.Instantiate <SketchBorderRenderer>(); Sketch.SketchEngine.Instantiate <RectTransformFrameRenderer>(); CanvasView.InvalidateSurface(); ExampleSketchObject.Position = new SKPoint(Sketch.Width / 2, Sketch.Height / 2); SensorSpeed speed = SensorSpeed.Game; Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(speed); Device.StartTimer(TimeSpan.FromSeconds(1 / 60f), () => { CanvasView.InvalidateSurface(); return(!true); }); }