C# Class OVRInputControl

Cross-platform wrapper for Unity Input. See OVRGamepadController for a list of the base axis and button names. Depending on joystick number and platform the base names will be pre-pended with "Platform:Joy #:" to look them up in the Unity Input table. For instance: using an axis name of "Left_X_Axis" with GetJoystickAxis() will result in looking up the axis named "Win: Joy 1: Left_X_Axis" when running on Windows and "Android: Joy 1: Left_X_Axis" when running on Android. In addition to wrapping joystick input, this class allows the assignment of up, held and down events for any key, mouse button, or joystick button via the AddInputHandler() method. Currently this class relies on enumerations defined in OVRGamepadController so that it remains compatible with existing Unity OVR projects. When this class is included it overloads the default GPC_GetAxis() and GPC_GetButton() calls to to ReadAxis() and ReadButton() in this class. Ideally this class would completely replace the OVRGamepadController class. This would involve changing the GPC_GetAxis() and GPC_GetButton() calls in a project and removing references to OVRGamepadController in this file (and moving some of the tables to InputControl).
ファイルを表示 Open project: leapmotion/ImageGrid Class Usage Examples

Public Properties

Property Type Description
verbose bool

Public Methods

Method Description
AddInputHandler ( DeviceType dt, MouseButton, mouseButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for mouse button input.

AddInputHandler ( DeviceType dt, OVRGamepadController, joystickButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for joystick button input.

AddInputHandler ( DeviceType dt, string keyName, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for key input

AddInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Adds a mapping from a joystick to a behavior.

ClearControlMappings ( ) : void

Removes all control mappings.

GetJoystickAxis ( int joystickNumber, OVRGamepadController, axis ) : float

Delegate for OVRGamepadController. Returns the current value of the specified joystick axis.

GetJoystickAxis ( int joystickNumber, string name ) : float

Returns the current value of the joystick axis specified by the name parameter. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Left_X_Axis" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Left_X_Axis" before it is queried.

GetJoystickButton ( int joystickNumber, OVRGamepadController, button ) : bool

Delegate for OVRGamepadController. Returns true if the specified joystick button is pressed.

GetJoystickButton ( int joystickNumber, string name ) : bool

Returns true if a joystick button is depressed. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Button A" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Button A" before it is queried.

GetMouseButton ( MouseButton, button ) : bool
ReadJoystickAxis ( OVRGamepadController, axis ) : float

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.

ReadJoystickButton ( OVRGamepadController, button ) : bool

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.

RemoveInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Removes a mapping from a joystick to a behavior.

Update ( ) : void

Updates the state of all input mappings. This must be called from a single MonoBehaviour's Update() method for input to be read.

Private Methods

Method Description
Init_Android ( ) : void

Initializes the input system for Android.

Init_OSX ( ) : void

Initializes the input system for OSX.

Init_OSX_Editor ( ) : void

Initializes the input system for OSX when running from the Unity editor.

Init_Windows ( ) : void

Initializes the input system for OSX.

Init_Windows_Editor ( ) : void

Initializes the input system for Windows when running from the Unity editor.

Init_iPhone ( ) : void

Initializes the input system for iPhone.

OVRInputControl ( ) : UnityEngine

Static contructor for the OVRInputControl class.

ShowAxisValues ( ) : void

Outputs debug spam for any non-zero axis. This is only used for finding which axes are which with new controllers.

ShowButtonValues ( ) : void

Outputs debug spam for any depressed button. This is only used for finding which buttons are which with new controllers.

UpdateInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Updates a single input mapping.

Method Details

AddInputHandler() public static method

Adds a handler for mouse button input.
public static AddInputHandler ( DeviceType dt, MouseButton, mouseButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
mouseButton MouseButton,
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
return void

AddInputHandler() public static method

Adds a handler for joystick button input.
public static AddInputHandler ( DeviceType dt, OVRGamepadController, joystickButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
joystickButton OVRGamepadController,
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
return void

AddInputHandler() public static method

Adds a handler for key input
public static AddInputHandler ( DeviceType dt, string keyName, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
keyName string
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
return void

AddInputMapping() public static method

Adds a mapping from a joystick to a behavior.
public static AddInputMapping ( int joystickNumber, MonoBehaviour comp ) : void
joystickNumber int
comp MonoBehaviour
return void

ClearControlMappings() public static method

Removes all control mappings.
public static ClearControlMappings ( ) : void
return void

GetJoystickAxis() public static method

Delegate for OVRGamepadController. Returns the current value of the specified joystick axis.
public static GetJoystickAxis ( int joystickNumber, OVRGamepadController, axis ) : float
joystickNumber int
axis OVRGamepadController,
return float

GetJoystickAxis() public static method

Returns the current value of the joystick axis specified by the name parameter. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Left_X_Axis" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Left_X_Axis" before it is queried.
public static GetJoystickAxis ( int joystickNumber, string name ) : float
joystickNumber int
name string
return float

GetJoystickButton() public static method

Delegate for OVRGamepadController. Returns true if the specified joystick button is pressed.
public static GetJoystickButton ( int joystickNumber, OVRGamepadController, button ) : bool
joystickNumber int
button OVRGamepadController,
return bool

GetJoystickButton() public static method

Returns true if a joystick button is depressed. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Button A" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Button A" before it is queried.
public static GetJoystickButton ( int joystickNumber, string name ) : bool
joystickNumber int
name string
return bool

GetMouseButton() public static method

public static GetMouseButton ( MouseButton, button ) : bool
button MouseButton,
return bool

ReadJoystickAxis() public static method

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.
public static ReadJoystickAxis ( OVRGamepadController, axis ) : float
axis OVRGamepadController,
return float

ReadJoystickButton() public static method

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.
public static ReadJoystickButton ( OVRGamepadController, button ) : bool
button OVRGamepadController,
return bool

RemoveInputMapping() public static method

Removes a mapping from a joystick to a behavior.
public static RemoveInputMapping ( int joystickNumber, MonoBehaviour comp ) : void
joystickNumber int
comp MonoBehaviour
return void

Update() public static method

Updates the state of all input mappings. This must be called from a single MonoBehaviour's Update() method for input to be read.
public static Update ( ) : void
return void

Property Details

verbose public_oe static_oe property

If true, prints information about each input event to the log.
public static bool verbose
return bool