Skip to content
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

Hardware buttons don't work #5761

Closed
elvvis opened this issue Jan 11, 2020 · 12 comments
Closed

Hardware buttons don't work #5761

elvvis opened this issue Jan 11, 2020 · 12 comments
Labels

Comments

@elvvis
Copy link

elvvis commented Jan 11, 2020

original message

  • KOReader version: v2019.12
  • Device: Tolino Epos 2

Issue

Hardware buttons for turning the pages do not work in landscape mode, but they do in portrait mode.

EDIT

answer for all devices: koreader maps android keycodes to specific actions. See defaults following aosp/sdk/ndk standard keycodes.

If your device don't follow standard google keycodes (mainly because it is a e-ink reader poorly launch'd) you'll need to override the keymap for your device

To log the keycodes used by your device read the next post

@pazos
Copy link
Member

pazos commented Jan 11, 2020

to log input events

  • Start KOReader, go to filemanager
  • Go to the tools menu -> developer options.
  • Enable debug logs

on linux/mac: adb logcat KOReader:* *:S | grep "key event =>"
on windows: adb shell logcat KOReader:* *:S | grep "key event =>".
Note: Legacy versions of windows' adb would require:

adb shell
logcat KOReader:* *:S | grep "key event =>"

Logs are something like


01-11 20:03:36.582 32486 32508 V KOReader:  key event => type: 1, code: 25(LPgFwd), value: 1, time: 1578769416.581970
01-11 20:03:36.925 32486 32508 V KOReader:  key event => type: 1, code: 25(LPgFwd), value: 1, time: 1578769416.925634
01-11 20:03:37.243 32486 32508 V KOReader:  key event => type: 1, code: 25(LPgFwd), value: 1, time: 1578769417.242855
01-11 20:03:37.372 32486 32508 V KOReader:  key event => type: 1, code: 25(LPgFwd), value: 0, time: 1578769417.372304
01-11 20:03:40.362 32486 32508 V KOReader:  key event => type: 1, code: 24(LPgBack), value: 1, time: 1578769420.362321
01-11 20:03:40.552 32486 32508 V KOReader:  key event => type: 1, code: 24(LPgBack), value: 0, time: 1578769420.552092

@elvvis
Copy link
Author

elvvis commented Jan 11, 2020

Here is the log file, entries for the landscape format begin in line 1301.
log.txt

@pazos
Copy link
Member

pazos commented Jan 11, 2020

@elvvis: could you please use the specific command, and just press one time each button in the same order for both portrait and landscape? Thanks!

I'm willing to help but the logs you're providing are not the logs that were requested.

@elvvis
Copy link
Author

elvvis commented Jan 11, 2020

@elvvis: could you please use the specific command, and just press one time each button in the same order for both portrait and landscape? Thanks!

I'm willing to help but the logs you're providing are not the logs that were requested.

Sorry, i can‘t use the specific command, because there is no ‚grep‘ on windows.

@pazos
Copy link
Member

pazos commented Jan 11, 2020

Note: Legacy versions of windows' adb would require:

adb shell
logcat KOReader:* *:S | grep "key event =>"

@elvvis
Copy link
Author

elvvis commented Jan 11, 2020

portrait:
V/KOReader( 4501): key event => type: 1, code: 22(Right), value: 1, time: 1578778454.760083
V/KOReader( 4501): key event => type: 1, code: 22(Right), value: 0, time: 1578778454.978017
V/KOReader( 4501): key event => type: 1, code: 21(Left), value: 1, time: 1578778456.689365
V/KOReader( 4501): key event => type: 1, code: 21(Left), value: 0, time: 1578778456.875**871

landscape:
V/KOReader( 4501): key event => type: 1, code: 22(Right), value: 1, time: 1578778477.939645
V/KOReader( 4501): key event => type: 1, code: 22(Right), value: 0, time: 1578778478.158157
V/KOReader( 4501): key event => type: 1, code: 21(Left), value: 1, time: 1578778480.279840
V/KOReader( 4501): key event => type: 1, code: 21(Left), value: 0, time: 1578778480.438948

@pazos
Copy link
Member

pazos commented Jan 11, 2020

@elvvis: much better, thanks!

As you see they're both the same events in potrait and landscape. So I dunno why it works on portrait and not in landscape.

Anyways, you can override the event map using this as a template and replacing values with the codes you provide.

That is: instead of left/right use LPgBack/LPgFwd. You can map these events as you like so both

return {
   [21] = "LPgBack",
   [22] = "LPgFwd",
}

and

return {
   [21] = "LPgFwd",
   [22] = "LPgBack",
}

should work.

@pazos pazos added firmware wontfix PR are welcomed and removed need more info labels Jan 11, 2020
@elvvis
Copy link
Author

elvvis commented Jan 11, 2020

With customizing the key mappings and use of LPgBack/LPgFwd instead of left/right it works.

@pazos
Copy link
Member

pazos commented Jan 12, 2020

With customizing the key mappings and use of LPgBack/LPgFwd instead of left/right it works.

Cool. I labeled as won't fix as it cannot be fixed programatically. Android ereaders are just like cars but in cars the layout of the pedals is enforced by regulations and laws and nothing is enforcing these devices to follow google keycodes.

It can be workarounded but requires code per device or type of device (like the epd driver). If someone wants to do it feel free to modify https://github.com/koreader/android-luajit-launcher/blob/master/app/src/org/koreader/launcher/DeviceInfo.kt, add a new type of BugDevice and catch your model. So you can return an event map different from defaults.

The workaround is simpler to do and easier to keep updated for borked devices (ie: keeping the wiki in sync with new reports).

Just like in #5364 we might want to stick with google best practices, allow PR for specific devices and keep the issue open to allow future duplicates.

I'll update the title and OP with the relevant info.

@pazos pazos changed the title Hardware buttons in landscape format Hardware buttons don't work Jan 12, 2020
@Frenzie
Copy link
Member

Frenzie commented Feb 5, 2020

@pazos Should this be closed?

@pazos
Copy link
Member

pazos commented Feb 5, 2020

The issue is linked in https://github.com/koreader/koreader/wiki/Android-tips-and-tricks, so it should be ok to close it if we close future duplicates too.

@Frenzie
Copy link
Member

Frenzie commented Feb 5, 2020

Alright, I'll close it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants