In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Internet Browser"

From WiiUBrew
Jump to navigation Jump to search
m (→‎External links: I hosted the wiiu object source code)
(→‎Touch Screen: W3C Events)
Line 139: Line 139:
  
 
<b>TODO:</b> <i>Determine meaning of tpValidity. It has a value of 3 when there is no touch and a value of 0 when there is a touch.</i>
 
<b>TODO:</b> <i>Determine meaning of tpValidity. It has a value of 3 when there is no touch and a value of 0 when there is a touch.</i>
 +
 +
In addition to these proprietary methods, the Gamepad delivers [http://www.w3.org/TR/touch-events/ W3C-standard touch events].
  
 
==== Analog Sticks ====
 
==== Analog Sticks ====

Revision as of 02:23, 4 December 2012

Internet Browser is a web browser preloaded on the Wii U. It is based on NetFront Browser NX v2.1, which uses the WebKit rendering engine.

Known User Agent Strings

Region Release Date UA String
US Nov 18, 2012 Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/2.1.0.8.21 NintendoBrowser/1.0.0.7494.US
EU Nov 30, 2012 Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/2.1.0.8.21 NintendoBrowser/1.0.0.7494.EU
AU Nov 30, 2012 TODO
JP Dec 8, 2012 TODO

Multimedia Support

Internet Browser supports HTML5 audio and video. The only video format supported is H.264 either in an MPEG-4 container or in an MPEG-2 transport stream with a M3U8 index according to the HTTP Live Streaming specification. The only audio format supported is AAC in an MPEG-4 container.

The browser can display BMP, PNG, GIF, JPEG, and SVG images, but Image Preview mode only supports JPEG images.

Other HTML5 features supported include canvas, web storage, web messaging, server-sent events, device orientation, and WOFF.

External plugins, such as Flash and Java, are not supported.

Controls

Under normal circumstances, Internet Browser uses the following controls:

Wii U GamePad Left Control Stick Scroll/Pan
Wii U GamePad Left Control Stick Click Hide/show bottom toolbar
Wii U GamePad Right Control Stick Zoom
Wii U GamePad Right Control Stick Click Toggle zoom in/out on center of screen
Wii U GamePad START Button Zoom in
Wii U GamePad SELECT Button Zoom out
Wii U GamePad L Button Button Back to previous page
Wii U GamePad R Button Button Forward to next page
Wii U GamePad ZL Button Button Switch to previous tab
Wii U GamePad ZR Button Button Switch to next tab
Hold Wii U GamePad ZL Button Button+Wii U GamePad ZR Button Button Tilt scrolling
Wii U GamePad D-Pad Select links / form fields
Wii U GamePad A Button Button Send the "Enter" key (keyCode 13)
Wii U GamePad B Button Button Back to previous page
Hold Wii U GamePad B Button Button Close current tab
Wii U GamePad Y Button Button View bookmarks
Wii U GamePad X Button Button Toggle curtain mode
Wii U GamePad HOME Button Quit browser
Tap screen Click page elements
Double-tap screen Zoom in/out on point
Touch drag Scroll/Pan

Some of these functions can be disabled by markup on a web page.


Wii U Scripting Functionality

In addition to W3C standard touch screen functionality, Internet Browser exposes many Wii U input and output functions to Javascript through the wiiu object.

wiiu.gamepad

The wiiu.gamepad object allows Javascript functions to read the current state of the primary GamePad.

Reading values

In order to read any values from the GamePad, the function wiiu.gamepad.update() must be invoked. This will populate all of the properties on the wiiu.gamepad object with the current information about the sticks, accelerometers, gyroscopes, buttons, and touch screen. It is safe to invoke this function in a timer for real-time updates.

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.

If the GamePad is connected wiiu.gamepad.isEnabled will be set to 1, else it will be set to 0.

Touch Screen

The wiiu.gamepad.tpTouch variable indicates whether or not there is currently an active touch on the screen. If this variable is 1, the following variables will be set:

Variable Value
wiiu.gamepad.tpX X position in screen coordinates
wiiu.gamepad.tpY Y position in screen coordinates
wiiu.gamepad.contentX X position in page coordinates
wiiu.gamepad.contentY Y position in page coordinates

TODO: Determine meaning of tpValidity. It has a value of 3 when there is no touch and a value of 0 when there is a touch.

In addition to these proprietary methods, the Gamepad delivers W3C-standard touch events.

Analog Sticks

The following variables store the current state of the left and right analog sticks. Each value ranges from -1.0 to +1.0.

Variable Value
wiiu.gamepad.lStickX Wii U GamePad Left Control Stick X deflection
wiiu.gamepad.lStickY Wii U GamePad Left Control Stick Y deflection
wiiu.gamepad.rStickX Wii U GamePad Right Control Stick X deflection
wiiu.gamepad.rStickY Wii U GamePad Right Control Stick Y deflection

Buttons

The variable wiiu.gamepad.hold is a bitmask indicating all buttons currently being depressed on the GamePad, including the click states of the analog sticks. Almost all buttons are represented by in this bitmask although the browser's default behaviors may cause some values to be unusable.

Button Decimal Hex
Wii U GamePad Left Control Stick Left 1073741824 0x40000000
Wii U GamePad Left Control Stick Right 536870912 0x20000000
Wii U GamePad Left Control Stick Up 268435456 0x10000000
Wii U GamePad Left Control Stick Down 134217728 0x08000000
Wii U GamePad Right Control Stick Left 67108864 0x04000000
Wii U GamePad Right Control Stick Right 33554432 0x02000000
Wii U GamePad Right Control Stick Up 16777216 0x01000000
Wii U GamePad Right Control Stick Down 8388608 0x00800000
Wii U GamePad Left Control Stick Click 262144 0x00040000
Wii U GamePad Right Control Stick Click 131072 0x00020000
Wii U GamePad TV Button 65536 0x00010000
Wii U GamePad A Button Button 32768 0x00008000
Wii U GamePad B Button Button 16384 0x00004000
Wii U GamePad X Button Button 8192 0x00002000
Wii U GamePad Y Button Button 4096 0x00001000
Wii U Controller D-Pad Left 2048 0x00000800
Wii U Controller D-Pad Right 1024 0x00000400
Wii U Controller D-Pad Up 512 0x00000200
Wii U Controller D-Pad Down 256 0x00000100
Wii U GamePad ZL Button Button 128 0x00000080
Wii U GamePad ZR Button Button 64 0x00000040
Wii U GamePad L Button Button 32 0x00000020
Wii U GamePad R Button Button 16 0x00000010
Wii U GamePad START Button 8 0x00000008
Wii U GamePad SELECT Button 4 0x00000004
Wii U GamePad HOME Button 2 0x00000002

The Power button does not appear in the hold variable in the browser, probably 0x01.

Pressing the Home button closes the browser but triggers the event with keycode 2, So you can see that by going back to the browser after pressing it (The Power button doesn't trigger the event).

Accelerometer

The following variables hold the current state of the GamePad's accelerometers.

Variable Value
wiiu.gamepad.accX Force on X (horizontal) axis
wiiu.gamepad.accY Force on Y (depth) axis
wiiu.gamepad.accZ Force on Z (vertical) axis

These variables form a vector showing the current acceleration forces on the GamePad, measured 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).

Gyroscope

The following variables hold the current state of the GamePad's gyroscopes.

Variable Value
wiiu.gamepad.gyroX Rotation speed around X (horizontal) axis
wiiu.gamepad.gyroY Rotation speed around Y (depth) axis
wiiu.gamepad.gyroZ Rotation speed around Z (vertical) axis

When the GamePad is motionless these values hover around 0.0.

Angle

The following variables hold the current angle of rotation of the GamePad.

Variable Value
wiiu.gamepad.angleX Rotation around X (horizontal) axis
wiiu.gamepad.angleY Rotation around Y (depth) axis
wiiu.gamepad.angleZ Rotation around Z (vertical) axis

A change of 1.0 in these values represents a complete revolution around the specified axis. These variables do not appear to wrap around; multiple revolutions around the same axis will cause the value to continuously increase or decrease.

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.

Orientation

There are nine variables that tie into the GamePad's orientation tracking, organized into three three-dimensional vectors:

Axis X Y Z
X (horizontal) axis wiiu.gamepad.dirXx wiiu.gamepad.dirXy wiiu.gamepad.dirXz
Y (depth) axis wiiu.gamepad.dirYx wiiu.gamepad.dirYy wiiu.gamepad.dirYz
Z (vertical) axis wiiu.gamepad.dirZx wiiu.gamepad.dirZy wiiu.gamepad.dirZz

This is a basis of three perpendicular unit vectors; that is, 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.

wiiu.remote

While Internet Browser exposes a wiiu.remote object, at the present time no way is known how to activate it. Presumedly it would allow Javascript functions to read the current state of the primary Wii Remote and its Motion Plus accessory.

All subsequent documentation is only a best guess at functionality based on the property names and how it worked on the Wii.

Reading values

In order to read any values from the Wii Remote, the function wiiu.remote.update() must be invoked. If the function call were to be successful, this would populate all of the properties on the wiiu.remote object with the current information about the pointer, accelerometers, gyroscopes, and buttons of the primary Wii Remote. It is safe to invoke this function in a timer for real-time updates.

After a successful update, wiiu.remote.isDataValid will be set to 1. If no update has happened yet, or if no Wii Remotes are not connected, it will be set to 0.

Buttons

The variable wiiu.remote.held is a bitmask indicating all buttons currently being depressed on the Wii Remote.

Button Decimal Hex
Wiimote + Button 4096 0x00001000
Wii U Controller D-Pad Up 2048 0x00000800
Wii U Controller D-Pad Down 1024 0x00000400
Wii U Controller D-Pad Right 512 0x00000200
Wii U Controller D-Pad Left 256 0x00000100
Wii U GamePad HOME Button 128 0x00000080
Wiimote - Button 16 0x00000010
Wiimote A Button 8 0x00000008
Wiimote B Button 4 0x00000004
Wiimote 2 Button 2 0x00000002
Wiimote 1 Button 1 0x00000001

Accelerometer

The following variables hold the current state of the Wii Remote's accelerometers.

Variable Value
wiiu.remote.accX Force on X (horizontal) axis
wiiu.remote.accY Force on Y (depth) axis
wiiu.remote.accZ Force on Z (vertical) axis

These variables form a vector showing the current acceleration forces on the Wii Remote, measured 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).

Pointer

The following variables track the Wii Remote's cursor on the screen.

Variable Value
wiiu.remote.dpdX X position in screen coordinates
wiiu.remote.dpdY X position in screen coordinates
wiiu.remote.dpdDistance Distance between Wii Remote and Sensor Bar
wiiu.remote.contentX X position in page coordinates
wiiu.remote.contentY X position in page coordinates
wiiu.remote.isCursorViewable 1 if cursor display is enabled
wiiu.remote.dpdValidity TODO: ?

Additionally, the function wiiu.remote.setCursorViewable() will enable or disable the display of the Wii Remote's cursor.

Motion Plus

There are nine variables that tie into the Motion Plus orientation tracking, organized into three three-dimensional vectors:

Axis X Y Z
X (horizontal) axis wiiu.remote.mplsDirXx wiiu.remote.mplsDirXy wiiu.remote.mplsDirXz
Y (depth) axis wiiu.remote.mplsDirYx wiiu.remote.mplsDirYy wiiu.remote.mplsDirYz
Z (vertical) axis wiiu.remote.mplsDirZx wiiu.remote.mplsDirZy wiiu.remote.mplsDirZz

This is a basis of three perpendicular unit vectors; that is, 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.

The following variables are also available to track the motion of the Wii Remote:

Variable Value
wiiu.remote.mplsAngX Rotation around X (horizontal) axis
wiiu.remote.mplsAngY Rotation around Y (depth) axis
wiiu.remote.mplsAngZ Rotation around Z (vertical) axis
wiiu.remote.mplsVelX Movement speed along X (horizontal) axis
wiiu.remote.mplsVelY Movement speed along Y (depth) axis
wiiu.remote.mplsVelZ Movement speed along Z (vertical) axis
wiiu.remote.mplsRollX TODO: ?
wiiu.remote.mplsRollY TODO: ?

wiiu.videoplayer

The wiiu.videoplayer object exposes the property viewMode and the functions setViewMode() and end(). setViewMode() accepts either 0 (windowed?) or 1 (full-screen?) as parameter.

TODO: Figure out what this is and how to use it.

wiiu.imageview

The wiiu.videoplayer object exposes the property viewMode and the functions end() and getErrorCode().

TODO: Figure out what this is and how to use it.

External links

  • Nintendo Japan's 'wiiu' reference page: [1] [Translated to English]
  • Sample page using the 'wiiu' object [2]
  • Open-Source code download [3]
  • Only the 'wiiu' object source code online [4]
  • Cyan's port of Blob Sallad for the Wii U Internet Browser [5]