diff --git a/assets/virtual-gamepad-logo-moshed-D18MUEaX.gif b/assets/virtual-gamepad-logo-moshed-D18MUEaX.gif new file mode 100644 index 0000000..9134901 Binary files /dev/null and b/assets/virtual-gamepad-logo-moshed-D18MUEaX.gif differ diff --git a/docs/assets/custom.css b/docs/assets/custom.css deleted file mode 100644 index 3cd6de8..0000000 --- a/docs/assets/custom.css +++ /dev/null @@ -1,123 +0,0 @@ -:root { - /* --light-color-background: #f2f4f8 !important; */ - /* --light-color-background-secondary: #8eccfa !important; */ - --light-color-accent: #67b3f6 !important; - --dark-color-accent: #083862 !important; - --light-code-background: #e0ebf5 !important; - /* --color-accent: #3582c4 !important; */ -} - -.tsd-page-toolbar { - padding: .5em 0; -} - -html .col-content { - padding-top: 6rem; -} - -html .menu-sticky-wrap { - top: 0; - margin-top: 0; - - height: 100vh; - padding-bottom: 2em; - padding-top: 5em; - box-sizing: border-box; -} - -html .menu-sticky-wrap.col-menu--hide { - padding-top: 1em; -} - -.tsd-index-accordion, -.tsd-panel.tsd-member { - margin-bottom: 2rem; - padding: 1.6rem; - background: white; - border-radius: 20px; - border: 1px solid var(--color-accent); -} - -.tsd-accordion-summary h5 { - margin-top: 0; -} - -.tsd-signatures .tsd-signature, -.tsd-signature { - background: var(--code-background); - border: none; - border-radius: 40px; - padding: 1rem; -} - -.tsd-parameter-signature { - list-style: none; -} - -a.tsd-index-link { - /* width: 100%; - flex-wrap: wrap; - justify-content: start; */ -} - -.tsd-navigation a.current, -.tsd-page-navigation a.current { - border-radius: 0.33em; -} - -#tsd-search { - border-radius: 0.33em; -} - -@media (prefers-color-scheme: dark) { - - .tsd-index-accordion, - .tsd-panel.tsd-member { - background: black; - } - - .tsd-signatures .tsd-signature, - .tsd-signature { - background: #17272d; - } -} - -/* -.container-main { - padding: 0 !important; -} - -@media (min-width: 1200px) { - html .col-content { - padding: 0 8rem; - } -} - -@media (min-width: 640px) { - html .col-content { - padding: 0 4rem; - } -} - -html .col-content { - padding: 0 2rem; -} - - -.tsd-signatures .tsd-signature:hover { - height: 0; - overflow: hidden; - position: relative; - padding: 0.5em; -} - -.tsd-signatures .tsd-signature::not(:hover)::after { - content: "show signature"; - display: block; - text-align: center; - position: absolute; - top: 0; - left: 0; - right: 0; -} -*/ diff --git a/docs/assets/material-style.css b/docs/assets/material-style.css new file mode 100644 index 0000000..b7e1d31 --- /dev/null +++ b/docs/assets/material-style.css @@ -0,0 +1,247 @@ +@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap"); + +:root, +:root[data-theme="light"], +:root[data-theme="dark"] { + --font-sans: "Space Grotesk", sans-serif; + --font-mono: "Space Mono", monospace; + + --color-background: var(--md-sys-color-surface-container); + --color-background-secondary: var(--md-sys-color-surface-container-high); + --color-background-warning: var(--md-sys-color-error-container); + --color-warning-text: var(--md-sys-color-on-error-container); + --color-icon-background: var(--md-sys-color-on-primary); + --color-accent: var(--md-sys-color-secondary-container); + --color-active-menu-item: var(--md-sys-color-surface-container-highest); + --color-text: var(--md-sys-color-on-surface); + --color-text-aside: var(--md-sys-color-on-surface-variant); + --color-link: var(--md-sys-color-primary); + + --color-ts-project: var(--md-sys-color-secondary); + --color-ts-module: var(--color-ts-project); + --color-ts-namespace: var(--color-ts-project); + + --color-ts-enum: var(--md-sys-color-tertiary); + --color-ts-enum-member: var(--color-ts-enum); + + --color-ts-variable: var(--md-sys-color-primary); + --color-ts-function: var(--md-sys-color-secondary); + --color-ts-class: var(--md-sys-color-tertiary); + --color-ts-interface: var(--md-sys-color-tertiary); + + --color-ts-constructor: var(--md-sys-color-inverse-primary); + + --color-ts-property: var(--md-sys-color-on-background); + --color-ts-method: var(--color-ts-function); + + --color-ts-call-signature: var(--color-ts-method); + --color-ts-index-signature: var(--color-ts-property); /* ? */ + --color-ts-constructor-signature: var(--color-ts-function); + --color-ts-parameter: var(--md-sys-color-primary); + + --color-ts-type-parameter: var(--md-sys-color-tertiary); + --color-ts-accessor: var(--color-ts-property); + --color-ts-get-signature: var(--color-ts-accessor); + --color-ts-set-signature: var(--color-ts-accessor); + --color-ts-type-alias: var(--md-sys-color-tertiary); + + /* --external-icon: var(--md-sys-external-icon); + --color-scheme: var(--md-sys-color-scheme); */ + + --top-app-bar-height: 4.5rem; + --footer-height: 3.5rem; +} + +body { + font-family: var(--font-sans); +} +code, +pre { + font-family: var(--font-mono); +} + +img { + max-width: 100%; +} + +*::-webkit-scrollbar { + width: 8px; + height: 8px; +} +*::-webkit-scrollbar-track { + background: none; +} +*::-webkit-scrollbar-thumb { + border: none; +} + +.container-main { + min-height: calc(100vh - var(--top-app-bar-height) - var(--footer-height)); +} +.col-content { + overflow: hidden; + box-sizing: border-box; + padding: 1.75rem; + border-radius: 28px; + background-color: var(--md-sys-color-surface); +} +.page-menu { + height: fit-content; + padding: 0.75rem 1.75rem; + border-radius: 28px; + background-color: var(--md-sys-color-surface); +} +.site-menu > *, +.page-menu > * { + position: relative; +} +.title { + display: block; + max-width: calc(100% - 5rem); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 22px; +} + +.tsd-page-toolbar { + padding: 8px 0; + height: calc(var(--top-app-bar-height) - 16px); + background-color: var(--color-background); + border-bottom: none; +} +.tsd-page-toolbar .tsd-toolbar-contents { + height: 56px; +} +.tsd-page-toolbar .table-cell { + height: 56px; + margin-left: 1.5rem; +} +.tsd-page-toolbar .tsd-toolbar-icon { + padding: 20px 0; +} +#tsd-search { + line-height: 56px; + border-radius: 22px; +} +#tsd-search .results { + z-index: -1; + top: calc(56px - 22px); + padding-top: 22px; + box-shadow: 0px 4px 2px rgba(0, 0, 0, 0.125); + background-color: var(--color-background-secondary); + border-bottom-left-radius: 22px; + border-bottom-right-radius: 22px; + overflow: hidden; +} +#tsd-search .results li { + background: none; +} +#tsd-search .results a { + padding: 1rem 0.25rem; +} +.col-sidebar { + padding-top: 0; + margin-right: 1rem; +} + +.tsd-signature { + padding: 1rem 1.5rem; + border-radius: 24px; + background-color: var(--md-sys-color-surface-container); +} + +.tsd-page-navigation ul { + padding-left: 0.44rem; +} +.tsd-navigation a, +.tsd-navigation summary > span, +.tsd-page-navigation a { + padding: 0.88rem; + border-radius: 24px; +} +.tsd-navigation a:hover, +.tsd-page-navigation a:hover { + text-decoration: none; + background-color: var(--md-sys-color-surface-container-high); +} +.page-menu .tsd-accordion-summary svg { + position: absolute; + right: 0; +} +.site-menu .tsd-navigation .tsd-accordion-summary { + display: flex; + flex-direction: row-reverse; + width: 100%; +} + +.tsd-small-nested-navigation { + margin-left: 1rem; +} +.tsd-nested-navigation { + margin-left: 2.5rem; +} +.tsd-nested-navigation > li > a, +.tsd-nested-navigation > li > span { + width: 100%; +} +.tsd-navigation > a, +.tsd-navigation .tsd-accordion-summary { + width: 100%; +} +.tsd-index-accordion .tsd-accordion-summary > svg { + position: absolute; + right: 1.5rem; + margin-top: 1rem; +} +.tsd-accordion-summary .tsd-kind-icon ~ span { + margin-right: 2.5rem; +} +.tsd-accordion-summary .tsd-nested-navigation > li > a, +.tsd-nested-navigation > li > span { + width: calc(100% - 0.44rem); +} +.tsd-kind-icon ~ span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.tsd-generator { + padding: 0; + border-top: none; + height: var(--footer-height); + line-height: var(--footer-height); +} +.tsd-generator > p { + padding: 0 2rem; +} + +@media (max-width: 769px) { + .container { + padding: 1rem; + } + .col-sidebar { + margin-right: 0; + } +} +@media (min-width: 770px) { + .container-main { + margin: 0 auto; + } + .site-menu { + margin-right: 0.5rem; + } +} +@media (min-width: 1200px) { + .page-menu, + .site-menu { + max-height: calc(100vh - var(--footer-height) - var(--top-app-bar-height)); + top: var(--top-app-bar-height); + } + .page-menu { + margin-left: 1rem; + } + .col-sidebar { + margin-right: 0; + } +} diff --git a/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html b/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html index 7499245..95968cd 100644 --- a/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html +++ b/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html @@ -1,6 +1,164 @@ -
Add an event listener for when a gamepad (either real or emulated) is connected
The calback function to call when a gamepad is connected
-add an event listener for when a gamepad (either real or emulated) is disconnected
+add an event listener for when a gamepad (either real or emulated) is disconnected
The calback function to call when a gamepad is disconnected
-Changes the button configs used by the wrapper (takes effect after the next gamepad update)
-Changes the button configs used by the wrapper (takes effect after the next gamepad update)
+Protected
tickProtected
tickClass to handle displaying the state of a gamepad on the screen. +
Class to handle displaying the state of a gamepad on the screen. This class will not draw anything to the screen. Instead it will update the classes / transforms of the elements you provide to represent the buttons and axes of the gamepad. See the examples for more information.
-Create a new GamepadDisplay instance
The config to use for the gamepad display
Optional
apiWrapper: GamepadApiWrapper(OPTIONAL) The gamepad api will use this GamepadApiWrapper instance to listen for gamepad events, otherwise it will create a new gamepad wrapper under the hood.
-Protected
apiProtected
axisProtected
btnProtected
configCleanup function to remove all event listeners created by the GamepadDisplay +
Protected
apiProtected
axisProtected
btnProtected
configCleanup function to remove all event listeners created by the GamepadDisplay Call this function before removing the gamepad display from the DOM or deleting the GamepadDisplay instance to prevent memory leaks
-Function called by default when any gamepad buttons change (called separately for each button (as configured in this GamepadDisplay)) If you specify your own DisplayGamepadConfig.buttonDisplayFunction in the config, this function won't get called. Instead, you can call this function with the same parameters as passed to the DisplayGamepadConfig.buttonDisplayFunction if you want to keep the default behaviour (and then you can add your own custom behaviour on top)
@@ -27,23 +185,38 @@Whether the button is currently being pressed (unused, but included for consistency with the ButtonDisplayFunction signature)
The changes that have occurred since the last update
The index of the button that has changed (unused, but included for consistency with the ButtonDisplayFunction signature)
-Function called by default when the gamepad axies change for a joystick (as configured in this GamepadDisplay) If you specify your own DisplayGamepadConfig.joystickDisplayFunction in the config, this function won't get called. Instead, you can call this function with the same parameters as passed to the DisplayGamepadConfig.joystickDisplayFunction if you want to keep the default behaviour (and then you can add your own custom behaviour on top)
The config for the joystick that has changed (as configured in DisplayGamepadConfig.sticks)
The new x axis value
The new y axis value
-Protected
displayThis function is registered as the callback for GamepadApiWrapper.onGamepadButtonChange +
Protected
displayThis function is registered as the callback for GamepadApiWrapper.onGamepadButtonChange it calls the DisplayGamepadConfig.buttonDisplayFunction (if specified) or the GamepadDisplay.DefaultButtonDisplayFunction otherwise for every button that has changed since the last update
The index of the gamepad that has changed
The new state of the gamepad as reported by the browser / GamepadApiWrapper.onGamepadButtonChange
An array of buttonChangeDetails or false, where each false in the array indicates that the corresponding button index has not changed since the last update.
-Protected
displayThis function is registered as the callback for GamepadApiWrapper.onGamepadAxisChange +
Protected
displayThis function is registered as the callback for GamepadApiWrapper.onGamepadAxisChange it calls the DisplayGamepadConfig.joystickDisplayFunction (if specified) or the GamepadDisplay.DefaultJoystickDisplayFunction otherwise for each configured joystick with axies that have changed
The index of the gamepad that has changed
The new state of the gamepad as reported by the browser / GamepadApiWrapper.onGamepadAxisChange
An array of booleans, where each true indicates that the corresponding axis has changed since the last update
-Class to handle emulated gamepads and injecting them into the browser getGamepads() and event listener APIs.
+Class to handle emulated gamepads and injecting them into the browser getGamepads() and event listener APIs.
-You MUST call
new GamepadEmulator()
before any other libraries or functions use or store the browser gamepad api for it to function!
the threshold above which a variable button is considered a "pressed" button
-Protected
buttonthe threshold above which a variable button is considered a "pressed" button
-Protected
emulatedA list of all the emulated gamepads, where the index is the "gamepadIndex" passed when AddEmulatedGamepad() was called (Ie: there may be holes in the list), +
Protected
buttonthe threshold above which a variable button is considered a "pressed" button
+Protected
emulatedA list of all the emulated gamepads, where the index is the "gamepadIndex" passed when AddEmulatedGamepad() was called (Ie: there may be holes in the list), when an emulated gamepad is "connected" ie: call AddEmulatedGamepad(), it is added to this list at the provided index (or returns false if there is already an emulated gamepad at that index). when an emulated gamepad is "disconnected" ie: call removeEmulatedGamepad(), it is removed from this list provided index (or returns false if there is already an emulated gamepad at that index).
-Protected
emulatedA list that mirrors the structure of GamepadEmulator.emulatedGamepads, but contains data internal to this class for keeping track of their state
-Optional
getstores a reference to the real, unpatched navigator.getGamepads() function (if available) *
-Protected
patchedthe reverse mapping array of GamepadEmulator.realGpadToPatchedIndexMap
-Protected
realA list of the indecies of all the real gamepads that have ever been conected durring this browser session, where the array index is the "gamepadIndex" returned by the native gamepad api, and the value is the index that gamepad should be exposed at in the emulated getGamepads() array
-Protected
undostores the function returned by monkeyPatchGamepadEvents() to undo the gamepad event monkey patch *
-Protected
Static
instancea static class variable to tell if any other instances of the GamepadEmulator class are active, and throw an error if a new one is created
-Protected
emulatedA list that mirrors the structure of GamepadEmulator.emulatedGamepads, but contains data internal to this class for keeping track of their state
+Optional
getstores a reference to the real, unpatched navigator.getGamepads() function (if available) *
+Protected
patchedthe reverse mapping array of GamepadEmulator.realGpadToPatchedIndexMap
+Protected
realA list of the indecies of all the real gamepads that have ever been conected durring this browser session, where the array index is the "gamepadIndex" returned by the native gamepad api, and the value is the index that gamepad should be exposed at in the emulated getGamepads() array
+Protected
undostores the function returned by monkeyPatchGamepadEvents() to undo the gamepad event monkey patch *
+Protected
Static
instancea static class variable to tell if any other instances of the GamepadEmulator class are active, and throw an error if a new one is created
+add event listeners to the html/svg button elements of an onscreen gamepad to emulate gamepad input when touched, clicked or dragged
the index of the emulated gamepad to register events for
an array of config objects that set how each of the buttons on the onscreen gamepad should behave, and how they map to the emulated gamepad buttons.
-add event listeners to the html/svg joystick elements of an onscreen gamepad to emulate gamepad input when dragged with a mouse, touch or pen.
the index of the emulated gamepad to register events for
an array of config objects that set how each of the joysticks on the onscreen gamepad should behave, and how they map to the emulated gamepad axes.
-Protected
Addcreates a new emmulated gamepad at the given index as would be read in navigator.getGamepads
+Protected
Addcreates a new emmulated gamepad at the given index as would be read in navigator.getGamepads
the index of the gamepad to create, pass null to create a new gamepad at the next available index
if a real gamepad is connected at the same index as this emulated one and overlayMode is true, the emulated gamepad values will get merged or overlayed on the real gamepad button and axis values, otherwise the emulated gamepad will be shifted to the next available index (appear as a separate gamepad from the real gamepad)
normally 18, the number of buttons on the gamepad
normally 4, the number of axes on the gamepad
-emulates moving an axis on the gamepad at the given axis index
the index of the emulated gamepad to move the axis on
the index of the axis to move
the value to set the axis to between -1 and 1 (0 = center, -1 = left/up, 1 = right/down)
-emulates pressing a button on an emulated gamepad at the given gamepad button index
the index of the emulated gamepad (as returned by navigator.getGamepads()) to press the button on
the index of the button to press on the gamepad
the value to set the button to between 0 and 1 (0 = not pressed, 1 = fully pressed, 0.5 = half pressed) if this value is greater than the pressedThreshold from the constructor, the button will be considered pressed
whether the button is considered "touched" or not, a "pressed" button is always considered "touched"
-removes the emmulated gamepad at the passed index as would be read from the list in navigator.getGamepads
+Protected
clonereturns copy of the passed Gamepad object +
Protected
cloneProtected
monkeyProtected
monkeyoverwrite the browser gamepad api getGamepads() to return the emulated gamepad data for gamepad indexes corresponding to emulated gamepads +
Protected
monkeyProtected
monkeyoverwrite the browser gamepad api getGamepads() to return the emulated gamepad data for gamepad indexes corresponding to emulated gamepads if a real gamepad is found with the same index value as an emulated gamepad, the the navigator.getGamepads() list will either shift the emulated gamepad's index up to make room for the real gamepad when (emulatedGamepad.overlayMode = false), or it will return the emulated gamepad "overlayed" on the real one where buttons pressed or axes moved on both the real gamepad and the emulated one will show up on that gamepad.
-Protected
nextProtected
nextSearches for the next available index a new emulated gamepad could go and returns that index this means no emulated gamepad is at that index and either the no real gamepad is at that index, or a real gamepad is at that index, but the
is true.
-Protected
nextSearches for the next available index a freshly connected real gamepad could go and returns that index +
Protected
nextSearches for the next available index a freshly connected real gamepad could go and returns that index this means no real gamepad is mapped to that index and either no emulated gamepad is at that index, or the emulated gamepad is in overlay mode
the index to start searching from
-Enum holds the index in the gamepad buttons array for standard playstation controller buttons
+Enum holds the index in the gamepad buttons array for standard playstation controller buttons
Enum holds the index in the gamepad axes array for standard controller axes (two thumb sticks)
+Enum holds the index in the gamepad axes array for standard controller axes (two thumb sticks)
Enum holds the index in the gamepad buttons array for standard xbox controller buttons
+Enum holds the index in the gamepad buttons array for standard xbox controller buttons
Sets the transform-origin css property of the passed element to the center of its BBOX (svg) or transform rect (html) as a pixel coordinate. +
Sets the transform-origin css property of the passed element to the center of its BBOX (svg) or transform rect (html) as a pixel coordinate.
This is intened mainly for elements that will not be moved except with the transform css property or svg attribute (relative to its parent).
If the passed element is moved by another method (margin, top, flex, etc...) you must call this again to update the transform-origin.
On newer browsers this function can often be replaced with transform-box: fill; transform-origin: 50% 50%
properties on svg elements
The element to set the transform-origin of.
-Scales vectors to ≤ 1 unit length where vectors that started with a length greater than max +
Scales vectors to ≤ 1 unit length where vectors that started with a length greater than max are clamped to length 1, and shorter vectors are scaled between 0 - 1 based on their original fraction of their length relative to max.
x component of the vector
y component of the vector
the length of the vector to clamp to
the scaled vector as an object with x and y components.
-+
Optional
heldThis button was pressed last update and is still pressed (only present if wrapperButtonConfig.fireWhileHolding was set to true on this button when the GamepadApiWrapper was initilized)
-Optional
pressedThis button was pressed this gamepad update
-Optional
releasedThis button was released this gamepad update
-Optional
touchThis button was touched this gamepad update
-Optional
touchThis button was no longer touched this gamepad update
-Optional
valueThe value of the button changed (e.g. for variable pressure buttons like shoulder triggers)
-Optional
pressedThis button was pressed this gamepad update
+Optional
releasedThis button was released this gamepad update
+Optional
touchThis button was touched this gamepad update
+Optional
touchThis button was no longer touched this gamepad update
+Optional
valueThe value of the button changed (e.g. for variable pressure buttons like shoulder triggers)
+Optional
axisA range in which axis values closer to zero than this are simply treated as zero Used to prevent noise from analog sticks from registering as changes when they are not being used
-Optional
buttonAn array of wrapperButtonConfig that tell the wrapper how to respond to button changes. Should be in the same order as buttons are listed in a native browser Gamepad.buttons list.
-Optional
updateThe (rough) delay between each update of the gamepad state in ms. +
Optional
buttonAn array of wrapperButtonConfig that tell the wrapper how to respond to button changes. Should be in the same order as buttons are listed in a native browser Gamepad.buttons list.
+Optional
updateThe (rough) delay between each update of the gamepad state in ms. A value of 0 means the gamepad state will be updated every frame
-Optional
buttonIf provided, this function will be called for each button with a state change (pressed, touched, released, etc...)
GamepadDisplay.DefaultButtonDisplayFunction for an example
-Configuration for Buttons and Variable Pressure Buttons (eg: shoulder triggers) to represent in the gamepad display
+Configuration for Buttons and Variable Pressure Buttons (eg: shoulder triggers) to represent in the gamepad display
GamepadDisplayButton and GamepadDisplayVariableButton standardGpadButtonMap for more information
-The index of the gamepad this Gamepad Display should track as returned from navigator.GetGamepads()
Optional
joystickIf provided, this function will be called when the gamepad axies change for a joystick instead of the default display function.
+The index of the gamepad this Gamepad Display should track as returned from navigator.GetGamepads()
Optional
joystickIf provided, this function will be called when the gamepad axies change for a joystick instead of the default display function.
GamepadDisplay.DefaultJoystickDisplayFunction for an example
-Optional
moveThe class to add to the corresponding direction indicator element when a gamepad joystick is moved in a direction or a variable button is pressed
-Optional
pressedThe class to add to the corresponding highlight element when a gamepad button is pressed
-Configuration for Joysticks to represent in the gamepad display (based on gamepad axes indecies as as returned by the browser gamepad api)
-Optional
touchedThe class to add to the corresponding highlight element when a gamepad button is touched (whether or not its pressed)
-Optional
moveThe class to add to the corresponding direction indicator element when a gamepad joystick is moved in a direction or a variable button is pressed
+Optional
pressedThe class to add to the corresponding highlight element when a gamepad button is pressed
+Configuration for Joysticks to represent in the gamepad display (based on gamepad axes indecies as as returned by the browser gamepad api)
+Optional
touchedThe class to add to the corresponding highlight element when a gamepad button is touched (whether or not its pressed)
+The element to add the touch and press classses, to represent touching or pressing on this button
+Optional
xAxis index (as returned by the browser gamepad api) to track for the horizontal movement of the display joystick +
Optional
xAxis index (as returned by the browser gamepad api) to track for the horizontal movement of the display joystick see standardGpadAxesMap
-Optional
yAxis index (as returned by the browser gamepad api) to track for the vertical movement of the display joystick +
Optional
yAxis index (as returned by the browser gamepad api) to track for the vertical movement of the display joystick see standardGpadAxesMap
-The element to move to represent pressing on this button
-Direction the GamepadDisplayVariableButton.buttonElement should move to represent being pressed
-Optional
directionDrag direction indicator / highlight element for this variable button
-Optional
extraoptional, for your own use
-The element to add the touch and press classses, to represent touching or pressing on this button
-How far the GamepadDisplayVariableButton.buttonElement should move to represent being pressed fully
-Direction the GamepadDisplayVariableButton.buttonElement should move to represent being pressed
+Optional
directionDrag direction indicator / highlight element for this variable button
+Optional
extraoptional, for your own use
+The element to add the touch and press classses, to represent touching or pressing on this button
+How far the GamepadDisplayVariableButton.buttonElement should move to represent being pressed fully
+The index of the button this emulated button should controll in the Gamepad.buttons array
-Optional
lockShould this button lock the cursor once it is preseed (mouse or touch), such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the finger leaves the screen or mouse lets go. +
Optional
lockShould this button lock the cursor once it is preseed (mouse or touch), such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the finger leaves the screen or mouse lets go. This option also prevents this button from reacting when a press starts on another button or page element and then the pointer/touch moves over the tap target of this button while being held down.
-Taps/clicks/hovers on this element will trigger events for this button on the emulated gamepad.
-Taps/clicks/hovers on this element will trigger events for this button on the emulated gamepad.
+Extends the browser Gamepad interface to include an emulation property that exposes how this gamepad is being emulated (or not) +
Extends the browser Gamepad interface to include an emulation property that exposes how this gamepad is being emulated (or not) This Gamepad API interface defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id. Normally Available only in secure webpage contexts.
-Optional
hapticReadonly
mappingOptional
hapticReadonly
mappingOptional
vibrationOptional
vibrationExtends the browser Gamepad Event interface to use an EGamepad type instead of a Gamepad
-Extends the browser Gamepad Event interface to use an EGamepad type instead of a Gamepad
+Readonly
eventReturns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
-Readonly
isReturns true if event was dispatched by the user agent, and false otherwise.
+Readonly
isReturns true if event was dispatched by the user agent, and false otherwise.
Readonly
srctrue if this e-gamepad was created in overlay mode
-Optional
removestores a refrence to a function to cleanup all event listeners created for controlling buttons on this egamepad
-Optional
removestores a refrence to a function to cleanup all event listeners created for controlling axes on this egamepad
-Optional
removestores a refrence to a function to cleanup all event listeners created for controlling buttons on this egamepad
+Optional
removestores a refrence to a function to cleanup all event listeners created for controlling axes on this egamepad
+What drag/movement directions does this joystick support
-The distance a drag gesture must go in pixels to register as a full 1 or -1 on the x or y axis (Alternatively, the distance from the touch start posisiton that the joystick can be dragged)
-Optional
lockShould the joystick lock the cursor once a drag gesture has started, such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the gesture is finished (finger leaves the screen or mouse lets go)
-The element where a tap or mouse click must start to control this joystick +
The distance a drag gesture must go in pixels to register as a full 1 or -1 on the x or y axis (Alternatively, the distance from the touch start posisiton that the joystick can be dragged)
+Optional
lockShould the joystick lock the cursor once a drag gesture has started, such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the gesture is finished (finger leaves the screen or mouse lets go)
+The element where a tap or mouse click must start to control this joystick The pointer does not need to remain within this element while dragging to continue controlling the joystick as long as the mouse / touch / pointer is held down
-Optional
xWhat emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged left (-) and right (+)
-Optional
yWhat emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged up (-) and down (+)
-Optional
xWhat emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged left (-) and right (+)
+Optional
yWhat emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged up (-) and down (+)
+The index of the button this emulated button should controll in the Gamepad.buttons array
-What drag/movement gesture directions should result in the button value of this varaible button increasing +
What drag/movement gesture directions should result in the button value of this varaible button increasing Typically only one direction will be set to true, but you can set multiple to true if you want to
-The distance drag gesture must go in pixels to appear as a fully pressed button: value = 1
-Optional
lockShould this variable button lock the cursor once a drag gesture has started, such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the gesture is finished (finger leaves the screen or mouse lets go) +
The distance drag gesture must go in pixels to appear as a fully pressed button: value = 1
+Optional
lockShould this variable button lock the cursor once a drag gesture has started, such that NO pointer/mouse/touch events are fired with that pointer on any other elements on the page unil the gesture is finished (finger leaves the screen or mouse lets go) This option also prevents this button from reacting when a press starts on another button or page element and then the pointer/touch moves over the tap target of this button while being held down.
-The element where a tap or mouse click must start to control this variable button. +
The element where a tap or mouse click must start to control this variable button. The pointer does not need to remain within this element while dragging to continue controlling the variable button as long as the mouse / touch / pointer is held down
-Const
A number of typical axes recognized by Gamepad API and mapped to +
Const
A number of typical axes recognized by Gamepad API and mapped to standard controls. Any extraneous axes will have larger indexes.
-Const
A number of typical buttons recognized by Gamepad API and mapped to +
Const
A number of typical buttons recognized by Gamepad API and mapped to standard controls. Any extraneous buttons will have larger indexes.
-Const
Const
Const
Const
Const
Const
Wrapper for the Gamepad API that smooths out browser inconsistancies. +
- Preparing search index...
- The search index is not available
virtual-gamepad-libClass GamepadApiWrapper
Wrapper for the Gamepad API that smooths out browser inconsistancies. Exposes changes to gamepads, buttons and axes as events.
-Index
Constructors
Index
Constructors
Properties
Constructors
constructor
Create a new GamepadApiWrapper
Parameters
The configuration options for this wrapper
Returns GamepadApiWrapper
See
wrapperConfig
-Properties
Protected
axisProtected
buttonProtected
currentProtected
gamepadProtected
gamepadProtected
gamepadProtected
gamepadProtected
updateMethods
Protected
checkParameters
Returns void
Protected
checkParameters
Returns void
Protected
checkReturns void
gamepad Api Supported
gamepadApiSupported: returns true if the native gamepad api is supported by the browser context
-Returns boolean
get Current Gamepad States
Returns the result of navigator.getGamepads() from the last update
+Properties
Protected
axisProtected
buttonProtected
currentProtected
gamepadProtected
gamepadProtected
gamepadProtected
gamepadProtected
updateMethods
Protected
checkParameters
Returns void
Protected
checkParameters
Returns void
Protected
checkReturns void
gamepad Api Supported
gamepadApiSupported: returns true if the native gamepad api is supported by the browser context
+Returns boolean
get Current Gamepad States
Returns the result of navigator.getGamepads() from the last update
Parameters
If true, navigator.getGamepads() will be called inmediately before returning, if gamepad changes happened since the last update, this will cause those change events to fire.
Returns (EGamepad | Gamepad)[]
An array of gamepad objects, or an empty array if the gamepad api is not supported
-get Gamepads
returns the value of navigator.getGamepads() in a cross-browser compatible way
+get Gamepads
returns the value of navigator.getGamepads() in a cross-browser compatible way
Returns (null | EGamepad | Gamepad)[]
An array of gamepad objects (including any emulated gamepads if the GamepadEmulator was set up), or an empty array if the gamepad api is not supported or gampad permissions haven't been granted.
-off Gamepad Axis Change
offGamepadAxisChange: remove an existing event listener for when a gamepad axis changes
+off Gamepad Axis Change
offGamepadAxisChange: remove an existing event listener for when a gamepad axis changes
Parameters
The calback function to remove (must be the same function passed to onGamepadAxisChange())
-Returns void
off Gamepad Button Change
offGamepadButtonChange: remove an existing event listener for when a gamepad button changes
+Returns void
off Gamepad Button Change
offGamepadButtonChange: remove an existing event listener for when a gamepad button changes
Parameters
The calback function to remove (must be the same function passed to onGamepadButtonChange())
-Returns void
off Gamepad Connect
remove an existing event listener for when a gamepad (either real or emulated) is connected
+Returns void
off Gamepad Connect
remove an existing event listener for when a gamepad (either real or emulated) is connected
Parameters
The calback function to remove (must be the same function passed to onGamepadConnect())
-Returns void
off Gamepad Disconnect
remove an existing event listener for when a gamepad (either real or emulated) is disconnected
+Returns void
off Gamepad Disconnect
remove an existing event listener for when a gamepad (either real or emulated) is disconnected
Parameters
The calback function to remove (must be the same function passed to onGamepadDisconnect())
-Returns void
on Gamepad Axis Change
add an event listener for each time a gamepad axis changes. +
Returns void
on Gamepad Axis Change
add an event listener for each time a gamepad axis changes. The callback function will be called with the gamepad index, the gamepad object, and a boolean array of the changed axes, The callback is called separately for each gamepad where axes have changed.
Parameters
The calback function to call when a gamepad axis state changes
-Returns AxisChangeCallback
on Gamepad Button Change
onGamepadButtonChange add an event listener for each time a gamepad button changes. +
Returns AxisChangeCallback
on Gamepad Button Change
onGamepadButtonChange add an event listener for each time a gamepad button changes. The callback function will be called with the gamepad index, the gamepad object, and a array of the changed buttons containing details about how the button transitioned or false if the button state didn't change this frame. Callback is called separately for each gamepad where buttons have changed.
Parameters
The calback function to call when a gamepad button state changes
-Returns ButtonChangeCallback
on Gamepad Connect
Add an event listener for when a gamepad (either real or emulated) is connected
+Returns ButtonChangeCallback