Use keyboard key names for navigation on controller.

This commit is contained in:
Bradley Eaton
2025-06-30 16:07:37 +01:00
parent a7d443ab23
commit eff4ca2f19
5 changed files with 20 additions and 56 deletions
-6
View File
@@ -1243,12 +1243,6 @@ export default function (view) {
if (layoutManager.tv && !currentVisibleMenu) {
// Change the behavior of some keys when the OSD is hidden
switch (key) {
case 'NavigationLeft':
case 'NavigationRight':
case 'GamepadLeftThumbLeft':
case 'GamepadLeftThumbRight':
case 'GamepadDPadLeft':
case 'GamepadDPadRight':
case 'ArrowLeft':
case 'ArrowRight':
if (!e.shiftKey) {
-6
View File
@@ -527,18 +527,12 @@ function stepKeyboard(elem, delta) {
*/
function onKeyDown(e) {
switch (keyboardnavigation.getKeyName(e)) {
case 'NavigationLeft':
case 'GamepadDPadLeft':
case 'GamepadLeftThumbLeft':
case 'ArrowLeft':
case 'Left':
stepKeyboard(this, -normalizeSliderStep(this, this.keyboardStepDown));
e.preventDefault();
e.stopPropagation();
break;
case 'NavigationRight':
case 'GamepadDPadRight':
case 'GamepadLeftThumbRight':
case 'ArrowRight':
case 'Right':
stepKeyboard(this, normalizeSliderStep(this, this.keyboardStepUp));
-6
View File
@@ -138,18 +138,12 @@ export class BookPlayer {
if (!this.loaded) return;
switch (key) {
case 'NavigationRight':
case 'GamepadDPadRight':
case 'GamepadLeftThumbRight':
case 'l':
case 'ArrowRight':
case 'Right':
e.preventDefault();
this.next();
break;
case 'NavigationLeft':
case 'GamepadDPadLeft':
case 'GamepadLeftThumbLeft':
case 'j':
case 'ArrowLeft':
case 'Left':
-6
View File
@@ -97,18 +97,12 @@ export class PdfPlayer {
const key = keyboardnavigation.getKeyName(e);
switch (key) {
case 'NavigationRight':
case 'GamepadDPadRight':
case 'GamepadLeftThumbRight':
case 'l':
case 'ArrowRight':
case 'Right':
e.preventDefault();
this.next();
break;
case 'NavigationLeft':
case 'GamepadDPadLeft':
case 'GamepadLeftThumbLeft':
case 'j':
case 'ArrowLeft':
case 'Left':
+20 -32
View File
@@ -24,25 +24,30 @@ const KeyNames = {
// UWP WebView section start --
// Navigation Up/Down/Left/Right is part of TVJS directionalnavigation-1.0.0.0.js
// Unsure what this is used for. Media remote?
138: 'NavigationUp',
139: 'NavigationDown',
140: 'NavigationLeft',
141: 'NavigationRight',
138: 'ArrowUp',
139: 'ArrowDown',
140: 'ArrowLeft',
141: 'ArrowRight',
195: 'GamepadA',
// Currently Xbox UWP WebView 2 sends code 27 (Escape instead) despite being undocumented
// Desktop UWP unchanged
196: 'GamepadB',
203: 'GamepadDPadUp',
204: 'GamepadDPadDown',
205: 'GamepadDPadLeft',
206: 'GamepadDPadRight',
// GamepadB
196: 'Escape',
// DPad Up/Down/Left/Right
203: 'ArrowUp',
204: 'ArrowDown',
205: 'ArrowLeft',
206: 'ArrowRight',
// Currently Xbox UWP WebView 2 sends Arrow keycodes despite being undocumented
// Desktop UWP unchanged
// Left Thumbstick
211: 'GamepadLeftThumbUp',
212: 'GamepadLeftThumbDown',
214: 'GamepadLeftThumbLeft',
213: 'GamepadLeftThumbRight',
// Left Thumbstick Up/Down/Left/Right
211: 'ArrowUp',
212: 'ArrowDown',
214: 'ArrowLeft',
213: 'ArrowRight',
// End of UWP WebView Section
// MediaRewind (Tizen/WebOS)
@@ -68,11 +73,7 @@ const KeyNames = {
/**
* Keys used for keyboard navigation.
*/
const NavigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'BrowserHome', 'Find',
'NavigationUp', 'NavigationDown', 'NavigationLeft', 'NavigationRight',
'GamepadDPadUp', 'GamepadDPadDown', 'GamepadDPadLeft', 'GamepadDPadRight',
'GamepadLeftThumbUp', 'GamepadLeftThumbDown', 'GamepadLeftThumbLeft', 'GamepadLeftThumbRight'];
const NavigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'BrowserHome', 'Find'];
/**
* Keys used for media playback control.
*/
@@ -173,9 +174,6 @@ export function enable() {
let capture = true;
switch (key) {
case 'NavigationLeft':
case 'GamepadDPadLeft':
case 'GamepadLeftThumbLeft':
case 'ArrowLeft':
if (!isInteractiveElement(document.activeElement)) {
inputManager.handleCommand('left');
@@ -183,15 +181,9 @@ export function enable() {
capture = false;
}
break;
case 'NavigationUp':
case 'GamepadDPadUp':
case 'GamepadLeftThumbUp':
case 'ArrowUp':
inputManager.handleCommand('up');
break;
case 'NavigationRight':
case 'GamepadDPadRight':
case 'GamepadLeftThumbRight':
case 'ArrowRight':
if (!isInteractiveElement(document.activeElement)) {
inputManager.handleCommand('right');
@@ -199,9 +191,6 @@ export function enable() {
capture = false;
}
break;
case 'NavigationDown':
case 'GamepadDPadDown':
case 'GamepadLeftThumbDown':
case 'ArrowDown':
inputManager.handleCommand('down');
break;
@@ -209,7 +198,6 @@ export function enable() {
case 'GamepadA':
inputManager.handleCommand('select');
break;
case 'GamepadB':
case 'Back':
inputManager.handleCommand('back');
break;