void Update() { if (Input.GetKeyDown(KeyCode.T)) { #if !UNITY_EDITOR if (transparent) { Camera.main.backgroundColor = Color.green; WindowApi.Opacify(); } else { Camera.main.clearFlags = CameraClearFlags.Color; Camera.main.backgroundColor = Color.clear; WindowApi.Transparentize(); } #endif transparent = !transparent; } else if (Input.GetKeyDown(KeyCode.E)) { if (monitoring) { MouseApi.Release(); KeyApi.Release(); } else { MouseApi.ObserveLeftMouseDown(() => Debug.Log("left mouse down")); MouseApi.ObserveLeftMouseUp(() => Debug.Log("left mouse up")); MouseApi.ObserveRightMouseDown(() => Debug.Log("right mouse down")); MouseApi.ObserveRightMouseUp(() => Debug.Log("right mouse up")); // accessibility permission is required KeyApi.ObserveKeyDown(code => Debug.Log($"key down: {code}")); KeyApi.ObserveKeyUp(code => Debug.Log($"key up: {code}")); } monitoring = !monitoring; } }
private void Start() { if (KeyApi.IsKeyEventObservable()) { KeyApi.ObserveKeyDown(code => { if (enabled) { ReceiveKeyPressed(code.ToUpper()); } }); } MouseApi.ObserveLeftMouseDown(() => { if (enabled) { ReceiveMouseButton(FingerController.LDown); } }); MouseApi.ObserveRightMouseDown(() => { if (enabled) { ReceiveMouseButton(FingerController.RDown); } }); _receivedMessageHandler.Commands.Subscribe((message) => { switch (message.Command) { case MessageCommandNames.EnableDesktopShareMode: { enabled = message.ToBoolean(); break; } } }); }