Skip to content

Commit

Permalink
Fixed trigger-after-grip
Browse files Browse the repository at this point in the history
Letting the runtime do the logical or between squeeze and trigger meant that if you were idling with sqeeze pressed you could not then press trigger to grab something. The grab action is split into two actions now, with one bound to squeeze and the other bound to trigger. Grabbing will now start whenever one of those actions fires and continue until they both release.
  • Loading branch information
JoeLudwig committed Jan 9, 2021
1 parent 59b3a9a commit 85ac9c9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
17 changes: 14 additions & 3 deletions websrc/default_hands/src/default_hands_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,28 @@ export let k_actionSets: ActionSet[] =
bindings:
[
...twoHandBinding( InteractionProfile.IndexController, Input.Squeeze ),
...twoHandBinding( InteractionProfile.IndexController, Input.Trigger ),

...twoHandBinding( InteractionProfile.TouchController, Input.Squeeze ),
...twoHandBinding( InteractionProfile.TouchController, Input.Trigger ),

...twoHandBinding( InteractionProfile.MixedRealityController, Input.Squeeze ),
...twoHandBinding( InteractionProfile.MixedRealityController, Input.Trigger ),

...twoHandBinding( InteractionProfile.ViveController, Input.Trigger ),

...twoHandBinding( InteractionProfile.ReverbG2Controller, Input.Squeeze ),
],
},
{
name: "grab_secondary",
localizedName: "Grab (Secondary)",
type: ActionType.Boolean,
bindings:
[
...twoHandBinding( InteractionProfile.IndexController, Input.Trigger ),

...twoHandBinding( InteractionProfile.TouchController, Input.Trigger ),

...twoHandBinding( InteractionProfile.MixedRealityController, Input.Trigger ),

...twoHandBinding( InteractionProfile.ReverbG2Controller, Input.Trigger ),
],
},
Expand Down
26 changes: 24 additions & 2 deletions websrc/default_hands/src/default_hands_main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
private grabRayHandler = 0;
private grabMoveHandler = 0;
private lastMoveTime = 0;
private rawGrabCount = 0;

constructor( props: any )
{
Expand All @@ -86,7 +87,10 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >

this.grabListenerHandle = inputProcessor.registerBooleanCallbacks( "interact", "grab",
handToDevice( this.props.hand ),
this.onGrabPressed, this.onGrabReleased );
this.onRawGrabPressed, this.onRawGrabReleased );
this.grabListenerHandle = inputProcessor.registerBooleanCallbacks( "interact", "grab_secondary",
handToDevice( this.props.hand ),
this.onRawGrabPressed, this.onRawGrabReleased );
this.menuListenerHandle = inputProcessor.registerBooleanCallbacks( "interact", "menu",
handToDevice( this.props.hand ),
this.onMenuPressed, this.onMenuReleased );
Expand Down Expand Up @@ -190,6 +194,25 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
}

@bind
private onRawGrabPressed()
{
this.rawGrabCount = Math.min( 2, this.rawGrabCount + 1 );
if( this.rawGrabCount == 1 )
{
this.onGrabPressed();
}
}

@bind
private onRawGrabReleased()
{
this.rawGrabCount = Math.max( 0, this.rawGrabCount - 1 );
if( this.rawGrabCount == 0 )
{
this.onGrabReleased();
}
}

private async onGrabPressed()
{
console.log( `${ EHand[ this.props.hand ] } grab pressed` );
Expand Down Expand Up @@ -240,7 +263,6 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
}


@bind
private async onGrabReleased()
{
console.log( `${ EHand[ this.props.hand ] } grab released` );
Expand Down

0 comments on commit 85ac9c9

Please sign in to comment.