|
11 | 11 | * @constructor |
12 | 12 | */ |
13 | 13 |
|
14 | | -Phaser.Device = function () { |
| 14 | +Phaser.Device = function (game) { |
| 15 | + |
| 16 | + /** |
| 17 | + * @property {Phaser.Game} game - A reference to the currently running game. |
| 18 | + */ |
| 19 | + this.game = game; |
15 | 20 |
|
16 | 21 | /** |
17 | 22 | * An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247 |
@@ -325,6 +330,30 @@ Phaser.Device = function () { |
325 | 330 | */ |
326 | 331 | this.littleEndian = false; |
327 | 332 |
|
| 333 | + /** |
| 334 | + * @property {boolean} fullscreen - Does the browser support the Full Screen API? |
| 335 | + * @default |
| 336 | + */ |
| 337 | + this.fullscreen = false; |
| 338 | + |
| 339 | + /** |
| 340 | + * @property {string} requestFullscreen - If the browser supports the Full Screen API this holds the call you need to use to activate it. |
| 341 | + * @default |
| 342 | + */ |
| 343 | + this.requestFullscreen = ''; |
| 344 | + |
| 345 | + /** |
| 346 | + * @property {string} cancelFullscreen - If the browser supports the Full Screen API this holds the call you need to use to cancel it. |
| 347 | + * @default |
| 348 | + */ |
| 349 | + this.cancelFullscreen = ''; |
| 350 | + |
| 351 | + /** |
| 352 | + * @property {boolean} fullscreenKeyboard - Does the browser support access to the Keyboard during Full Screen mode? |
| 353 | + * @default |
| 354 | + */ |
| 355 | + this.fullscreenKeyboard = false; |
| 356 | + |
328 | 357 | // Run the checks |
329 | 358 | this._checkAudio(); |
330 | 359 | this._checkBrowser(); |
@@ -422,6 +451,65 @@ Phaser.Device.prototype = { |
422 | 451 |
|
423 | 452 | this.quirksMode = (document.compatMode === 'CSS1Compat') ? false : true; |
424 | 453 |
|
| 454 | + |
| 455 | + |
| 456 | + }, |
| 457 | + |
| 458 | + /** |
| 459 | + * Checks for support of the Full Screen API. |
| 460 | + * |
| 461 | + * @method Phaser.Device#checkFullScreenSupport |
| 462 | + */ |
| 463 | + checkFullScreenSupport: function () { |
| 464 | + |
| 465 | + var fs = [ |
| 466 | + 'requestFullscreen', |
| 467 | + 'requestFullScreen', |
| 468 | + 'webkitRequestFullscreen', |
| 469 | + 'webkitRequestFullScreen', |
| 470 | + 'msRequestFullscreen', |
| 471 | + 'msRequestFullScreen', |
| 472 | + 'mozRequestFullScreen', |
| 473 | + 'mozRequestFullscreen' |
| 474 | + ]; |
| 475 | + |
| 476 | + for (var i = 0; i < fs.length; i++) |
| 477 | + { |
| 478 | + if (this.game.canvas[fs[i]]) |
| 479 | + { |
| 480 | + this.fullscreen = true; |
| 481 | + this.requestFullscreen = fs[i]; |
| 482 | + } |
| 483 | + } |
| 484 | + |
| 485 | + var cfs = [ |
| 486 | + 'cancelFullScreen', |
| 487 | + 'exitFullscreen', |
| 488 | + 'webkitCancelFullScreen', |
| 489 | + 'webkitExitFullscreen', |
| 490 | + 'msCancelFullScreen', |
| 491 | + 'msExitFullscreen', |
| 492 | + 'mozCancelFullScreen', |
| 493 | + 'mozExitFullscreen' |
| 494 | + ]; |
| 495 | + |
| 496 | + if (this.fullscreen) |
| 497 | + { |
| 498 | + for (var i = 0; i < cfs.length; i++) |
| 499 | + { |
| 500 | + if (this.game.canvas[cfs[i]]) |
| 501 | + { |
| 502 | + this.cancelFullscreen = cfs[i]; |
| 503 | + } |
| 504 | + } |
| 505 | + } |
| 506 | + |
| 507 | + // Keyboard Input? |
| 508 | + if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) |
| 509 | + { |
| 510 | + this.fullscreenKeyboard = true; |
| 511 | + } |
| 512 | + |
425 | 513 | }, |
426 | 514 |
|
427 | 515 | /** |
|
0 commit comments