added remote keyboard bootmenu
All checks were successful
/ mirror_to_github (push) Successful in 29s
/ test (push) Successful in 5s

This commit is contained in:
Leon van Kammen 2025-02-14 12:08:14 +01:00
parent 16b8ab7122
commit e36c56ffce
5 changed files with 118 additions and 75 deletions

View file

@ -297,6 +297,7 @@ if( typeof AFRAME != 'undefined '){
boot: "com/isoterminal/feat/boot.js", boot: "com/isoterminal/feat/boot.js",
javascript: "com/isoterminal/feat/javascript.js", javascript: "com/isoterminal/feat/javascript.js",
jsconsole: "com/isoterminal/feat/jsconsole.js", jsconsole: "com/isoterminal/feat/jsconsole.js",
remotekeyboard: "com/isoterminal/feat/remotekeyboard.js",
indexhtml: "com/isoterminal/feat/index.html.js", indexhtml: "com/isoterminal/feat/index.html.js",
indexjs: "com/isoterminal/feat/index.js.js", indexjs: "com/isoterminal/feat/index.js.js",
autorestore: "com/isoterminal/feat/autorestore.js", autorestore: "com/isoterminal/feat/autorestore.js",

View file

@ -216,26 +216,24 @@ ISOTerminal.prototype.getLoaderMsg = function(){
] ]
let motd = ` let motd = `
\r . . ____ _____________ ________. ._. ._. . . \r. . ____ _____________ ________. ._. ._. . .
\r . . .\\ \\/ /\\______ \\/ _____// | \\. . \r. . .\\ \\/ /\\______ \\/ _____// | \\. .
\r . . . \\ / | _/\\_____ \\/ ~ \\ . \r. . . \\ / | _/\\_____ \\/ ~ \\ .
\r . . . / \\ | | \\/ \\ Y / . \r. . . / \\ | | \\/ \\ Y / .
\r . . ./___/\\ \\ |____|_ /_______ /\\___|_ /. . \r. . ./___/\\ \\ |____|_ /_______ /\\___|_ /. .
\r . . . . . .\\_/. . . . \\/ . . . .\\/ . . _ \\/ . . \r. . . . . .\\_/. . . . \\/ . . . .\\/ . . _ \\/ . .
\r https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬ \r https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬
\r local-first, polyglot, unixy WebXR IDE & runtime \rlocal-first, polyglot, unixy WebXR IDE & runtime
\r \r
\r credits \rcredits
\r ------- \r-------
\r @nlnet@nlnet.nl \rhttps://www.w3.org/TR/webxr
\r @lvk@mastodon.online \rhttps://xrfragment.org
\r @utopiah@mastodon.pirateparty.be  \rhttps://threejs.org
\r https://www.w3.org/TR/webxr \rhttps://aframe.org
\r https://xrfragment.org \rhttps://busybox.net
\r https://threejs.org \rhttps://buildroot.org
\r https://aframe.org \rfediverse: @lvk@mastodon.online @utopiah@mastodon.pirateparty.be @nlnet@nlnet.nl
\r https://busybox.net
\r https://buildroot.org
\r` \r`
const text_color = "\r" const text_color = "\r"

View file

@ -6,9 +6,9 @@ ISOTerminal.prototype.bootMenu = function(e){
this.boot.menu.selected = false // reset this.boot.menu.selected = false // reset
let msg = '\n\r' let msg = '\n\r'
this.boot.menu.map( (m) => { this.boot.menu.map( (m) => {
msg += `\r ${m.key}) ${m.title(this.opts)}\n` msg += `\r${m.key}) ${m.title(this.opts)}\n`
}) })
if( this.boot.menu.length ) msg += `\n\r enter choice> ` msg += `\n\renter choice> `
this.send(msg) this.send(msg)
} }
@ -51,49 +51,3 @@ if( typeof window.PromiseWorker != 'undefined' ){ // if xrsh v86 is able to run
) )
} }
// REPL: jsconsole
ISOTerminal.prototype.boot.menu.push(
{
key: "j",
title: (opts) => "just give me an javascript-console in WebXR instantly",
init: function(){
this.prompt = "\r> "
this.emit('enable-console',{stdout:true})
this.emit('status',"javascript console")
this.console = ""
setTimeout( () => {
this.send(this.prompt)
}, 100 )
},
keyHandler: function(ch){
let erase = false
if( ch == '\x7F' ){
ch = "\b \b" // why does write() not just support \x7F ?
erase = true
}
this.send(ch)
const reset = () => {
this.console = ""
setTimeout( () => {
if( this.boot.menu.selected ) this.send(this.prompt)
},100)
}
if( (ch == "\n" || ch == "\r") ){
try{
this.send("\n\r")
if( this.console ) eval(this.console)
reset()
}catch(e){
reset()
throw e // re throw
}
}else{
if( erase ){
this.console = this.console.split('').slice(0,-1).join('')
}else{
this.console += ch
}
}
}
}
)

View file

@ -79,4 +79,52 @@ ISOTerminal.addEventListener('init', function(){
this.addEventListener('enable-console', function(opts){ this.addEventListener('enable-console', function(opts){
this.enableConsole(opts.detail) this.enableConsole(opts.detail)
}) })
// REPL: jsconsole
ISOTerminal.prototype.boot.menu.push(
{
key: "j",
title: (opts) => "just give me an javascript-console in WebXR instantly",
init: function(){
this.prompt = "\r> "
this.emit('enable-console',{stdout:true})
this.emit('status',"javascript console")
this.console = ""
setTimeout( () => {
this.send(this.prompt)
}, 100 )
},
keyHandler: function(ch){
let erase = false
if( ch == '\x7F' ){
ch = "\b \b" // why does write() not just support \x7F ?
erase = true
}
this.send(ch)
const reset = () => {
this.console = ""
setTimeout( () => {
if( this.boot.menu.selected ) this.send(this.prompt)
},100)
}
if( (ch == "\n" || ch == "\r") ){
try{
this.send("\n\r")
if( this.console ) eval(this.console)
reset()
}catch(e){
reset()
throw e // re throw
}
}else{
if( erase ){
this.console = this.console.split('').slice(0,-1).join('')
}else{
this.console += ch
}
}
}
}
)
}) })

View file

@ -0,0 +1,42 @@
ISOTerminal.prototype.enableRemoteKeyboard = function(opts){
// initialize REPL
ISOTerminal.prototype.boot.menu.push(
{
key: "k",
title: (opts) => "connect a remote keyboard",
init: function( mainmenu ){
this.emit('status',"")
this.emit('enable-console',{stdout:true})
setTimeout( () => {
this.send("\n\r1. open a terminal on your laptop/desktop\n\r")
this.send("2. run (or install) the keyboard forwarder:\n\n\r")
this.send("\t$ wget https://xrsh.isvery.ninja/xrsh\n\r")
this.send("\t$ chmod +x xrsh\n\r")
this.send("\t$ ./xrsh --keyboard\n\r\n\r")
this.send("\tNOTE: windows-users need WSL\n\n\r")
this.send("press a key to connect.. (or 'm' for mainmenu)\n\r")
}, 100 )
},
keyHandler: function(ch){
this.send(ch)
if( ch == 'm'){
this.bootMenu()
}else if( (ch == "\n" || ch == "\r") ){
try{
console.log("running websocket server")
this.send("\n\r")
}catch(e){
reset()
throw e // re throw
}
}
}
}
)
}
ISOTerminal.addEventListener('init', function(){
this.enableRemoteKeyboard()
})