aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/sources
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-02-28 10:21:16 +0900
committerDevine Lu Linvega <[email protected]>2019-02-28 10:21:16 +0900
commit23cb5505533a250ba55ac674ff3b24c5b76a4d46 (patch)
treeac32de4a0b7ef8dcde70d0786efa279fcd5eddc1 /desktop/sources
parent2c38639ea66e18743a35e0d5b2432c261d6daed2 (diff)
downloadOrca-23cb5505533a250ba55ac674ff3b24c5b76a4d46.tar.gz
Orca-23cb5505533a250ba55ac674ff3b24c5b76a4d46.zip
Improved UDP controls
Diffstat (limited to 'desktop/sources')
-rw-r--r--desktop/sources/scripts/io.udp.js19
-rw-r--r--desktop/sources/scripts/terminal.js9
2 files changed, 15 insertions, 13 deletions
diff --git a/desktop/sources/scripts/io.udp.js b/desktop/sources/scripts/io.udp.js
index b9b5213..7101461 100644
--- a/desktop/sources/scripts/io.udp.js
+++ b/desktop/sources/scripts/io.udp.js
@@ -57,17 +57,20 @@ function Udp (terminal) {
this.listener.close()
})
- this.act = function(msg){
- if(msg === 'play'){
+ this.act = function (msg) {
+ const key = `${msg}`.substr(0, 1)
+ const val = parseInt(`${msg}`.substr(1))
+ if (key === 'p') {
terminal.play()
- }
- else if(msg === 'stop'){
+ } else if (key === 's') {
terminal.stop()
- }
- else if(msg === 'run'){
+ } else if (key === 'r') {
terminal.run()
- }
- else{
+ } else if (key === 'f' && Number.isInteger(val)) {
+ terminal.orca.f = val
+ } else if (key === 'b' && Number.isInteger(val)) {
+ terminal.setSpeed(val)
+ } else {
console.warn(`Unknown message: ${msg}`)
}
}
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index 3f2964c..91db20c 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -57,14 +57,14 @@ function Terminal () {
this.update()
}
- this.play = function(){
+ this.play = function () {
console.log('play')
this.isPaused = false
this.update()
this.clock().setRunning(true)
}
- this.stop = function(){
+ this.stop = function () {
console.log('stop')
this.isPaused = true
this.update()
@@ -136,10 +136,9 @@ function Terminal () {
}
this.togglePlay = function () {
- if(this.isPaused === true){
+ if (this.isPaused === true) {
this.play()
- }
- else{
+ } else {
this.stop()
}
}