Skip to content

Commit

Permalink
Add --fullscreen and --connect=F400000000000000 arguments for launchi…
Browse files Browse the repository at this point in the history
…ng the app in fullscreen and auto-connect to console #312
  • Loading branch information
unknownskl committed Jul 16, 2022
1 parent 8f10850 commit a9116a0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## v1.2.0-beta6 - 2022-07-16
- Fix error retrieving xCloud token 'InvalidCountry' #300 (credits to `award` on the OpenXbox discord)
- Fix message 'No friends online' when no friends are online
- Added `--fullscreen` argumments to launch app in fullscreen #312
- Added switch `--connect=F400000000000000` argumments to auto-connect to a console #312
- Updated dependencies

## v1.2.0-beta5 - 2022-07-06
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"main": ".webpack/main",
"scripts": {
"start": "ISDEV=true electron-forge start",
"startfullscreen": "ISDEV=true electron-forge start -- --fullscreen",
"startconnect": "ISDEV=true electron-forge start -- --connect=F400000000000000",
"compile": "electron-forge make",
"test": "echo \"Error: no test specified\" && exit 1",
"package": "electron-forge package",
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default class Application {
const inputxCloudStreamingToken = document.getElementById('token_xcloud_streaming_token')
const inputxCloudStreamingHost = document.getElementById('token_xcloud_streaming_host')
const inputxCloudMSALToken = document.getElementById('token_xcloud_msal_token')
const inputAutoconnect = document.getElementById('switch_autoconnect')

const inputWebTokenInterval = setInterval(() => {
const valueUhs = (<HTMLInputElement>inputWebUhs).value
Expand Down Expand Up @@ -231,6 +232,12 @@ export default class Application {
this._tokenStore.addEventListener('onstreamingtoken', (token) => {
if(this._tokenStore._web.uhs !== '' && this._tokenStore._streamingToken !== ''){
this._router.setView('app')

// Check if we have an auto-connect token
const consoleId = (<HTMLInputElement>inputAutoconnect).value
if(consoleId !== ''){
this.startStream('xhome', consoleId)
}
}
})

Expand Down
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
function setxCloudMSALToken(token){
document.getElementById('token_xcloud_msal_token').value = token
}
function setAutoconnect(consoleId){
document.getElementById('switch_autoconnect').value = consoleId
}
window.addEventListener('resize', () => {
if(document.getElementById('videoHolder') !== null && document.querySelector("#videoHolder video") !== null) {
var videoRender = document.querySelector("#videoHolder video")
Expand All @@ -37,6 +40,7 @@
<input id="token_xcloud_streaming_token" value="" type="hidden" />
<input id="token_xcloud_streaming_host" value="" type="hidden" />
<input id="token_xcloud_msal_token" value="" type="hidden" />
<input id="switch_autoconnect" value="" type="hidden" />

<div id="appRoot">

Expand Down
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import * as path from 'path';
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;

const switches = {
fullscreen: false,
autoconnect: false,
connectConsoleId: ''
}

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
Expand All @@ -31,6 +37,7 @@ const createWindow = (): void => {
mainWindow = new BrowserWindow({
width: 1500,
height: 875,
fullscreen: switches.fullscreen,

webPreferences: {
nodeIntegration: true,
Expand Down Expand Up @@ -107,6 +114,13 @@ app.on('ready', () => {
tokenStore.addEventListener('onstreamingtoken', (token:any) => {
mainWindow.webContents.executeJavaScript("setStreamingToken('"+token+"');");
console.log('xhome tokens set')

// Lets set the consoleid of the console we want to connect to
if(switches.autoconnect === true && switches.connectConsoleId != ''){
mainWindow.webContents.executeJavaScript("setAutoconnect('"+switches.connectConsoleId+"');");
// mainWindow.webContents.executeJavaScript("startStream('"+switches.connectConsoleId+"');");
// .startStream('xhome', consoles[device].serverId)
}
})

tokenStore.addEventListener('onxcloudstreamingtoken', (token:any) => {
Expand Down Expand Up @@ -183,6 +197,26 @@ app.on('activate', () => {
}
});

console.log('Bootstrapping Xbox-xCloud-Client using args:', process.argv)

// Read fullscreen switch
if(process.argv.includes('--fullscreen')){
console.log('- Fullscreen switch acive')
switches.fullscreen = true
}

// Read auto-connect switch
// if(process.argv.includes('--connect')){
for(const arg in process.argv){
if(process.argv[arg].includes('--connect')){
// got value:
console.log('- Connect switch active, value:', process.argv[arg].substring(10))
switches.autoconnect = true
switches.connectConsoleId = process.argv[arg].substring(10)
}
}
// }

// appMenu().renderMenu()
const menu = new appMenu()

Expand Down

0 comments on commit a9116a0

Please sign in to comment.