Skip to content

QuarkXRClientPlugin Script (ConnectivityAPI and RemoteUserInputAPI)

Krasi Nikolov edited this page Jan 5, 2021 · 2 revisions

In order for any of the SDK functionalities to work you need to have QuarkXRClientPlugin.cs attached to a game object in your scene.

ConnectivityAPI

ConnectivityAPI has five events and two methods:

Events:

<ServerEventArgs> OnServerFound;

<ServerEventArgs> OnServerLost;

<ServerEventArgs> OnConnectedToServer;

<ServerEventArgs> OnDisconnectedFromServer;

<ServerEventArgs> OnConnectionToServerFailed;

Description: ServerEventArgs contains: Id, Name, Host and Port. Id can be used to connect to a remote server at a later point.

Methods:

ConnectToServer

ConnectToServer(long id)

Description: ConnectToServer lets you connect to a remote server. Id - specifies which server to connect to, and is retrieved from the OnServerFound event. If value is set to “-1” the framework will choose a random available server to connect to.

DisconnectFromServer

DisconnectFromServer()

Description: DisconnectFromServer disconnects from the server you’re connected to.

RemoteUserInputAPI

RemoteUserInputAPI has three methods for mouse input and two methods for keyboard input.

Mouse input

RemoteMoveMouse

RemoteMoveMouse(int x, int y, bool relative)

Description: Lets you move the mouse cursor. If relative is set to true, then x and y represent relative offsets (in pixels) from the current mouse position. If relative is set to false - x, y are absolute coordinates in pixels on the Windows virtual desktop.

Example 1:

If you want to move the cursor in the middle of the streamed desktop and your virtual desktop resolution is 1920x1080p you can call the function as follows: QuarkXRClientPlugin.RemoteMoveMouse(960, 540, false);

Example 2:

The usual use case for Unity applications should be the following:

if (updateMousePose)
{
   quarkXRPlugin.RemoteMoveMouse((int)(streamedScreenWidth  * hit.textureCoord.x), (int)(streamedScreenHeight * (1 - hit.textureCoord.y)), false);
}

RemoteScrollMouse

RemoteScrollMouse(int delta, bool horizontal)

Description: Lets you scroll the mouse wheel. Delta - specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. If horizontal is set to true: A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.

Example:

float scrollSpeed = 15;

private void UpdateMouseScroll()
{
    if(isPointingScreen)
    {
        Vector2 thumbstick = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick, controllerHelper.m_controller);

        if (thumbstick.y != 0)
        {
            // use Time.deltaTime to update the scroll without depending on the frame rate
            float scroll = thumbstick.y * scrollSpeed * Time.deltaTime * 100;

            quarkXRPlugin.RemoteScrollMouse((int)scroll, false);
        }
    }
}

RemotePressMouseButton

RemotePressMouseButton(KeyCode key, bool down)

Description: RemotePressMouseButton lets you send any mouse button to the streamed desktop. Valid values: KeyCode.Mouse0 - Left Button, KeyCode.Mouse1 - Right Button, KeyCode.Mouse2 - Middle Button, KeyCode.Mouse3 - First Additional Button, KeyCode.Mouse4 - Second Additional Button; down - determines whether the button is pressed

Example:

void UpdateLeftClick(OVRInput.Controller controller)
{
    if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, controller))
    {
        quarkXRPlugin.RemotePressMouseButton(KeyCode.Mouse0, true);
        isLeftClickPressed = true;
    }
    else if (isLeftClickPressed)
    {
        quarkXRPlugin.RemotePressMouseButton(KeyCode.Mouse0, false);
        isLeftClickPressed = false;
    }
}

Keyboard input

RemotePressKeyboardKey

RemotePressKeyboardKey(KeyCode key, bool down)

Description: RemotePressKeyboardKey can be used to “press” a physical key on the keyboard. Valid values : KeyCode key < 320 (KeyCode.Menu)

Example:

private void SendButtonEvent_KeyCode(KeyCode code, bool isPressed)
{
    quarkXRPlugin.RemotePressKeyboardKey(code, isPressed);
}

RemoteTypeKeyboardChar

RemoteTypeKeyboardChar(char ch)

Description: RemoteTypeKeyboardChar lets you send any unicode character (e.g. &, *, $) to the streamed desktop.

Example:

private void SendButtonEvent_Char(char character)
{
    quarkXRPlugin.RemoteTypeKeyboardChar(character);
}

Note: We recommend using RemoteTypeKeyboardChar to type any Unicode character in a text field. If needed, RemotePressKeyboardKey can be used to press any keyboard key on the remote server, including modifier, menu or function keys.

Clone this wiki locally