// Copyright 2014-2025 Jesper Larsson
//
// This file is part of Klipspringer, <https://klipspringer.avadeaux.net/>
//
// Klipspringer is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// Klipspringer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Klipspringer. If
// not, see <https://www.gnu.org/licenses/>.
import { listenForEvents } from './device_input.js';
// Set up to control players from a little numeric keyboard. Edit it to make it
// work for some other keyboard.
export const setupNumpad = (opts, getCallable, playStream) => {
const KEY_BACKSPACE = 14;
const KEY_TAB = 15;
const KEY_ENTER = 28;
const KEY_KPASTERISK = 55;
const KEY_KP7 = 71;
const KEY_KP8 = 72;
const KEY_KP9 = 73;
const KEY_KPMINUS = 74;
const KEY_KP4 = 75;
const KEY_KP5 = 76;
const KEY_KP6 = 77;
const KEY_KPPLUS = 78;
const KEY_KP1 = 79;
const KEY_KP2 = 80;
const KEY_KP3 = 81;
const KEY_KP0 = 82;
const KEY_KPDOT = 83;
const KEY_KPSLASH = 98;
listenForEvents(opts.numpad, opts.eventsizes, getCallable, [
[1, KEY_KP1, 1, () => { playStream(0) }],
[1, KEY_KP2, 1, () => { playStream(1) }],
[1, KEY_KP3, 1, () => { playStream(2) }],
[1, KEY_KP4, 1, () => { playStream(3) }],
[1, KEY_KP5, 1, () => { playStream(4) }],
[1, KEY_KP6, 1, () => { playStream(5) }],
[1, KEY_KP7, 1, () => { playStream(6) }],
[1, KEY_KP8, 1, () => { playStream(7) }],
[1, KEY_KP9, 1, () => { playStream(8) }],
[1, KEY_KP0, 1, intf => { if (intf && intf.quit) { intf.quit() } }],
[1, KEY_KPDOT, 1, intf => { if (intf && intf.toggle_pause) { intf.toggle_pause() } }]
]);
}
Version: v4.3.2.2 (2026-05-16T17:03:34+02:00)
Raw file
Source code overview
Klipspringer home