Created
December 26, 2016 17:41
-
-
Save demonixis/8912aecfe2861deaf6ae022f0ad5e44a to your computer and use it in GitHub Desktop.
An input device for InControl for the Oculus Touch Controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using InControl; | |
using UnityEngine; | |
namespace Demonixis.Toolbox | |
{ | |
public class OculusTouchVirtualDevice : InputDevice | |
{ | |
private Vector2 _leftTouch = Vector2.zero; | |
private Vector2 _rightTouch = Vector2.zero; | |
public float Sensitivity = 1.0f; | |
public OculusTouchVirtualDevice() | |
: base("Oculus Touch Controllers") | |
{ | |
AddControl(InputControlType.LeftStickLeft, "Left Stick Left"); | |
AddControl(InputControlType.LeftStickRight, "Left Stick Right"); | |
AddControl(InputControlType.LeftStickUp, "Left Stick Up"); | |
AddControl(InputControlType.LeftStickDown, "Left Stick Down"); | |
AddControl(InputControlType.RightStickLeft, "Right Stick Left"); | |
AddControl(InputControlType.RightStickRight, "Right Stick Right"); | |
AddControl(InputControlType.RightStickUp, "Right Stick Up"); | |
AddControl(InputControlType.RightStickDown, "Right Stick Down"); | |
AddControl(InputControlType.Action1, "A"); | |
AddControl(InputControlType.Action2, "B"); | |
AddControl(InputControlType.Action3, "X"); | |
AddControl(InputControlType.Action4, "Y"); | |
AddControl(InputControlType.LeftTrigger, "Left Trigger"); | |
AddControl(InputControlType.LeftBumper, "Left Bumper"); | |
AddControl(InputControlType.RightTrigger, "Right Trigger"); | |
AddControl(InputControlType.RightBumper, "Right Bumper"); | |
AddControl(InputControlType.Command, "Start"); | |
} | |
public override void Update(ulong updateTick, float deltaTime) | |
{ | |
UpdateLeftStickWithValue(OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick), updateTick, deltaTime); | |
UpdateRightStickWithRawValue(OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick), updateTick, deltaTime); | |
UpdateWithState(InputControlType.Action1, OVRInput.Get(OVRInput.Button.One), updateTick, deltaTime); | |
UpdateWithState(InputControlType.Action2, OVRInput.Get(OVRInput.Button.Two), updateTick, deltaTime); | |
UpdateWithState(InputControlType.Action3, OVRInput.Get(OVRInput.Button.Three), updateTick, deltaTime); | |
UpdateWithState(InputControlType.Action4, OVRInput.Get(OVRInput.Button.Four), updateTick, deltaTime); | |
UpdateWithValue(InputControlType.LeftTrigger, OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger), updateTick, deltaTime); | |
UpdateWithValue(InputControlType.LeftBumper, OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger), updateTick, deltaTime); | |
UpdateWithValue(InputControlType.RightTrigger, OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger), updateTick, deltaTime); | |
UpdateWithValue(InputControlType.RightBumper, OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger), updateTick, deltaTime); | |
UpdateWithState(InputControlType.Command, OVRInput.Get(OVRInput.Button.Start), updateTick, deltaTime); | |
Commit(updateTick, deltaTime); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment