From 5e90c82c494567a091ff13a632ec34dd33fa9e1b Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 8 Aug 2017 19:54:45 -0300 Subject: Make keyboard controls work with caps-lock pressed --- src/play.js | 13 ++++++++----- todo.txt | 11 +++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/play.js b/src/play.js index db7088c..6b9f26c 100755 --- a/src/play.js +++ b/src/play.js @@ -348,6 +348,11 @@ async function main(args) { Buffer.concat([escModifier, shiftModifier, Buffer.from([num])]) ) + const equalsChar = char => ( + Buffer.from(char.toLowerCase()).equals(data) || + Buffer.from(char.toUpperCase()).equals(data) + ) + if (Buffer.from([0x20]).equals(data)) { player.togglePause() } @@ -376,7 +381,7 @@ async function main(args) { player.volDown(10) } - if (Buffer.from('s').equals(data)) { + if (equalsChar('s')) { clearConsoleLine() console.log( "Skipping the track that's currently playing. " + @@ -396,15 +401,13 @@ async function main(args) { playController.skipUpNext() } - if ( - Buffer.from('i').equals(data) || - Buffer.from('t').equals(data) - ) { + if (equalsChar('i') || equalsChar('t')) { clearConsoleLine() playController.logTrackInfo() } if ( + equalsChar('q') || Buffer.from('q').equals(data) || Buffer.from([0x03]).equals(data) || // ^C Buffer.from([0x04]).equals(data) // ^D diff --git a/todo.txt b/todo.txt index b8c992d..81243c6 100644 --- a/todo.txt +++ b/todo.txt @@ -278,3 +278,14 @@ TODO: FIFO doesn't work on Windows. TODO: It looks like the SoX player is broken? - Fix this! (Done!) + +TODO: Support caps-lock variants of letter-based keyboard controls, and avoid + separate functionality based on shift being pressed or not. (What this + practically means is - make keyboard controls work even if caps-lock is + pressed!) + (Done!) + +TODO: Only create one converter instance (per DownloadController). + +TODO: More selectors! No-loop/loop options of ordered and shuffled would be + nice. -- cgit 1.3.0-6-gf8a5