Skip to content
Jules Blok edited this page Feb 26, 2019 · 13 revisions

Deprecated

Input scripting has been replaced by SteamVR Input in version 1.4.0 and above.

howto

Old Scripting Functionality

Overview

Revive supports scripting the Oculus Touch input mapping, this allows for full customization of any part of the input mapping. Scripts are loaded from the Documents\Revive\Input folder, while it is possible to get Revive to load your script by default (by naming it default.lua), it's often preferable to make your script game-specific.

You can do this by finding the game in your Oculus Apps\Software folder and using the folder name as the name for your input script. For example a script written specifically for Robo Recall would be named epic-games-odin.lua. This ensures that every time Robo Recall is started through either the Revive Dashboard or through SteamVR the new script is loaded.

Scripting documentation

The default input mapping can be seen in the repository, it may be helpful to download it as a base for your new script: https://github.com/LibreVR/Revive/blob/master/Revive/default.lua

Each input script is associated with a certain controller and has access to the following pre-defined globals:

Global Description
state The last known state of the controller associated with this script.
time Time in seconds when the last known state was queried.
controller_model The model name of this controller.
grip_mode The user configuration for the grip button. Deprecated.

Every function has access to a global state table that contains buttons and axes. All buttons and axes have members that indicate whether it is pressed or touched. The following buttons are available:

Button Description
System The bottom-most button on the Vive controller, reserved for the dashboard.
ApplicationMenu The top-most button on the Vive controller.
Grip The side buttons on the controller.
DPad_<direction> There are Left, Up, Right and Down variants for the DPad, they are unused.
A, B, X, Y Some custom controllers may use these to expose extra buttons.
ProximitySensor You can use this to determine whether the user has the headset on...

The axes are in the array part of the table, they can be accessed with the indices 1 through 5. The commonly known axes are also given using the constants state[SteamVR_Touchpad] and state[SteamVR_Trigger].

An input mapping script needs to contain following functions. Each of these functions has the parameter right_hand which indicates whether or not the buttons are being queried for the right-handed touch controller (The one with the A and B buttons).

GetButtons(right_hand)

This function needs to return all the currently pressed buttons on the controller. Because this function requires you to return multiple values it's easiest to first gather all buttons in a table and then unpacking that table upon return by calling unpack() on the table.

The constants that can be returned form this function are defined as follows:

Button Constant Description
ovrButton_A A button on the right Touch controller.
ovrButton_B B button on the right Touch controller.
ovrButton_RThumb Thumb stick button on the right Touch controller.
ovrButton_X X button on the left Touch controller.
ovrButton_Y Y button on the left Touch controller.
ovrButton_LThumb Thumb stick button on the left Touch controller.
ovrButton_Enter Enter button on the left Touch controller.

GetTouches(right_hand)

This function needs to return all the currently touched buttons and gestures on the controller. Because this function requires you to return multiple values it's easiest to first gather all buttons in a table and then unpacking that table upon return by calling unpack() on the table.

The constants that can be returned form this function are defined as follows:

Touch Constant Description
ovrTouch_A User is touching A button on the right controller.
ovrTouch_B User is touching B button on the right controller.
ovrTouch_RThumb User has a finger on the thumb stick of the right controller.
ovrTouch_RThumbRest User has a finger on the textured thumb rest of the right controller.
ovrTouch_RIndexTrigger User is touching the index finger trigger on the right controller.
ovrTouch_X User is touching X button on the left controller.
ovrTouch_Y User is touching Y button on the left controller.
ovrTouch_LThumb User has a finger on the thumb stick of the left controller.
ovrTouch_LThumbRest User has a finger on the textured thumb rest of the left controller.
ovrTouch_LIndexTrigger User is touching the index finger trigger on the left controller.
ovrTouch_RIndexPointing Users right index finger is pointing forward past the trigger.
ovrTouch_RThumbUp Users right thumb is up and away from buttons on the controller, a gesture that can be interpreted as right thumbs up.
ovrTouch_LIndexPointing Users left index finger is pointing forward past the trigger.
ovrTouch_LThumbUp Users left thumb is up and away from buttons on the controller, a gesture that can be interpreted as left thumbs up.

GetThumbstick(right_hand, deadzone)

This function returns the x and y values of the current thumbstick position. Optionally a small deadzone can be applied to the user-configureable deadzone setting is given by the deadzone parameter.

GetTriggers(right_hand)

This function returns the index trigger and grip (hand) trigger values.