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

@ -294,14 +294,15 @@ if( typeof AFRAME != 'undefined '){
await AFRAME.utils.require(this.requires)
let features = { // ISOTerminal plugins
boot: "com/isoterminal/feat/boot.js",
javascript: "com/isoterminal/feat/javascript.js",
jsconsole: "com/isoterminal/feat/jsconsole.js",
indexhtml: "com/isoterminal/feat/index.html.js",
indexjs: "com/isoterminal/feat/index.js.js",
autorestore: "com/isoterminal/feat/autorestore.js",
pastedropFeat: "com/isoterminal/feat/pastedrop.js",
httpfs: "com/isoterminal/feat/httpfs.js",
boot: "com/isoterminal/feat/boot.js",
javascript: "com/isoterminal/feat/javascript.js",
jsconsole: "com/isoterminal/feat/jsconsole.js",
remotekeyboard: "com/isoterminal/feat/remotekeyboard.js",
indexhtml: "com/isoterminal/feat/index.html.js",
indexjs: "com/isoterminal/feat/index.js.js",
autorestore: "com/isoterminal/feat/autorestore.js",
pastedropFeat: "com/isoterminal/feat/pastedrop.js",
httpfs: "com/isoterminal/feat/httpfs.js",
}
if( this.data.emulator == 'fbterm' ){
features['fbtermjs'] = "com/isoterminal/term.js"

View file

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

View file

@ -6,9 +6,9 @@ ISOTerminal.prototype.bootMenu = function(e){
this.boot.menu.selected = false // reset
let msg = '\n\r'
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)
}
@ -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.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()
})