Joy-Con WebHID is a Javascript driver for Nintendo Joy-Cons with support for all buttons, analog sticks, and the device’s gyroscope and accelerometer sensors.
As you can see in the demo the orientation for ‘beta’ and ‘gamma’ stays in place, but for ‘alpha’ is always decreasing until it reaches zero.
How to prevent that?
if (joyCon instanceof JoyConLeft) {
rootStyle.setProperty('--left-alpha', `${orientation.alpha}deg`);
rootStyle.setProperty('--left-beta', `${orientation.beta}deg`);
rootStyle.setProperty('--left-gamma', `${orientation.gamma}deg`);
} else if (joyCon instanceof JoyConRight) {
rootStyle.setProperty('--right-alpha', `${orientation.alpha}deg`);
rootStyle.setProperty('--right-beta', `${orientation.beta}deg`);
rootStyle.setProperty('--right-gamma', `${orientation.gamma}deg`);
}
Full source code here.
I would like to control a sword for a Javacript game using this driver.
How to correctly achieve that?