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

Support auto-detection of input devices via fbink_input #11807

Merged
merged 38 commits into from
May 15, 2024

Conversation

NiLuJe
Copy link
Member

@NiLuJe NiLuJe commented May 12, 2024

  • Kobo: Drop a bunch of if ladder crap and switch to auto-detection of input devices via fbink_input
  • Kindle: Drop an even larger bundle of crap to do the same ;p. (re: KOReader not starting (Kindle Scribe) #11392)
  • ExternalKeyboard: Switch to fbink_input to whitelist keyboards instead of the manual parsing of caps via its FindKeyboard class
  • Input: Extended open/close wrappers to handle logging & tracking of dupe open/close calls.

Depends on koreader/koreader-base#1782 & koreader/koreader-base#1785


This change is Reviewable

Copy link
Member Author

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Frenzie, @pazos, and @poire-z)

@mergen3107
Copy link
Contributor

Thanks @NiLuJe ! That looks awesome and neat!

Let me give it a test :D

@mergen3107
Copy link
Contributor

Also, will Kindle Voyage's "sensor" buttons be OK?

@NiLuJe
Copy link
Member Author

NiLuJe commented May 12, 2024

Also, will Kindle Voyage's "sensor" buttons be OK?

Hopefully ;p.

Let me give it a test :D

In addition to both PR's content, you'll need this extra library in koreader's libs folder:
libfbink_input-KINDLE.tar.gz

@mergen3107
Copy link
Contributor

Both PRs? Am I missing a second PR?

@mergen3107
Copy link
Contributor

Ah, sorry, I missed koreader-base PR ref

@Commodore64user
Copy link
Contributor

Also, will Kindle Voyage's "sensor" buttons be OK?

Hopefully ;p.

why would they not?

@mergen3107
Copy link
Contributor

@NiLuJe
I updated KOReader to latest nightly, applied this PR (OK), copied the lib file, then tried to apply diff from base PR (not OK).
It complained that CMakeLists and other stuff doesn't exist, so I removed those diff parts and left only the part where it creates the ffi file.

Result is this:

---------------------------------------------
                launching...
  _  _____  ____                _
 | |/ / _ \|  _ \ ___  __ _  __| | ___ _ __
 | ' / | | | |_) / _ \/ _` |/ _` |/ _ \ '__|
 | . \ |_| |  _ <  __/ (_| | (_| |  __/ |
 |_|\_\___/|_| \_\___|\__,_|\__,_|\___|_|

 It's a scroll... It's a codex... It's KOReader!

 [*] Current time: 05/12/24-15:20:34
 [*] Version: v2024.04-34-gbaab32633_2024-05-11

ffi.load: libs/libutf8proc.so.3
ffi.load: blitbuffer
05/12/24-15:20:34 DEBUG fts: Preferred MONOTONIC clock source is CLOCK_MONOTONIC 
05/12/24-15:20:34 DEBUG fts: Preferred REALTIME clock source is CLOCK_REALTIME 
05/12/24-15:20:34 DEBUG fts: BOOTTIME clock source is supported 
05/12/24-15:20:34 DEBUG FB info (post fixup) {
  bpp = 8,
  fb_size = 4642560,
  height_mm = 208,
  line_length = 1872,
  mmio_len = 0,
  rotate = 3,
  smem_len = 9285120,
  stride_pixels = 1872,
  type = 0,
  width_mm = 156,
  xoffset = 0,
  xres = 1860,
  xres_virtual = 1860,
  yoffset = 0,
  yres = 2480,
  yres_virtual = 2480
} --[[table: 0xb6bbf9e8]] 
05/12/24-15:20:34 DEBUG FB mapped at cdata<void *>: 0xb6192000 of 4644864 bytes 
ffi.load: sqlite3
ffi.load: fbink_input
ffi.load (assisted searchpath): ./libs/libfbink_input.so.1
[FBInk] /dev/input/event0: `bd71828-pwrkey` = KEY | POWER_BUTTON
[FBInk] /dev/input/event1: `kx132-accel` = ACCELEROMETER | ROTATION_EVENT
[FBInk] /dev/input/event2: `WacomDigitizer` = TABLET | ROTATION_EVENT
[FBInk] /dev/input/event3: `pt_mt` = TOUCHSCREEN
[FBInk] /dev/input/event4: `stylus-custom` = TABLET | ROTATION_EVENT | SCALED_TABLET
05/12/24-15:20:34 DEBUG Opening input device pt_mt @ /dev/input/event3 
./luajit: frontend/device/kindle/device.lua:225: attempt to index field 'input' (a nil value)
stack traceback:
	frontend/device/kindle/device.lua:225: in function 'openInputDevices'
	frontend/device/kindle/device.lua:297: in function 'init'
	frontend/device/kindle/device.lua:1306: in function 'init'
	frontend/device.lua:62: in main chunk
	[C]: in function 'require'
	./reader.lua:151: in main chunk
	[C]: at 0x00013ebd

@mergen3107
Copy link
Contributor

L225 is this:

                self.input.open(path)

@mergen3107
Copy link
Contributor

That was on KOReader on Scribe.
Let go and try to apply PRs in dev env and compile :D

@NiLuJe
Copy link
Member Author

NiLuJe commented May 12, 2024

Oops, oversight; would only have happened on devices without keys. Previous commit should take care of it, thanks!

@mergen3107
Copy link
Contributor

Thanks! With this fix, it worked great!

ffi.load (assisted searchpath): ./libs/libfbink_input.so.1
[FBInk] /dev/input/event0: `bd71828-pwrkey` = KEY | POWER_BUTTON
[FBInk] /dev/input/event1: `kx132-accel` = ACCELEROMETER | ROTATION_EVENT
[FBInk] /dev/input/event2: `WacomDigitizer` = TABLET | ROTATION_EVENT
[FBInk] /dev/input/event3: `pt_mt` = TOUCHSCREEN
[FBInk] /dev/input/event4: `stylus-custom` = TABLET | ROTATION_EVENT | SCALED_TABLET
05/12/24-15:33:22 DEBUG Opening input device pt_mt @ /dev/input/event3 
05/12/24-15:33:22 DEBUG Opening input device stylus-custom @ /dev/input/event4 
05/12/24-15:33:22 DEBUG Opening (gyro event) input device kx132-accel @ /dev/input/event1 
[ko-input] Forked off fake event generator (pid: 18030)

Full log, test inputs, then exit:
crashlog_success.txt

We don't want to define it multiple times in case of funky caps,
and it's likely to be event0 anyway.
Instead of having to deal with this in Device or Plugin
implementations...
The default imp is not FFI at all, it's a Lua/C module.

True, we *also* have platform-specific imps via FFI, though.
number.

Update ExternalKeyboard accordingly, and make it ask for an explicit
Input close on unplug.

We previously relied on an internal ENODEV check in the Lua/C module.
Also tweak logging some more
Deduping & logging is handled by Input itself
That nobody ever uses because it requires both a rooted device,
*and* manual intervention to allow access to the char devices.
The FFI wrappers don't use it anyway
In cases the input backend already closed the fd, we still need to clear
our array
We still need this wrapper to clear the hash, as we can't do that from
the C module.
@NiLuJe
Copy link
Member Author

NiLuJe commented May 14, 2024

Moved the logging & dupe protection logic to Input itself, which requires a mild API addition to the Lua/C module.

And to rework the wrappers for the custom FFI imps so as not to break on that, because the standard wrappers expect a concept of paths & fd to begin with, and particularly that (Lua) open/close take a path, as it's used to index a hashmap.

Since none of the FFI imps do that (they pass no arguments), they need simple wrappers that do nothing more than forward the call.

Copy link
Member Author

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 7 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Frenzie, @pazos, and @poire-z)

Copy link
Member Author

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Frenzie, @pazos, and @poire-z)

@NiLuJe NiLuJe merged commit fd5260f into koreader:master May 15, 2024
4 checks passed
@NiLuJe NiLuJe added this to the 2024.05 milestone May 15, 2024
NiLuJe added a commit to NiLuJe/koreader that referenced this pull request May 15, 2024
Somehow managed to skip my mind, but, IIRC, they're often on a separate
input device.

Regression since koreader#11807
NiLuJe added a commit that referenced this pull request May 15, 2024
…input-scan misdetections (#11827)

* Kindle: Don't forget to open INPU_DPAD devices for the fiveways. Somehow managed to skip my mind, they're often on a separate input device.

Regression since #11807

* Update FBInk to fix a few cases of input_scan misdetection (on misconfigured drivers (e.g., no DIRECT prop on supported kernels), or old kernels with no EVIOCGPROP support).

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

Successfully merging this pull request may close these issues.

None yet

3 participants