UNPKG

50.4 kBHTMLView Raw
1<!DOCTYPE html>
2
3<html lang="en">
4<head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width">
7 <title>CrossBrowdy API documentation Source: CrossBase/input/controllers/CB_Controllers.js</title>
8
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
13
14 <link type="text/css" rel="stylesheet" href="styles/site.cosmo.css">
15
16</head>
17
18<body style="min-width:800px; overflow-wrap:break-word; word-wrap:break-word; word-break:break-word; line-break:strict; hyphens:none; -webkit-hyphens:none; -moz-hyphens:none;">
19
20<div class="navbar navbar-default navbar-fixed-top ">
21<div class="container">
22 <div class="navbar-header">
23 <a class="navbar-brand" href="index.html">CrossBrowdy API documentation</a>
24 <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25 <span class="icon-bar"></span>
26 <span class="icon-bar"></span>
27 <span class="icon-bar"></span>
28 </button>
29 </div>
30 <div class="navbar-collapse collapse" id="topNavigation">
31 <ul class="nav navbar-nav">
32
33 <li class="dropdown">
34 <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
35 <ul class="dropdown-menu inline">
36 <li><a href="CB_Arrays.html">CB_Arrays</a></li><li><a href="CB_AudioDetector.html">CB_AudioDetector</a></li><li><a href="CB_Client.html">CB_Client</a></li><li><a href="CB_Collisions.html">CB_Collisions</a></li><li><a href="CB_Configuration.html">CB_Configuration</a></li><li><a href="CB_Configuration.CrossBase.html">CB_Configuration.CrossBase</a></li><li><a href="CB_Configuration.CrossBrowdy.html">CB_Configuration.CrossBrowdy</a></li><li><a href="CB_Controllers.html">CB_Controllers</a></li><li><a href="CB_Controllers_Proprietary.html">CB_Controllers_Proprietary</a></li><li><a href="CB_Controllers_Proprietary.WII.html">CB_Controllers_Proprietary.WII</a></li><li><a href="CB_Controllers_Proprietary.WII_U.html">CB_Controllers_Proprietary.WII_U</a></li><li><a href="CB_Device.html">CB_Device</a></li><li><a href="CB_Device.AmbientLight.html">CB_Device.AmbientLight</a></li><li><a href="CB_Device.Battery.html">CB_Device.Battery</a></li><li><a href="CB_Device.Location.html">CB_Device.Location</a></li><li><a href="CB_Device.Motion.html">CB_Device.Motion</a></li><li><a href="CB_Device.Orientation.html">CB_Device.Orientation</a></li><li><a href="CB_Device.Proximity.html">CB_Device.Proximity</a></li><li><a href="CB_Device.Vibration.html">CB_Device.Vibration</a></li><li><a href="CB_Elements.html">CB_Elements</a></li><li><a href="CB_Events.html">CB_Events</a></li><li><a href="CB_Keyboard.html">CB_Keyboard</a></li><li><a href="CB_Keyboard.chars.html">CB_Keyboard.chars</a></li><li><a href="CB_Keyboard.extended.html">CB_Keyboard.extended</a></li><li><a href="CB_Keyboard.keys.html">CB_Keyboard.keys</a></li><li><a href="CB_Modules.html">CB_Modules</a></li><li><a href="CB_Mouse.html">CB_Mouse</a></li><li><a href="CB_Mouse.CursorImage.html">CB_Mouse.CursorImage</a></li><li><a href="CB_Net.html">CB_Net</a></li><li><a href="CB_Net.Fetch.html">CB_Net.Fetch</a></li><li><a href="CB_Net.REST.html">CB_Net.REST</a></li><li><a href="CB_Net.Sockets.html">CB_Net.Sockets</a></li><li><a href="CB_Net.Sockets.SockJS.html">CB_Net.Sockets.SockJS</a></li><li><a href="CB_Net.XHR.html">CB_Net.XHR</a></li><li><a href="CB_Pointer.html">CB_Pointer</a></li><li><a href="CB_Screen.html">CB_Screen</a></li><li><a href="CB_Speaker.html">CB_Speaker</a></li><li><a href="CB_Touch.html">CB_Touch</a></li><li><a href="CB_baseSymbols.html">CB_baseSymbols</a></li>
37 </ul>
38 </li>
39
40 <li class="dropdown">
41 <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
42 <ul class="dropdown-menu inline">
43 <li><a href="CB_AudioFile.html">CB_AudioFile</a></li><li><a href="CB_AudioFileCache.html">CB_AudioFileCache</a></li><li><a href="CB_AudioFileSprites.html">CB_AudioFileSprites</a></li><li><a href="CB_AudioFileSpritesPool.html">CB_AudioFileSpritesPool</a></li><li><a href="CB_AudioFile_API.AAPI.html">CB_AudioFile_API.AAPI</a></li><li><a href="CB_AudioFile_API.ACMP.html">CB_AudioFile_API.ACMP</a></li><li><a href="CB_AudioFile_API.SM2.html">CB_AudioFile_API.SM2</a></li><li><a href="CB_AudioFile_API.WAAPI.html">CB_AudioFile_API.WAAPI</a></li><li><a href="CB_Canvas.html">CB_Canvas</a></li><li><a href="CB_GraphicSprites.html">CB_GraphicSprites</a></li><li><a href="CB_GraphicSpritesScene.html">CB_GraphicSpritesScene</a></li>
44 </ul>
45 </li>
46
47 <li class="dropdown">
48 <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
49 <ul class="dropdown-menu inline">
50 <li><a href="global.html#CB_BASE_NAME">CB_BASE_NAME</a></li><li><a href="global.html#CB_CREDITS_DEFAULT">CB_CREDITS_DEFAULT</a></li><li><a href="global.html#CB_NAME">CB_NAME</a></li><li><a href="global.html#CB_OPTIONS">CB_OPTIONS</a></li><li><a href="global.html#CB_VERSION">CB_VERSION</a></li><li><a href="global.html#CB_addCredits">CB_addCredits</a></li><li><a href="global.html#CB_baseToBase">CB_baseToBase</a></li><li><a href="global.html#CB_baseToInt">CB_baseToInt</a></li><li><a href="global.html#CB_br2nl">CB_br2nl</a></li><li><a href="global.html#CB_brToNl">CB_brToNl</a></li><li><a href="global.html#CB_combineArraysOrObjects">CB_combineArraysOrObjects</a></li><li><a href="global.html#CB_combineAutomatically">CB_combineAutomatically</a></li><li><a href="global.html#CB_combineJSON">CB_combineJSON</a></li><li><a href="global.html#CB_combineURIParameters">CB_combineURIParameters</a></li><li><a href="global.html#CB_combineURLParameters">CB_combineURLParameters</a></li><li><a href="global.html#CB_console">CB_console</a></li><li><a href="global.html#CB_copyObject">CB_copyObject</a></li><li><a href="global.html#CB_countDecimalDigits">CB_countDecimalDigits</a></li><li><a href="global.html#CB_countDecimalPart">CB_countDecimalPart</a></li><li><a href="global.html#CB_countDecimals">CB_countDecimals</a></li><li><a href="global.html#CB_countIntegerDigits">CB_countIntegerDigits</a></li><li><a href="global.html#CB_countIntegerPart">CB_countIntegerPart</a></li><li><a href="global.html#CB_credits">CB_credits</a></li><li><a href="global.html#CB_forEach">CB_forEach</a></li><li><a href="global.html#CB_forceString">CB_forceString</a></li><li><a href="global.html#CB_getBase64StringObject">CB_getBase64StringObject</a></li><li><a href="global.html#CB_getCookie">CB_getCookie</a></li><li><a href="global.html#CB_getDatum">CB_getDatum</a></li><li><a href="global.html#CB_getJSONPropertyValue">CB_getJSONPropertyValue</a></li><li><a href="global.html#CB_getLZStringObject">CB_getLZStringObject</a></li><li><a href="global.html#CB_getValueIndex">CB_getValueIndex</a></li><li><a href="global.html#CB_getValuePath">CB_getValuePath</a></li><li><a href="global.html#CB_includeJSFile">CB_includeJSFile</a></li><li><a href="global.html#CB_indexOf">CB_indexOf</a></li><li><a href="global.html#CB_init">CB_init</a></li><li><a href="global.html#CB_intToBase">CB_intToBase</a></li><li><a href="global.html#CB_isArray">CB_isArray</a></li><li><a href="global.html#CB_isEmail">CB_isEmail</a></li><li><a href="global.html#CB_isFileLocal">CB_isFileLocal</a></li><li><a href="global.html#CB_isString">CB_isString</a></li><li><a href="global.html#CB_lastIndexOf">CB_lastIndexOf</a></li><li><a href="global.html#CB_ltrim">CB_ltrim</a></li><li><a href="global.html#CB_nl2br">CB_nl2br</a></li><li><a href="global.html#CB_nlToBr">CB_nlToBr</a></li><li><a href="global.html#CB_numberFormat">CB_numberFormat</a></li><li><a href="global.html#CB_numberOfDecimalDigits">CB_numberOfDecimalDigits</a></li><li><a href="global.html#CB_numberOfDecimals">CB_numberOfDecimals</a></li><li><a href="global.html#CB_numberOfIntegerDigits">CB_numberOfIntegerDigits</a></li><li><a href="global.html#CB_parseJSON">CB_parseJSON</a></li><li><a href="global.html#CB_parseString">CB_parseString</a></li><li><a href="global.html#CB_regularExpressionString">CB_regularExpressionString</a></li><li><a href="global.html#CB_renderString">CB_renderString</a></li><li><a href="global.html#CB_replaceAll">CB_replaceAll</a></li><li><a href="global.html#CB_rtrim">CB_rtrim</a></li><li><a href="global.html#CB_scriptPath">CB_scriptPath</a></li><li><a href="global.html#CB_scriptPathCalculate">CB_scriptPathCalculate</a></li><li><a href="global.html#CB_setCookie">CB_setCookie</a></li><li><a href="global.html#CB_setDatum">CB_setDatum</a></li><li><a href="global.html#CB_sizeOf">CB_sizeOf</a></li><li><a href="global.html#CB_sizeof">CB_sizeof</a></li><li><a href="global.html#CB_stringifyJSON">CB_stringifyJSON</a></li><li><a href="global.html#CB_symmetricCall">CB_symmetricCall</a></li><li><a href="global.html#CB_symmetricCallClear">CB_symmetricCallClear</a></li><li><a href="global.html#CB_this">CB_this</a></li><li><a href="global.html#CB_trim">CB_trim</a></li>
51 </ul>
52 </li>
53
54 </ul>
55
56 <div class="col-sm-3 col-md-3">
57 <form class="navbar-form" role="search">
58 <div class="input-group">
59 <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
60 <div class="input-group-btn">
61 <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
62 </div>
63 </div>
64 </form>
65 </div>
66
67 </div>
68
69</div>
70</div>
71
72
73<div class="container" id="toc-content" style="width:100%;">
74<div class="row" style="width:100%;">
75
76
77 <div class="col-md-12">
78
79 <div id="main">
80
81
82 <h1 class="page-title">Source: CrossBase/input/controllers/CB_Controllers.js</h1>
83
84<section>
85 <article>
86 <pre
87 class="sunlight-highlight-javascript linenums">/**
88 * @file Controllers (gamepads, joysticks, remotes, etc.) management. Contains the {@link CB_Controllers} static class.
89 * @author Joan Alba Maldonado &lt;workindalian@gmail.com>
90 * @license Creative Commons Attribution 4.0 International. See more at {@link https://crossbrowdy.com/about#what_is_the_crossbrowdy_copyright_and_license}.
91 */
92
93
94/**
95 * Static class to manage different controllers (gamepads, joysticks, remotes, etc.). It will return itself if it is tried to be instantiated. It uses [gamepad-plus]{@link https://github.com/MozillaReality/gamepad-plus}.
96 * @namespace CB_Controllers
97 * @todo Find a way to do button mapping (so we could use names as LEFT, RIGHT, etc.) and normalization for most web clients and gamepads (without forgetting proprietary ones as WII U, etc.).
98 * @todo Consider using always a numeric index instead of the ID of the gamepad (array instead of object), which could be a string, for CB_Controllers._gamepads (for optimization purposes).
99 * @todo Consider modifying {@link CB_Controllers.isButtonDown} function or add a new one to check whether any button (or axes) is down or not.
100 */
101//* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
102CB_Controllers = function() { return CB_Controllers; };
103{
104 CB_Controllers.initialized = false; //It will tells whether the object has been initialized or not.
105 CB_Controllers._gamePadHaveEvents = "ongamepadconnected" in window;
106 CB_Controllers._gamepads = {}; //Object that keeps the indexes of the current gamepads and the gamepad objects as their values.
107 CB_Controllers._eventsHolder = {}; //Keeps the functions to fire for every special event (if any).
108
109
110 //Initializes all values:
111 CB_Controllers.init = function()
112 {
113 if (CB_Controllers.initialized) { return CB_Controllers; }
114
115 //Initializes proprietary controllers:
116 CB_Controllers_Proprietary["WII_U"].init();
117 CB_Controllers_Proprietary["WII"].init();
118
119 //The object has been initialized:
120 CB_Controllers.initialized = true;
121
122 //TODO: use gamepad-plus to make it compatible with more web clients (and do not forget keyEventsEnabled property).
123
124 if (!CB_Controllers._gamePadHaveEvents)
125 {
126 var gamePadPolling = function() { CB_Controllers._gamePadScanAll(); setTimeout(gamePadPolling, 500); };
127 gamePadPolling();
128 }
129 else
130 {
131 CB_Events.add(CB_Client.getWindow(), "gamepadconnected", CB_Controllers._gamePadConnectHandler, true, true, false);
132 CB_Events.add(CB_Client.getWindow(), "gamepaddisconnected", CB_Controllers._gamePadDisconnectHandler, true, true, false);
133 }
134
135 return CB_Controllers;
136 }
137
138
139 //Handler to execute when a gamepad is connected (using GamePad API):
140 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
141 CB_Controllers._gamePadConnectHandler = function(e)
142 {
143 CB_Controllers._gamePadAdd(e.gamepad);
144 }
145
146
147 //Handler to execute when a gamepad is disconnected (using GamePad API):
148 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
149 CB_Controllers._gamePadDisconnectHandler = function(e)
150 {
151 CB_Controllers._gamePadRemove(e.gamepad);
152 }
153
154
155 //Adds a new gamepad (using GamePad API):
156 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
157 CB_Controllers._gamePadAdd = function(gamepad)
158 {
159 CB_Controllers._gamepads[gamepad.index] = gamepad;
160
161 //See https://github.com/luser/gamepadtest/blob/master/index.html
162 //requestAnimationFrame(CB_Controllers._gamePadUpdateAll);
163 CB_Controllers._gamePadUpdateAll();
164
165 //If there is any, executes the desired event:
166 if (typeof(CB_Controllers._eventsHolder["onConnect"]) === "function") { CB_Controllers._eventsHolder["onConnect"](gamepad, CB_Controllers._gamepads); }
167 }
168
169
170 //Removes a gamepad (using GamePad API):
171 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
172 CB_Controllers._gamePadRemove = function(gamepad)
173 {
174 //CB_Controllers._gamepads[gamepad.index] = undefined;
175 delete CB_Controllers._gamepads[gamepad.index];
176
177 //If there is any, executes the desired event:
178 if (typeof(CB_Controllers._eventsHolder["onDisconnect"]) === "function") { CB_Controllers._eventsHolder["onDisconnect"](gamepad, CB_Controllers._gamepads); }
179 }
180
181
182 //Updates the status of all gamepads, if any (using GamePad API):
183 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
184 CB_Controllers._gamePadUpdateAllTimeout = null;
185 CB_Controllers._gamePadUpdateAll = function()
186 {
187 //TODO: normalize, when possible, values for different web clients and gamepads.
188
189 clearTimeout(CB_Controllers._gamePadUpdateAllTimeout);
190
191 if (!CB_Controllers._gamePadHaveEvents) { CB_Controllers._gamePadScanAll(); }
192
193 var i = 0;
194
195 for (var j in CB_Controllers._gamepads)
196 {
197 var controller = CB_Controllers._gamepads[j];
198
199 //for (i = 0; i &lt; controller.buttons.length; i++)
200 for (i in controller.buttons)
201 {
202 if (typeof(controller.buttons[i]) !== "object" || controller.buttons[i] === null)
203 {
204 controller.buttons[i] =
205 {
206 value: controller.buttons[i],
207 pressed: controller.buttons[i] == 1.0
208 };
209 }
210 }
211
212 /*
213 for (i = 0; i &lt; controller.axes.length; i++)
214 {
215 var a = axes[i];
216 a.innerHTML = i + ": " + controller.axes[i].toFixed(4);
217 a.setAttribute("value", controller.axes[i] + 1);
218 }*/
219 }
220
221 //requestAnimationFrame(CB_Controllers._gamePadUpdateAll);
222 CB_Controllers._gamePadUpdateAllTimeout = setTimeout(CB_Controllers._gamePadUpdateAll, 1);
223 }
224
225
226 //Scans all gamepads, if any (using GamePad API):
227 //* Source: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
228 CB_Controllers._gamePadScanAll = function()
229 {
230 var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : (navigator.webkitGamepads ? navigator.webkitGamepads : []));
231
232 //Looks for new connected ones:
233 for (var i = 0; i &lt; gamepads.length; i++)
234 {
235 if (gamepads[i])
236 {
237 //if (gamepads[i].index in CB_Controllers._gamepads) { CB_Controllers._gamepads[gamepads[i].index] = gamepads[i]; }
238 if (typeof(CB_Controllers._gamepads[gamepads[i].index]) !== "undefined") { CB_Controllers._gamepads[gamepads[i].index] = gamepads[i]; }
239 else { CB_Controllers._gamePadAdd(gamepads[i]); }
240 }
241 }
242
243 //Looks for disconnected ones:
244 //for (i = 0; i &lt; CB_Controllers._gamepads.length; i++)
245 for (i in CB_Controllers._gamepads)
246 {
247 if (CB_Controllers._gamepads[i])
248 {
249 if (typeof(gamepads[CB_Controllers._gamepads[i].index]) === "undefined") { CB_Controllers._gamePadRemove(CB_Controllers._gamepads[i]); }
250 }
251 }
252 }
253
254
255 /**
256 * Sets a function to execute when a gamepad is connected (["onGamepadConnected"]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepadconnected} event is fired) or removes it. More information: [Gamepad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}.
257 * @function
258 * @param {function|null} callbackFunction - The function (event listener) that we want to execute when the event is fired. The first parameter received for this function will be the gamepad object affected and the second parameter will be an object containing all current gamepads objects (properties will be the index of each gamepad). If a null value is used, the event will be removed.
259 * @param {boolean} [keepOldFunction=true] - Defines whether we want to keep any possible previous event listener for the same target and event name or not.
260 * @todo Make it compatible with proprietary ones (if possible).
261 */
262 CB_Controllers.onConnect = function(callbackFunction, keepOldFunction)
263 {
264 return CB_Controllers._setSpecialEventFunction("onConnect", callbackFunction, keepOldFunction);
265 }
266
267
268 /**
269 * Sets a function to execute when a gamepad is disconnected (["onGamepadDisconnected"]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepaddisconnected} event is fired) or removes it. More information: [Gamepad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}.
270 * @function
271 * @param {function|null} callbackFunction - The function (event listener) that we want to execute when the event is fired. The first parameter received for this function will be the gamepad object affected and the second parameter will be an object containing all current gamepads objects (properties will be the index of each gamepad). If a null value is used, the event will be removed.
272 * @param {boolean} [keepOldFunction=true] - Defines whether we want to keep any possible previous event listener for the same target and event name or not.
273 * @todo Make it compatible with proprietary ones (if possible).
274 */
275 CB_Controllers.onDisconnect = function(callbackFunction, keepOldFunction)
276 {
277 return CB_Controllers._setSpecialEventFunction("onDisconnect", callbackFunction, keepOldFunction);
278 }
279
280
281 //Sets a function to execute when an event happens (a non-existing event on JavaScript):
282 CB_Controllers._setSpecialEventFunction = function(eventName, eventFunction, keepOldFunction)
283 {
284 //If no function has been sent, cancel all previous functions and exits:
285 if (typeof(eventFunction) !== "function")
286 {
287 if (eventFunction === null) { CB_Controllers._eventsHolder[eventName] = null; }
288 return;
289 }
290
291 //If not set, it keeps old function by default:
292 if (typeof(keepOldFunction) === "undefined" || keepOldFunction === null) { keepOldFunction = true; }
293
294 //If we don't want to keep the old function:
295 if (!keepOldFunction)
296 {
297 CB_Controllers._eventsHolder[eventName] = eventFunction;
298 }
299 //...otherwise if we want to keep the old function, we keep it:
300 else
301 {
302 //Stores old function:
303 var eventFunctionOld = CB_Controllers._eventsHolder[eventName]; //Stores old function of eventFunctionHolder.
304 CB_Controllers._eventsHolder[eventName] =
305 function(e)
306 {
307 if (typeof(eventFunctionOld) === "function") { eventFunctionOld(e); }
308 eventFunction(e);
309 };
310 }
311 }
312
313
314
315 //Finds and returns a desired property from one or more gamepads:
316 CB_Controllers._findProperty = function(findFunction, valueIfNotFound, gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary, extraData)
317 {
318 if (typeof(findFunction) !== "function") { findFunction = CB_Controllers._findButtonsDown; }
319 if (typeof(valueIfNotFound) === "undefined") { valueIfNotFound = {}; }
320
321 if (avoidProprietary !== true &amp;&amp; avoidProprietary !== false) { avoidProprietary = CB_Configuration[CB_BASE_NAME].CB_Controllers_avoidProprietary_DEFAULT; }
322
323 gamepadId = CB_trim(gamepadId);
324 if (gamepadId !== "")
325 {
326 if (gamepadIdNumeric || !isNaN(gamepadId) &amp;&amp; (typeof(gamepadIdNumeric) === "undefined" || gamepadIdNumeric === null))
327 {
328 gamepadIdNumeric = true;
329 gamepadId = parseInt(gamepadId);
330 }
331 }
332
333 var gamepads = CB_Controllers.getGamePads(avoidProprietary);
334
335 var properties = valueIfNotFound;
336
337 //If desired, just gets the buttons down from the devices compatible with the HTML5 Gamepad API:
338 if (avoidProprietary) { properties = findFunction(gamepadId, gamepadIdNumeric, caseSensitive, gamepads, extraData); }
339 //...otherwise, also gets from the ones which use a proprietary API:
340 else
341 {
342 //Gets the buttons down from the devices compatible with the HTML5 Gamepad API:
343
344 properties = findFunction(gamepadId, gamepadIdNumeric, caseSensitive, gamepads.standard.gamepads, extraData);
345
346 //Adds also the buttons down from the devices which use a proprietary API:
347 var propertiesProprietary;
348 for (var proprietarySystem in gamepads)
349 {
350 if (proprietarySystem === "standard") { continue; } //Just checks proprietary systems.
351 for (var devicesType in gamepads[proprietarySystem])
352 {
353 propertiesProprietary = findFunction(gamepadId, gamepadIdNumeric, caseSensitive, gamepads[proprietarySystem][devicesType], extraData);
354 for (var propertyIndex in propertiesProprietary)
355 {
356 if (!properties[propertyIndex]) { properties[propertyIndex] = propertiesProprietary[propertyIndex]; }
357 }
358 }
359 }
360 }
361
362 return properties;
363 }
364
365
366 //Returns an array with the axes from a given devices object (sub-objects returned by the CB_Controllers.getGamePads function):
367 CB_Controllers._findAxes = function(gamepadId, gamepadIdNumeric, caseSensitive, devicesObject, extraData)
368 {
369 var axes = [];
370
371 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
372 var axesLoopLength, y;
373 for (var x in devicesObject)
374 {
375 if (devicesObject[x].usingPrototype) { continue; } //Skips non-real status objects.
376 if
377 (
378 gamepadId === ""
379 || gamepadIdNumeric &amp;&amp; gamepadId === parseInt(x)
380 || !gamepadIdNumeric &amp;&amp; (caseSensitive &amp;&amp; CB_trim(devicesObject[x].id) === gamepadId || !caseSensitive &amp;&amp; CB_trim(devicesObject[x].id).toLowerCase() === gamepadId.toLowerCase())
381 )
382 {
383 if (CB_isArray(devicesObject[x].axes))
384 {
385 axesLoopLength = devicesObject[x].axes.length;
386 for (y = 0; y &lt; axesLoopLength; y++)
387 {
388 if (!axes[y]) { axes[y] = devicesObject[x].axes[y]; }
389 }
390 }
391 }
392 }
393
394 return axes;
395 }
396
397
398 /**
399 * Gets an array with information about the status of the axes of a given gamepad (or from all if none is given).
400 * @function
401 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any). When more than one gamepad is checked, the first axes values found which are not zero (0) will have priority.
402 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
403 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
404 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
405 * @returns {array} Returns an array with information about the status of the axes of a given gamepad (or from all if none is given).
406 */
407 CB_Controllers.getAxes = function(gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary)
408 {
409 return CB_Controllers._findProperty(CB_Controllers._findAxes, [], gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary);
410 }
411
412
413 //Returns an object with the the buttons down from a given devices object (sub-objects returned by the CB_Controllers.getGamePads function):
414 CB_Controllers._findAxesDown = function(gamepadId, gamepadIdNumeric, caseSensitive, devicesObject, extraData)
415 {
416 var axes = [];
417
418 if (isNaN(extraData.minimumValue) || extraData.minimumValue === null) { extraData.minimumValue = 0.5; }
419 if (isNaN(extraData.maximumValue) || extraData.maximumValue === null) { extraData.maximumValue = extraData.minimumValue &lt;= 0 ? -0.5 : 1; }
420 if (extraData.maximumValue &lt; extraData.minimumValue)
421 {
422 extraData._minimumValueBackup = extraData.minimumValue;
423 extraData.minimumValue = extraData.maximumValue;
424 extraData.maximumValue = extraData._minimumValueBackup;
425 }
426
427 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
428 var axesLoopLength, y;
429 for (var x in devicesObject)
430 {
431 if (devicesObject[x].usingPrototype) { continue; } //Skips non-real status objects.
432 if
433 (
434 gamepadId === ""
435 || gamepadIdNumeric &amp;&amp; gamepadId === parseInt(x)
436 || !gamepadIdNumeric &amp;&amp; (caseSensitive &amp;&amp; CB_trim(devicesObject[x].id) === gamepadId || !caseSensitive &amp;&amp; CB_trim(devicesObject[x].id).toLowerCase() === gamepadId.toLowerCase())
437 )
438 {
439 if (CB_isArray(devicesObject[x].axes))
440 {
441 axesLoopLength = devicesObject[x].axes.length;
442 for (y = 0; y &lt; axesLoopLength; y++)
443 {
444 if (!axes[y] &amp;&amp; devicesObject[x].axes[y] !== null &amp;&amp; !isNaN(devicesObject[x].axes[y]) &amp;&amp; devicesObject[x].axes[y] >= extraData.minimumValue &amp;&amp; devicesObject[x].axes[y] &lt;= extraData.maximumValue) { axes[y] = devicesObject[x].axes[y]; }
445 }
446 }
447 }
448 }
449
450 return axes;
451 }
452
453
454 /**
455 * Gets an array with the axes pressed of a given gamepad (or from all if none is given). If more than one gamepad is pressing the same axis, it will return the value of the first one found.
456 * @function
457 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any).
458 * @param {float} [minimumValue=0.5] - The minimum value (included) that the checked axis or axes must have to consider them to be pressed.
459 * @param {float} [maximumValue=1|-0.5] - The maximum value (included) that the checked axis or axes must have to consider them to be pressed. The default value will be -0.5 if the given "minimumValue" is negative or zero (0) or it will be 1 otherwise.
460 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
461 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
462 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
463 * @returns {Object} Returns an array with the axes pressed of a given gamepad (or from all if none is given). If more than one gamepad is pressing the same axis, it will return the value of the first one found.
464 */
465 CB_Controllers.getAxesDown = function(gamepadId, minimumValue, maximumValue, gamepadIdNumeric, caseSensitive, avoidProprietary)
466 {
467 return CB_Controllers._findProperty(CB_Controllers._findAxesDown, [], gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary, { minimumValue: minimumValue, maximumValue: maximumValue });
468 }
469
470
471 /**
472 * Returns whether a given axis or axes are being pressed or not (accepts one index or more than one with an array).
473 * @function
474 * @param {integer|array} axesNumbers - Number with the index of the axis or array of numbers with the indexes of the axes that we want to check.
475 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any).
476 * @param {float} [minimumValue=0.5] - The minimum value (included) that the checked axis or axes must have to consider them to be pressed.
477 * @param {float} [maximumValue=1|-0.5] - The maximum value (included) that the checked axis or axes must have to consider them to be pressed. The default value will be -0.5 if the given "minimumValue" is negative or zero (0) or it will be 1 otherwise.
478 * @param {boolean} [allPressed=false] - If set to true, the function will return true only in the case that all given axes are being pressed. In the case that this parameter is set to true and the "gamepadId" parameter is set to an empty string, it will not have in mind whether the axes are pressed by a unique gamepad or by different ones as long as all axes are pressed.
479 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
480 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
481 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
482 * @returns {boolean} If the "allPressed" parameter is false, returns true if the given code or any of the given codes is pressed. If the "allPressed" parameter is set to true, it will return true only in the case that all given axes are being pressed. In the case that the "allPressed" parameter is set to true and the gamepadId parameter is set to an empty string, it will not have in mind whether the axes are pressed by a unique gamepad or by different ones as long as all axes are pressed.
483 * @todo Make it compatible with proprietary gamepads (if possible).
484 */
485 CB_Controllers.isAxisDown = function(axesNumbers, gamepadId, minimumValue, maximumValue, allPressed, gamepadIdNumeric, caseSensitive, avoidProprietary)
486 {
487 //TODO: make it compatible with proprietary gamepads (if possible).
488 //TODO: consider to have in mind the axis.
489 var isDown = false;
490
491 //If the parameter given is not an array, we force it to be an array:
492 if (!CB_isArray(axesNumbers)) { axesNumbers = [axesNumbers]; }
493
494 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
495 var axesAll = CB_Controllers.getAxesDown(gamepadId, minimumValue, maximumValue, gamepadIdNumeric, caseSensitive, avoidProprietary);
496
497 //Checks whether the buttons given are being pressed or not (checking whether all are pressed, if desired):
498 var axesNumbersLength = axesNumbers.length;
499 for (var x = 0; x &lt; axesNumbersLength; x++)
500 {
501 //If the code given is a number, it exists in the axesAll array and it is being pressed:
502 if (typeof(axesNumbers[x]) !== "undefined" &amp;&amp; axesNumbers[x] !== null &amp;&amp; !isNaN(axesNumbers[x]) &amp;&amp; typeof(axesAll[axesNumbers[x]]) !== "undefined")
503 {
504 isDown = true;
505 if (!allPressed) { break; } //If the user does not want to know whether all are keys given are pressed, with one is enough so it exits.
506 }
507 //...otherwise, if the user wanted to know whether all given keys were pressed:
508 else if (allPressed)
509 {
510 //Not all given keys are pressed so it exits:
511 isDown = false;
512 break;
513 }
514 }
515
516 return isDown;
517 }
518
519
520 //Returns an object with the the buttons down from a given devices object (sub-objects returned by the CB_Controllers.getGamePads function):
521 CB_Controllers._findButtons = function(gamepadId, gamepadIdNumeric, caseSensitive, devicesObject, extraData)
522 {
523 var buttons = {};
524
525 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
526 for (var x in devicesObject)
527 {
528 if (devicesObject[x].usingPrototype) { continue; } //Skips non-real status objects.
529 if
530 (
531 gamepadId === ""
532 || gamepadIdNumeric &amp;&amp; gamepadId === parseInt(x)
533 || !gamepadIdNumeric &amp;&amp; (caseSensitive &amp;&amp; CB_trim(devicesObject[x].id) === gamepadId || !caseSensitive &amp;&amp; CB_trim(devicesObject[x].id).toLowerCase() === gamepadId.toLowerCase())
534 )
535 {
536 for (var buttonCode in devicesObject[x].buttons)
537 {
538 if (typeof(devicesObject[x].buttons[buttonCode].pressed) === "undefined") { continue; } //Skips properties which do not contain button objects.
539 buttons[buttonCode] =
540 {
541 "pressed" : devicesObject[x].buttons[buttonCode].pressed,
542 "touched" : devicesObject[x].buttons[buttonCode].touched,
543 "value" : devicesObject[x].buttons[buttonCode].value
544 };
545 }
546 }
547 }
548
549 return buttons;
550 }
551
552
553 /**
554 * Gets an object with all the buttons of a given gamepad (or from all if none is given).
555 * @function
556 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any).
557 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
558 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
559 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
560 * @returns {Object} Returns an object with all the buttons of a given gamepad (or from all if none is given). The indexes will be the button code and the values will be an object with information about the button (with properties such as "pressed", "value", etc.).
561 */
562 CB_Controllers.getButtons = function(gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary)
563 {
564 return CB_Controllers._findProperty(CB_Controllers._findButtons, {}, gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary);
565 }
566
567
568
569 //Returns an object with the the buttons down from a given devices object (sub-objects returned by the CB_Controllers.getGamePads function):
570 CB_Controllers._findButtonsDown = function(gamepadId, gamepadIdNumeric, caseSensitive, devicesObject, extraData)
571 {
572 var buttonsDown = {};
573
574 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
575 for (var x in devicesObject)
576 {
577 if (devicesObject[x].usingPrototype) { continue; } //Skips non-real status objects.
578 if
579 (
580 gamepadId === ""
581 || gamepadIdNumeric &amp;&amp; gamepadId === parseInt(x)
582 || !gamepadIdNumeric &amp;&amp; (caseSensitive &amp;&amp; CB_trim(devicesObject[x].id) === gamepadId || !caseSensitive &amp;&amp; CB_trim(devicesObject[x].id).toLowerCase() === gamepadId.toLowerCase())
583 )
584 {
585 for (var buttonCode in devicesObject[x].buttons)
586 {
587 if (devicesObject[x].buttons[buttonCode].pressed)
588 {
589 buttonsDown[buttonCode] = true;
590 }
591 }
592 }
593 }
594
595 return buttonsDown;
596 }
597
598
599 /**
600 * Gets an object with the buttons pressed of a given gamepad (or from all if none is given).
601 * @function
602 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any).
603 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
604 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
605 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
606 * @returns {Object} Returns an object with the buttons pressed of a given gamepad (or from all if none is given).
607 */
608 CB_Controllers.getButtonsDown = function(gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary)
609 {
610 return CB_Controllers._findProperty(CB_Controllers._findButtonsDown, {}, gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary);
611 }
612
613
614 /**
615 * Returns whether a given button or buttons are being pressed or not (accepts one key code or more than one with an array).
616 * @function
617 * @param {integer|array} buttonCodes - Number with the button code or array of numbers with the button codes that we want to check.
618 * @param {integer|string} [gamepadId=""] - If an empty string is given, all gamepads available will be checked. Otherwise, it will only check the gamepad with the given ID or index (if any).
619 * @param {boolean} [allPressed=false] - If set to true, the function will return true only in the case that all given buttons are being pressed. In the case that this parameter is set to true and the "gamepadId" parameter is set to an empty string, it will not have in mind whether the buttons are pressed by a unique gamepad or by different ones as long as all buttons are pressed.
620 * @param {boolean} [gamepadIdNumeric=false|true] - If the "gamepadId" parameter is an empty string, this parameter will be ignored. Otherwise, if the "gamepadId" parameter is not empty and this parameter is set to true, the gamepadId parameter will be converted to integer using "parseInt" internally. By default, this parameter is false unless the given "gamepadId" is numeric.
621 * @param {boolean} [caseSensitive=false] - Defines whether the "gamepadId" given should match the ID of the gamepad being case sensitive or not. This parameter will only be considered when the "gamepadIdNumeric" parameter is set to false.
622 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads will not be checked (performance will be faster).
623 * @returns {boolean} If the "allPressed" parameter is false, returns true if the given code or any of the given codes is pressed. If the "allPressed" parameter is set to true, it will return true only in the case that all given buttons are being pressed. In the case that the "allPressed" parameter is set to true and the gamepadId parameter is set to an empty string, it will not have in mind whether the buttons are pressed by a unique gamepad or by different ones as long as all buttons are pressed.
624 * @todo Make it compatible with proprietary gamepads (if possible).
625 */
626 CB_Controllers.isButtonDown = function(buttonCodes, gamepadId, allPressed, gamepadIdNumeric, caseSensitive, avoidProprietary)
627 {
628 //TODO: make it compatible with proprietary gamepads (if possible).
629 //TODO: consider to have in mind the axis.
630 var isDown = false;
631
632 //If the parameter given is not an array, we force it to be an array:
633 if (!CB_isArray(buttonCodes)) { buttonCodes = [buttonCodes]; }
634
635 //Gets the pressed buttons from the desired gamepad ID (or from all the gamepads if there is no gamepad ID given):
636 var buttonsDown = CB_Controllers.getButtonsDown(gamepadId, gamepadIdNumeric, caseSensitive, avoidProprietary);
637
638 //Checks whether the buttons given are being pressed or not (checking whether all are pressed, if desired):
639 var buttonCodesLength = buttonCodes.length;
640 for (var x = 0; x &lt; buttonCodesLength; x++)
641 {
642 //If the code given is a number, it exists in the buttonsDown array and it is being pressed:
643 if (typeof(buttonCodes[x]) !== "undefined" &amp;&amp; buttonCodes[x] !== null &amp;&amp; !isNaN(buttonCodes[x]) &amp;&amp; typeof(buttonsDown[buttonCodes[x]]) !== "undefined" &amp;&amp; buttonsDown[buttonCodes[x]])
644 {
645 isDown = true;
646 if (!allPressed) { break; } //If the user does not want to know whether all are keys given are pressed, with one is enough so it exits.
647 }
648 //...otherwise, if the user wanted to know whether all given keys were pressed:
649 else if (allPressed)
650 {
651 //Not all given keys are pressed so it exits:
652 isDown = false;
653 break;
654 }
655 }
656
657 return isDown;
658 }
659
660
661 /**
662 * Returns an object with the current gamepad objects, if any (using the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API} for non-proprietary gamepads).
663 * @function
664 * @param {boolean} [avoidProprietary={@link CB_Configuration.CrossBase.CB_Controllers_avoidProprietary_DEFAULT}] - If set to true, proprietary gamepads which do not use the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API} (as WII, WI U gamepads, etc.) will not be included in the returning object and it will only include the ones detected by the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}. Otherwise, if set to true, the returning object will contain one property called "standard" which will contain an object with the "gamepads" property with the gamepad objects that use the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API} and possibly different properties (one per each proprietary system) and inside of them an object with the "gamepads" property and maybe also other properties for other kind of devices which will include the status objects of those devices for each proprietary system. For gamepads that support the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}, the indexes will be the identifier for each gamepad and the value its gamepad object. For proprietary gamepads, it will contain the returning value of the "getGamePads" function of each proprietary API.
665 * @returns {Object} Returns an object with the current gamepad objects, if any (using the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API} for non-proprietary gamepads).
666 * @todo The proprietary ones should return better-normalized values to simulate the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}.
667 */
668 CB_Controllers.getGamePads = function(avoidProprietary)
669 {
670 if (avoidProprietary !== true &amp;&amp; avoidProprietary !== false) { avoidProprietary = CB_Configuration[CB_BASE_NAME].CB_Controllers_avoidProprietary_DEFAULT; }
671
672 CB_Controllers._gamePadUpdateAll(); //Updates and normalizes all.
673
674 if (!avoidProprietary)
675 {
676 //TODO: the proprietary ones should return normalize values to simulate the GamePad API.
677 return {
678 standard: { "gamepads" : CB_Controllers._gamepads },
679 WII_U : CB_Controllers_Proprietary["WII_U"].getGamePads(),
680 WII : CB_Controllers_Proprietary["WII"].getGamePads()
681 };
682 }
683
684 return CB_Controllers._gamepads;
685 }
686
687
688 //TODO: find a way to do button mapping (so we could use names as LEFT, RIGHT, etc.) and normalization for most web clients and gamepads (without forgetting proprietary ones as WII U, etc.).
689}</pre>
690 </article>
691</section>
692
693
694
695
696
697 </div>
698 </div>
699
700 <div class="clearfix"></div>
701
702
703
704</div>
705</div>
706
707
708 <div class="modal fade" id="searchResults">
709 <div class="modal-dialog">
710 <div class="modal-content">
711 <div class="modal-header">
712 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
713 <h4 class="modal-title">Search results</h4>
714 </div>
715 <div class="modal-body"></div>
716 <div class="modal-footer">
717 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
718 </div>
719 </div><!-- /.modal-content -->
720 </div><!-- /.modal-dialog -->
721 </div>
722
723
724<footer>
725
726
727 <span class="copyright">
728 <a href="printable/" target="_blank">See a more printer-friendly version</a><hr /><span style="color:#000000">© <address style="display:inline; font-style:normal;"><a href="https://crossbrowdy.com/" target="_blank">CrossBrowdy</a> API documentation</address> by <a href="https://joanalbamaldonado.com/" target="_blank">Joan Alba Maldonado</a> - <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">Creative Commons Attribution 4.0 International</a><br />DocStrap Copyright © 2012-2015 The contributors to the JSDoc3 and DocStrap projects.</span>
729 </span>
730
731<span class="jsdoc-message">
732 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a>
733
734 on Wed Mar 22nd 2023
735
736 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
737</span>
738</footer>
739
740<script src="scripts/docstrap.lib.js"></script>
741<script src="scripts/toc.js"></script>
742
743 <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
744
745
746<script>
747$( function () {
748 $( "[id*='$']" ).each( function () {
749 var $this = $( this );
750
751 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
752 } );
753
754 $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
755 var $this = $( this );
756
757 var example = $this.find( "code" );
758 exampleText = example.html();
759 var lang = /{@lang (.*?)}/.exec( exampleText );
760 if ( lang && lang[1] ) {
761 exampleText = exampleText.replace( lang[0], "" );
762 example.html( exampleText );
763 lang = lang[1];
764 } else {
765 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
766 lang = langClassMatch ? langClassMatch[1] : "javascript";
767 }
768
769 if ( lang ) {
770
771 $this
772 .addClass( "sunlight-highlight-" + lang )
773 .addClass( "linenums" )
774 .html( example.html() );
775
776 }
777 } );
778
779 Sunlight.highlightAll( {
780 lineNumbers : true,
781 showMenu : true,
782 enableDoclinks : true
783 } );
784
785 $.catchAnchorLinks( {
786 navbarOffset: 10
787 } );
788 $( "#toc" ).toc( {
789 anchorName : function ( i, heading, prefix ) {
790 return $( heading ).attr( "id" ) || ( prefix + i );
791 },
792 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
793 showAndHide : false,
794 smoothScrolling: true
795 } );
796
797 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
798 $( '.dropdown-toggle' ).dropdown();
799
800 $( "table" ).each( function () {
801 var $this = $( this );
802 $this.addClass('table');
803 } );
804
805} );
806</script>
807
808
809
810<!--Navigation and Symbol Display-->
811
812<script>
813 $( function () {
814 $( '#main' ).localScroll( {
815 offset : { top : 60 } //offset by the height of your header (give or take a few px, see what works for you)
816 } );
817 $( "dt.name" ).each( function () {
818 var $this = $( this ).find("h4");
819 var icon = $( "<i/>" ).addClass( "icon-plus-sign" ).addClass( "pull-right" ).addClass( "icon-white" );
820 var dt = $(this);
821 var children = dt.next( "dd" );
822
823 dt.prepend( icon ).css( {cursor : "pointer"} );
824 dt.addClass( "member-collapsed" ).addClass( "member" );
825
826
827 children.hide();
828
829 dt.children().on( "click", function () {
830 children = dt.next( "dd" );
831 children.slideToggle( "fast", function () {
832
833 if ( children.is( ":visible" ) ) {
834 icon.addClass( "icon-minus-sign" ).removeClass( "icon-plus-sign" ).removeClass( "icon-white" );
835 dt.addClass( "member-open" ).animate( "member-collapsed" );
836 } else {
837 icon.addClass( "icon-plus-sign" ).removeClass( "icon-minus-sign" ).addClass( "icon-white" );
838 dt.addClass( "member-collapsed" ).removeClass( "member-open" );
839 }
840 } );
841 } );
842
843 } );
844 } );
845</script>
846
847
848<!--Google Analytics-->
849
850
851
852 <script type="text/javascript">
853 $(document).ready(function() {
854 SearcherDisplay.init();
855 });
856 </script>
857
858
859</body>
860</html>