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 @@ -GamepadApiWrapper | virtual-gamepad-lib

Wrapper for the Gamepad API that smooths out browser inconsistancies. +GamepadApiWrapper | virtual-gamepad-lib

Wrapper for the Gamepad API that smooths out browser inconsistancies. Exposes changes to gamepads, buttons and axes as events.

-

Constructors

Constructors

Properties

Constructors

Properties

axisDeadZone: number
buttonConfigs: wrapperButtonConfig[]
currentStateOfGamepads: (EGamepad | Gamepad)[]
gamepadAxisChangeListeners: AxisChangeCallback[]
gamepadButtonChangeListeners: ButtonChangeCallback[]
gamepadConnectListeners: GamepadEventCallback[]
gamepadDisconnectListeners: GamepadEventCallback[]
updateDelay: number

Methods

  • gamepadApiSupported: returns true if the native gamepad api is supported by the browser context

    -

    Returns boolean

Properties

axisDeadZone: number
buttonConfigs: wrapperButtonConfig[]
currentStateOfGamepads: (EGamepad | Gamepad)[]
gamepadAxisChangeListeners: AxisChangeCallback[]
gamepadButtonChangeListeners: ButtonChangeCallback[]
gamepadConnectListeners: GamepadEventCallback[]
gamepadDisconnectListeners: GamepadEventCallback[]
updateDelay: number

Methods

  • gamepadApiSupported: returns true if the native gamepad api is supported by the browser context

    +

    Returns boolean

  • Returns the result of navigator.getGamepads() from the last update

    Parameters

    • forceUpdate: boolean = false

      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

    -
  • 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.

    -
  • offGamepadAxisChange: remove an existing event listener for when a gamepad axis changes

    +
  • offGamepadAxisChange: remove an existing event listener for when a gamepad axis changes

    Parameters

    • Callback: AxisChangeCallback

      The calback function to remove (must be the same function passed to onGamepadAxisChange())

      -

    Returns void

  • offGamepadButtonChange: remove an existing event listener for when a gamepad button changes

    +

Returns void

  • offGamepadButtonChange: remove an existing event listener for when a gamepad button changes

    Parameters

    • Callback: ButtonChangeCallback

      The calback function to remove (must be the same function passed to onGamepadButtonChange())

      -

    Returns void

  • remove an existing event listener for when a gamepad (either real or emulated) is connected

    +

Returns void

  • remove an existing event listener for when a gamepad (either real or emulated) is connected

    Parameters

    • Callback: GamepadEventCallback

      The calback function to remove (must be the same function passed to onGamepadConnect())

      -

    Returns void

  • remove an existing event listener for when a gamepad (either real or emulated) is disconnected

    +

Returns void

Returns void

Returns AxisChangeCallback

Returns ButtonChangeCallback

Returns GamepadEventCallback

Returns GamepadEventCallback

+

Returns void

diff --git a/docs/classes/GamepadDisplay.GamepadDisplay.html b/docs/classes/GamepadDisplay.GamepadDisplay.html index 10ea9f1..567d6f1 100644 --- a/docs/classes/GamepadDisplay.GamepadDisplay.html +++ b/docs/classes/GamepadDisplay.GamepadDisplay.html @@ -1,7 +1,165 @@ -GamepadDisplay | virtual-gamepad-lib

Class to handle displaying the state of a gamepad on the screen. +GamepadDisplay | virtual-gamepad-lib

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.

-

Constructors

Constructors

Properties

Constructors

Properties

apiWrapper: GamepadApiWrapper
axisChangeListener: ((gpadIndex: number, gpadState: EGamepad | Gamepad, axisChangesMask: boolean[]) => void)
btnChangeListener: ((gpadIndex: number, gpadState: EGamepad | Gamepad, buttonChangesMask: (false | buttonChangeDetails)[]) => void)

Methods

  • Cleanup function to remove all event listeners created by the GamepadDisplay +

Returns GamepadDisplay

Properties

apiWrapper: GamepadApiWrapper
axisChangeListener: ((gpadIndex: number, gpadState: EGamepad | Gamepad, axisChangesMask: boolean[]) => void)
btnChangeListener: ((gpadIndex: number, gpadState: EGamepad | Gamepad, buttonChangesMask: (false | buttonChangeDetails)[]) => void)

Methods

  • Cleanup 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

    -

    Returns void

  • Function called by default when any gamepad buttons change (called separately for each button (as configured in this GamepadDisplay)) +

    Returns void

  • 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 @@
  • pressed: boolean

    Whether the button is currently being pressed (unused, but included for consistency with the ButtonDisplayFunction signature)

  • changes: buttonChangeDetails

    The changes that have occurred since the last update

  • btnIndex: number

    The index of the button that has changed (unused, but included for consistency with the ButtonDisplayFunction signature)

    -

Returns void

  • Function called by default when the gamepad axies change for a joystick (as configured in this GamepadDisplay) +

Returns void

Returns void

Returns void

+

Returns void

diff --git a/docs/classes/GamepadEmulator.GamepadEmulator.html b/docs/classes/GamepadEmulator.GamepadEmulator.html index cfdfdcb..1de7725 100644 --- a/docs/classes/GamepadEmulator.GamepadEmulator.html +++ b/docs/classes/GamepadEmulator.GamepadEmulator.html @@ -1,8 +1,166 @@ -GamepadEmulator | virtual-gamepad-lib

Class to handle emulated gamepads and injecting them into the browser getGamepads() and event listener APIs.

+GamepadEmulator | virtual-gamepad-lib

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!

-

Constructors

Constructors

Properties

buttonPressThreshold emulatedGamepads emulatedGamepadsMetadata @@ -32,56 +190,71 @@
  • MUST be called before any other libraries or functions use or store the browser gamepad api!
  • Parameters

    • buttonPressThreshold: number

      the threshold above which a variable button is considered a "pressed" button

      -

    Returns GamepadEmulator

    Properties

    buttonPressThreshold: number = 0.1

    the threshold above which a variable button is considered a "pressed" button

    -
    emulatedGamepads: (null | EGamepad)[] = []

    A 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), +

    Returns GamepadEmulator

    Properties

    buttonPressThreshold: number = 0.1

    the threshold above which a variable button is considered a "pressed" button

    +
    emulatedGamepads: (null | EGamepad)[] = []

    A 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).

    -
    emulatedGamepadsMetadata: (null | EGamepadPrivateData)[] = []

    A list that mirrors the structure of GamepadEmulator.emulatedGamepads, but contains data internal to this class for keeping track of their state

    -
    getNativeGamepads?: (() => (null | Gamepad)[]) = undefined

    stores a reference to the real, unpatched navigator.getGamepads() function (if available) *

    -
    patchedGpadToRealIndexMap: number[] = []

    the reverse mapping array of GamepadEmulator.realGpadToPatchedIndexMap

    -
    realGpadToPatchedIndexMap: number[] = []

    A 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

    -
    undoEventPatch: (() => void) = ...

    stores the function returned by monkeyPatchGamepadEvents() to undo the gamepad event monkey patch *

    -
    instanceRunning: boolean = false

    a 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

    -

    Methods

    • add event listeners to the html/svg button elements of an onscreen gamepad to emulate gamepad input when touched, clicked or dragged

      +
    emulatedGamepadsMetadata: (null | EGamepadPrivateData)[] = []

    A list that mirrors the structure of GamepadEmulator.emulatedGamepads, but contains data internal to this class for keeping track of their state

    +
    getNativeGamepads?: (() => (null | Gamepad)[]) = undefined

    stores a reference to the real, unpatched navigator.getGamepads() function (if available) *

    +
    patchedGpadToRealIndexMap: number[] = []

    the reverse mapping array of GamepadEmulator.realGpadToPatchedIndexMap

    +
    realGpadToPatchedIndexMap: number[] = []

    A 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

    +
    undoEventPatch: (() => void) = ...

    stores the function returned by monkeyPatchGamepadEvents() to undo the gamepad event monkey patch *

    +
    instanceRunning: boolean = false

    a 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

    +

    Methods

    • add event listeners to the html/svg button elements of an onscreen gamepad to emulate gamepad input when touched, clicked or dragged

      Parameters

      • gpadIndex: number

        the index of the emulated gamepad to register events for

      • buttonConfigs: (ButtonConfig | VariableButtonConfig)[]

        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.

        -

      Returns void

    • 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.

      +

    Returns void

    Returns void

    Returns false | EGamepad

    Returns void

    Returns void

    Returns void

    Returns void

    Returns void

    Returns null | EGamepad

    Returns number

    +

    Returns number

    diff --git a/docs/enums/enums.gamepadButtonType.html b/docs/enums/enums.gamepadButtonType.html index 46b6944..a8fe3df 100644 --- a/docs/enums/enums.gamepadButtonType.html +++ b/docs/enums/enums.gamepadButtonType.html @@ -1,3 +1,176 @@ -gamepadButtonType | virtual-gamepad-lib

    Enumeration gamepadButtonType

    Enumeration Members

    onOff +gamepadButtonType | virtual-gamepad-lib

    Enumeration gamepadButtonType

    Enumeration Members

    Enumeration Members

    onOff: "onOff"
    variable: "variable"
    +

    Enumeration Members

    onOff: "onOff"
    variable: "variable"
    diff --git a/docs/enums/enums.gamepadDirection.html b/docs/enums/enums.gamepadDirection.html index 0f0523f..1b0451d 100644 --- a/docs/enums/enums.gamepadDirection.html +++ b/docs/enums/enums.gamepadDirection.html @@ -1,5 +1,178 @@ -gamepadDirection | virtual-gamepad-lib

    Enumeration gamepadDirection

    Enumeration Members

    down +gamepadDirection | virtual-gamepad-lib

    Enumeration gamepadDirection

    Enumeration Members

    Enumeration Members

    down: "down"
    left: "left"
    right: "right"
    up: "up"
    +

    Enumeration Members

    down: "down"
    left: "left"
    right: "right"
    up: "up"
    diff --git a/docs/enums/enums.gamepadEmulationState.html b/docs/enums/enums.gamepadEmulationState.html index 7bf2e1e..8bd0a73 100644 --- a/docs/enums/enums.gamepadEmulationState.html +++ b/docs/enums/enums.gamepadEmulationState.html @@ -1,4 +1,177 @@ -gamepadEmulationState | virtual-gamepad-lib

    Enumeration gamepadEmulationState

    Enumeration Members

    emulated +gamepadEmulationState | virtual-gamepad-lib

    Enumeration gamepadEmulationState

    Enumeration Members

    Enumeration Members

    emulated: "emulated"
    overlay: "overlay"
    real: "real"
    +

    Enumeration Members

    emulated: "emulated"
    overlay: "overlay"
    real: "real"
    diff --git a/docs/enums/enums.playStationButtonMap.html b/docs/enums/enums.playStationButtonMap.html index cdb3f92..aa95fc9 100644 --- a/docs/enums/enums.playStationButtonMap.html +++ b/docs/enums/enums.playStationButtonMap.html @@ -1,8 +1,166 @@ -playStationButtonMap | virtual-gamepad-lib

    Enumeration playStationButtonMap

    Enum holds the index in the gamepad buttons array for standard playstation controller buttons

    +playStationButtonMap | virtual-gamepad-lib

    Enumeration playStationButtonMap

    Enum holds the index in the gamepad buttons array for standard playstation controller buttons

    // Get the button state for the Cross button of the first gamepad:
    navigator.getGamepads()[0].buttons[playStationButtonMap.Cross]
    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Circle: 1
    Cross: 0
    DPadDown: 13
    DPadLeft: 14
    DPadRight: 15
    DPadUp: 12
    L1: 4
    L2: 6
    LStick: 10
    Options: 9
    PlayStation: 16
    R1: 5
    R2: 7
    RStick: 11
    Share: 8
    Square: 2
    Triangle: 3
    +

    Enumeration Members

    Circle: 1
    Cross: 0
    DPadDown: 13
    DPadLeft: 14
    DPadRight: 15
    DPadUp: 12
    L1: 4
    L2: 6
    LStick: 10
    Options: 9
    PlayStation: 16
    R1: 5
    R2: 7
    RStick: 11
    Share: 8
    Square: 2
    Triangle: 3
    diff --git a/docs/enums/enums.standardGpadAxesMap.html b/docs/enums/enums.standardGpadAxesMap.html index 4a2c659..da9af7d 100644 --- a/docs/enums/enums.standardGpadAxesMap.html +++ b/docs/enums/enums.standardGpadAxesMap.html @@ -1,9 +1,182 @@ -standardGpadAxesMap | virtual-gamepad-lib

    Enumeration standardGpadAxesMap

    Enum holds the index in the gamepad axes array for standard controller axes (two thumb sticks)

    +standardGpadAxesMap | virtual-gamepad-lib

    Enumeration standardGpadAxesMap

    Enum holds the index in the gamepad axes array for standard controller axes (two thumb sticks)

    // Get the axis state for the left thumbstick horizontal axis of the first gamepad:
    navigator.getGamepads()[0].axes[standardGpadAxesMap.LStickX]
    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    LStickX: 0
    LStickY: 1
    RStickX: 2
    RStickY: 3
    +

    Enumeration Members

    LStickX: 0
    LStickY: 1
    RStickX: 2
    RStickY: 3
    diff --git a/docs/enums/enums.xboxButtonMap.html b/docs/enums/enums.xboxButtonMap.html index b8f9d5a..362414d 100644 --- a/docs/enums/enums.xboxButtonMap.html +++ b/docs/enums/enums.xboxButtonMap.html @@ -1,8 +1,166 @@ -xboxButtonMap | virtual-gamepad-lib

    Enumeration xboxButtonMap

    Enum holds the index in the gamepad buttons array for standard xbox controller buttons

    +xboxButtonMap | virtual-gamepad-lib

    Enumeration xboxButtonMap

    Enum holds the index in the gamepad buttons array for standard xbox controller buttons

    Get the button state for the A button of the first gamepad:
    navigator.getGamepads()[0].buttons[xboxButtonMap.A]
    -

    Enumeration Members

    A +

    Enumeration Members

    A B Back DPadDown @@ -19,4 +177,19 @@ X Xbox Y -

    Enumeration Members

    A: 0
    B: 1
    Back: 8
    DPadDown: 13
    DPadLeft: 14
    DPadRight: 15
    DPadUp: 12
    LShoulder: 4
    LStick: 10
    LTrigger: 6
    RShoulder: 5
    RStick: 11
    RTrigger: 7
    Start: 9
    X: 2
    Xbox: 16
    Y: 3
    +

    Enumeration Members

    A: 0
    B: 1
    Back: 8
    DPadDown: 13
    DPadLeft: 14
    DPadRight: 15
    DPadUp: 12
    LShoulder: 4
    LStick: 10
    LTrigger: 6
    RShoulder: 5
    RStick: 11
    RTrigger: 7
    Start: 9
    X: 2
    Xbox: 16
    Y: 3
    diff --git a/docs/functions/utilities.CenterTransformOrigin.html b/docs/functions/utilities.CenterTransformOrigin.html index d226b95..fa31b42 100644 --- a/docs/functions/utilities.CenterTransformOrigin.html +++ b/docs/functions/utilities.CenterTransformOrigin.html @@ -1,6 +1,179 @@ -CenterTransformOrigin | virtual-gamepad-lib
    • 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. +CenterTransformOrigin | virtual-gamepad-lib

      • 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

        Parameters

        • element: HTMLElement | SVGGraphicsElement

          The element to set the transform-origin of.

          -

        Returns void

      +

    Returns void

    diff --git a/docs/functions/utilities.CenterTransformOriginDebug.html b/docs/functions/utilities.CenterTransformOriginDebug.html index 249d61a..84eb4b6 100644 --- a/docs/functions/utilities.CenterTransformOriginDebug.html +++ b/docs/functions/utilities.CenterTransformOriginDebug.html @@ -1,3 +1,176 @@ -CenterTransformOriginDebug | virtual-gamepad-lib
    • Adds a visual shaded box around the bbox or bounding rect of the passed element for debugging

      +CenterTransformOriginDebug | virtual-gamepad-lib
      • Adds a visual shaded box around the bbox or bounding rect of the passed element for debugging

        Parameters

        • element: HTMLElement | SVGGraphicsElement

          The element to show the visual bounding box of

          -

        Returns void

      +

    Returns void

    diff --git a/docs/functions/utilities.NormalizeClampVector.html b/docs/functions/utilities.NormalizeClampVector.html index 405d159..b1d4a1d 100644 --- a/docs/functions/utilities.NormalizeClampVector.html +++ b/docs/functions/utilities.NormalizeClampVector.html @@ -1,8 +1,181 @@ -NormalizeClampVector | virtual-gamepad-lib
    • Scales vectors to ≤ 1 unit length where vectors that started with a length greater than max +NormalizeClampVector | virtual-gamepad-lib

      • 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.

        Parameters

        • x: number

          x component of the vector

        • y: number

          y component of the vector

        • max: number

          the length of the vector to clamp to

        Returns {
            x: number;
            y: number;
        }

        the scaled vector as an object with x and y components.

        -
        • x: number
        • y: number
      +
      • x: number
      • y: number
    diff --git a/docs/index.html b/docs/index.html index 9e3e969..4127e43 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,162 @@ -virtual-gamepad-lib

    virtual-gamepad-lib

    +virtual-gamepad-lib

    virtual-gamepad-lib

    Virtual Gamepad Lib

    @@ -115,4 +273,19 @@

    Virtual Gamepad Lib

  • build:examples - Build the examples
  • preview:examples - Preview the examples once built
  • -
    +
    diff --git a/docs/interfaces/GamepadApiWrapper.buttonChangeDetails.html b/docs/interfaces/GamepadApiWrapper.buttonChangeDetails.html index 82f03ae..a419dc9 100644 --- a/docs/interfaces/GamepadApiWrapper.buttonChangeDetails.html +++ b/docs/interfaces/GamepadApiWrapper.buttonChangeDetails.html @@ -1,4 +1,162 @@ -buttonChangeDetails | virtual-gamepad-lib
    interface buttonChangeDetails {
        heldDown?: boolean;
        pressed?: boolean;
        released?: boolean;
        touchDown?: boolean;
        touchUp?: boolean;
        valueChanged?: boolean;
    }

    Properties

    heldDown? +buttonChangeDetails | virtual-gamepad-lib
    interface buttonChangeDetails {
        heldDown?: boolean;
        pressed?: boolean;
        released?: boolean;
        touchDown?: boolean;
        touchUp?: boolean;
        valueChanged?: boolean;
    }

    Properties

    Properties

    heldDown?: boolean

    This 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)

    -
    pressed?: boolean

    This button was pressed this gamepad update

    -
    released?: boolean

    This button was released this gamepad update

    -
    touchDown?: boolean

    This button was touched this gamepad update

    -
    touchUp?: boolean

    This button was no longer touched this gamepad update

    -
    valueChanged?: boolean

    The value of the button changed (e.g. for variable pressure buttons like shoulder triggers)

    -
    +
    pressed?: boolean

    This button was pressed this gamepad update

    +
    released?: boolean

    This button was released this gamepad update

    +
    touchDown?: boolean

    This button was touched this gamepad update

    +
    touchUp?: boolean

    This button was no longer touched this gamepad update

    +
    valueChanged?: boolean

    The value of the button changed (e.g. for variable pressure buttons like shoulder triggers)

    +
    diff --git a/docs/interfaces/GamepadApiWrapper.wrapperButtonConfig.html b/docs/interfaces/GamepadApiWrapper.wrapperButtonConfig.html index 4a9a802..208c9e8 100644 --- a/docs/interfaces/GamepadApiWrapper.wrapperButtonConfig.html +++ b/docs/interfaces/GamepadApiWrapper.wrapperButtonConfig.html @@ -1,3 +1,176 @@ -wrapperButtonConfig | virtual-gamepad-lib
    interface wrapperButtonConfig {
        fireWhileHolding: boolean;
    }

    Properties

    fireWhileHolding +wrapperButtonConfig | virtual-gamepad-lib
    interface wrapperButtonConfig {
        fireWhileHolding: boolean;
    }

    Properties

    Properties

    fireWhileHolding: boolean

    If true, the gamepad wrapper will keep firing button change events, while the button is held down

    -
    +
    diff --git a/docs/interfaces/GamepadApiWrapper.wrapperConfig.html b/docs/interfaces/GamepadApiWrapper.wrapperConfig.html index db5dba0..f7e7e0a 100644 --- a/docs/interfaces/GamepadApiWrapper.wrapperConfig.html +++ b/docs/interfaces/GamepadApiWrapper.wrapperConfig.html @@ -1,9 +1,182 @@ -wrapperConfig | virtual-gamepad-lib
    interface wrapperConfig {
        axisDeadZone?: number;
        buttonConfigs?: wrapperButtonConfig[];
        updateDelay?: number;
    }

    Properties

    axisDeadZone? +wrapperConfig | virtual-gamepad-lib
    interface wrapperConfig {
        axisDeadZone?: number;
        buttonConfigs?: wrapperButtonConfig[];
        updateDelay?: number;
    }

    Properties

    axisDeadZone?: number

    A 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

    -
    buttonConfigs?: wrapperButtonConfig[]

    An 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.

    -
    updateDelay?: number

    The (rough) delay between each update of the gamepad state in ms. +

    buttonConfigs?: wrapperButtonConfig[]

    An 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.

    +
    updateDelay?: number

    The (rough) delay between each update of the gamepad state in ms. A value of 0 means the gamepad state will be updated every frame

    -
    +
    diff --git a/docs/interfaces/GamepadDisplay.DisplayGamepadConfig.html b/docs/interfaces/GamepadDisplay.DisplayGamepadConfig.html index 9b66a77..caf3d89 100644 --- a/docs/interfaces/GamepadDisplay.DisplayGamepadConfig.html +++ b/docs/interfaces/GamepadDisplay.DisplayGamepadConfig.html @@ -1,4 +1,162 @@ -DisplayGamepadConfig | virtual-gamepad-lib
    interface DisplayGamepadConfig {
        buttonDisplayFunction?: ButtonDisplayFunction;
        buttons: (
            | undefined
            | null
            | GamepadDisplayButton
            | GamepadDisplayVariableButton)[];
        gamepadIndex: number;
        joystickDisplayFunction?: JoystickDisplayFunction;
        moveDirectionHighlightClass?: string;
        pressedHighlightClass?: string;
        sticks: GamepadDisplayJoystick[];
        touchedHighlightClass?: string;
    }

    Properties

    buttonDisplayFunction? +DisplayGamepadConfig | virtual-gamepad-lib
    interface DisplayGamepadConfig {
        buttonDisplayFunction?: ButtonDisplayFunction;
        buttons: (
            | undefined
            | null
            | GamepadDisplayButton
            | GamepadDisplayVariableButton)[];
        gamepadIndex: number;
        joystickDisplayFunction?: JoystickDisplayFunction;
        moveDirectionHighlightClass?: string;
        pressedHighlightClass?: string;
        sticks: GamepadDisplayJoystick[];
        touchedHighlightClass?: string;
    }

    Properties

    buttonDisplayFunction?: ButtonDisplayFunction

    If provided, this function will be called for each button with a state change (pressed, touched, released, etc...)

    buttons: (
        | undefined
        | null
        | GamepadDisplayButton
        | GamepadDisplayVariableButton)[]

    Configuration for Buttons and Variable Pressure Buttons (eg: shoulder triggers) to represent in the gamepad display

    +
    buttons: (
        | undefined
        | null
        | GamepadDisplayButton
        | GamepadDisplayVariableButton)[]

    Configuration for Buttons and Variable Pressure Buttons (eg: shoulder triggers) to represent in the gamepad display

    • The index of the button in the array corresponds to the index of the button as returned by the browser gamepad api.
    • Add null in the array for any button you don't want to track.
    gamepadIndex: number

    The index of the gamepad this Gamepad Display should track as returned from navigator.GetGamepads()

    -
    joystickDisplayFunction?: JoystickDisplayFunction

    If provided, this function will be called when the gamepad axies change for a joystick instead of the default display function.

    +
    gamepadIndex: number

    The index of the gamepad this Gamepad Display should track as returned from navigator.GetGamepads()

    +
    joystickDisplayFunction?: JoystickDisplayFunction

    If provided, this function will be called when the gamepad axies change for a joystick instead of the default display function.

    moveDirectionHighlightClass?: string

    The class to add to the corresponding direction indicator element when a gamepad joystick is moved in a direction or a variable button is pressed

    -
    pressedHighlightClass?: string

    The 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)

    -
    touchedHighlightClass?: string

    The class to add to the corresponding highlight element when a gamepad button is touched (whether or not its pressed)

    -
    +
    moveDirectionHighlightClass?: string

    The class to add to the corresponding direction indicator element when a gamepad joystick is moved in a direction or a variable button is pressed

    +
    pressedHighlightClass?: string

    The 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)

    +
    touchedHighlightClass?: string

    The class to add to the corresponding highlight element when a gamepad button is touched (whether or not its pressed)

    +
    diff --git a/docs/interfaces/GamepadDisplay.GamepadDisplayButton.html b/docs/interfaces/GamepadDisplay.GamepadDisplayButton.html index 16c261d..fdd93b5 100644 --- a/docs/interfaces/GamepadDisplay.GamepadDisplayButton.html +++ b/docs/interfaces/GamepadDisplay.GamepadDisplayButton.html @@ -1,6 +1,179 @@ -GamepadDisplayButton | virtual-gamepad-lib
    interface GamepadDisplayButton {
        extraData?: any;
        highlight: HTMLElement | SVGElement;
        type: onOff;
    }

    Properties

    extraData? +GamepadDisplayButton | virtual-gamepad-lib
    interface GamepadDisplayButton {
        extraData?: any;
        highlight: HTMLElement | SVGElement;
        type: onOff;
    }

    Properties

    extraData?: any

    optional, for your own use

    -
    highlight: HTMLElement | SVGElement

    The element to add the touch and press classses, to represent touching or pressing on this button

    -
    type: onOff
    +
    highlight: HTMLElement | SVGElement

    The element to add the touch and press classses, to represent touching or pressing on this button

    +
    type: onOff
    diff --git a/docs/interfaces/GamepadDisplay.GamepadDisplayJoystick.html b/docs/interfaces/GamepadDisplay.GamepadDisplayJoystick.html index 9a40774..9a97cf5 100644 --- a/docs/interfaces/GamepadDisplay.GamepadDisplayJoystick.html +++ b/docs/interfaces/GamepadDisplay.GamepadDisplayJoystick.html @@ -1,4 +1,162 @@ -GamepadDisplayJoystick | virtual-gamepad-lib
    interface GamepadDisplayJoystick {
        highlights?: {
            down?: null | HTMLElement | SVGElement;
            left?: null | HTMLElement | SVGElement;
            right?: null | HTMLElement | SVGElement;
            up?: null | HTMLElement | SVGElement;
        };
        joystickElement: HTMLElement | SVGElement;
        movementRange: number;
        xAxisIndex?: number;
        yAxisIndex?: number;
    }

    Properties

    highlights? +GamepadDisplayJoystick | virtual-gamepad-lib
    interface GamepadDisplayJoystick {
        highlights?: {
            down?: null | HTMLElement | SVGElement;
            left?: null | HTMLElement | SVGElement;
            right?: null | HTMLElement | SVGElement;
            up?: null | HTMLElement | SVGElement;
        };
        joystickElement: HTMLElement | SVGElement;
        movementRange: number;
        xAxisIndex?: number;
        yAxisIndex?: number;
    }

    Properties

    highlights? joystickElement movementRange xAxisIndex? @@ -7,8 +165,23 @@
    • Can be used for e.g. arrows to indicate the direction of the joystick
    -
    joystickElement: HTMLElement | SVGElement
    movementRange: number
    xAxisIndex?: number

    Axis index (as returned by the browser gamepad api) to track for the horizontal movement of the display joystick +

    joystickElement: HTMLElement | SVGElement
    movementRange: number
    xAxisIndex?: number

    Axis index (as returned by the browser gamepad api) to track for the horizontal movement of the display joystick see standardGpadAxesMap

    -
    yAxisIndex?: number

    Axis index (as returned by the browser gamepad api) to track for the vertical movement of the display joystick +

    yAxisIndex?: number

    Axis index (as returned by the browser gamepad api) to track for the vertical movement of the display joystick see standardGpadAxesMap

    -
    +
    diff --git a/docs/interfaces/GamepadDisplay.GamepadDisplayVariableButton.html b/docs/interfaces/GamepadDisplay.GamepadDisplayVariableButton.html index 737a8d9..8402dde 100644 --- a/docs/interfaces/GamepadDisplay.GamepadDisplayVariableButton.html +++ b/docs/interfaces/GamepadDisplay.GamepadDisplayVariableButton.html @@ -1,4 +1,162 @@ -GamepadDisplayVariableButton | virtual-gamepad-lib
    interface GamepadDisplayVariableButton {
        buttonElement: HTMLElement | SVGElement;
        direction: gamepadDirection;
        directionHighlight?: HTMLElement | SVGElement;
        extraData?: any;
        highlight: HTMLElement | SVGElement;
        movementRange: number;
        type: variable;
    }

    Properties

    buttonElement +GamepadDisplayVariableButton | virtual-gamepad-lib
    interface GamepadDisplayVariableButton {
        buttonElement: HTMLElement | SVGElement;
        direction: gamepadDirection;
        directionHighlight?: HTMLElement | SVGElement;
        extraData?: any;
        highlight: HTMLElement | SVGElement;
        movementRange: number;
        type: variable;
    }

    Properties

    buttonElement: HTMLElement | SVGElement

    The element to move to represent pressing on this button

    -
    direction: gamepadDirection

    Direction the GamepadDisplayVariableButton.buttonElement should move to represent being pressed

    -
    directionHighlight?: HTMLElement | SVGElement

    Drag direction indicator / highlight element for this variable button

    -
    extraData?: any

    optional, for your own use

    -
    highlight: HTMLElement | SVGElement

    The element to add the touch and press classses, to represent touching or pressing on this button

    -
    movementRange: number

    How far the GamepadDisplayVariableButton.buttonElement should move to represent being pressed fully

    -
    type: variable
    +
    direction: gamepadDirection

    Direction the GamepadDisplayVariableButton.buttonElement should move to represent being pressed

    +
    directionHighlight?: HTMLElement | SVGElement

    Drag direction indicator / highlight element for this variable button

    +
    extraData?: any

    optional, for your own use

    +
    highlight: HTMLElement | SVGElement

    The element to add the touch and press classses, to represent touching or pressing on this button

    +
    movementRange: number

    How far the GamepadDisplayVariableButton.buttonElement should move to represent being pressed fully

    +
    type: variable
    diff --git a/docs/interfaces/GamepadEmulator.ButtonConfig.html b/docs/interfaces/GamepadEmulator.ButtonConfig.html index 0332747..29f0a70 100644 --- a/docs/interfaces/GamepadEmulator.ButtonConfig.html +++ b/docs/interfaces/GamepadEmulator.ButtonConfig.html @@ -1,9 +1,182 @@ -ButtonConfig | virtual-gamepad-lib
    interface ButtonConfig {
        buttonIndex: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        type: onOff;
    }

    Properties

    buttonIndex +ButtonConfig | virtual-gamepad-lib
    interface ButtonConfig {
        buttonIndex: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        type: onOff;
    }

    Properties

    buttonIndex: number

    The index of the button this emulated button should controll in the Gamepad.buttons array

    -
    lockTargetWhilePressed?: boolean

    Should 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. +

    lockTargetWhilePressed?: boolean

    Should 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.

    -
    tapTarget: HTMLElement | SVGElement

    Taps/clicks/hovers on this element will trigger events for this button on the emulated gamepad.

    -
    type: onOff
    +
    tapTarget: HTMLElement | SVGElement

    Taps/clicks/hovers on this element will trigger events for this button on the emulated gamepad.

    +
    type: onOff
    diff --git a/docs/interfaces/GamepadEmulator.EGamepad.html b/docs/interfaces/GamepadEmulator.EGamepad.html index 81e8174..6615f71 100644 --- a/docs/interfaces/GamepadEmulator.EGamepad.html +++ b/docs/interfaces/GamepadEmulator.EGamepad.html @@ -1,6 +1,164 @@ -EGamepad | virtual-gamepad-lib

    Extends the browser Gamepad interface to include an emulation property that exposes how this gamepad is being emulated (or not) +EGamepad | virtual-gamepad-lib

    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.

    -
    interface EGamepad {
        axes: number[];
        buttons: GamepadButton[];
        connected: boolean;
        displayId: string;
        emulation: undefined | gamepadEmulationState;
        hapticActuators?: (null | GamepadHapticActuator)[];
        id: string;
        index: number;
        mapping: GamepadMappingType;
        timestamp: number;
        vibrationActuator?: GamepadHapticActuator;
    }

    Hierarchy

    • Omit<Gamepad, "vibrationActuator">
      • EGamepad

    Properties

    interface EGamepad {
        axes: number[];
        buttons: GamepadButton[];
        connected: boolean;
        displayId: string;
        emulation: undefined | gamepadEmulationState;
        hapticActuators?: (null | GamepadHapticActuator)[];
        id: string;
        index: number;
        mapping: GamepadMappingType;
        timestamp: number;
        vibrationActuator?: GamepadHapticActuator;
    }

    Hierarchy

    • Omit<Gamepad, "vibrationActuator">
      • EGamepad

    Properties

    axes: number[]
    buttons: GamepadButton[]
    connected: boolean
    displayId: string
    emulation: undefined | gamepadEmulationState
    hapticActuators?: (null | GamepadHapticActuator)[]
    id: string
    index: number
    mapping: GamepadMappingType
    buttons: GamepadButton[]
    connected: boolean
    displayId: string
    emulation: undefined | gamepadEmulationState
    hapticActuators?: (null | GamepadHapticActuator)[]
    id: string
    index: number
    mapping: GamepadMappingType
    timestamp: number
    vibrationActuator?: GamepadHapticActuator
    +
    vibrationActuator?: GamepadHapticActuator
    diff --git a/docs/interfaces/GamepadEmulator.EGamepadEvent.html b/docs/interfaces/GamepadEmulator.EGamepadEvent.html index 5f56331..9937b08 100644 --- a/docs/interfaces/GamepadEmulator.EGamepadEvent.html +++ b/docs/interfaces/GamepadEmulator.EGamepadEvent.html @@ -1,5 +1,163 @@ -EGamepadEvent | virtual-gamepad-lib

    Extends the browser Gamepad Event interface to use an EGamepad type instead of a Gamepad

    -
    interface EGamepadEvent {
        AT_TARGET: 2;
        BUBBLING_PHASE: 3;
        CAPTURING_PHASE: 1;
        NONE: 0;
        bubbles: boolean;
        cancelBubble: boolean;
        cancelable: boolean;
        composed: boolean;
        currentTarget: null | EventTarget;
        defaultPrevented: boolean;
        eventPhase: number;
        gamepad: EGamepad;
        isTrusted: boolean;
        returnValue: boolean;
        srcElement: null | EventTarget;
        target: null | EventTarget;
        timeStamp: number;
        type: string;
        composedPath(): EventTarget[];
        initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
        preventDefault(): void;
        stopImmediatePropagation(): void;
        stopPropagation(): void;
    }

    Hierarchy

    • Omit<GamepadEvent, "gamepad">
      • EGamepadEvent

    Properties

    AT_TARGET +EGamepadEvent | virtual-gamepad-lib

    Extends the browser Gamepad Event interface to use an EGamepad type instead of a Gamepad

    +
    interface EGamepadEvent {
        AT_TARGET: 2;
        BUBBLING_PHASE: 3;
        CAPTURING_PHASE: 1;
        NONE: 0;
        bubbles: boolean;
        cancelBubble: boolean;
        cancelable: boolean;
        composed: boolean;
        currentTarget: null | EventTarget;
        defaultPrevented: boolean;
        eventPhase: number;
        gamepad: EGamepad;
        isTrusted: boolean;
        returnValue: boolean;
        srcElement: null | EventTarget;
        target: null | EventTarget;
        timeStamp: number;
        type: string;
        composedPath(): EventTarget[];
        initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
        preventDefault(): void;
        stopImmediatePropagation(): void;
        stopPropagation(): void;
    }

    Hierarchy

    • Omit<GamepadEvent, "gamepad">
      • EGamepadEvent

    Properties

    eventPhase: number

    Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.

    MDN Reference

    -
    gamepad: EGamepad
    isTrusted: boolean

    Returns true if event was dispatched by the user agent, and false otherwise.

    +
    gamepad: EGamepad
    isTrusted: boolean

    Returns true if event was dispatched by the user agent, and false otherwise.

    MDN Reference

    returnValue: boolean

    MDN Reference

    srcElement: null | EventTarget

    MDN Reference

    @@ -54,4 +212,19 @@

    MDN Reference

    Returns void

    • When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.

      MDN Reference

      -

      Returns void

    +

    Returns void

    diff --git a/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html b/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html index 9a73894..eb420ed 100644 --- a/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html +++ b/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html @@ -1,7 +1,180 @@ -EGamepadPrivateData | virtual-gamepad-lib
    interface EGamepadPrivateData {
        overlayMode: boolean;
        removeButtonListenersFunc?: (() => void);
        removeJoystickListenersFunc?: (() => void);
    }

    Properties

    overlayMode +EGamepadPrivateData | virtual-gamepad-lib
    interface EGamepadPrivateData {
        overlayMode: boolean;
        removeButtonListenersFunc?: (() => void);
        removeJoystickListenersFunc?: (() => void);
    }

    Properties

    overlayMode: boolean

    true if this e-gamepad was created in overlay mode

    -
    removeButtonListenersFunc?: (() => void)

    stores a refrence to a function to cleanup all event listeners created for controlling buttons on this egamepad

    -
    removeJoystickListenersFunc?: (() => void)

    stores a refrence to a function to cleanup all event listeners created for controlling axes on this egamepad

    -
    +
    removeButtonListenersFunc?: (() => void)

    stores a refrence to a function to cleanup all event listeners created for controlling buttons on this egamepad

    +
    removeJoystickListenersFunc?: (() => void)

    stores a refrence to a function to cleanup all event listeners created for controlling axes on this egamepad

    +
    diff --git a/docs/interfaces/GamepadEmulator.JoystickConfig.html b/docs/interfaces/GamepadEmulator.JoystickConfig.html index e5d7833..7236e21 100644 --- a/docs/interfaces/GamepadEmulator.JoystickConfig.html +++ b/docs/interfaces/GamepadEmulator.JoystickConfig.html @@ -1,14 +1,187 @@ -JoystickConfig | virtual-gamepad-lib
    interface JoystickConfig {
        directions: {
            down?: boolean;
            left?: boolean;
            right?: boolean;
            up?: boolean;
        };
        dragDistance: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        xAxisIndex?: number;
        yAxisIndex?: number;
    }

    Properties

    directions +JoystickConfig | virtual-gamepad-lib
    interface JoystickConfig {
        directions: {
            down?: boolean;
            left?: boolean;
            right?: boolean;
            up?: boolean;
        };
        dragDistance: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        xAxisIndex?: number;
        yAxisIndex?: number;
    }

    Properties

    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    }

    What drag/movement directions does this joystick support

    -
    dragDistance: number

    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)

    -
    lockTargetWhilePressed?: boolean

    Should 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)

    -
    tapTarget: HTMLElement | SVGElement

    The element where a tap or mouse click must start to control this joystick +

    dragDistance: number

    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)

    +
    lockTargetWhilePressed?: boolean

    Should 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)

    +
    tapTarget: HTMLElement | SVGElement

    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

    -
    xAxisIndex?: number

    What emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged left (-) and right (+)

    -
    yAxisIndex?: number

    What emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged up (-) and down (+)

    -
    +
    xAxisIndex?: number

    What emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged left (-) and right (+)

    +
    yAxisIndex?: number

    What emulated gamepad axis (the index in Gamepad.axes) to drive When the virtual joystick is dragged up (-) and down (+)

    +
    diff --git a/docs/interfaces/GamepadEmulator.VariableButtonConfig.html b/docs/interfaces/GamepadEmulator.VariableButtonConfig.html index 414df1f..509cbf0 100644 --- a/docs/interfaces/GamepadEmulator.VariableButtonConfig.html +++ b/docs/interfaces/GamepadEmulator.VariableButtonConfig.html @@ -1,15 +1,188 @@ -VariableButtonConfig | virtual-gamepad-lib
    interface VariableButtonConfig {
        buttonIndex: number;
        directions: {
            down?: boolean;
            left?: boolean;
            right?: boolean;
            up?: boolean;
        };
        dragDistance: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        type: variable;
    }

    Properties

    buttonIndex +VariableButtonConfig | virtual-gamepad-lib
    interface VariableButtonConfig {
        buttonIndex: number;
        directions: {
            down?: boolean;
            left?: boolean;
            right?: boolean;
            up?: boolean;
        };
        dragDistance: number;
        lockTargetWhilePressed?: boolean;
        tapTarget: HTMLElement | SVGElement;
        type: variable;
    }

    Properties

    buttonIndex: number

    The index of the button this emulated button should controll in the Gamepad.buttons array

    -
    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    }

    What drag/movement gesture directions should result in the button value of this varaible button increasing +

    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    }

    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

    -
    dragDistance: number

    The distance drag gesture must go in pixels to appear as a fully pressed button: value = 1

    -
    lockTargetWhilePressed?: boolean

    Should 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) +

    dragDistance: number

    The distance drag gesture must go in pixels to appear as a fully pressed button: value = 1

    +
    lockTargetWhilePressed?: boolean

    Should 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.

    -
    tapTarget: HTMLElement | SVGElement

    The element where a tap or mouse click must start to control this variable button. +

    tapTarget: HTMLElement | SVGElement

    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

    -
    type: variable
    +
    type: variable
    diff --git a/docs/media/package.json b/docs/media/package.json index 75ce9b8..c706eec 100644 --- a/docs/media/package.json +++ b/docs/media/package.json @@ -87,6 +87,7 @@ "np": "^10.0.7", "svgo": "^3.3.2", "typedoc": "^0.26.4", + "typedoc-material-theme": "^1.1.0", "typescript": "^5.4.0", "vite": "^5.3.4", "vite-plugin-dts": "^3.9.1", diff --git a/docs/modules/GamepadApiWrapper.html b/docs/modules/GamepadApiWrapper.html index e89ba5a..b8184c1 100644 --- a/docs/modules/GamepadApiWrapper.html +++ b/docs/modules/GamepadApiWrapper.html @@ -1,8 +1,181 @@ -GamepadApiWrapper | virtual-gamepad-lib

    Module GamepadApiWrapper

    Index

    Classes

    GamepadApiWrapper +GamepadApiWrapper | virtual-gamepad-lib
    +
    diff --git a/docs/modules/GamepadDisplay.html b/docs/modules/GamepadDisplay.html index 39956d8..b0e2df7 100644 --- a/docs/modules/GamepadDisplay.html +++ b/docs/modules/GamepadDisplay.html @@ -1,8 +1,181 @@ -GamepadDisplay | virtual-gamepad-lib

    Index

    Classes

    GamepadDisplay +GamepadDisplay | virtual-gamepad-lib
    +
    diff --git a/docs/modules/GamepadEmulator.html b/docs/modules/GamepadEmulator.html index 0948f2f..fc29797 100644 --- a/docs/modules/GamepadEmulator.html +++ b/docs/modules/GamepadEmulator.html @@ -1,4 +1,162 @@ -GamepadEmulator | virtual-gamepad-lib

    Index

    Classes

    GamepadEmulator +GamepadEmulator | virtual-gamepad-lib
    +
    diff --git a/docs/modules/enums.html b/docs/modules/enums.html index bb7741f..1a3ade0 100644 --- a/docs/modules/enums.html +++ b/docs/modules/enums.html @@ -1,4 +1,162 @@ -enums | virtual-gamepad-lib

    Index

    Enumerations

    gamepadButtonType +enums | virtual-gamepad-lib
    +
    diff --git a/docs/modules/utilities.html b/docs/modules/utilities.html index fc2e0ba..e49495f 100644 --- a/docs/modules/utilities.html +++ b/docs/modules/utilities.html @@ -1,4 +1,177 @@ -utilities | virtual-gamepad-lib

    Index

    Functions

    CenterTransformOrigin +utilities | virtual-gamepad-lib
    +
    diff --git a/docs/types/GamepadApiWrapper.AxisChangeCallback.html b/docs/types/GamepadApiWrapper.AxisChangeCallback.html index 1adbc6b..5ddb72e 100644 --- a/docs/types/GamepadApiWrapper.AxisChangeCallback.html +++ b/docs/types/GamepadApiWrapper.AxisChangeCallback.html @@ -1 +1,174 @@ -AxisChangeCallback | virtual-gamepad-lib
    AxisChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: boolean[]) => void)
    +AxisChangeCallback | virtual-gamepad-lib
    AxisChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: boolean[]) => void)
    diff --git a/docs/types/GamepadApiWrapper.ButtonChangeCallback.html b/docs/types/GamepadApiWrapper.ButtonChangeCallback.html index d171ccc..9c9e4b7 100644 --- a/docs/types/GamepadApiWrapper.ButtonChangeCallback.html +++ b/docs/types/GamepadApiWrapper.ButtonChangeCallback.html @@ -1 +1,174 @@ -ButtonChangeCallback | virtual-gamepad-lib
    ButtonChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: (buttonChangeDetails | false)[]) => void)
    +ButtonChangeCallback | virtual-gamepad-lib
    ButtonChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: (buttonChangeDetails | false)[]) => void)
    diff --git a/docs/types/GamepadApiWrapper.GamepadEventCallback.html b/docs/types/GamepadApiWrapper.GamepadEventCallback.html index d2eec69..150cbb0 100644 --- a/docs/types/GamepadApiWrapper.GamepadEventCallback.html +++ b/docs/types/GamepadApiWrapper.GamepadEventCallback.html @@ -1 +1,174 @@ -GamepadEventCallback | virtual-gamepad-lib
    GamepadEventCallback: ((e: GamepadEvent) => void)
    +GamepadEventCallback | virtual-gamepad-lib
    GamepadEventCallback: ((e: GamepadEvent) => void)
    diff --git a/docs/types/GamepadDisplay.ButtonDisplayFunction.html b/docs/types/GamepadDisplay.ButtonDisplayFunction.html index f8514c0..0f79e36 100644 --- a/docs/types/GamepadDisplay.ButtonDisplayFunction.html +++ b/docs/types/GamepadDisplay.ButtonDisplayFunction.html @@ -1 +1,174 @@ -ButtonDisplayFunction | virtual-gamepad-lib
    ButtonDisplayFunction: ((buttonConfig: GamepadDisplayButton | GamepadDisplayVariableButton, value: number, touched: boolean, pressed: boolean, changes: buttonChangeDetails, btnIndex: number) => void)
    +ButtonDisplayFunction | virtual-gamepad-lib
    ButtonDisplayFunction: ((buttonConfig: GamepadDisplayButton | GamepadDisplayVariableButton, value: number, touched: boolean, pressed: boolean, changes: buttonChangeDetails, btnIndex: number) => void)
    diff --git a/docs/types/GamepadDisplay.JoystickDisplayFunction.html b/docs/types/GamepadDisplay.JoystickDisplayFunction.html index 00dd5af..26bbac4 100644 --- a/docs/types/GamepadDisplay.JoystickDisplayFunction.html +++ b/docs/types/GamepadDisplay.JoystickDisplayFunction.html @@ -1 +1,174 @@ -JoystickDisplayFunction | virtual-gamepad-lib
    JoystickDisplayFunction: ((stickConfig: GamepadDisplayJoystick, xAxisValue: number, yAxisValue: number) => void)
    +JoystickDisplayFunction | virtual-gamepad-lib
    JoystickDisplayFunction: ((stickConfig: GamepadDisplayJoystick, xAxisValue: number, yAxisValue: number) => void)
    diff --git a/docs/variables/GamepadEmulator.DEFAULT_GPAD_AXIS_COUNT.html b/docs/variables/GamepadEmulator.DEFAULT_GPAD_AXIS_COUNT.html index fcd4f5f..0bf5ad5 100644 --- a/docs/variables/GamepadEmulator.DEFAULT_GPAD_AXIS_COUNT.html +++ b/docs/variables/GamepadEmulator.DEFAULT_GPAD_AXIS_COUNT.html @@ -1,3 +1,176 @@ -DEFAULT_GPAD_AXIS_COUNT | virtual-gamepad-lib
    DEFAULT_GPAD_AXIS_COUNT: number = 4

    A number of typical axes recognized by Gamepad API and mapped to +DEFAULT_GPAD_AXIS_COUNT | virtual-gamepad-lib

    DEFAULT_GPAD_AXIS_COUNT: number = 4

    A number of typical axes recognized by Gamepad API and mapped to standard controls. Any extraneous axes will have larger indexes.

    -
    +
    diff --git a/docs/variables/GamepadEmulator.DEFAULT_GPAD_BUTTON_COUNT.html b/docs/variables/GamepadEmulator.DEFAULT_GPAD_BUTTON_COUNT.html index 8b96bf9..a4d69d8 100644 --- a/docs/variables/GamepadEmulator.DEFAULT_GPAD_BUTTON_COUNT.html +++ b/docs/variables/GamepadEmulator.DEFAULT_GPAD_BUTTON_COUNT.html @@ -1,3 +1,176 @@ -DEFAULT_GPAD_BUTTON_COUNT | virtual-gamepad-lib
    DEFAULT_GPAD_BUTTON_COUNT: number = 18

    A number of typical buttons recognized by Gamepad API and mapped to +DEFAULT_GPAD_BUTTON_COUNT | virtual-gamepad-lib

    DEFAULT_GPAD_BUTTON_COUNT: number = 18

    A number of typical buttons recognized by Gamepad API and mapped to standard controls. Any extraneous buttons will have larger indexes.

    -
    +
    diff --git a/docs/variables/enums.playStationAxesMap.html b/docs/variables/enums.playStationAxesMap.html index 42c2aaa..9464fad 100644 --- a/docs/variables/enums.playStationAxesMap.html +++ b/docs/variables/enums.playStationAxesMap.html @@ -1 +1,174 @@ -playStationAxesMap | virtual-gamepad-lib

    Variable playStationAxesMapConst

    playStationAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap
    +playStationAxesMap | virtual-gamepad-lib

    Variable playStationAxesMapConst

    playStationAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap
    diff --git a/docs/variables/enums.standardGpadButtonMap.html b/docs/variables/enums.standardGpadButtonMap.html index 6c83a6f..0d1cd17 100644 --- a/docs/variables/enums.standardGpadButtonMap.html +++ b/docs/variables/enums.standardGpadButtonMap.html @@ -1 +1,174 @@ -standardGpadButtonMap | virtual-gamepad-lib

    Variable standardGpadButtonMapConst

    standardGpadButtonMap: typeof xboxButtonMap = xboxButtonMap
    +standardGpadButtonMap | virtual-gamepad-lib

    Variable standardGpadButtonMapConst

    standardGpadButtonMap: typeof xboxButtonMap = xboxButtonMap
    diff --git a/docs/variables/enums.xboxAxesMap.html b/docs/variables/enums.xboxAxesMap.html index fc8b117..0ee750a 100644 --- a/docs/variables/enums.xboxAxesMap.html +++ b/docs/variables/enums.xboxAxesMap.html @@ -1 +1,174 @@ -xboxAxesMap | virtual-gamepad-lib

    Variable xboxAxesMapConst

    xboxAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap
    +xboxAxesMap | virtual-gamepad-lib

    Variable xboxAxesMapConst

    xboxAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap
    diff --git a/index.html b/index.html index 641e94b..95d279e 100644 --- a/index.html +++ b/index.html @@ -7,17 +7,20 @@ +

    Virtual Gamepad Examples

    + Documentation Full Example Simple Example Keyboard & Direct Emulation Example Game Engine (3rd Party Library) Example (Phaser 3) -
    - Documentation + Virtual Gamepad Banner Image +