Tilt Five™ Unity API  1.4.1
TiltFive.Input Class Reference

Provides access to Wand inputs More...

Public Types

enum class  WandButton : UInt32 {
  T5 = 1 << 0 , One = 1 << 1 , Two = 1 << 2 , Three = 1 << 7 ,
  Y = 1 << 3 , B = 1 << 4 , A = 1 << 5 , X = 1 << 6 ,
  System = T5 , Z = Three
}
 

Static Public Member Functions

static bool GetButton (WandButton button, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button is currently being pressed. More...
 
static bool TryGetButton (WandButton button, out bool pressed, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button is currently being pressed. Fails if the wand is unavailable. More...
 
static bool GetButtonDown (WandButton button, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button was pressed during this frame. More...
 
static bool TryGetButtonDown (WandButton button, out bool buttonDown, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button was pressed during this frame. Fails if the wand is unavailable. More...
 
static bool GetButtonUp (WandButton button, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button was released during this frame. More...
 
static bool TryGetButtonUp (WandButton button, out bool buttonUp, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Whether the indicated wand button was released during this frame. Fails if the wand is unavailable. More...
 
static Vector2 GetStickTilt (ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Gets the direction and magnitude of the stick's tilt for the indicated wand. More...
 
static bool TryGetStickTilt (out Vector2 stickTilt, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Gets the direction and magnitude of the stick's tilt for the indicated wand. Fails if the wand is unavailable. More...
 
static float GetTrigger (ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Gets the degree to which the trigger is depressed, from 0.0 (released) to 1.0 (fully depressed). More...
 
static bool TryGetTrigger (out float triggerDisplacement, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
 Gets the degree to which the trigger is depressed, from 0.0 (released) to 1.0 (fully depressed). Fails if the wand is unavailable. More...
 
static bool GetWandAvailability (ControllerIndex controllerIndex=ControllerIndex.Right)
 Gets the connection status of the indicated wand. More...
 
static void Update ()
 

Static Private Member Functions

static Input ()
 

Detailed Description

Provides access to Wand inputs

Definition at line 30 of file Input.cs.

Member Enumeration Documentation

◆ WandButton

enum TiltFive.Input.WandButton : UInt32
strong
Enumerator
T5 
One 
Two 
Three 
System 

Definition at line 34 of file Input.cs.

35  {
36  T5 = 1 << 0,
37  One = 1 << 1,
38  Two = 1 << 2,
39  Three = 1 << 7,
40  Y = 1 << 3,
41  B = 1 << 4,
42  A = 1 << 5,
43  X = 1 << 6,
44  [Obsolete("WandButton.System is deprecated, please use Wandbutton.T5 instead.")]
45  System = T5,
46  [Obsolete("WandButton.Z is deprecated, please use Wandbutton.Three instead.")]
47  Z = Three,
48  }

Constructor & Destructor Documentation

◆ Input()

static TiltFive.Input.Input ( )
staticprivate

Definition at line 324 of file Input.cs.

325  {
326  Wand.Scan();
327  }

Member Function Documentation

◆ GetButton()

static bool TiltFive.Input.GetButton ( WandButton  button,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button is currently being pressed.

Parameters
buttonThe wand button to check.
controllerIndexUnless specified, the state of the right-hand wand is returned.

If the wand is unavailable, this function returns a default value of false.

Returns
Returns true if the button is being pressed
Parameters
playerIndexThe index of the player using the wand we want to query.
Returns

Definition at line 74 of file Input.cs.

76  {
77  return TryGetButton(button, out var pressed, controllerIndex, playerIndex) && pressed;
78  }
static bool TryGetButton(WandButton button, out bool pressed, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
Whether the indicated wand button is currently being pressed. Fails if the wand is unavailable.
Definition: Input.cs:89

References TiltFive.Input.TryGetButton().

◆ GetButtonDown()

static bool TiltFive.Input.GetButtonDown ( WandButton  button,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button was pressed during this frame.

Parameters
buttonThe wand button to check.
controllerIndexUnless specified, the state of the right-hand wand is returned.
playerIndexThe index of the player using the wand we want to query.

If the wand is unavailable, this function returns a default value of false.

Returns
Returns true if the button was pressed during this frame.

Definition at line 109 of file Input.cs.

111  {
112  return TryGetButtonDown(button, out var buttonDown, controllerIndex, playerIndex) && buttonDown;
113  }
static bool TryGetButtonDown(WandButton button, out bool buttonDown, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
Whether the indicated wand button was pressed during this frame. Fails if the wand is unavailable.
Definition: Input.cs:124

References TiltFive.Input.TryGetButtonDown().

◆ GetButtonUp()

static bool TiltFive.Input.GetButtonUp ( WandButton  button,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button was released during this frame.

Parameters
buttonThe wand button to check.
controllerIndexUnless specified, the state of the right-hand wand is returned.
playerIndexThe index of the player using the wand we want to query.
Returns
Returns true if the button was released this frame, or false if the wand is unavailable.

Definition at line 144 of file Input.cs.

146  {
147  return TryGetButtonUp(button, out var buttonUp, controllerIndex, playerIndex) && buttonUp;
148  }
static bool TryGetButtonUp(WandButton button, out bool buttonUp, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
Whether the indicated wand button was released during this frame. Fails if the wand is unavailable.
Definition: Input.cs:160

References TiltFive.Input.TryGetButtonUp().

◆ GetStickTilt()

static Vector2 TiltFive.Input.GetStickTilt ( ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Gets the direction and magnitude of the stick's tilt for the indicated wand.

Parameters
controllerIndexUnless specified, the state of the right-hand wand joystick is used.
playerIndexThe index of the player using the wand we want to query.
Returns
Returns a vector representing the direction and magnitude of the stick's tilt.

Definition at line 180 of file Input.cs.

181  {
182  if(TryGetStickTilt(out var stickTilt, controllerIndex, playerIndex))
183  {
184  return stickTilt;
185  }
186  return Vector2.zero;
187  }
static bool TryGetStickTilt(out Vector2 stickTilt, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
Gets the direction and magnitude of the stick's tilt for the indicated wand. Fails if the wand is una...
Definition: Input.cs:196

References TiltFive.Input.TryGetStickTilt().

◆ GetTrigger()

static float TiltFive.Input.GetTrigger ( ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Gets the degree to which the trigger is depressed, from 0.0 (released) to 1.0 (fully depressed).

Parameters
controllerIndexUnless specified, the state of the right-hand wand trigger is used.
playerIndexThe index of the player using the wand we want to query.
Returns
Returns a float representing how much the trigger has depressed by the user, from 0.0 (released) to 1.0 (fully depressed).

Definition at line 214 of file Input.cs.

215  {
216  if(TryGetTrigger(out var triggerDisplacement, controllerIndex, playerIndex))
217  {
218  return triggerDisplacement;
219  }
220  return 0f;
221  }
static bool TryGetTrigger(out float triggerDisplacement, ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One)
Gets the degree to which the trigger is depressed, from 0.0 (released) to 1.0 (fully depressed)....
Definition: Input.cs:231

References TiltFive.Input.TryGetTrigger().

◆ GetWandAvailability()

static bool TiltFive.Input.GetWandAvailability ( ControllerIndex  controllerIndex = ControllerIndex.Right)
static

Gets the connection status of the indicated wand.

Parameters
controllerIndexUnless specified, the right-hand wand is queried.
Returns
Returns true if connected, false otherwise.

Definition at line 247 of file Input.cs.

248  {
249  return Wand.TryCheckConnected(out var connected, PlayerIndex.One, controllerIndex) && connected;
250  }
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

References TiltFive.Wand.TryCheckConnected().

◆ TryGetButton()

static bool TiltFive.Input.TryGetButton ( WandButton  button,
out bool  pressed,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button is currently being pressed. Fails if the wand is unavailable.

Parameters
buttonThe wand button to check.
pressed
controllerIndexUnless specified, the state of the right-hand wand is returned.
playerIndexThe index of the player using the wand we want to query.

If the wand is unavailable, this function returns false and pressed is set to a default value of false.

Returns
Returns true if the button state was successfully obtained.

Definition at line 89 of file Input.cs.

91  {
92  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
93  {
94  pressed = false;
95  return false;
96  }
97 
98  return Wand.TryGetButton(button, out pressed, glassesHandle, controllerIndex);
99  }

Referenced by TiltFive.Input.GetButton().

◆ TryGetButtonDown()

static bool TiltFive.Input.TryGetButtonDown ( WandButton  button,
out bool  buttonDown,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button was pressed during this frame. Fails if the wand is unavailable.

Parameters
buttonThe wand button to check.
buttonDownWhether the button was pressed during this frame.
controllerIndexUnless specified, the state of the right-hand wand is returned.
playerIndexThe index of the player using the wand we want to query.

If the wand is unavailable, this function returns false and buttonDown is given a default value of false.

Returns
Returns true if the button state was successfully obtained.

Definition at line 124 of file Input.cs.

126  {
127  // The specified player's glasses aren't even connected, let alone the wand. No way to get a rising edge here.
128  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
129  {
130  buttonDown = false;
131  return false;
132  }
133 
134  return Wand.TryGetButtonDown(button, out buttonDown, glassesHandle, controllerIndex);
135  }

Referenced by TiltFive.Input.GetButtonDown().

◆ TryGetButtonUp()

static bool TiltFive.Input.TryGetButtonUp ( WandButton  button,
out bool  buttonUp,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Whether the indicated wand button was released during this frame. Fails if the wand is unavailable.

Parameters
buttonThe wand button to check.
buttonUpWhether the button was released during this frame.
controllerIndexUnless specified, the state of the right-hand wand is returned.
playerIndexThe index of the player using the wand we want to query.

If the wand is unavailable, this function returns false and buttonUp is set to the return value of GetButtonUp(WandButton, WandTarget) GetButtonUp.

Returns
Returns true if the button state was successfully obtained.

Definition at line 160 of file Input.cs.

162  {
163  // TODO: Tweak the Wand.cs TryGetButtonDown to check if the glasses disconnected this frame.
164  // If it did, and the button was held last frame, then buttonUp can be true.
165  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
166  {
167  buttonUp = false;
168  return false;
169  }
170 
171  return Wand.TryGetButtonUp(button, out buttonUp, glassesHandle, controllerIndex);
172  }

Referenced by TiltFive.Input.GetButtonUp().

◆ TryGetStickTilt()

static bool TiltFive.Input.TryGetStickTilt ( out Vector2  stickTilt,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Gets the direction and magnitude of the stick's tilt for the indicated wand. Fails if the wand is unavailable.

Parameters
stickTiltA vector representing the direction and magnitude of the stick's tilt.
controllerIndexUnless specified, the state of the right-hand wand joystick is used.
playerIndexThe index of the player using the wand we want to query.
Returns
Returns true if the joystick state was successfully obtained.

Definition at line 196 of file Input.cs.

198  {
199  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
200  {
201  stickTilt = Vector2.zero;
202  return false;
203  }
204  return Wand.TryGetStickTilt(out stickTilt, glassesHandle, controllerIndex);
205  }

Referenced by TiltFive.Input.GetStickTilt().

◆ TryGetTrigger()

static bool TiltFive.Input.TryGetTrigger ( out float  triggerDisplacement,
ControllerIndex  controllerIndex = ControllerIndex.Right,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Gets the degree to which the trigger is depressed, from 0.0 (released) to 1.0 (fully depressed). Fails if the wand is unavailable.

Parameters
triggerDisplacementA float representing how much the trigger has depressed by the user, from 0.0 (released) to 1.0 (fully depressed).
controllerIndexUnless specified, the state of the right-hand wand trigger is used.
playerIndexThe index of the player using the wand we want to query.
Returns
Returns true if the trigger state was successfully obtained.

Definition at line 231 of file Input.cs.

233  {
234  if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
235  {
236  triggerDisplacement = 0f;
237  return false;
238  }
239  return Wand.TryGetTrigger(out triggerDisplacement, glassesHandle, controllerIndex);
240  }

Referenced by TiltFive.Input.GetTrigger().

◆ Update()

static void TiltFive.Input.Update ( )
static

Definition at line 252 of file Input.cs.

253  {
254  // Deleting this function would be appropriate, but since it's public,
255  // there's a small chance it could break someone's code...
256  // ...not that I can think of a use-case that involves calling TiltFive.Input.Update()
257  }

The documentation for this class was generated from the following file: