Skip to content

Commit

Permalink
Adding keys and buttons triggers
Browse files Browse the repository at this point in the history
Keys ↑ and ↓ mapped onto chapters, then on playlist #108
  • Loading branch information
dascritch committed Apr 2, 2021
1 parent e3b5eee commit bdcd478
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/build_interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function buildInterface(container) {
container.shadowId(that)?.addEventListener('click', cliquables[that], passiveEvent);
}

// handheld nav to allow long press to repeat action
let _buttons = ['fastreward', 'reward', 'foward', 'fastfoward'];
// *ward : handheld nav to allow long press to repeat action
let _buttons = ['prevcue', 'fastreward', 'reward', 'foward', 'fastfoward', 'nextcue'];
for (let that of _buttons) {
const button_element = container.shadowId(that);
button_element?.addEventListener('pointerdown', pressManager.press);
Expand Down
32 changes: 32 additions & 0 deletions src/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ export const trigger = {
case 32 : // space
toggleplay();
break;
// pageUp 33
// pageDown 34
case 35 : // end
document.CPU.seekElementAt(audiotag, audiotag.duration);
break;
Expand All @@ -369,6 +371,12 @@ export const trigger = {
case KEY_RIGHT_ARROW : // →
seek_relative(+ (document.CPU.keymove * mult));
break;
case 38 : // ↑
event.prevcue(event);
break;
case 40 : // ↓
event.nextcue(event);
break;
default:
return ;
}
Expand Down Expand Up @@ -424,6 +432,30 @@ export const trigger = {
trigger.key(event, document.CPU.fastFactor);
},

/**
* @summary Pressing prevcue button, or hit ↑ key
* Function associated, see below, DO NOT RENAME
*
* @param {Object} event The event
*/
prevcue : function(event) {
let container = findContainer(event.target);
container.focusedId();
console.log('prevcue' , container.focusedId())
},

/**
* @summary Pressing nextcue button, or hit ↓ key
* Function associated, see below, DO NOT RENAME
*
* @param {Object} event The event
*/
nextcue : function(event) {
let container = findContainer(event.target);
container.focusedId();
console.log('prevcue' , container.focusedId())
},

/**
* @summary Refresh document body when changing chapter
*
Expand Down

0 comments on commit bdcd478

Please sign in to comment.