Tilt Five Unity API  1.3.0
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
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 bool SetRumbleMotor (uint motor, float intensity)
 
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 340 of file Input.cs.

341  {
342  Wand.ScanForWands();
343  }

References TiltFive.Wand.ScanForWands().

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 73 of file Input.cs.

75  {
76  return TryGetButton(button, out var pressed, controllerIndex, playerIndex) && pressed;
77  }
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:88

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 108 of file Input.cs.

110  {
111  return TryGetButtonDown(button, out var buttonDown, controllerIndex, playerIndex) && buttonDown;
112  }
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:123

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 143 of file Input.cs.

145  {
146  return TryGetButtonUp(button, out var buttonUp, controllerIndex, playerIndex) && buttonUp;
147  }
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:159

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 179 of file Input.cs.

180  {
181  if(TryGetStickTilt(out var stickTilt, controllerIndex, playerIndex))
182  {
183  return stickTilt;
184  }
185  return Vector2.zero;
186  }
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:195

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 213 of file Input.cs.

214  {
215  if(TryGetTrigger(out var triggerDisplacement, controllerIndex, playerIndex))
216  {
217  return triggerDisplacement;
218  }
219  return 0f;
220  }
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:230

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 246 of file Input.cs.

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

References TiltFive.Wand.TryCheckConnected().

Referenced by TiltFive.Wand.TryScanForWands().

◆ SetRumbleMotor()

static bool TiltFive.Input.SetRumbleMotor ( uint  motor,
float  intensity 
)
static

Definition at line 252 of file Input.cs.

253  {
254 
255  int result = 0;
256  try
257  {
258  result = NativePlugin.SetRumbleMotor(motor, intensity);
259  }
260  catch (Exception e)
261  {
262  Log.Error(e.Message);
263  }
264 
265  return (0 != result);
266  }
The Logger.
Definition: Log.cs:42
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127

References TiltFive.Logging.Log.Error(), and TiltFive.NativePlugin.SetRumbleMotor().

◆ 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 88 of file Input.cs.

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

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 123 of file Input.cs.

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

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 159 of file Input.cs.

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

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 195 of file Input.cs.

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

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 230 of file Input.cs.

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

Referenced by TiltFive.Input.GetTrigger().

◆ Update()

static void TiltFive.Input.Update ( )
static

Definition at line 268 of file Input.cs.

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

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