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).
Afficher le fichier Open project: leapmotion/ImageGrid Class Usage Examples

Méthodes publiques

Свойство Type Description
verbose bool

Méthodes publiques

Méthode 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

Méthode 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 méthode

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
Résultat void

AddInputHandler() public static méthode

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
Résultat void

AddInputHandler() public static méthode

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
Résultat void

AddInputMapping() public static méthode

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

ClearControlMappings() public static méthode

Removes all control mappings.
public static ClearControlMappings ( ) : void
Résultat void

GetJoystickAxis() public static méthode

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

GetJoystickAxis() public static méthode

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
Résultat float

GetJoystickButton() public static méthode

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

GetJoystickButton() public static méthode

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
Résultat bool

GetMouseButton() public static méthode

public static GetMouseButton ( MouseButton, button ) : bool
button MouseButton,
Résultat bool

ReadJoystickAxis() public static méthode

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

ReadJoystickButton() public static méthode

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

RemoveInputMapping() public static méthode

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

Update() public static méthode

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
Résultat void

Property Details

verbose public_oe static_oe property

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