-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect back button event from LG Magic remote #127
base: main
Are you sure you want to change the base?
Conversation
@@ -19,11 +19,15 @@ class RemoteControlManager implements RemoteControlManagerInterface { | |||
Backspace: SupportedKeys.Back, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this simple change would be enough, wouldn't it? 😁 No need for the rest below. Or maybe I'm missing something?
Backspace: SupportedKeys.Back, | |
Backspace: SupportedKeys.Back, | |
GoBack: SupportedKeys.Back, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish not to use that ugly hack in my code 🤪. What is happening when I pressed the back button on the Lg Magic Remote is that an event is raised with
event.code
empty and event.key === 'GoBack'
The mappedKey
is mapped on event.code
so it doesn't trigger the desired key.
Any idea about how to fix this in a proper way?
🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha alright, that's the thing I missed indeed!
Then this will work. It's just the example app anyway.
My suggestion though would be to make the if branch more explicit as an exit condition (following this). What do you think? 😁
//For LG WebOs Magic Remote
if (event.key === 'GoBack') {
this.eventEmitter.emit('keyDown', SupportedKeys.Back);
return
}
if (!mappedKey) {
return;
}
this.eventEmitter.emit('keyDown', mappedKey);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes! Far better!
It's a sample app, but it's my favorite TV app around! There are some options for the future we can discuss like:
- Promoting this sample as a boilerplate for TV!
I have a private repo of this app I use for studying/experimenting/presenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a reference for using .key
on the event? webOS docs suggest using keyCode === 461
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested on an LG C2 and experienced they key is code
was empty and key
is GoBack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you find that keyCode
was empty as well? If that's the case then their docs are wrong (not the first time) 😅
I don't have a smart remote available, but testing on simulator (v24) and with LG 32LQ630BPUA keyCode
behaves as documented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes keycode was empty using this app. @matthewcaminiti Can you test the app in this repos with your TV/Emulator and check what code is returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good to know! I gotta test on a newer device. May need to use both key
/keyCode
to cover old+new WebOS.
On my TV device (LG 32LQ630BPUA ... old model with latest software) I've yet to figure out how to get logs from it, but when using key === 'GoBack'
it doesn't work, suggesting key
is empty.
On simulator it's as follows:
This to detect the "Back" button of an LG Magic Remote for Web OS.
Tested with the web build of the project.
The appinfo.json of the WebOS project needs to include
"disableBackHistoryAPI": true
More info for LG WebOS here