mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Add support for the screenshot feature in Android app
This commit is contained in:
parent
6d28e88b85
commit
2eaca3e441
@ -28,6 +28,8 @@ const DEFAULT_FLAGS = {
|
|||||||
const BX_FLAGS = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
const BX_FLAGS = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
||||||
delete window.BX_FLAGS;
|
delete window.BX_FLAGS;
|
||||||
|
|
||||||
|
const AppInterface = window.AppInterface;
|
||||||
|
|
||||||
let REMOTE_PLAY_SERVER;
|
let REMOTE_PLAY_SERVER;
|
||||||
|
|
||||||
const ENABLE_NATIVE_MKB_BETA = false;
|
const ENABLE_NATIVE_MKB_BETA = false;
|
||||||
@ -96,7 +98,7 @@ const BxEvent = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.AppInterface && window.AppInterface.onEvent(eventName);
|
AppInterface && AppInterface.onEvent(eventName);
|
||||||
target.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -6198,7 +6200,7 @@ class VibrationManager {
|
|||||||
static #playDeviceVibration(data) {
|
static #playDeviceVibration(data) {
|
||||||
// console.log(+new Date, data);
|
// console.log(+new Date, data);
|
||||||
|
|
||||||
if ('AppInterface' in window) {
|
if (AppInterface) {
|
||||||
AppInterface.vibrate(JSON.stringify(data), window.BX_VIBRATION_INTENSITY);
|
AppInterface.vibrate(JSON.stringify(data), window.BX_VIBRATION_INTENSITY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8749,12 +8751,9 @@ div[class*=StreamMenu-module__menuContainer] > div[class*=Menu-module] {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 16vh;
|
width: 60px;
|
||||||
height: 16vh;
|
height: 60px;
|
||||||
max-width: 128px;
|
padding: 16px;
|
||||||
max-height: 128px;
|
|
||||||
padding: 2vh;
|
|
||||||
padding: 24px 24px 12px 12px;
|
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-origin: content-box;
|
background-origin: content-box;
|
||||||
@ -8771,7 +8770,7 @@ div[class*=StreamMenu-module__menuContainer] > div[class*=Menu-module] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bx-screenshot-button[data-capturing=true] {
|
.bx-screenshot-button[data-capturing=true] {
|
||||||
padding: 1vh;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-screenshot-canvas {
|
.bx-screenshot-canvas {
|
||||||
@ -10280,7 +10279,7 @@ function injectSettingsButton($parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show link to Android app
|
// Show link to Android app
|
||||||
if (!window.AppInterface) {
|
if (!AppInterface) {
|
||||||
const userAgent = UserAgent.getDefault().toLowerCase();
|
const userAgent = UserAgent.getDefault().toLowerCase();
|
||||||
if (userAgent.includes('android')) {
|
if (userAgent.includes('android')) {
|
||||||
const $btn = createButton({
|
const $btn = createButton({
|
||||||
@ -11343,6 +11342,15 @@ function takeScreenshot(callback) {
|
|||||||
const $canvasContext = $SCREENSHOT_CANVAS.getContext('2d');
|
const $canvasContext = $SCREENSHOT_CANVAS.getContext('2d');
|
||||||
|
|
||||||
$canvasContext.drawImage($STREAM_VIDEO, 0, 0, $SCREENSHOT_CANVAS.width, $SCREENSHOT_CANVAS.height);
|
$canvasContext.drawImage($STREAM_VIDEO, 0, 0, $SCREENSHOT_CANVAS.width, $SCREENSHOT_CANVAS.height);
|
||||||
|
|
||||||
|
// Get data URL and pass to parent app
|
||||||
|
if (AppInterface) {
|
||||||
|
const data = $SCREENSHOT_CANVAS.toDataURL('image/png').split(';base64,')[1];
|
||||||
|
AppInterface.saveScreenshot(GAME_TITLE_ID, data);
|
||||||
|
callback && callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$SCREENSHOT_CANVAS.toBlob(blob => {
|
$SCREENSHOT_CANVAS.toBlob(blob => {
|
||||||
// Download screenshot
|
// Download screenshot
|
||||||
const now = +new Date;
|
const now = +new Date;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user