From d8cf6d5d17262cabc92ba784dfd38e667da54de6 Mon Sep 17 00:00:00 2001 From: KW-M <16263357+KW-M@users.noreply.github.com> Date: Tue, 26 Nov 2024 04:02:26 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20KW-M/vir?= =?UTF-8?q?tual-gamepad-lib@944c4d2401fe91f34273fc7f6a1398340e5b80f1=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/custom_gamepads-BMNoLoPF.css | 1 + assets/custom_gamepads-DPQ0p1vn.js | 1 + ...a.js => display-gamepad-right-BmtaGMJm.js} | 6 +- assets/game_engine-CpyXkHZU.js | 1 + assets/game_engine-DYryWnDF.js | 1 - assets/helpers-DCx76efX.js | 1 + assets/simple-AtMKnGyp.js | 1 + assets/simple-WOrj11eu.js | 1 - custom_gamepads/index.html | 118 ++++++++++++++++++ .../GamepadApiWrapper.GamepadApiWrapper.html | 32 ++--- .../GamepadDisplay.GamepadDisplay.html | 14 +-- .../GamepadEmulator.GamepadEmulator.html | 58 ++++----- docs/enums/enums.PRESET_SVG_GPAD_CLASS.html | 4 +- docs/enums/enums.gamepadButtonType.html | 4 +- docs/enums/enums.gamepadDirection.html | 4 +- docs/enums/enums.gamepadEmulationState.html | 4 +- docs/enums/enums.playStationButtonMap.html | 4 +- docs/enums/enums.standardGpadAxesMap.html | 4 +- docs/enums/enums.standardGpadButtonMap.html | 4 +- docs/enums/enums.xboxButtonMap.html | 4 +- ...helpers.setupPresetInteractiveGamepad.html | 2 +- .../utilities.CenterTransformOrigin.html | 2 +- .../utilities.CenterTransformOriginDebug.html | 2 +- .../utilities.NormalizeClampVector.html | 2 +- ...GamepadApiWrapper.buttonChangeDetails.html | 14 +-- ...GamepadApiWrapper.wrapperButtonConfig.html | 4 +- .../GamepadApiWrapper.wrapperConfig.html | 8 +- .../GamepadDisplay.DisplayGamepadConfig.html | 18 +-- ...GamepadDisplay.GamepadDisplayJoystick.html | 10 +- ...epadDisplay.GamepadDisplayOnOffButton.html | 6 +- ...dDisplay.GamepadDisplayVariableButton.html | 14 +-- docs/interfaces/GamepadEmulator.EGamepad.html | 6 +- .../GamepadEmulator.EGamepadEvent.html | 4 +- .../GamepadEmulator.EGamepadPrivateData.html | 8 +- .../GamepadEmulator.JoystickTouchConfig.html | 14 +-- ...amepadEmulator.OnOffButtonTouchConfig.html | 10 +- ...padEmulator.VariableButtonTouchConfig.html | 14 +-- ...elpers.interactiveGamepadPresetConfig.html | 4 +- docs/modules/GamepadApiWrapper.html | 2 +- docs/modules/GamepadDisplay.html | 2 +- docs/modules/GamepadEmulator.html | 2 +- docs/modules/enums.html | 2 +- docs/modules/helpers.html | 2 +- docs/modules/index.html | 2 +- docs/modules/utilities.html | 2 +- .../GamepadApiWrapper.AxisChangeCallback.html | 2 +- ...amepadApiWrapper.ButtonChangeCallback.html | 2 +- ...amepadApiWrapper.GamepadEventCallback.html | 2 +- .../GamepadDisplay.ButtonDisplayFunction.html | 2 +- .../GamepadDisplay.GamepadDisplayButton.html | 2 +- ...amepadDisplay.JoystickDisplayFunction.html | 2 +- docs/types/GamepadEmulator.ButtonConfig.html | 2 +- .../GamepadEmulator.ButtonTouchConfig.html | 2 +- .../types/GamepadEmulator.JoystickConfig.html | 2 +- .../GamepadEmulator.OnOffButtonConfig.html | 2 +- .../GamepadEmulator.VariableButtonConfig.html | 2 +- docs/types/enums.gpadAxesMapType.html | 2 +- docs/types/enums.gpadButtonMapType.html | 2 +- ...mepadEmulator.DEFAULT_GPAD_AXIS_COUNT.html | 2 +- ...padEmulator.DEFAULT_GPAD_BUTTON_COUNT.html | 2 +- .../enums.PRESET_SVG_GPAD_BTN_IDS.html | 2 +- ...ms.PRESET_SVG_GPAD_BTN_TAP_TARGET_IDS.html | 2 +- ...IAGONAL_TAP_TARGET_IDS_TO_BTN_INDEXES.html | 2 +- docs/variables/enums.playStationAxesMap.html | 2 +- docs/variables/enums.xboxAxesMap.html | 2 +- game_engine/index.html | 5 +- simple/index.html | 5 +- 67 files changed, 298 insertions(+), 175 deletions(-) create mode 100644 assets/custom_gamepads-BMNoLoPF.css create mode 100644 assets/custom_gamepads-DPQ0p1vn.js rename assets/{display-gamepad-right-DSHUDGha.js => display-gamepad-right-BmtaGMJm.js} (94%) create mode 100644 assets/game_engine-CpyXkHZU.js delete mode 100644 assets/game_engine-DYryWnDF.js create mode 100644 assets/helpers-DCx76efX.js create mode 100644 assets/simple-AtMKnGyp.js delete mode 100644 assets/simple-WOrj11eu.js create mode 100644 custom_gamepads/index.html diff --git a/assets/custom_gamepads-BMNoLoPF.css b/assets/custom_gamepads-BMNoLoPF.css new file mode 100644 index 0000000..7e1a651 --- /dev/null +++ b/assets/custom_gamepads-BMNoLoPF.css @@ -0,0 +1 @@ +.gpad-container svg,svg.gpad-container{pointer-events:none}.gpad-tap-target{visibility:hidden;cursor:pointer;pointer-events:all}.gpad-highlight{opacity:0}.gpad-highlight.touched{opacity:.5}.gpad-highlight.touched.pressed{opacity:1}.gpad-direction-highlight{opacity:0}.gpad-direction-highlight.moved,.gpad-direction-highlight.active{opacity:.8}html{font-family:Inter,Avenir,Helvetica,Arial,sans-serif;font-size:16px;line-height:24px;font-weight:400;color-scheme:light dark;color:#213547;background:linear-gradient(to top right,#00378a,#50cdff);background-color:#fff;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}body{overflow-x:hidden;margin:0;padding:0;display:flex;flex-direction:column;align-items:center;min-height:100vh}*{box-sizing:border-box}a{font-weight:500;color:#200187;text-decoration:underline}a:hover{color:#747bff}.hidden{display:none!important}h1{font-size:3.2em}h1,h2,h3,h4{line-height:1.1}h3{background-color:#8400ff;color:#fff}h4{color:#fff}button{border-radius:8px;border:2px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#f9f9f9;color:#213547;cursor:pointer;transition:border-color .25s;margin:.4rem}button:hover{border-color:#646cff}button:focus,button:focus-visible{outline:4px auto -webkit-focus-ring-color}@media (prefers-color-scheme: dark){html{background-color:#fff;background:linear-gradient(to top right,#9d4fe6,#6c00d0);color:#f1f1f1}a:hover{color:#535bf2}button{background-color:#1a1a1a;color:#f9f9f9}}#corner-docs{background-color:#bdfc48;display:block;position:fixed;font-size:x-large;top:0;right:0;padding:.5em 3em;transform:rotate(45deg) translate(2em,-1em);margin:0;z-index:1000}#corner-docs-l{background-color:#feb943;display:block;position:fixed;font-size:x-large;top:0;left:0;padding:.5em 3em;transform:rotate(-45deg) translate(-2.5em,-1em);margin:0;z-index:1000}.text-block{display:block;position:relative;width:max-content;margin:0 auto;padding:1rem;max-width:100%;text-align:left;border-radius:10px}.table-container{display:block;position:relative;width:max-content;margin:0 auto;padding:.4rem;max-width:100%;text-align:left;background-color:#000;height:100%;box-sizing:border-box;overflow:auto}table{border-collapse:collapse;color:#000;text-align:center;width:100%}table td,table th{border:1px solid rgb(0,136,255);padding:5px 8px}table tr{background-color:#fff}table tr:nth-child(2n){background-color:#f2f2f2}table tr:hover{background-color:#ddd}table th{padding-top:12px;padding-bottom:12px;background-color:#04aa6d;color:#fff;white-space:wrap;width:min-content}kbd{text-align:center;-moz-box-shadow:inset 0 0 1px rgb(150,150,150),inset 0 -.05em .4em rgb(80,80,80),0 .1em 0 rgb(30,30,30),0 .1em .1em rgba(0,0,0,.3);-webkit-box-shadow:inset 0 0 1px rgb(150,150,150),inset 0 -.05em .4em rgb(80,80,80),0 .1em 0 rgb(30,30,30),0 .1em .1em rgba(0,0,0,.3);background:-moz-linear-gradient(top,rgb(60,60,60),rgb(80,80,80));background:-webkit-gradient(linear,left top,left bottom,from(rgb(60,60,60)),to(rgb(80,80,80)));background:#505050;box-shadow:inset 0 0 1px #969696,inset 0 -.05em .4em #505050,0 .1em #1e1e1e,0 .1em .1em #0000004d;color:#fafafa;text-shadow:-1px -1px 0 rgb(70,70,70);padding:.2em .5em;display:inline-block;margin:2px;border-radius:5px}.gpad-display{display:contents}.gpad-display svg{position:fixed;user-select:none;width:max-content;bottom:0;max-height:14cm;pointer-events:none}#gpad_display_left svg{left:0;transform:translate(-20%)}#gpad_display_right svg{right:0;transform:translate(20%)}.gpad-display-full svg{left:50%;width:100%;max-width:100vw;transform:translate(-50%)}#split_gpad_display_container{position:relative;width:100%;display:flex;justify-content:space-around;align-items:center;user-select:none}#split_gpad_display_container svg{position:relative;transform:none;max-width:50%;background-color:#ffffffa7;border-radius:20px}#split_gpad_display_container svg .gpad-base{fill:#fff!important}#split_gpad_display_container svg .gpad-stick-base{fill:#fa0!important;stroke-width:0!important}#split_gpad_display_container svg .gpad-shadow{fill:#970000!important;fill-opacity:1!important}#split_gpad_display_container svg .gpad-icon{fill:#970000!important;fill-opacity:1!important}#split_gpad_display_container svg #stick_left .gpad-shadow,#split_gpad_display_container svg #stick_right .gpad-shadow{fill-opacity:1!important;fill:#970000!important}#split_gpad_display_container svg #stick_left .gpad-btn-bg *,#split_gpad_display_container svg #stick_right .gpad-btn-bg *{fill:#fff!important}#split_gpad_display_container svg #stick_left .gpad-btn-bg path,#split_gpad_display_container svg #stick_right .gpad-btn-bg path{fill:#970000!important}#split_gpad_display_container svg .gpad-btn-bg{fill:#fa0!important}#split_gpad_display_container svg .gpad-btn-bg+path{fill:#970000!important}#split_gpad_display_container svg .gpad-highlight{filter:hue-rotate(160deg)}#split_gpad_display_container svg .gpad-label{fill:#fa0!important}#split_gpad_display_container svg .gpad-direction-highlight{fill:#9500ff!important}#gpad_display_html{max-width:100%;overflow:scroll;user-select:none;display:grid;align-content:center;justify-items:center;align-items:center;grid-template-columns:1fr 1fr 1fr;background:linear-gradient(40deg,#03e364,#0dacc5);padding:20px;gap:20px;border-radius:40px;box-shadow:0 2px 50px #0000001a;margin:80px auto}.custom-gpad-buttons{display:grid;align-content:center;justify-items:center;align-items:center;grid-template-columns:repeat(3,1fr);gap:10px}.custom-gpad-buttons h3{grid-column-end:span 3;padding:16px;text-align:center;border-radius:6px;width:100%}.gpad-custom-button{display:flex;justify-content:center;align-items:center;font-size:xx-large;min-width:50px;height:50px;border-radius:10px;width:100%;color:#fff;border:solid 4px #707070;background-color:#000;box-shadow:0 0 10px #0000001a;cursor:pointer;padding:4px 8px}.gpad-custom-button.touched,.gpad-custom-thumbstick.touched{border-color:#fa0}.gpad-custom-button.pressed,.gpad-custom-thumbstick.pressed{border-color:#a6ff00}.custom-gpad-axis-bg{height:200px;width:200px;border-radius:150px;background-color:#000;position:relative;overflow:hidden;box-shadow:inset 0 10px 30px #00000080}.custom-gpad-axis-bg h3{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:#fff;margin:0;text-align:center;padding:18px 30px;background:#0000007e}.custom-gpad-horiz-axis h3{left:0;padding:30px 21px;transform:translateY(-50%)}.custom-gpad-xy-axis h3{left:50%;top:0;padding:20px 200px;transform:translate(-50%)}.custom-gpad-vert-axis{width:60px;background-color:#0ff}.custom-gpad-horiz-axis{height:60px;background-color:orange}.custom-gpad-xy-axis{background-color:purple}.gpad-custom-thumbstick{position:absolute;width:50px;height:50px;border-radius:50%;cursor:move;border:solid 4px #707070;background-color:#000;top:calc(50% - 25px);left:calc(50% - 25px);box-shadow:2px 2px 10px #00000080}.gpad-custom-thumbstick.bottom-stick{bottom:6px;top:unset;cursor:n-resize}.gpad-custom-thumbstick.top-stick{top:6px;bottom:unset;cursor:s-resize}.custom-gpad-drag-button{display:flex;justify-content:center;align-items:center;font-size:xx-large;width:50px;height:50px;border-radius:4px 50% 4px 4px;background-color:#000;box-shadow:0 0 10px #0000001a;cursor:pointer;gap:10px} diff --git a/assets/custom_gamepads-DPQ0p1vn.js b/assets/custom_gamepads-DPQ0p1vn.js new file mode 100644 index 0000000..1e519ef --- /dev/null +++ b/assets/custom_gamepads-DPQ0p1vn.js @@ -0,0 +1 @@ +import{G as P,a as w,d as x,g as c,e,f as R,c as p,P as y,C as D,h as S}from"./GamepadEmulator-CNWoeGf3.js";import{G as k}from"./GamepadDisplay-3X_eRe0j.js";import{L as v,R as C}from"./display-gamepad-right-BmtaGMJm.js";const _=new P(.1),m=new w({updateDelay:0,axisDeadZone:.05,buttonConfigs:[]}),f=0;_.AddEmulatedGamepad(f,!0,22,6);m.onGamepadConnect(i=>{console.log("Gamepad connected: ",i)});m.onGamepadDisconnect(i=>{console.log("Gamepad disconnected: ",i)});const T=()=>{const i=document.getElementById("split_gpad_display_container"),s=document.getElementById("gpad_display_html");document.getElementById("gpad_display_left").innerHTML=v,document.getElementById("gpad_display_right").innerHTML=C,A(f),q(f),E(f),G(f),m.onGamepadButtonChange((n,r,t)=>{console.log(`Gamepad ${n} button change: `,t)}),m.onGamepadAxisChange((n,r,t)=>{console.log(`Gamepad ${n} axis change: `,r.axes,t)});function A(n){_.AddButtonTouchEventListeners(n,x.map((r,t)=>{const g=r.includes("trigger"),o=r.includes("stick");return g?{buttonIndex:t,type:c.variable,tapTarget:i.querySelector("#"+r),dragDistance:50,lockTargetWhilePressed:!0,directions:{[e.up]:!1,[e.down]:!0,[e.left]:!1,[e.right]:!1}}:{buttonIndex:t,type:c.onOff,lockTargetWhilePressed:o===!0,tapTarget:i.querySelector("#"+r)}}).concat(Object.entries(R).map(([r,t])=>({buttonIndexes:t,type:c.onOff,tapTarget:i.querySelector("#"+r),lockTargetWhilePressed:!1})))),_.AddJoystickTouchEventListeners(n,[{tapTarget:i.querySelector("#"+x[p.LStick]),dragDistance:30,xAxisIndex:0,yAxisIndex:1,lockTargetWhilePressed:!0,directions:{[e.up]:!0,[e.down]:!0,[e.left]:!0,[e.right]:!0}},{tapTarget:i.querySelector("#"+x[p.RStick]),dragDistance:30,xAxisIndex:2,yAxisIndex:3,lockTargetWhilePressed:!0,directions:{[e.up]:!0,[e.down]:!0,[e.left]:!0,[e.right]:!0}}])}function E(n){const r=document.querySelector(`#${y[p.LStick]}`),t=document.querySelector(`#${y[p.RStick]}`);D(r),D(t);const g=y.map(a=>a.includes("trigger")?{type:c.variable,direction:e.down,buttonElement:i.querySelector(`#${a}`),highlight:i.querySelector(`#${a} .${S.ButtonHighlight}`),directionHighlight:i.querySelector(`#${a} .${S.DirectionHighlight}`),movementRange:10,extraData:{myCustomData:"variable btn name is "+a}}:{type:c.onOff,highlight:i.querySelector(`#${a} .${S.ButtonHighlight}`),extraData:{myCustomData:"onOff btn name is "+a}}),o=[{joystickElement:i.querySelector(`#${y[p.LStick]}`),xAxisIndex:0,yAxisIndex:1,movementRange:10,extraData:{directionHighlightArrows:{[e.up]:i.querySelector("#l_stick_up_direction_highlight"),[e.down]:i.querySelector("#l_stick_down_direction_highlight"),[e.left]:i.querySelector("#l_stick_left_direction_highlight"),[e.right]:i.querySelector("#l_stick_right_direction_highlight")}}},{joystickElement:i.querySelector(`#${y[p.RStick]}`),xAxisIndex:2,yAxisIndex:3,movementRange:10,extraData:{directionHighlightArrows:{[e.up]:i.querySelector("#r_stick_up_direction_highlight"),[e.down]:i.querySelector("#r_stick_down_direction_highlight"),[e.left]:i.querySelector("#r_stick_left_direction_highlight"),[e.right]:i.querySelector("#r_stick_right_direction_highlight")}}}],l=new k({gamepadIndex:n,pressedHighlightClass:"pressed",touchedHighlightClass:"touched",moveDirectionHighlightClass:"moved",buttons:g,sticks:o,joystickDisplayFunction:function(a,u,h){a.joystickElement.style.transform=`rotateY(${u*30}deg) rotateX(${-h*30}deg) translateZ(17px)`;const d=a.extraData.directionHighlightArrows;d[e.up].style.opacity=Math.max(-h,0).toString(),d[e.down].style.opacity=Math.max(h,0).toString(),d[e.left].style.opacity=Math.max(-u,0).toString(),d[e.right].style.opacity=Math.max(u,0).toString()},buttonDisplayFunction:function(a,u,h,d,b,I){l.DefaultButtonDisplayFunction(a,u,h,d,b,I),a.type===c.variable&&(a.buttonElement.style.fill=`hsl(${u*360}, 100%, 50%)`)}},m)}function q(n){const r=[];for(let t=0;t<=3;t++){const g=t===1,o=t===0,l=t===2;r.push({buttonIndex:t,type:c.variable,lockTargetWhilePressed:!0,tapTarget:s.querySelector("#drag-button-"+t),dragDistance:100,directions:{[e.up]:!1,[e.down]:g,[e.left]:o,[e.right]:l}})}for(let t=3;t<=20;t++)r.push({buttonIndex:t,type:c.onOff,lockTargetWhilePressed:!1,tapTarget:s.querySelector("#button-"+t)});r.push({type:c.onOff,buttonIndex:21,tapTarget:s.querySelector("#axis-0 .gpad-custom-thumbstick"),lockTargetWhilePressed:!0}),_.AddButtonTouchEventListeners(n,r),_.AddJoystickTouchEventListeners(n,[{tapTarget:s.querySelector("#axis-0 .gpad-custom-thumbstick"),dragDistance:100,xAxisIndex:0,lockTargetWhilePressed:!0,directions:{[e.up]:!1,[e.down]:!1,[e.left]:!0,[e.right]:!0}},{tapTarget:s.querySelector("#axis-1 .gpad-custom-thumbstick"),dragDistance:200,yAxisIndex:1,lockTargetWhilePressed:!0,directions:{[e.up]:!0,[e.down]:!1,[e.left]:!1,[e.right]:!1}},{tapTarget:s.querySelector("#axis-2 .gpad-custom-thumbstick"),dragDistance:200,yAxisIndex:3,lockTargetWhilePressed:!0,directions:{[e.up]:!1,[e.down]:!0,[e.left]:!1,[e.right]:!1}},{tapTarget:s.querySelector("#axis-3 .gpad-custom-thumbstick"),dragDistance:100,xAxisIndex:2,lockTargetWhilePressed:!0,directions:{[e.up]:!1,[e.down]:!1,[e.left]:!0,[e.right]:!0}},{tapTarget:s.querySelector("#axis-4 .gpad-custom-thumbstick"),dragDistance:100,xAxisIndex:4,yAxisIndex:5,lockTargetWhilePressed:!0,directions:{[e.up]:!0,[e.down]:!0,[e.left]:!0,[e.right]:!0}}])}function G(n){const r=[];for(let o=0;o<=2;o++){let l;o==0?l=e.left:o==1?l=e.down:l=e.right,r.push({type:c.variable,direction:l,movementRange:60,buttonElement:s.querySelector("#drag-button-"+o),highlight:s.querySelector("#drag-button-"+o)})}for(let o=3;o<=20;o++)r.push({type:c.onOff,highlight:s.querySelector("#button-"+o)});r.push({type:c.onOff,highlight:s.querySelector("#axis-0 .gpad-custom-thumbstick")});const t=[{joystickElement:s.querySelector("#axis-0 .gpad-custom-thumbstick"),xAxisIndex:0,movementRange:70},{joystickElement:s.querySelector("#axis-1 .gpad-custom-thumbstick"),yAxisIndex:1,movementRange:140},{joystickElement:s.querySelector("#axis-2 .gpad-custom-thumbstick"),yAxisIndex:3,movementRange:140},{joystickElement:s.querySelector("#axis-3 .gpad-custom-thumbstick"),xAxisIndex:2,movementRange:70},{joystickElement:s.querySelector("#axis-4 .gpad-custom-thumbstick"),xAxisIndex:4,yAxisIndex:5,movementRange:70}],g=new k({gamepadIndex:n,pressedHighlightClass:"pressed",touchedHighlightClass:"touched",moveDirectionHighlightClass:"moved",buttons:r,sticks:t,buttonDisplayFunction:function(o,l,a,u,h,d){g.DefaultButtonDisplayFunction(o,l,a,u,h,d),o.type===c.variable&&(o.buttonElement.style.backgroundColor=`hsl(0, 0%, ${l*100}%)`)}},m)}};console.log("Waiting for page to load...",document.readyState);document.readyState==="complete"?T():window.addEventListener("load",T); diff --git a/assets/display-gamepad-right-DSHUDGha.js b/assets/display-gamepad-right-BmtaGMJm.js similarity index 94% rename from assets/display-gamepad-right-DSHUDGha.js rename to assets/display-gamepad-right-BmtaGMJm.js index 117c3cc..aa98a03 100644 --- a/assets/display-gamepad-right-DSHUDGha.js +++ b/assets/display-gamepad-right-BmtaGMJm.js @@ -1,4 +1,4 @@ -import{G,a as D,D as M,b as V,d as w,g as l,e as g,f as q,P as s,c as r,C as u,h}from"./GamepadEmulator-CNWoeGf3.js";import{G as Q}from"./GamepadDisplay-3X_eRe0j.js";const I=(t,A)=>{var p,f;A=Object.assign({GpadDisplayConfig:{gamepadIndex:0},EmulatedGamepadIndex:0,EmulatedGamepadOverlayMode:!0,AllowDpadDiagonals:!1,VariableTriggers:!0,ClickableJoysticks:!0,JoystickDragDistance:50,TriggerDragDistance:50},A),t.classList.add("gpad-container");const n=(p=A.GpadEmulator)!=null?p:new G(.1),o=(f=A.GpadApiWrapper)!=null?f:new D({updateDelay:0,axisDeadZone:.05,buttonConfigs:[]}),d=A.EmulatedGamepadIndex;n.AddEmulatedGamepad(d,A.EmulatedGamepadOverlayMode,M,V);const c=[];for(let a=0;aa.includes("trigger")&&A.VariableTriggers?{type:l.variable,direction:g.down,buttonElement:t.querySelector(`#${a}`),highlight:t.querySelector(`#${a} .${h.ButtonHighlight}`),directionHighlight:t.querySelector(`#${a} .${h.DirectionHighlight}`),movementRange:10}:{type:l.onOff,highlight:t.querySelector(`#${a} .${h.ButtonHighlight}`),extraData:{myCustomData:"onOff btn name is "+a}}),b=[{joystickElement:t.querySelector(`#${s[r.LStick]}`),xAxisIndex:0,yAxisIndex:1,movementRange:10},{joystickElement:t.querySelector(`#${s[r.RStick]}`),xAxisIndex:2,yAxisIndex:3,movementRange:10}],E=new Q(Object.assign({gamepadIndex:d,buttons:m,sticks:b},A.GpadDisplayConfig),o);return{gpadEmulator:n,gpadApiWrapper:o,gpadDisplay:E}},X=` +const A=` @@ -115,7 +115,7 @@ import{G,a as D,D as M,b as V,d as w,g as l,e as g,f as q,P as s,c as r,C as u,h -`,R=` +`,a=` @@ -236,4 +236,4 @@ import{G,a as D,D as M,b as V,d as w,g as l,e as g,f as q,P as s,c as r,C as u,h -`;export{X as L,R,I as s}; +`;export{A as L,a as R}; diff --git a/assets/game_engine-CpyXkHZU.js b/assets/game_engine-CpyXkHZU.js new file mode 100644 index 0000000..2cef720 --- /dev/null +++ b/assets/game_engine-CpyXkHZU.js @@ -0,0 +1 @@ +import{G,a as O,c as g,s as h}from"./GamepadEmulator-CNWoeGf3.js";import{s as T}from"./helpers-DCx76efX.js";import{L,R as C}from"./display-gamepad-right-BmtaGMJm.js";import"./GamepadDisplay-3X_eRe0j.js";const o=new G(.1),I=new O({updateDelay:0,axisDeadZone:.05});globalThis.onGameReady=()=>{const a=document.getElementById("gpad_display_container"),m=document.getElementById("loading-msg");m==null||m.remove(),document.getElementById("gpad_display_left").innerHTML=L,document.getElementById("gpad_display_right").innerHTML=C;const e=0;T(a,{AllowDpadDiagonals:!0,GpadEmulator:o,GpadApiWrapper:I,EmulatedGamepadIndex:e,EmulatedGamepadOverlayMode:!0}),o.PressButton(e,g.Start,1,!0),setTimeout(()=>{o.PressButton(e,g.Start,0,!1)},10);const r=new Set;window.onkeydown=s=>{if(s.shiftKey||s.altKey||s.metaKey)return;const n=s.key.toLowerCase();r.add(n);const l=parseInt(n),c=s.ctrlKey;n==="a"?o.MoveAxis(e,h.LStickX,-1):n==="d"?o.MoveAxis(e,h.LStickX,1):n==="w"?o.MoveAxis(e,h.LStickY,-1):n==="s"?o.MoveAxis(e,h.LStickY,1):n==="arrowleft"?(o.MoveAxis(e,h.RStickX,-1),s.preventDefault()):n==="arrowright"?(o.MoveAxis(e,h.RStickX,1),s.preventDefault()):n==="arrowup"?(o.MoveAxis(e,h.RStickY,-1),s.preventDefault()):n==="arrowdown"?(o.MoveAxis(e,h.RStickY,1),s.preventDefault()):isNaN(l)?n===" "&&o.PressButton(e,g.A,c?0:1,!0):o.PressButton(e,l,c?0:1,!0)},window.onkeyup=s=>{if(s.shiftKey||s.altKey||s.metaKey)return;r.delete(s.key.toLowerCase());const n=parseInt(s.key);!r.has("a")&&!r.has("d")&&o.MoveAxis(e,h.LStickX,0),!r.has("w")&&!r.has("s")&&o.MoveAxis(e,h.LStickY,0),!r.has("arrowleft")&&!r.has("arrowright")&&o.MoveAxis(e,h.RStickX,0),!r.has("arrowup")&&!r.has("arrowdown")&&o.MoveAxis(e,h.RStickY,0),isNaN(n)?s.key===" "&&o.PressButton(e,g.A,0,!1):o.PressButton(e,n,0,!1)}};const V="modulepreload",K=function(a){return"/virtual-gamepad-lib/"+a},A={},F=function(m,e,r){let s=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.allSettled(e.map(d=>{if(d=K(d),d in A)return;A[d]=!0;const p=d.endsWith(".css"),v=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${v}`))return;const u=document.createElement("link");if(u.rel=p?"stylesheet":V,p||(u.as="script"),u.crossOrigin="",u.href=d,c&&u.setAttribute("nonce",c),document.head.appendChild(u),p)return new Promise((k,x)=>{u.addEventListener("load",k),u.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function n(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&n(c.reason);return m().catch(n)})},U="/virtual-gamepad-lib/assets/space-CVr01FEs.png",N="/virtual-gamepad-lib/assets/space-CdjOIDe1.json",z="/virtual-gamepad-lib/assets/explosion-DEnJI5xL.json",X="/virtual-gamepad-lib/assets/explosion-BthNb2Mv.png",Y="/virtual-gamepad-lib/assets/nebula-CGbfovh_.jpg";F(()=>import("./phaser-wt8jUpzW.js"),[]).then(()=>{const a=window.Phaser;var m={type:a.AUTO,parent:"phaser-example",width:800,height:600,input:{gamepad:!0},physics:{default:"arcade",arcade:{debug:!1,fps:60,gravity:{y:0}}},scene:{preload:x,create:P,update:M,extend:{checkBulletVsEnemy:D,launchEnemy:S,hitShip:R,hitEnemy:B}}},e,r,s,n,l,c=0,d,p,v;new a.Game(m);var u=new a.Class({Extends:a.Physics.Arcade.Image,initialize:function(i){a.Physics.Arcade.Image.call(this,i,0,0,"space","blaster"),this.setBlendMode(1),this.setDepth(1),this.speed=800,this.lifespan=1e3,this._temp=new a.Math.Vector2},fire:function(t){this.lifespan=1e3,this.setActive(!0),this.setVisible(!0),this.setAngle(t.body.rotation),this.setPosition(t.x,t.y),this.body.reset(t.x,t.y),this.body.setSize(10,10,!0);var i=a.Math.DegToRad(t.body.rotation);this.scene.physics.velocityFromRotation(i,this.speed,this.body.velocity),this.body.velocity.x*=2,this.body.velocity.y*=2},update:function(t,i){this.lifespan-=i,this.lifespan<=0&&this.kill()},kill:function(){this.setActive(!1),this.setVisible(!1),this.body.stop()}}),k=new a.Class({Extends:a.Physics.Arcade.Sprite,initialize:function(i){a.Physics.Arcade.Sprite.call(this,i,0,0,"mine-sheet"),this.setDepth(1),this.speed=100,this.checkOutOfBounds=!1,this.target=new a.Math.Vector2},launch:function(){this.play("mine-anim"),this.checkOutOfBounds=!1;var t=a.Geom.Rectangle.RandomOutside(v,p);p.getRandomPoint(this.target),this.speed=a.Math.Between(100,400),this.setActive(!0),this.setVisible(!0),this.setPosition(t.x,t.y),this.body.reset(t.x,t.y);var i=a.Math.Angle.BetweenPoints(t,this.target);this.scene.physics.velocityFromRotation(i,this.speed,this.body.velocity)},update:function(t,i){var y=p.contains(this.x,this.y);!this.checkOutOfBounds&&y?this.checkOutOfBounds=!0:this.checkOutOfBounds&&!y&&this.kill()},kill:function(){this.setActive(!1),this.setVisible(!1),this.body.stop(),this.scene.launchEnemy()}});function x(){this.load.image("background",Y),this.load.atlas("space",U,N),this.load.atlas("explosion",X,z)}function P(){this.add.sprite(0,0,"test"),v=new a.Geom.Rectangle(-200,-200,1200,1e3),p=new a.Geom.Rectangle(0,0,800,600),this.textures.addSpriteSheetFromAtlas("mine-sheet",{atlas:"space",frame:"mine",frameWidth:64}),this.anims.create({key:"mine-anim",frames:this.anims.generateFrameNumbers("mine-sheet",{start:0,end:15}),frameRate:20,repeat:-1}),this.add.tileSprite(400,300,800,600,"background"),this.add.image(0,0,"space","purple-planet").setOrigin(0),n=this.physics.add.group({classType:u,maxSize:30,runChildUpdate:!0}),e=this.physics.add.image(400,300,"space","ship").setDepth(2),e.setDamping(!0),e.setDrag(.95),e.setMaxVelocity(400),l=this.physics.add.group({classType:k,maxSize:60,runChildUpdate:!0}),s=this.add.text(10,10,"Press a button on the Gamepad to use",{font:"16px Courier",fill:"#00ff00"}),this.input.gamepad.on("down",function(f,b,E){f.getAxisTotal()<4?s.setText("Gamepad does not have enough axis for a twin-stick demo"):(s.setText("Left Stick to move, Right Stick to shoot"),f.setAxisThreshold(.3),r=f)},this),d=this.add.particles("explosion"),d.createEmitter({frame:"red",angle:{min:0,max:360,steps:32},lifespan:1e3,speed:400,quantity:32,scale:{start:.3,end:0},on:!1}),d.createEmitter({frame:"muzzleflash2",lifespan:200,scale:{start:2,end:0},rotate:{start:0,end:180},on:!1});var t=this.add.particles("space"),i=t.createEmitter({frame:"blue",speed:200,lifespan:{onEmit:function(f,b,E,w){return a.Math.Percent(e.body.speed,0,400)*2e3}},alpha:{onEmit:function(f,b,E,w){return a.Math.Percent(e.body.speed,0,400)}},angle:{onEmit:function(f,b,E,w){var _=0;return e.angle-180+_}},scale:{start:.6,end:0},blendMode:"ADD"});i.startFollow(e),this.physics.add.overlap(n,l,this.hitEnemy,this.checkBulletVsEnemy,this);for(var y=0;y<6;y++)this.launchEnemy();globalThis.onGameReady()}function S(){var t=l.get();t&&t.launch()}function D(t,i){return t.active&&i.active}function R(t,i){}function B(t,i){d.emitParticleAt(i.x,i.y),this.cameras.main.shake(500,.01),t.kill(),i.kill()}function M(t){if(r&&(s.setText([r.leftStick.x,e.body.angularVelocity]),e.setAngularVelocity(300*r.leftStick.x),r.leftStick.y<=0&&this.physics.velocityFromRotation(e.rotation,Math.abs(800*r.leftStick.y),e.body.acceleration),this.physics.world.wrap(e,32),r.A&&t>c)){var i=n.get();i&&(i.fire(e),c=t+100)}}}); diff --git a/assets/game_engine-DYryWnDF.js b/assets/game_engine-DYryWnDF.js deleted file mode 100644 index d6ff663..0000000 --- a/assets/game_engine-DYryWnDF.js +++ /dev/null @@ -1 +0,0 @@ -import{G,a as O,c as g,s as h}from"./GamepadEmulator-CNWoeGf3.js";import{L as T,R as L,s as C}from"./display-gamepad-right-DSHUDGha.js";import"./GamepadDisplay-3X_eRe0j.js";const o=new G(.1),I=new O({updateDelay:0,axisDeadZone:.05});globalThis.onGameReady=()=>{const a=document.getElementById("gpad_display_container"),m=document.getElementById("loading-msg");m==null||m.remove(),document.getElementById("gpad_display_left").innerHTML=T,document.getElementById("gpad_display_right").innerHTML=L;const e=0;C(a,{AllowDpadDiagonals:!0,GpadEmulator:o,GpadApiWrapper:I,EmulatedGamepadIndex:e,EmulatedGamepadOverlayMode:!0}),o.PressButton(e,g.Start,1,!0),setTimeout(()=>{o.PressButton(e,g.Start,0,!1)},10);const r=new Set;window.onkeydown=s=>{if(s.shiftKey||s.altKey||s.metaKey)return;const n=s.key.toLowerCase();r.add(n);const l=parseInt(n),c=s.ctrlKey;n==="a"?o.MoveAxis(e,h.LStickX,-1):n==="d"?o.MoveAxis(e,h.LStickX,1):n==="w"?o.MoveAxis(e,h.LStickY,-1):n==="s"?o.MoveAxis(e,h.LStickY,1):n==="arrowleft"?(o.MoveAxis(e,h.RStickX,-1),s.preventDefault()):n==="arrowright"?(o.MoveAxis(e,h.RStickX,1),s.preventDefault()):n==="arrowup"?(o.MoveAxis(e,h.RStickY,-1),s.preventDefault()):n==="arrowdown"?(o.MoveAxis(e,h.RStickY,1),s.preventDefault()):isNaN(l)?n===" "&&o.PressButton(e,g.A,c?0:1,!0):o.PressButton(e,l,c?0:1,!0)},window.onkeyup=s=>{if(s.shiftKey||s.altKey||s.metaKey)return;r.delete(s.key.toLowerCase());const n=parseInt(s.key);!r.has("a")&&!r.has("d")&&o.MoveAxis(e,h.LStickX,0),!r.has("w")&&!r.has("s")&&o.MoveAxis(e,h.LStickY,0),!r.has("arrowleft")&&!r.has("arrowright")&&o.MoveAxis(e,h.RStickX,0),!r.has("arrowup")&&!r.has("arrowdown")&&o.MoveAxis(e,h.RStickY,0),isNaN(n)?s.key===" "&&o.PressButton(e,g.A,0,!1):o.PressButton(e,n,0,!1)}};const V="modulepreload",K=function(a){return"/virtual-gamepad-lib/"+a},A={},F=function(m,e,r){let s=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.allSettled(e.map(d=>{if(d=K(d),d in A)return;A[d]=!0;const p=d.endsWith(".css"),v=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${v}`))return;const u=document.createElement("link");if(u.rel=p?"stylesheet":V,p||(u.as="script"),u.crossOrigin="",u.href=d,c&&u.setAttribute("nonce",c),document.head.appendChild(u),p)return new Promise((k,x)=>{u.addEventListener("load",k),u.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function n(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&n(c.reason);return m().catch(n)})},U="/virtual-gamepad-lib/assets/space-CVr01FEs.png",N="/virtual-gamepad-lib/assets/space-CdjOIDe1.json",z="/virtual-gamepad-lib/assets/explosion-DEnJI5xL.json",X="/virtual-gamepad-lib/assets/explosion-BthNb2Mv.png",Y="/virtual-gamepad-lib/assets/nebula-CGbfovh_.jpg";F(()=>import("./phaser-wt8jUpzW.js"),[]).then(()=>{const a=window.Phaser;var m={type:a.AUTO,parent:"phaser-example",width:800,height:600,input:{gamepad:!0},physics:{default:"arcade",arcade:{debug:!1,fps:60,gravity:{y:0}}},scene:{preload:x,create:P,update:M,extend:{checkBulletVsEnemy:D,launchEnemy:S,hitShip:R,hitEnemy:B}}},e,r,s,n,l,c=0,d,p,v;new a.Game(m);var u=new a.Class({Extends:a.Physics.Arcade.Image,initialize:function(i){a.Physics.Arcade.Image.call(this,i,0,0,"space","blaster"),this.setBlendMode(1),this.setDepth(1),this.speed=800,this.lifespan=1e3,this._temp=new a.Math.Vector2},fire:function(t){this.lifespan=1e3,this.setActive(!0),this.setVisible(!0),this.setAngle(t.body.rotation),this.setPosition(t.x,t.y),this.body.reset(t.x,t.y),this.body.setSize(10,10,!0);var i=a.Math.DegToRad(t.body.rotation);this.scene.physics.velocityFromRotation(i,this.speed,this.body.velocity),this.body.velocity.x*=2,this.body.velocity.y*=2},update:function(t,i){this.lifespan-=i,this.lifespan<=0&&this.kill()},kill:function(){this.setActive(!1),this.setVisible(!1),this.body.stop()}}),k=new a.Class({Extends:a.Physics.Arcade.Sprite,initialize:function(i){a.Physics.Arcade.Sprite.call(this,i,0,0,"mine-sheet"),this.setDepth(1),this.speed=100,this.checkOutOfBounds=!1,this.target=new a.Math.Vector2},launch:function(){this.play("mine-anim"),this.checkOutOfBounds=!1;var t=a.Geom.Rectangle.RandomOutside(v,p);p.getRandomPoint(this.target),this.speed=a.Math.Between(100,400),this.setActive(!0),this.setVisible(!0),this.setPosition(t.x,t.y),this.body.reset(t.x,t.y);var i=a.Math.Angle.BetweenPoints(t,this.target);this.scene.physics.velocityFromRotation(i,this.speed,this.body.velocity)},update:function(t,i){var y=p.contains(this.x,this.y);!this.checkOutOfBounds&&y?this.checkOutOfBounds=!0:this.checkOutOfBounds&&!y&&this.kill()},kill:function(){this.setActive(!1),this.setVisible(!1),this.body.stop(),this.scene.launchEnemy()}});function x(){this.load.image("background",Y),this.load.atlas("space",U,N),this.load.atlas("explosion",X,z)}function P(){this.add.sprite(0,0,"test"),v=new a.Geom.Rectangle(-200,-200,1200,1e3),p=new a.Geom.Rectangle(0,0,800,600),this.textures.addSpriteSheetFromAtlas("mine-sheet",{atlas:"space",frame:"mine",frameWidth:64}),this.anims.create({key:"mine-anim",frames:this.anims.generateFrameNumbers("mine-sheet",{start:0,end:15}),frameRate:20,repeat:-1}),this.add.tileSprite(400,300,800,600,"background"),this.add.image(0,0,"space","purple-planet").setOrigin(0),n=this.physics.add.group({classType:u,maxSize:30,runChildUpdate:!0}),e=this.physics.add.image(400,300,"space","ship").setDepth(2),e.setDamping(!0),e.setDrag(.95),e.setMaxVelocity(400),l=this.physics.add.group({classType:k,maxSize:60,runChildUpdate:!0}),s=this.add.text(10,10,"Press a button on the Gamepad to use",{font:"16px Courier",fill:"#00ff00"}),this.input.gamepad.on("down",function(f,b,E){f.getAxisTotal()<4?s.setText("Gamepad does not have enough axis for a twin-stick demo"):(s.setText("Left Stick to move, Right Stick to shoot"),f.setAxisThreshold(.3),r=f)},this),d=this.add.particles("explosion"),d.createEmitter({frame:"red",angle:{min:0,max:360,steps:32},lifespan:1e3,speed:400,quantity:32,scale:{start:.3,end:0},on:!1}),d.createEmitter({frame:"muzzleflash2",lifespan:200,scale:{start:2,end:0},rotate:{start:0,end:180},on:!1});var t=this.add.particles("space"),i=t.createEmitter({frame:"blue",speed:200,lifespan:{onEmit:function(f,b,E,w){return a.Math.Percent(e.body.speed,0,400)*2e3}},alpha:{onEmit:function(f,b,E,w){return a.Math.Percent(e.body.speed,0,400)}},angle:{onEmit:function(f,b,E,w){var _=0;return e.angle-180+_}},scale:{start:.6,end:0},blendMode:"ADD"});i.startFollow(e),this.physics.add.overlap(n,l,this.hitEnemy,this.checkBulletVsEnemy,this);for(var y=0;y<6;y++)this.launchEnemy();globalThis.onGameReady()}function S(){var t=l.get();t&&t.launch()}function D(t,i){return t.active&&i.active}function R(t,i){}function B(t,i){d.emitParticleAt(i.x,i.y),this.cameras.main.shake(500,.01),t.kill(),i.kill()}function M(t){if(r&&(s.setText([r.leftStick.x,e.body.angularVelocity]),e.setAngularVelocity(300*r.leftStick.x),r.leftStick.y<=0&&this.physics.velocityFromRotation(e.rotation,Math.abs(800*r.leftStick.y),e.body.acceleration),this.physics.world.wrap(e,32),r.A&&t>c)){var i=n.get();i&&(i.fire(e),c=t+100)}}}); diff --git a/assets/helpers-DCx76efX.js b/assets/helpers-DCx76efX.js new file mode 100644 index 0000000..c05bde5 --- /dev/null +++ b/assets/helpers-DCx76efX.js @@ -0,0 +1 @@ +import{G as f,a as I,D as P,b as E,d as y,g as o,e as r,f as b,P as d,c as g,C as _,h as p}from"./GamepadEmulator-CNWoeGf3.js";import{G as O}from"./GamepadDisplay-3X_eRe0j.js";const v=(a,t)=>{var D,T;t=Object.assign({GpadDisplayConfig:{gamepadIndex:0},EmulatedGamepadIndex:0,EmulatedGamepadOverlayMode:!0,AllowDpadDiagonals:!1,VariableTriggers:!0,ClickableJoysticks:!0,JoystickDragDistance:50,TriggerDragDistance:50},t),a.classList.add("gpad-container");const n=(D=t.GpadEmulator)!=null?D:new f(.1),c=(T=t.GpadApiWrapper)!=null?T:new I({updateDelay:0,axisDeadZone:.05,buttonConfigs:[]}),u=t.EmulatedGamepadIndex;n.AddEmulatedGamepad(u,t.EmulatedGamepadOverlayMode,P,E);const l=[];for(let e=0;ee.includes("trigger")&&t.VariableTriggers?{type:o.variable,direction:r.down,buttonElement:a.querySelector(`#${e}`),highlight:a.querySelector(`#${e} .${p.ButtonHighlight}`),directionHighlight:a.querySelector(`#${e} .${p.DirectionHighlight}`),movementRange:10}:{type:o.onOff,highlight:a.querySelector(`#${e} .${p.ButtonHighlight}`),extraData:{myCustomData:"onOff btn name is "+e}}),G=[{joystickElement:a.querySelector(`#${d[g.LStick]}`),xAxisIndex:0,yAxisIndex:1,movementRange:10},{joystickElement:a.querySelector(`#${d[g.RStick]}`),xAxisIndex:2,yAxisIndex:3,movementRange:10}],x=new O(Object.assign({gamepadIndex:u,buttons:A,sticks:G},t.GpadDisplayConfig),c);return{gpadEmulator:n,gpadApiWrapper:c,gpadDisplay:x}};export{v as s}; diff --git a/assets/simple-AtMKnGyp.js b/assets/simple-AtMKnGyp.js new file mode 100644 index 0000000..e573dd4 --- /dev/null +++ b/assets/simple-AtMKnGyp.js @@ -0,0 +1 @@ +import{G as m}from"./GamepadEmulator-CNWoeGf3.js";import{s as E}from"./helpers-DCx76efX.js";import{L as p,R as _}from"./display-gamepad-right-BmtaGMJm.js";import"./GamepadDisplay-3X_eRe0j.js";const g=new m(.1);window.addEventListener("DOMContentLoaded",()=>{const u=document.getElementById("gpad_display_container"),s=document.getElementById("axis-table"),c=document.getElementById("button-table");document.getElementById("gpad_display_left").innerHTML=p,document.getElementById("gpad_display_right").innerHTML=_;const d=0,{gpadApiWrapper:i}=E(u,{AllowDpadDiagonals:!0,GpadEmulator:g,EmulatedGamepadIndex:d,EmulatedGamepadOverlayMode:!0});i.onGamepadButtonChange((l,e,o)=>{if(console.log(`Gamepad ${l} button change: `,o),l===d)for(let t=0;t{if(console.log(`Gamepad ${l} axis change: `,e.axes,o),l===d)for(let t=0;t{const u=document.getElementById("gpad_display_container"),s=document.getElementById("axis-table"),c=document.getElementById("button-table");document.getElementById("gpad_display_left").innerHTML=E,document.getElementById("gpad_display_right").innerHTML=p;const d=0,{gpadApiWrapper:i}=_(u,{AllowDpadDiagonals:!0,GpadEmulator:g,EmulatedGamepadIndex:d,EmulatedGamepadOverlayMode:!0});i.onGamepadButtonChange((l,e,o)=>{if(console.log(`Gamepad ${l} button change: `,o),l===d)for(let t=0;t{if(console.log(`Gamepad ${l} axis change: `,e.axes,o),l===d)for(let t=0;t + + + + + Custom Gamepads Example + + + + + + + + + + + + + Docs + Source + +

Custom Gamepads Example

+

Plug in a gamepad or use the on-screen controls.

+
+ + +
+ + +
+ + +
+ + +

Split SVG Gamepad With 8-way dpad and drag direction + indicators, + styled + using CSS

+ + +
+ + +
+ +
+ + +
+

Fully Custom HTML Gamepad

+

(Connected to the same underlying emulated gamepad)

+
+

Dragable Buttons

+
◄0
+
1▼
+
2►
+
+ +
+

AXIS 1

+
+
+
+

AXIS 2

+
+
+
+

Normal Buttons

+
3
+
4
+
5
+
6
+
7
+
8
+
+
+

AXIS 0

+
+
+
+

AXIS 3

+
+
+
+

More Normal Buttons

+
9
+
10
+
11
+
12
+
13
+
14
+
+ +
+

Even More Buttons

+
15
+
16
+
17
+
18
+
19
+
20
+
+
+

AXIS x=4 y=5

+
+
+ +
+ + + + + + diff --git a/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html b/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html index e15b691..792694e 100644 --- a/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html +++ b/docs/classes/GamepadApiWrapper.GamepadApiWrapper.html @@ -158,7 +158,7 @@ }

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

-

Constructors

Constructors

Properties

Constructors

Properties

_getGamepads: (() => (null | Gamepad)[])
_requestAnimationFrame: ((callback: FrameRequestCallback) => number)
axisDeadZone: number
buttonConfigs: wrapperButtonConfig[]
currentStateOfGamepads: (undefined | EGamepad | Gamepad)[]
gamepadAxisChangeListeners: AxisChangeCallback[]
gamepadButtonChangeListeners: ButtonChangeCallback[]
gamepadConnectListeners: GamepadEventCallback[]
gamepadDisconnectListeners: GamepadEventCallback[]
updateDelay: number

Methods

  • (destructor) - Cleans up any event listeners and stops the gamepad check loop. Do not re-use class instance after calling cleanup().

    -

    Returns void

  • 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

    +

Properties

_getGamepads: (() => (null | Gamepad)[])
_requestAnimationFrame: ((callback: FrameRequestCallback) => number)
axisDeadZone: number
buttonConfigs: wrapperButtonConfig[]
currentStateOfGamepads: (undefined | EGamepad | Gamepad)[]
gamepadAxisChangeListeners: AxisChangeCallback[]
gamepadButtonChangeListeners: ButtonChangeCallback[]
gamepadConnectListeners: GamepadEventCallback[]
gamepadDisconnectListeners: GamepadEventCallback[]
updateDelay: number

Methods

  • (destructor) - Cleans up any event listeners and stops the gamepad check loop. Do not re-use class instance after calling cleanup().

    +

    Returns void

  • 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 (undefined | 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

Returns void

Returns void

Returns AxisChangeCallback

Returns ButtonChangeCallback

Returns GamepadEventCallback

Returns GamepadEventCallback

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

apiWrapper config displayButtonChanges @@ -170,22 +170,22 @@

Constructors

Properties

apiWrapper: GamepadApiWrapper
displayButtonChanges: ButtonChangeCallback = ...

This function is registered as the callback for () +

Returns GamepadDisplay

Properties

apiWrapper: GamepadApiWrapper
displayButtonChanges: ButtonChangeCallback = ...

This function is registered as the callback for () 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.

-
displayJoystickChanges: AxisChangeCallback = ...

This function is registered as the callback for () +

displayJoystickChanges: AxisChangeCallback = ...

This function is registered as the callback for () 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

An array of booleans, where each true indicates that the corresponding axis has changed since the last update

-

Methods

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

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)

    @@ -195,14 +195,14 @@
  • 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

Enumeration gamepadButtonType

Enumeration Members

onOff +

Enumeration gamepadButtonType

Enumeration Members

Enumeration Members

onOff
variable

Enumeration gamepadDirection

Enumeration Members

down +

Enumeration gamepadDirection

Enumeration Members

Enumeration Members

down
left
right
up

Enumeration gamepadEmulationState

Enumeration Members

emulated +

Enumeration gamepadEmulationState

Enumeration Members

Enumeration Members

emulated
overlay
real

Enumeration standardGpadButtonMap

Enumeration Members

A +

Enumeration standardGpadButtonMap

Enumeration Members

A B Back DPadDown @@ -173,7 +173,7 @@ Vendor X Y -

Enumeration Members

A
B
Back
DPadDown
DPadLeft
DPadRight
DPadUp
LShoulder
LStick
LTrigger
RShoulder
RStick
RTrigger
Start
Vendor
X
Y

Function setupPresetInteractiveGamepad

Function setupPresetInteractiveGamepad

  • 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

interface buttonChangeDetails {
    heldDown?: boolean;
    pressed?: boolean;
    released?: boolean;
    touchDown?: boolean;
    touchUp?: boolean;
    valueChanged?: boolean;
}

Properties

heldDown? +
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)

-
interface wrapperButtonConfig {
    fireWhileHolding: boolean;
}

Properties

fireWhileHolding +
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

-
interface wrapperConfig {
    axisDeadZone?: number;
    buttonConfigs?: wrapperButtonConfig[];
    updateDelay?: number;
}

Properties

axisDeadZone? +
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. Array index corresponds the the index of the button the a native browser gamepad.buttons array as returned from eg: navigator.getGamepads()[0].buttons

-
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. Array index corresponds the the index of the button the a native browser gamepad.buttons array as returned from eg: navigator.getGamepads()[0].buttons

+
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

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

Properties

buttonDisplayFunction? +
interface DisplayGamepadConfig {
    buttonDisplayFunction?: ButtonDisplayFunction;
    buttons?: (undefined | null | GamepadDisplayButton)[];
    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)[]

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

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

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)

-
interface GamepadDisplayJoystick {
    extraData?: any;
    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

extraData? +
interface GamepadDisplayJoystick {
    extraData?: any;
    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

extraData?: any

optional, for your own use

-
highlights?: {
    down?: null | HTMLElement | SVGElement;
    left?: null | HTMLElement | SVGElement;
    right?: null | HTMLElement | SVGElement;
    up?: null | HTMLElement | SVGElement;
}

use GamepadDisplayJoystick.extraData with a custom DisplayGamepadConfig.joystickDisplayFunction instead, see the custom gamepads example/demo

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

highlights?: {
    down?: null | HTMLElement | SVGElement;
    left?: null | HTMLElement | SVGElement;
    right?: null | HTMLElement | SVGElement;
    up?: null | HTMLElement | SVGElement;
}

use GamepadDisplayJoystick.extraData with a custom DisplayGamepadConfig.joystickDisplayFunction instead, see the custom gamepads example/demo

+
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

-
interface GamepadDisplayOnOffButton {
    extraData?: any;
    highlight: HTMLElement | SVGElement;
    type: onOff;
}

Properties

extraData? +
interface GamepadDisplayOnOffButton {
    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
interface GamepadDisplayVariableButton {
    buttonElement: HTMLElement | SVGElement;
    direction: gamepadDirection;
    directionHighlight?: HTMLElement | SVGElement;
    extraData?: any;
    highlight?: HTMLElement | SVGElement;
    movementRange: number;
    type: variable;
}

Properties

buttonElement +
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 - to represent touching or 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 - to represent touching or pressing on this button, defaults to the same element as buttonElement

-
movementRange: number

How far the GamepadDisplayVariableButton.buttonElement should move to represent being pressed fully in HTML or SVG pixels

-
type: variable

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: readonly number[];
    buttons: readonly GamepadButton[];
    connected: boolean;
    displayId: string;
    emulation: undefined | gamepadEmulationState;
    hapticActuators?: GamepadHapticActuator[];
    id: string;
    index: number;
    mapping: GamepadMappingType;
    timestamp: number;
    vibrationActuator?: GamepadHapticActuator;
}

Hierarchy

  • Omit<Gamepad, "vibrationActuator">
    • EGamepad

Properties

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

Hierarchy

  • Omit<Gamepad, "vibrationActuator">
    • EGamepad

Properties

axes buttons connected displayId @@ -172,11 +172,11 @@

Properties

axes: readonly number[]
buttons: readonly GamepadButton[]
connected: boolean
displayId: string
emulation: undefined | gamepadEmulationState
hapticActuators?: GamepadHapticActuator[]
id: string
displayId: string
emulation: undefined | gamepadEmulationState
hapticActuators?: GamepadHapticActuator[]
id: string
index: number
mapping: GamepadMappingType
timestamp: number
vibrationActuator?: GamepadHapticActuator

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

-
interface EGamepadEvent {
    AT_TARGET: 2;
    bubbles: boolean;
    BUBBLING_PHASE: 3;
    cancelable: boolean;
    cancelBubble: boolean;
    CAPTURING_PHASE: 1;
    composed: boolean;
    currentTarget: null | EventTarget;
    defaultPrevented: boolean;
    eventPhase: number;
    gamepad: EGamepad;
    isTrusted: boolean;
    NONE: 0;
    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

interface EGamepadEvent {
    AT_TARGET: 2;
    bubbles: boolean;
    BUBBLING_PHASE: 3;
    cancelable: boolean;
    cancelBubble: boolean;
    CAPTURING_PHASE: 1;
    composed: boolean;
    currentTarget: null | EventTarget;
    defaultPrevented: boolean;
    eventPhase: number;
    gamepad: EGamepad;
    isTrusted: boolean;
    NONE: 0;
    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

NONE
returnValue: boolean

MDN Reference

srcElement: null | EventTarget

MDN Reference

diff --git a/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html b/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html index 5d40898..fc4c257 100644 --- a/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html +++ b/docs/interfaces/GamepadEmulator.EGamepadPrivateData.html @@ -156,13 +156,13 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -
interface EGamepadPrivateData {
    overlayMode: boolean;
    removeButtonListenersFunc?: (() => void);
    removeJoystickListenersFunc?: (() => void);
}

Properties

overlayMode +
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

-
interface JoystickTouchConfig {
    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    };
    dragDistance: number;
    lockTargetWhilePressed?: boolean;
    tapTarget: HTMLElement | SVGElement;
    xAxisIndex?: number;
    yAxisIndex?: number;
}

Properties

directions +
interface JoystickTouchConfig {
    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. See: gamepadDirection

-
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 EGamepad.axes) to drive When the virtual joystick is dragged left (-) and right (+)

-
yAxisIndex?: number

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

-
interface OnOffButtonTouchConfig {
    buttonIndex: number;
    buttonIndexes?: number[];
    lockTargetWhilePressed?: boolean;
    tapTarget: HTMLElement | SVGElement;
    type: onOff;
}

Properties

buttonIndex +
interface OnOffButtonTouchConfig {
    buttonIndex: number;
    buttonIndexes?: number[];
    lockTargetWhilePressed?: boolean;
    tapTarget: HTMLElement | SVGElement;
    type: onOff;
}

Properties

buttonIndex: number

The index of the gamepad button this tap target should control corresponds to the button index as found in the EGamepad.buttons array Can also pass a value from the standardGpadButtonMap, xboxButtonMap, etc...

-
buttonIndexes?: number[]

Allows this tap target to control multiple gamepad buttons at once +

buttonIndexes?: number[]

Allows this tap target to control multiple gamepad buttons at once useful for e.g. allowing diagonal directions of a dpad. Overrides buttonIndex - Each number in the array is the index corresponding to a button in the EGamepad.buttons array that this tap target will control

-
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
interface VariableButtonTouchConfig {
    buttonIndex: number;
    buttonIndexes?: number[];
    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    };
    dragDistance: number;
    lockTargetWhilePressed?: boolean;
    tapTarget: HTMLElement | SVGElement;
    type: variable;
}

Properties

buttonIndex +
interface VariableButtonTouchConfig {
    buttonIndex: number;
    buttonIndexes?: number[];
    directions: {
        down?: boolean;
        left?: boolean;
        right?: boolean;
        up?: boolean;
    };
    dragDistance: number;
    lockTargetWhilePressed?: boolean;
    tapTarget: HTMLElement | SVGElement;
    type: variable;
}

Properties

Properties

buttonIndex: number

The index of the gamepad button this tap target should control corresponds to the button index as found in the EGamepad.buttons array Can also pass a value from the standardGpadButtonMap, xboxButtonMap, etc...

-
buttonIndexes?: number[]

Allows this tap target to control multiple gamepad buttons at once +

buttonIndexes?: number[]

Allows this tap target to control multiple gamepad buttons at once useful for e.g. allowing diagonal directions of a dpad. Overrides buttonIndex - Each number in the array is the index corresponding to a button in the EGamepad.buttons array that this tap target will control

-
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. See: gamepadDirection

-
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 and lockTargetWhilePressed is true

-
type: variable

Interface interactiveGamepadPresetConfig

optional parameters to override default behavior of setupPresetInteractiveGamepad

-
interface interactiveGamepadPresetConfig {
    AllowDpadDiagonals?: boolean;
    ClickableJoysticks?: boolean;
    EmulatedGamepadIndex?: number;
    EmulatedGamepadOverlayMode?: boolean;
    GpadApiWrapper?: GamepadApiWrapper;
    GpadDisplayConfig?: DisplayGamepadConfig;
    GpadEmulator?: GamepadEmulator;
    JoystickDragDistance?: number;
    TriggerDragDistance?: number;
    VariableTriggers?: boolean;
}

Properties

interface interactiveGamepadPresetConfig {
    AllowDpadDiagonals?: boolean;
    ClickableJoysticks?: boolean;
    EmulatedGamepadIndex?: number;
    EmulatedGamepadOverlayMode?: boolean;
    GpadApiWrapper?: GamepadApiWrapper;
    GpadDisplayConfig?: DisplayGamepadConfig;
    GpadEmulator?: GamepadEmulator;
    JoystickDragDistance?: number;
    TriggerDragDistance?: number;
    VariableTriggers?: boolean;
}

Properties

AllowDpadDiagonals?: boolean
ClickableJoysticks?: boolean
EmulatedGamepadIndex?: number
EmulatedGamepadOverlayMode?: boolean
GpadApiWrapper?: GamepadApiWrapper
GpadDisplayConfig?: DisplayGamepadConfig
GpadEmulator?: GamepadEmulator
JoystickDragDistance?: number
TriggerDragDistance?: number
VariableTriggers?: boolean

Module GamepadApiWrapper

Index

Classes

GamepadApiWrapper +

Module GamepadApiWrapper

Index

Classes

Interfaces

buttonChangeDetails wrapperButtonConfig wrapperConfig diff --git a/docs/modules/GamepadDisplay.html b/docs/modules/GamepadDisplay.html index 4a903c8..5b2269a 100644 --- a/docs/modules/GamepadDisplay.html +++ b/docs/modules/GamepadDisplay.html @@ -156,7 +156,7 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -

Index

Classes

GamepadDisplay +

Index

Classes

Interfaces

DisplayGamepadConfig GamepadDisplayJoystick GamepadDisplayOnOffButton diff --git a/docs/modules/GamepadEmulator.html b/docs/modules/GamepadEmulator.html index 94d7a93..791e4d6 100644 --- a/docs/modules/GamepadEmulator.html +++ b/docs/modules/GamepadEmulator.html @@ -156,7 +156,7 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -

Index

Classes

GamepadEmulator +

Index

Classes

Interfaces

EGamepad EGamepadEvent EGamepadPrivateData diff --git a/docs/modules/enums.html b/docs/modules/enums.html index 820e548..14b818b 100644 --- a/docs/modules/enums.html +++ b/docs/modules/enums.html @@ -156,7 +156,7 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -

Index

Enumerations

gamepadButtonType +

Index

Enumerations

gamepadButtonType gamepadDirection gamepadEmulationState playStationButtonMap diff --git a/docs/modules/helpers.html b/docs/modules/helpers.html index 0b08976..2c1167f 100644 --- a/docs/modules/helpers.html +++ b/docs/modules/helpers.html @@ -156,7 +156,7 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -

Index

Interfaces

interactiveGamepadPresetConfig +

References

AxisChangeCallback +

References

AxisChangeCallback ButtonChangeCallback buttonChangeDetails ButtonConfig diff --git a/docs/modules/utilities.html b/docs/modules/utilities.html index 934fe6d..e3a65ce 100644 --- a/docs/modules/utilities.html +++ b/docs/modules/utilities.html @@ -156,7 +156,7 @@ --md-sys-color-surface-container-high: #ede6eb; --md-sys-color-surface-container-highest: #e8e0e5 } -

Index

Functions

CenterTransformOrigin +
AxisChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: readonly boolean[]) => void)
AxisChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: readonly boolean[]) => void)
ButtonChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: readonly (buttonChangeDetails | false)[]) => void)
ButtonChangeCallback: ((gpadIndex: number, gpad: EGamepad | Gamepad, changesMask: readonly (buttonChangeDetails | false)[]) => void)
GamepadEventCallback: ((e: GamepadEvent) => void)
GamepadEventCallback: ((e: GamepadEvent) => void)
ButtonDisplayFunction: ((buttonConfig: GamepadDisplayButton, value: number, touched: boolean, pressed: boolean, changes: buttonChangeDetails, btnIndex: number) => void)
ButtonDisplayFunction: ((buttonConfig: GamepadDisplayButton, value: number, touched: boolean, pressed: boolean, changes: buttonChangeDetails, btnIndex: number) => void)
JoystickDisplayFunction: ((stickConfig: GamepadDisplayJoystick, xAxisValue: number, yAxisValue: number) => void)
JoystickDisplayFunction: ((stickConfig: GamepadDisplayJoystick, xAxisValue: number, yAxisValue: number) => void)
ButtonConfig: ButtonTouchConfig

ButtonConfig is now called ButtonTouchConfig

-
JoystickConfig: JoystickTouchConfig

JoystickConfig is now called JoystickTouchConfig

-
OnOffButtonConfig: OnOffButtonTouchConfig

OnOffButtonConfig is now called OnOffButtonTouchConfig

-
VariableButtonConfig: VariableButtonTouchConfig

VariableButtonConfig is now called VariableButtonTouchConfig

-

Type Alias gpadAxesMapType

gpadAxesMapType: typeof xboxAxesMap | typeof playStationAxesMap | standardGpadAxesMap

Type Alias gpadAxesMapType

gpadAxesMapType: typeof xboxAxesMap | typeof playStationAxesMap | standardGpadAxesMap
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.

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

-

Variable PRESET_SVG_GPAD_BTN_IDSConst

PRESET_SVG_GPAD_BTN_IDS: string[] = ...

Holds the SVG element ids of button display elements in the example gamepad SVGs in the same order as the standard button map & browser gpad api

-

Variable PRESET_SVG_GPAD_BTN_TAP_TARGET_IDSConst

PRESET_SVG_GPAD_BTN_TAP_TARGET_IDS: string[] = ...

Holds the SVG element ids of button tap/touch targets in the example gamepad SVGs in the same order as the standard button map & browser gpad api

-

Variable playStationAxesMapConst

playStationAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap

Variable playStationAxesMapConst

playStationAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap

Variable xboxAxesMapConst

xboxAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap

Variable xboxAxesMapConst

xboxAxesMap: typeof standardGpadAxesMap = standardGpadAxesMap
+ - + + diff --git a/simple/index.html b/simple/index.html index adbfc6e..f2b21da 100644 --- a/simple/index.html +++ b/simple/index.html @@ -9,10 +9,11 @@ - + - + +