UNPKG

42.3 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_Proprietary_WII_U.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_baseSymbols.html">CB_baseSymbols</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>
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_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_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_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_addCredits">CB_addCredits</a></li><li><a href="global.html#CB_BASE_NAME">CB_BASE_NAME</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_CREDITS_DEFAULT">CB_CREDITS_DEFAULT</a></li><li><a href="global.html#CB_forceString">CB_forceString</a></li><li><a href="global.html#CB_forEach">CB_forEach</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_NAME">CB_NAME</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_OPTIONS">CB_OPTIONS</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><li><a href="global.html#CB_VERSION">CB_VERSION</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_Proprietary_WII_U.js</h1>
83
84<section>
85 <article>
86 <pre
87 class="sunlight-highlight-javascript linenums">/**
88 * @file Nintendo Wii U gamepad and remotes (Wiimotes) management. Contains the {@link CB_Controllers_Proprietary.WII_U} 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 * Static class to manage the Nintendo Wii U gamepad and remotes. It will return itself if it is tried to be instantiated. NOTE: This class is still under development.
95 * @namespace CB_Controllers_Proprietary.WII_U
96 * @todo Function or option that returns an array with the pressed buttons (LEFT: true, L: true, R: false, etc.). Use the bitmasks of CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS and CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.
97 */
98//* Source: http://wiiubrew.org/wiki/Internet_Browser and https://www.nintendo.com/wiiu/built-in-software/browser-specs/extended-functionality/
99if (typeof(CB_Controllers_Proprietary) === "undefined") { var CB_Controllers_Proprietary = {}; }
100CB_Controllers_Proprietary.WII_U = function() { return CB_Controllers_Proprietary.WII_U; };
101{
102 CB_Controllers_Proprietary.WII_U.initialized = false; //It will tells whether the object has been initialized or not.
103
104 /**
105 * Keeps the "wiiu" object (if any).
106 * @var
107 * @readonly
108 * @type {Object}
109 * @default
110 */
111 CB_Controllers_Proprietary.WII_U.wiiuObject = null;
112
113 /**
114 * Keeps the last return value of the {@link CB_Controllers_Proprietary.WII_U.getGamePadStatus} function (if any). The value should be the last status object returned.
115 * @var
116 * @readonly
117 * @type {Object}
118 * @default
119 */
120 CB_Controllers_Proprietary.WII_U.gamepadLastStatus = null; //Last read status for the gamepad.
121
122
123 /**
124 * Keeps an array with numeric indexes (should be from 0 to 7 maximum) that belong to each remote number and whose values contain the last return value of the {@link CB_Controllers_Proprietary.WII_U.getRemoteStatus} function (if any). Each value should be the last status object returned.
125 * @var
126 * @readonly
127 * @type {array}
128 * @default
129 */
130 CB_Controllers_Proprietary.WII_U.remoteLastStatus = []; //Last read status for the remote.
131
132 /**
133 * Object which keeps the values for the Nintendo Wii U gamepad's buttons (bitmasks).
134 * @memberof CB_Controllers_Proprietary.WII_U
135 * @name GAMEPAD_BUTTONS
136 * @constant
137 * @type {Object}
138 * @default
139 * @property {number} LEFT_STICK_LEFT - LEFT on the LEFT STICK. Default action: Scroll/Pan.
140 * @property {number} LEFT_STICK_RIGHT - RIGHT on the LEFT STICK. Default action: Scroll/Pan.
141 * @property {number} LEFT_STICK_UP - UP on the LEFT STICK. Default action: Scroll/Pan.
142 * @property {number} LEFT_STICK_DOWN - DOWN on the LEFT STICK. Default action: Scroll/Pan.
143 * @property {number} LEFT_STICK_CLICK - CLICK on the LEFT STICK. Default action: Hide/show bottom toolbar.
144 * @property {number} RIGHT_STICK_LEFT - LEFT on the RIGHT STICK. Default action: Zoom.
145 * @property {number} RIGHT_STICK_RIGHT - RIGHT on the RIGHT STICK. Default action: Zoom.
146 * @property {number} RIGHT_STICK_UP - UP on the RIGHT STICK. Default action: Zoom.
147 * @property {number} RIGHT_STICK_DOWN - DOWN on the RIGHT STICK. Default action: Zoom.
148 * @property {number} RIGHT_STICK_CLICK - CLICK on the RIGHT STICK. Default actionn: Toggle zoom in/out on center of screen.
149 * @property {number} TV - "TV" button.
150 * @property {number} A - "A" button. Send the "Enter" key (keyCode 13).
151 * @property {number} B - "B" button. Default action: Back to previous page (hold B: Close current tab).
152 * @property {number} X - "X" button. Default action: Toggle curtain mode.
153 * @property {number} Y - "Y" button. Default action: View bookmarks.
154 * @property {number} LEFT - LEFT button on the control pad. Default action: Select links / form fields.
155 * @property {number} RIGHT - RIGHT button on the control pad. Default action: Select links / form fields.
156 * @property {number} UP - UP button on the control pad. Default action: Select links / form fields.
157 * @property {number} DOWN - DOWN button on the control pad. Default action: Select links / form fields.
158 * @property {number} ZL - "ZL" button. Default action: Switch to previous tab (hold ZL+ZR: Tilt scrolling).
159 * @property {number} ZR - "ZR" button. Default action: Switch to next tab (hold ZL+ZR: Tilt scrolling).
160 * @property {number} L - "L" button. Default action: Back to previous page.
161 * @property {number} R - "R" button. Default action: Forward to next page.
162 * @property {number} START - "START" button.
163 * @property {number} PLUS - Alias for {@link CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.START}.
164 * @property {number} SELECT - "SELECT" button.
165 * @property {number} MINUS - Alias for {@link CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.SELECT}.
166 * @property {number} HOME - HOME button. Default action: Quit browser.
167 */
168 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS = {};
169 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT_STICK_LEFT = 0x40000000; //1073741824. Default action: Scroll/Pan.
170 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT_STICK_RIGHT = 0x20000000; //536870912. Default action: Scroll/Pan.
171 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT_STICK_UP = 0x10000000; //268435456. Default action: Scroll/Pan.
172 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT_STICK_DOWN = 0x08000000; //134217728. Default action: Scroll/Pan.
173 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT_STICK_CLICK = 0x00040000; //262144. Default action: Hide/show bottom toolbar.
174 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT_STICK_LEFT = 0x04000000; //67108864. Default action: Zoom.
175 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT_STICK_RIGHT = 0x02000000; //33554432. Default action: Zoom.
176 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT_STICK_UP = 0x01000000; //16777216. Default action: Zoom.
177 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT_STICK_DOWN = 0x00800000; //8388608. Default action: Zoom.
178 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT_STICK_CLICK = 0x00020000; //131072. Default actionn: Toggle zoom in/out on center of screen.
179 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.TV = 0x00010000; //65536.
180 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.A = 0x00008000; //32768. Default action: Send the "Enter" key (keyCode 13).
181 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.B = 0x00004000; //16384. Default action: Back to previous page (hold B: Close current tab).
182 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.X = 0x00002000; //8192. Default action: Toggle curtain mode.
183 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.Y = 0x00001000; //4096. Default action: View bookmarks.
184 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.LEFT = 0x00000800; //2048. Default action: Select links / form fields.
185 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.RIGHT = 0x00000400; //1024. Default action: Select links / form fields.
186 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.UP = 0x00000200; //512. Default action: Select links / form fields.
187 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.DOWN = 0x00000100; //256. Default action: Select links / form fields.
188 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.ZL = 0x00000080; //128. Default action: Switch to previous tab (hold ZL+ZR: Tilt scrolling).
189 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.ZR = 0x00000040; //64. Default action: Switch to next tab (hold ZL+ZR: Tilt scrolling).
190 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.L = 0x00000020; //32. Default action: Back to previous page.
191 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.R = 0x00000010; //16. Default action: Forward to next page.
192 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.START = CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.PLUS = 0x00000008; //8.
193 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.SELECT = CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.MINUS = 0x00000004; //4.
194 CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS.HOME = 0x00000002; //2. Default action: Quit browser.
195
196
197 /**
198 * Object which keeps the values for the Nintendo Wii U remote's buttons (bitmasks).
199 * @memberof CB_Controllers_Proprietary.WII_U
200 * @name REMOTE_BUTTONS
201 * @constant
202 * @type {Object}
203 * @default
204 * @property {number} UP - UP button.
205 * @property {number} DOWN - DOWN button.
206 * @property {number} LEFT - LEFT button.
207 * @property {number} RIGHT - RIGHT button.
208 * @property {number} A - "A" button.
209 * @property {number} B - "B" button.
210 * @property {number} ONE - "1" button.
211 * @property {number} _1 - Alias for {@link CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.ONE}.
212 * @property {number} 1 - Alias for {@link CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.ONE}.
213 * @property {number} TWO - "2" button.
214 * @property {number} _2 - Alias for {@link CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.TWO}.
215 * @property {number} 2 - Alias for {@link CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.TWO}.
216 * @property {number} PLUS - PLUS ("+") button.
217 * @property {number} MINUS - MINUS ("-") button.
218 * @property {number} HOME - HOME button.
219 */
220 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS = {};
221 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.UP = 0x00000800; //2048.
222 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.DOWN = 0x00000400; //1024.
223 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.LEFT = 0x00000100; //256.
224 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.RIGHT = 0x00000200; //512.
225 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.A = 0x00000008; //8.
226 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.B = 0x00000004; //4.
227 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.ONE = CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS._1 = CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS["1"] = 0x00000001; //1.
228 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.TWO = CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS._2 = CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS["2"] = 0x00000002; //2.
229 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.PLUS = 0x00001000; //4096.
230 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.MINUS = 0x00000010; //16.
231 CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.HOME = 0x00000080; //128.
232
233
234 //Initializes all values:
235 CB_Controllers_Proprietary.WII_U.init = function()
236 {
237 if (CB_Controllers_Proprietary.WII_U.initialized) { return CB_Controllers_Proprietary.WII_U; }
238
239 //The object has been initialized:
240 CB_Controllers_Proprietary.WII_U.initialized = true;
241
242 //If it does not exist any property, creates it (empty object):
243 if (typeof(wiiu) === "undefined" || wiiu === null) { var wiiu = {}; }
244 if (typeof(wiiu.gamepad) === "undefined" || wiiu.gamepad === null)
245 {
246 wiiu.gamepad =
247 {
248 usingPrototype: true, //This property will not exist in the case it is using the real API.
249
250 //General:
251 isDataValid: 0, //After a successful update, wiiu.gamepad.isDataValid will be set to 1. If no update has happened yet, or if the GamePad is not connected, it will be set to 0.
252 isEnabled: 0, //If the GamePad is connected wiiu.gamepad.isEnabled will be set to 1, else it will be set to 0.
253
254 //Touch screen:
255 tpTouch: 0, //1 if touch is present.
256 tpValidity: 3, //0 = X and Y coordinates valid, 1 = X coordinate invalid, 2 = Y coordinate invalid, 3 = X and Y coordinates invalid.
257 tpX: undefined, //X position in screen coordinates.
258 tpY: undefined, //Y position in screen coordinates.
259 contentX: undefined, //X position in page coordinates.
260 contentY: undefined, //Y position in page coordinates.
261
262 //Analog sticks (from -1.0 to 1.0):
263 lStickX: 0, //GamePad Left Control Stick X deflection.
264 lStickY: 0, //GamePad Left Control Stick Y deflection.
265 rStickX: 0, //GamePad Right Control Stick X deflection.
266 rStickY: 0, //GamePad Right Control Stick Y deflection.
267
268 //Buttons:
269 hold: 0, //Bitmask (to use with properties of CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS).
270
271 //Accelerometer (acceleration forces in Gs. When held level and motionless, the force of gravity will cause these variables to contain the vector (0.0, -1.0, 0.0)):
272 accX: undefined, //Force on X (horizontal) axis.
273 accY: undefined, //Force on Y (depth) axis.
274 accZ: undefined, //Force on Z (vertical) axis.
275
276 //Gyroscope (when the GamePad is motionless these values hover around 0.0):
277 gyroX: undefined, //Rotation speed around X (horizontal) axis.
278 gyroY: undefined, //Rotation speed around Y (depth) axis.
279 gyroZ: undefined, //Rotation speed around Z (vertical) axis.
280
281 //Angle (if properly calibrated, angleX and angleZ should hover around 0.0 when the GamePad is held level, but as the gyroscopes have limited range and resolution the alignment will drift with use):
282 //Note: A change of 1.0 in these values represents a complete revolution around the specified axis. Multiple revolutions around the same axis will cause the value to continuously increase or decrease.
283 angleX: undefined, //Rotation around X (horizontal) axis.
284 angleY: undefined, //Rotation around Y (depth) axis.
285 angleZ: undefined, //Rotation around Z (vertical) axis.
286
287 //Orientation:
288 //Note: This is a basis of 3 perpendicular unit vectors; each vector has length 1.0 and points along the relevant axis of the GamePad relative to an arbitrary starting orientation in three-dimensional space.
289 //X (horizontal) axis:
290 dirXx: undefined,
291 dirXy: undefined,
292 dirXz: undefined,
293 //Y (depth) axis:
294 dirYx: undefined,
295 dirYy: undefined,
296 dirYz: undefined,
297 //Z (vertical) axis:
298 dirZx: undefined,
299 dirZy: undefined,
300 dirZz: undefined
301 };
302 }
303 if (typeof(wiiu.gamepad.update) !== "function") { wiiu.gamepad.update = function() { return wiiu.gamepad; }; }
304
305 if (typeof(wiiu.remote) === "undefined" || wiiu.remote === null)
306 {
307 var remoteFakeObject =
308 {
309 usingPrototype: true, //This property will not exist in the case it is using the real API.
310
311 //General:
312 isDataValid: 0, //If the specified Wii Remote returns valid data, wiiu.remote.isDataValid will be set to 1. If no update has happened yet, or if the selected Wii Remote is not connected, it will be set to 0.
313
314 //Buttons:
315 held: 0, //Bitmask (to use with properties of CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS).
316
317 //Accelerometer (acceleration forces in Gs. When held level and motionless, the force of gravity will cause these variables to contain the vector (0.0, -1.0, 0.0)):
318 accX: undefined, //Force on X (horizontal) axis
319 accY: undefined, //Force on Y (depth) axis
320 accZ: undefined, //Force on Z (vertical) axis
321
322 //Pointer (track the Wii Remote's cursor on the screen):
323 setCursorViewable: function(n, enable) { return null; }, //Enable or disable the display of a Wii Remote's cursor.
324 dpdX: undefined, //X position in screen coordinates
325 dpdY: undefined, //Y position in screen coordinates
326 dpdDistance: undefined, //Distance between Wii Remote and Sensor Bar
327 contentX: undefined, //X position in page coordinates
328 contentY: undefined, //Y position in page coordinates
329 isCursorViewable: 0, //1 if cursor display is enabled
330 dpdValidity: 3, //0 = X and Y coordinates valid, 1 = X coordinate invalid, 2 = Y coordinate invalid, 3 = X and Y coordinates invalid.
331
332 //Motion Plus:
333 //Note: Basis of 3 perpendicular unit vectors; Each vector has length 1.0 and points along the relevant axis of the GamePad relative to an arbitrary starting orientation in three-dimensional space.
334 //X (horizontal) axis
335 mplsDirXx: undefined,
336 mplsDirXy: undefined,
337 mplsDirXz: undefined,
338 //Y (depth) axis
339 mplsDirYx: undefined,
340 mplsDirYy: undefined,
341 mplsDirYz: undefined,
342 //Z (vertical) axis
343 mplsDirZx: undefined,
344 mplsDirZy: undefined,
345 mplsDirZz: undefined,
346 //The following variables are also available to track the motion of the Wii Remote:
347 mplsAngX: undefined, //Rotation around X (horizontal) axis.
348 mplsAngY: undefined, //Rotation around Y (depth) axis.
349 mplsAngZ: undefined, //Rotation around Z (vertical) axis.
350 mplsVelX: undefined, //Movement speed along X (horizontal) axis.
351 mplsVelY: undefined, //Movement speed along Y (depth) axis.
352 mplsVelZ: undefined, //Movement speed along Z (vertical) axis.
353 mplsRollX: undefined, //TODO: ? (Source: http://wiiubrew.org/wiki/Internet_Browser).
354 mplsRollY: undefined //TODO: ?.
355 };
356
357 wiiu.remote =
358 {
359 _devices: [remoteFakeObject]
360 };
361 }
362 if (typeof(wiiu.remote.update) !== "function") { wiiu.remote.update = function(n) { return typeof(wiiu.remote._devices[n]) === "undefined" ? remoteFakeObject : wiiu.remote._devices[n]; }; }
363
364 //Stores the object (maybe fake one):
365 CB_Controllers_Proprietary.WII_U.wiiuObject = wiiu;
366
367 //Gets the status for the first time:
368 CB_Controllers_Proprietary.WII_U.getGamePadStatus();
369
370 return CB_Controllers_Proprietary.WII_U;
371 }
372
373
374 /**
375 * Normalizes the given gamepad status object, adding missing properties.
376 * @function
377 * @param {object} gamepadStatusObject - The gamepad status object that we want to normalize.
378 * @returns {Object} Returns the given gamepad status object but normalized, adding missing properties.
379 */
380 CB_Controllers_Proprietary.WII_U.normalizeGamepad = function(statusObject)
381 {
382 if (typeof(statusObject) === "undefined" || statusObject === null) { statusObject = {}; }
383
384 //Sets the "id" and "index" properties:
385 statusObject.index = 0;
386 statusObject.id = "WII_U_GAMEPAD_0";
387
388 //Sets its "connected" property:
389 statusObject.connected = !!statusObject.isEnabled;
390
391 //Updates the "timestamp" property if the data has been updated:
392 if (statusObject.isDataValid) { statusObject.timestamp = window.performance.now(); }
393
394 //Sets the "buttons" property:
395 if (typeof(statusObject.buttons) === "undefined" || statusObject.buttons === null) { statusObject.buttons = {}; }
396 for (var buttonName in CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS)
397 {
398 if (typeof(statusObject.buttons[buttonName]) === "undefined" || statusObject.buttons[buttonName] === null) { statusObject.buttons[buttonName] = {}; }
399 statusObject.buttons[buttonName].pressed = statusObject.buttons[buttonName].touched = !!(statusObject.hold &amp; CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS[buttonName]); //statusObject.hold is a bitmask with the buttons pressed.
400 statusObject.buttons[buttonName].value = statusObject.buttons[buttonName].pressed ? 1 : 0;
401 }
402
403 //Sets the "axes" property:
404 if (typeof(statusObject.axes) === "undefined" || statusObject.axes === null) { statusObject.axes = [0, 0, 0, 0, 0, 0]; }
405
406 //Axes for LEFT, RIGHT, UP and DOWN:
407 statusObject.axes[0] = 0;
408 if (statusObject.buttons.LEFT.pressed) { statusObject.axes[0] += -1; }
409 if (statusObject.buttons.RIGHT.pressed) { statusObject.axes[0] += 1; }
410 statusObject.axes[1] = 0;
411 if (statusObject.buttons.UP.pressed) { statusObject.axes[1] += -1; }
412 if (statusObject.buttons.DOWN.pressed) { statusObject.axes[1] += 1; }
413
414 //Axes for LEFT, RIGHT, UP and DOWN of the LEFT STICK and their value:
415 statusObject.axes[2] = statusObject.lStickX || 0;
416 statusObject.buttons.LEFT_STICK_LEFT.value = 0;
417 statusObject.buttons.LEFT_STICK_RIGHT.value = 0;
418 if (statusObject.axes[2] &lt; 0) { statusObject.buttons.LEFT_STICK_LEFT.value = statusObject.axes[2] * -1; }
419 else if (statusObject.axes[2] > 0) { statusObject.buttons.LEFT_STICK_RIGHT.value = statusObject.axes[2]; }
420 statusObject.axes[3] = statusObject.lStickY || 0;
421 statusObject.buttons.LEFT_STICK_UP.value = 0;
422 statusObject.buttons.LEFT_STICK_DOWN.value = 0;
423 if (statusObject.axes[3] &lt; 0) { statusObject.buttons.LEFT_STICK_UP.value = statusObject.axes[3] * -1; }
424 else if (statusObject.axes[3] > 0) { statusObject.buttons.LEFT_STICK_DOWN.value = statusObject.axes[3]; }
425
426
427
428 //Axes for LEFT, RIGHT, UP and DOWN of the RIGHT STICK and their value:
429 statusObject.axes[4] = statusObject.rStickX || 0;
430 statusObject.buttons.RIGHT_STICK_LEFT.value = 0;
431 statusObject.buttons.RIGHT_STICK_RIGHT.value = 0;
432 if (statusObject.axes[4] &lt; 0) { statusObject.buttons.RIGHT_STICK_LEFT.value = statusObject.axes[4] * -1; }
433 else if (statusObject.axes[4] > 0) { statusObject.buttons.RIGHT_STICK_RIGHT.value = statusObject.axes[4]; }
434
435 statusObject.axes[5] = statusObject.rStickY || 0;
436 statusObject.buttons.RIGHT_STICK_UP.value = 0;
437 statusObject.buttons.RIGHT_STICK_DOWN.value = 0;
438 if (statusObject.axes[5] &lt; 0) { statusObject.buttons.RIGHT_STICK_UP.value = statusObject.axes[5] * -1; }
439 else if (statusObject.axes[5] > 0) { statusObject.buttons.RIGHT_STICK_DOWN.value = statusObject.axes[5]; }
440
441
442 //Updates the rest of the properties:
443 statusObject.mapping = "";
444 statusObject.vibrationActuator = null;
445
446 return statusObject;
447 }
448
449
450 /**
451 * Normalizes the given remote status object, adding missing properties.
452 * @function
453 * @param {object} gamepadStatusObject - The remote status object that we want to normalize.
454 * @param {integer} [n=0] - Number of the remote whose status we want to get, from 0 to 7 (both numbers included, 8 in total). It will be used as its identifier.
455 * @returns {Object} Returns the given remote status object but normalized, adding missing properties.
456 */
457 CB_Controllers_Proprietary.WII_U.normalizeRemote = function(statusObject, n)
458 {
459 if (typeof(statusObject) === "undefined" || statusObject === null) { statusObject = {}; }
460
461 //Sets the "id" and "index" properties:
462 statusObject.index = n ? n : 0;
463 statusObject.id = "WII_U_REMOTE_" + statusObject.index;
464
465 //Sets its "connected" property:
466 if (!statusObject.connected) { statusObject.connected = !!statusObject.isDataValid; }
467
468 //Updates the "timestamp" property if the data has been updated:
469 if (statusObject.isDataValid) { statusObject.timestamp = window.performance.now(); }
470
471 //Sets the "buttons" property:
472 if (typeof(statusObject.buttons) === "undefined" || statusObject.buttons === null) { statusObject.buttons = {}; }
473 for (var buttonName in CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS)
474 {
475 if (typeof(statusObject.buttons[buttonName]) === "undefined" || statusObject.buttons[buttonName] === null) { statusObject.buttons[buttonName] = {}; }
476 statusObject.buttons[buttonName].pressed = statusObject.buttons[buttonName].touched = !!(statusObject.held &amp; CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS[buttonName]); //statusObject.held is a bitmask with the buttons pressed.
477 statusObject.buttons[buttonName].value = statusObject.buttons[buttonName].pressed ? 1 : 0;
478 }
479
480 //Sets the "axes" property:
481 if (typeof(statusObject.axes) === "undefined" || statusObject.axes === null) { statusObject.axes = [0, 0]; }
482
483 //Axes for LEFT, RIGHT, UP and DOWN:
484 statusObject.axes[0] = 0;
485 if (statusObject.buttons.LEFT.pressed) { statusObject.axes[0] += -1; }
486 if (statusObject.buttons.RIGHT.pressed) { statusObject.axes[0] += 1; }
487 statusObject.axes[1] = 0;
488 if (statusObject.buttons.UP.pressed) { statusObject.axes[1] += -1; }
489 if (statusObject.buttons.DOWN.pressed) { statusObject.axes[1] += 1; }
490
491 //Updates the rest of the properties:
492 statusObject.mapping = "";
493 statusObject.vibrationActuator = null;
494
495 return statusObject;
496 }
497
498
499 /**
500 * Returns an object with the current status of each button of the gamepad. Already calls {@link CB_Controllers_Proprietary.WII_U.normalizeGamepad} automatically.
501 * @function
502 * @returns {Object} Returns an object with the current status of each button of the gamepad.
503 */
504 CB_Controllers_Proprietary.WII_U.getGamePadStatus = function()
505 {
506 return CB_Controllers_Proprietary.WII_U.gamepadLastStatus = CB_Controllers_Proprietary.WII_U.normalizeGamepad(CB_Controllers_Proprietary.WII_U.wiiuObject.gamepad.update());
507 }
508
509
510 /**
511 * Returns an object with the current status of each button of the desired remote. Already calls {@link CB_Controllers_Proprietary.WII_U.normalizeRemote} automatically.
512 * @function
513 * @param {integer} [n=0] - Number of the remote whose status we want to get, from 0 to 7 (both numbers included, 8 in total).
514 * @returns {Object} Returns an object with the current status of each button of the desired remote.
515 * @todo Check documentation to see whether the first index should be 0 or 1 and maximum 7 or 8.
516 */
517 CB_Controllers_Proprietary.WII_U.getRemoteStatus = function(n)
518 {
519 if (typeof(n) === "undefined" || n === null || !isNaN(n) || n &lt; 0) { n = 0; } //TODO: check documentation to see whether the minimum should be 0 or 1 and maximum 7 or 8.
520 else if (n > 8) { n = 7; }
521 return CB_Controllers_Proprietary.WII_U.remoteLastStatus[n] = CB_Controllers_Proprietary.WII_U.normalizeRemote(CB_Controllers_Proprietary.WII_U.wiiuObject.remote.update(n), n);
522 }
523
524
525 /**
526 * Returns an object with the gamepad and all remotes simulating the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}. Uses the {@link CB_Controllers_Proprietary.WII_U.getRemoteStatus} and {@link CB_Controllers_Proprietary.WII_U.getRemoteStatus} internally so the objects will be normalized already.
527 * @function
528 * @returns {Object} Returns an object with two properties: "gamepads" and "remotes". Each of those two properties will have an object as value whose names will be the index of the device and the value an object with the status of that device. In the case of the gamepad (which is unique), there will only be one index ("0", zero). In the case of the remotes, it will contain the status objects of all the remotes. The number of remotes is 8 (index from "0" to "7"). Simulating the [GamePad API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API}. Those status objects which are not using the real API will have a property called "usingPrototype" set to true.
529 * @todo Check the documentation to find out the maximum number of remotes allowed and find out whether the first index should be 0 or 1 and last one 7 or 8.
530 */
531 CB_Controllers_Proprietary.WII_U.getGamePads = function()
532 {
533 //TODO: normalize all to simulate GamePad API.
534 return {
535 "gamepads" : { "0" : CB_Controllers_Proprietary.WII_U.getGamePadStatus() },
536 "remotes" :
537 {
538 //TODO: check the documentation to find out the maximum number of remotes allowed.
539 "0" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(0),
540 "1" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(1),
541 "2" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(2),
542 "3" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(3),
543 "4" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(4),
544 "5" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(5),
545 "6" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(6),
546 "7" : CB_Controllers_Proprietary.WII_U.getRemoteStatus(7)
547 }
548 };
549 }
550
551
552 //TODO: function or option that returns an array with the pressed buttons (LEFT: true, L: true, R: false, etc.). Use the bitmasks of CB_Controllers_Proprietary.WII_U.GAMEPAD_BUTTONS and CB_Controllers_Proprietary.WII_U.REMOTE_BUTTONS.
553
554}</pre>
555 </article>
556</section>
557
558
559
560
561
562 </div>
563 </div>
564
565 <div class="clearfix"></div>
566
567
568
569</div>
570</div>
571
572
573 <div class="modal fade" id="searchResults">
574 <div class="modal-dialog">
575 <div class="modal-content">
576 <div class="modal-header">
577 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
578 <h4 class="modal-title">Search results</h4>
579 </div>
580 <div class="modal-body"></div>
581 <div class="modal-footer">
582 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
583 </div>
584 </div><!-- /.modal-content -->
585 </div><!-- /.modal-dialog -->
586 </div>
587
588
589<footer>
590
591
592 <span class="copyright">
593 <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>
594 </span>
595
596<span class="jsdoc-message">
597 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
598
599 on Mon Feb 3rd 2020
600
601 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
602</span>
603</footer>
604
605<script src="scripts/docstrap.lib.js"></script>
606<script src="scripts/toc.js"></script>
607
608 <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
609
610
611<script>
612$( function () {
613 $( "[id*='$']" ).each( function () {
614 var $this = $( this );
615
616 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
617 } );
618
619 $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
620 var $this = $( this );
621
622 var example = $this.find( "code" );
623 exampleText = example.html();
624 var lang = /{@lang (.*?)}/.exec( exampleText );
625 if ( lang && lang[1] ) {
626 exampleText = exampleText.replace( lang[0], "" );
627 example.html( exampleText );
628 lang = lang[1];
629 } else {
630 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
631 lang = langClassMatch ? langClassMatch[1] : "javascript";
632 }
633
634 if ( lang ) {
635
636 $this
637 .addClass( "sunlight-highlight-" + lang )
638 .addClass( "linenums" )
639 .html( example.html() );
640
641 }
642 } );
643
644 Sunlight.highlightAll( {
645 lineNumbers : true,
646 showMenu : true,
647 enableDoclinks : true
648 } );
649
650 $.catchAnchorLinks( {
651 navbarOffset: 10
652 } );
653 $( "#toc" ).toc( {
654 anchorName : function ( i, heading, prefix ) {
655 return $( heading ).attr( "id" ) || ( prefix + i );
656 },
657 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
658 showAndHide : false,
659 smoothScrolling: true
660 } );
661
662 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
663 $( '.dropdown-toggle' ).dropdown();
664
665 $( "table" ).each( function () {
666 var $this = $( this );
667 $this.addClass('table');
668 } );
669
670} );
671</script>
672
673
674
675<!--Navigation and Symbol Display-->
676
677<script>
678 $( function () {
679 $( '#main' ).localScroll( {
680 offset : { top : 60 } //offset by the height of your header (give or take a few px, see what works for you)
681 } );
682 $( "dt.name" ).each( function () {
683 var $this = $( this ).find("h4");
684 var icon = $( "<i/>" ).addClass( "icon-plus-sign" ).addClass( "pull-right" ).addClass( "icon-white" );
685 var dt = $(this);
686 var children = dt.next( "dd" );
687
688 dt.prepend( icon ).css( {cursor : "pointer"} );
689 dt.addClass( "member-collapsed" ).addClass( "member" );
690
691
692 children.hide();
693
694 dt.children().on( "click", function () {
695 children = dt.next( "dd" );
696 children.slideToggle( "fast", function () {
697
698 if ( children.is( ":visible" ) ) {
699 icon.addClass( "icon-minus-sign" ).removeClass( "icon-plus-sign" ).removeClass( "icon-white" );
700 dt.addClass( "member-open" ).animate( "member-collapsed" );
701 } else {
702 icon.addClass( "icon-plus-sign" ).removeClass( "icon-minus-sign" ).addClass( "icon-white" );
703 dt.addClass( "member-collapsed" ).removeClass( "member-open" );
704 }
705 } );
706 } );
707
708 } );
709 } );
710</script>
711
712
713<!--Google Analytics-->
714
715
716
717 <script type="text/javascript">
718 $(document).ready(function() {
719 SearcherDisplay.init();
720 });
721 </script>
722
723
724</body>
725</html>