Merge pull request #7549 from mzsm/WiiU

Support Wii U Internet Browser, Extended Functionality
This commit is contained in:
Masahiro Wakame
2016-01-11 23:31:07 +09:00
2 changed files with 168 additions and 0 deletions

56
wiiu/wiiu-tests.ts Normal file
View File

@@ -0,0 +1,56 @@
/// <reference path="./wiiu.d.ts" />
var state = window.wiiu.gamepad.update();
if( !state.isEnabled || !state.isDataValid ){
console.log('gyro X:' + state.gyroX.toString() + ' Y:' + state.gyroY.toString() + ' Z:' + state.gyroZ.toString());
console.log('angle X:' + state.angleX.toString() + ' Y:' + state.angleY.toString() + ' Z:' + state.angleZ.toString());
console.log('dirX X:' + state.dirXx.toString() + ' Y:' + state.dirXy.toString() + ' Z:' + state.dirXz.toString());
console.log('dirY X:' + state.dirYx.toString() + ' Y:' + state.dirYy.toString() + ' Z:' + state.dirYz.toString());
console.log('dirZ X:' + state.dirZx.toString() + ' Y:' + state.dirZy.toString() + ' Z:' + state.dirZz.toString());
console.log('acc X:' + state.accX.toString() + ' Y:' + state.accY.toString() + ' Z:' + state.accZ.toString());
console.log('LStick axis X:' + state.lStickX.toString() + ' Y:' + state.lStickY.toString());
console.log('RStick axis X:' + state.rStickX.toString() + ' Y:' + state.rStickY.toString());
if(state.hold & window.wiiu.Button.A){
console.log('pushing A button');
}
if( state.tpTouch && state.tpValidity == window.wiiu.TPValidity.VALID ){
console.log("touch X:" + state.contentX.toString() + " Y:" + state.contentY.toString());
}
}
document.getElementById('video').addEventListener('wiiu_videoplayer_end', (e) => {
console.log(e);
console.log('VideoPlayer end');
});
if(window.wiiu.videoplayer.viewMode == 0){
window.wiiu.videoplayer.viewMode = 1;
}
window.wiiu.videoplayer.end();
window.addEventListener('wiiu_imageview_start', (e) => {
console.log(e);
console.log('ImageViewer start');
});
window.addEventListener('wiiu_imageview_end', (e) => {
console.log(e);
console.log('ImageViewer end');
});
window.addEventListener('wiiu_imageview_change_viewmode', (e) => {
console.log(e);
console.log('ImageViewer change viewmode');
if(window.wiiu.imageview.viewMode == 1){
window.wiiu.imageview.viewMode = 0;
}
});
window.addEventListener('wiiu_imageview_change_content', (e) => {
console.log(e);
console.log('ImageViewer change content');
});
window.addEventListener('wiiu_imageview_error', (e) => {
console.log(e);
console.log('ImageViewer error');
console.log(window.wiiu.imageview.getErrorCode());
});

112
wiiu/wiiu.d.ts vendored Normal file
View File

@@ -0,0 +1,112 @@
// Type definitions for Extended Functionality of Wii U Internet Browser
// Project: https://www.nintendo.co.jp/wiiu/hardware/internetbrowser/extended_functionality.html
// Definitions by: MIZUSHIMA Junki <https://github.com/mzsm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module wiiu {
const enum TPValidity {
VALID = 0,
X_INVALID = 1,
Y_INVALID = 2,
INVALID = 3
}
const enum Button {
MINUS = 0x00000004,
SELECT = MINUS,
PLUS = 0x00000008,
START = PLUS,
R = 0x00000010,
L = 0x00000020,
ZR = 0x00000040,
ZL = 0x00000080,
DOWN = 0x00000100,
UP = 0x00000200,
RIGHT = 0x00000400,
LEFT = 0x00000800,
Y = 0x00001000,
X = 0x00002000,
B = 0x00004000,
A = 0x00008000,
R_STICK = 0x00020000,
L_STICK = 0x00040000,
R_STICK_DOWN = 0x00800000,
R_STICK_UP = 0x01000000,
R_STICK_RIGHT = 0x02000000,
R_STICK_LEFT = 0x04000000,
L_STICK_DOWN = 0x08000000,
L_STICK_UP = 0x10000000,
L_STICK_RIGHT = 0x20000000,
L_STICK_LEFT = 0x40000000
}
interface WiiuGamePad {
isEnabled: boolean;
isDataValid: boolean;
tpTouch: boolean;
tpValidity: number;
contentX: number;
contentY: number;
lStickX: number;
lStickY: number;
rStickX: number;
rStickY: number;
hold: number;
accX: number;
accY: number;
accZ: number;
gyroX: number;
gyroY: number;
gyroZ: number;
angleX: number;
angleY: number;
angleZ: number;
dirXx: number;
dirXy: number;
dirYx: number;
dirXz: number;
dirYy: number;
dirYz: number;
dirZx: number;
dirZz: number;
dirZy: number;
update(): WiiuGamePad;
}
interface VideoPlayer {
viewMode: number;
end(): boolean;
}
const enum ImageViewErrorCode {
UNSUPPORTED_FORMAT = 202,
DIMENSIONS_TOO_LARGE = 203,
FILE_SIZE_TOO_LARGE = 204,
TOO_MANY_PIXELS_PROGRESSIVE_JPEG = 205
}
interface ImageView {
viewMode: number;
end(): boolean;
getErrorCode(): number;
}
var gamepad: WiiuGamePad;
var videoplayer: VideoPlayer;
var imageview: ImageView;
}
interface HTMLElement {
addEventListener(type: "wiiu_videoplayer_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
}
interface Window {
wiiu: typeof wiiu;
addEventListener(type: "wiiu_imageview_start", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
addEventListener(type: "wiiu_imageview_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
addEventListener(type: "wiiu_imageview_change_viewmode", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
addEventListener(type: "wiiu_imageview_change_content", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
addEventListener(type: "wiiu_imageview_error", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
}