aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/sources
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-04 14:19:23 +1200
committerDevine Lu Linvega <[email protected]>2018-12-04 14:19:23 +1200
commitd2ac12e3a3185cf9f35bf1c0b977e43e13c856c3 (patch)
tree820b6db216e96727ac63fc8c82063a3b0e2fce94 /desktop/sources
parenta210116160bfe5a8e4b8f4a59727d9c7a2883c7d (diff)
downloadOrca-d2ac12e3a3185cf9f35bf1c0b977e43e13c856c3.tar.gz
Orca-d2ac12e3a3185cf9f35bf1c0b977e43e13c856c3.zip
Progress on keys operator
Diffstat (limited to 'desktop/sources')
-rw-r--r--desktop/sources/scripts/io.js14
-rw-r--r--desktop/sources/scripts/keyboard.js5
-rw-r--r--desktop/sources/scripts/terminal.js3
3 files changed, 12 insertions, 10 deletions
diff --git a/desktop/sources/scripts/io.js b/desktop/sources/scripts/io.js
index 5f89cb5..191d6c5 100644
--- a/desktop/sources/scripts/io.js
+++ b/desktop/sources/scripts/io.js
@@ -5,7 +5,7 @@ function IO (terminal) {
this.midi = { device: 0 }
this.outputs = []
- this.stack = null
+ this.stack = { keys: [] }
this.start = function () {
this.clear()
@@ -13,7 +13,8 @@ function IO (terminal) {
}
this.clear = function () {
- this.stack = { udp: [], midi: [], keys: [] }
+ this.stack.udp = {}
+ this.stack.midi = {}
}
this.run = function () {
@@ -25,9 +26,6 @@ function IO (terminal) {
for (const id in this.stack.midi) {
this.playMidi(this.stack.midi[id])
}
- for (const id in this.stack.keys) {
- this.playKey(this.stack.keys[id])
- }
}
// Keyboard
@@ -37,7 +35,7 @@ function IO (terminal) {
}
this.playKey = function (key) {
- console.log(key)
+ // Idle. Read by the ! operator.
}
// UDP
@@ -64,6 +62,8 @@ function IO (terminal) {
}
this.playMidi = function (data) {
+ if (!this.outputs[device]) { console.warn('No midi device!'); return }
+
const device = this.midi.device
const channel = convertChannel(data[0])
const note = convertNote(data[1], data[2])
@@ -135,7 +135,7 @@ function IO (terminal) {
}
this.length = function () {
- return this.stack.udp.length + this.stack.midi.length
+ return this.stack.udp.length + this.stack.midi.length + this.stack.keys.length
}
this.toString = function () {
diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js
index 9cc52b8..fb34a59 100644
--- a/desktop/sources/scripts/keyboard.js
+++ b/desktop/sources/scripts/keyboard.js
@@ -48,12 +48,13 @@ function Keyboard (orca, terminal) {
if (event.key.length === 1) {
// Send key
- if ((event.metaKey || event.ctrlKey)) {
+ if (this.mode === 1 && event.key !== '/') {
terminal.io.sendKey(event.key)
event.preventDefault()
return
+ } else {
+ terminal.cursor.write(event.key)
}
- terminal.cursor.write(event.key)
terminal.update()
}
}
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index 99eaf19..21f3579 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -30,6 +30,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.resize()
host.appendChild(this.el)
this.theme.install(host)
+ orca.terminal = this
}
this.start = function () {
@@ -176,7 +177,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.write(`${this.cursor.x},${this.cursor.y}`, col * 0, 1, this.size.grid.w)
this.write(`${this.cursor.w}:${this.cursor.h}`, col * 1, 1, this.size.grid.w)
this.write(`${this.cursor.inspect()}`, col * 2, 1, this.size.grid.w)
- this.write(`${this.source}${this.cursor.mode === 1 ? '+' : ''}`, col * 3, 1, this.size.grid.w)
+ this.write(`${this.source}${this.keyboard.mode === 1 ? '^' : this.cursor.mode === 1 ? '+' : ''}`, col * 3, 1, this.size.grid.w)
// Grid
this.write(`${orca.w}x${orca.h}`, col * 0, 0, this.size.grid.w)
this.write(`${this.size.grid.w}/${this.size.grid.h}`, col * 1, 0, this.size.grid.w)