Skip to content

Commit 6397664

Browse files
authored
Merge pull request #290 from Thaina/patch-1
fix typo and simplified boolean logic
2 parents 0404faf + a535eb7 commit 6397664

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

Packages/webxr/Runtime/Plugins/WebGL/webxr.jspre

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,8 @@ setTimeout(function () {
995995
if (xrData.controllerA.updatedProfiles == 1 || xrData.controllerB.updatedProfiles == 1)
996996
{
997997
var inputProfiles = {};
998-
inputProfiles.conrtoller1 = xrData.controllerA.profiles;
999-
inputProfiles.conrtoller2 = xrData.controllerB.profiles;
998+
inputProfiles.controller1 = xrData.controllerA.profiles;
999+
inputProfiles.controller2 = xrData.controllerB.profiles;
10001000
if (xrData.controllerA.updatedProfiles == 1)
10011001
{
10021002
xrData.controllerA.updatedProfiles = 2;

Packages/webxr/Runtime/Scripts/WebXRControllerData.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public class WebXRControllerData
3434
[System.Serializable]
3535
public class WebXRControllersProfiles
3636
{
37-
public string[] conrtoller1;
38-
public string[] conrtoller2;
37+
public string[] controller1;
38+
public string[] controller2;
3939
}
4040

4141
public enum WebXRHandJoint
@@ -122,26 +122,9 @@ public WebXRControllerButton(bool isPressed, bool isTouched, float buttonValue)
122122

123123
public void UpdateState(bool isPressed, bool isTouched, float buttonValue)
124124
{
125-
if (isPressed && pressed) // nothing
126-
{
127-
down = false;
128-
up = false;
129-
}
130-
else if (isPressed && !pressed) // up
131-
{
132-
down = true;
133-
up = false;
134-
}
135-
else if (!isPressed && !pressed) // nothing
136-
{
137-
down = false;
138-
up = false;
139-
}
140-
else if (!isPressed && pressed) // down
141-
{
142-
down = false;
143-
up = true;
144-
}
125+
down = isPressed && !pressed;
126+
up = !isPressed && pressed;
127+
145128
pressed = isPressed;
146129
touched = isTouched;
147130
value = buttonValue;

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ public void OnXRCapabilities(WebXRDisplayCapabilities cap)
395395

396396
public void OnInputProfiles(WebXRControllersProfiles controllersProfiles)
397397
{
398-
controller1.profiles = controllersProfiles.conrtoller1;
399-
controller2.profiles = controllersProfiles.conrtoller2;
398+
controller1.profiles = controllersProfiles.controller1;
399+
controller2.profiles = controllersProfiles.controller2;
400400
}
401401

402402
public void setXrState(WebXRState state, int viewsCount, Rect leftRect, Rect rightRect)

0 commit comments

Comments
 (0)