-
Notifications
You must be signed in to change notification settings - Fork 1
Analog Stick Events
Event | Fires when… |
---|---|
gc.analog.start |
…an analog stick moves from center. |
gc.analog.hold |
…an analog stick is away from center. Fires continuously until the analog stick returns to center. |
gc.analog.change |
…an analog stick's position changes. Similar to gc.analog.hold , but does not fire when the stick is away from center but the position hasn't changed. |
gc.analog.end |
…an analog stick returns to center. |
These events pass an AnalogStick instance to the detail
property of the Event
object.
window.addEventListener('gc.analog.hold', function(event) {
console.log(event.detail);
}, false);
>> AnalogStick {…}
This is fired as when an analog stick leaves it's center position.
This event fires rapidly as long as an analog stick is not at it's center positon. The interval at which it fires is tied to requestAnimationFrame()
and therefor cannot be guaranteed to be regular.
This event fires any time the analog stick's position has changed since the last update. It is similar to gc.analog.hold
with the main difference being that it does not fire while the stick is held still in a single location.
This is fired when an analog stick returns to it's center postion.
An AnalogStick
object represents an analog stick input's state.
Name | Type | Description |
---|---|---|
controllerIndex |
Int |
The [[index |
time |
Int |
A DOMHighResTimeStamp representing when the analog stick was updated. |
name |
String |
The name of the analog stick. |
position.x |
Float |
A number between -1 (left) and 1 (right), indicating the x-axis position of the analog stick. |
position.y |
Float |
A number between -1 (up) and 1 (down), indicating the y-axis position of the analog stick. |
angle.degrees |
Float /NaN
|
A number between 0 and 360 indicating the angle in degrees the analog stick is pressed, or NaN if the stick is at origin. |
angle.radians |
Float /NaN
|
A number between 0 and ~6.283 ( 2π ) indicating the angle in radians the analog stick is pressed, or NaN if the stick is at origin. |
Be aware that the recommended method of checking whether a value is NaN
is to use the isNaN()
function.
// AnalogStick object
AnalogStick {
controllerIndex: 0,
time: 4526.165,
name: "LEFT_ANALOG_STICK",
position: { x: 0, y: 0 },
angle: { degrees: NaN, radians: NaN }
}
The MIT License (MIT)
Copyright © 2022 Jack Carey
Setup
Buttons & Analog Sticks
Controller Layouts
Configuring Settings
Controller Events
Button Events
Analog Stick Events
Controller.supported
Controller.controllers
Controller.controllerCount
Controller.search()
Controller.getController()
Controller.watchAll()
Controller.unwatchAll()
.connectedTimestamp
.id
.index
.inputs
.layoutInfo
.name
.watch()
.unwatch()
Settings Objects
List of Settings
settings.list()
settings.clear()
settings.update()
→ Grunt Tasks
→ Registering Settings
→ Creating Layout Maps