예제 #1
0
 /// <summary>
 /// Updates the KeyboardManager status with the current connection status of the VncManager observed,
 /// indicating if key strokes should be sent to the server or not.
 /// </summary>
 public void UpdateObserver()
 {
     if (VncManager.GetInstance(true) != null)
     {
         _isOnline = VncManager.GetInstance(true).ConnectionStatus;
     }
     _isOnScreen = !_isOnScreen;
 }
예제 #2
0
        /// <summary>
        /// Takes the input key detected by Unity, translates it regarding the present key modifiers
        /// (Shift, AltGr and Caps Lock), then translates it into its hexadecimal virtual keycode and sends it over
        /// to game VncClient.
        /// </summary>
        /// <param name="keyCode">Key stroke detected by the game.</param>
        /// <param name="pressed">True if the key stroke is a key press, false if it is a key release.</param>
        private IEnumerator <float> TranslateKeyStroke(KeyCode keyCode, bool pressed)
        {
            // If a modifier key was pressed down or up, update the corresponding modifier.
            CheckModifiers(keyCode, pressed);

            // Translate the received keycode to its byte representation sent to server
            uint virtualKey = VirtualKeyFromKey(keyCode);

            // Send the key stroke to server, marking it as a press or release
            if (VncManager.GetInstance(true) != null)
            {
                VncManager.GetInstance(true).SendKeyToServer(virtualKey, pressed);
            }

            yield break;
        }