Skip to content

Add plugin to configure Tapback sensitivity on Kindle 12th Gen - #15968

Open
vitorroman17 wants to merge 10 commits into
koreader:masterfrom
vitorroman17:tapback-plugin
Open

Add plugin to configure Tapback sensitivity on Kindle 12th Gen#15968
vitorroman17 wants to merge 10 commits into
koreader:masterfrom
vitorroman17:tapback-plugin

Conversation

@vitorroman17

@vitorroman17 vitorroman17 commented Aug 29, 2026

Copy link
Copy Markdown

This PR adds a simple plugin (tapback.koplugin) that allows users to configure the sensitivity (threshold) for the hardware tap gesture (accelerometer tapback) on the new Kindle 12th Gen devices.

Currently, the default threshold in the sysfs node is extremely low (1), which makes the device trigger page turns on very light taps or accidental bumps. This plugin provides a UI under More Tools -> Tapback sensitivity to adjust the X, Y, and Z axis thresholds independently and persists the settings across reboots.


This change is Reviewable

@Frenzie

Frenzie commented Aug 29, 2026

Copy link
Copy Markdown
Member

It's a good idea, but the functionality should go in the Kindle device abstraction. If this was co-developed by AI, tell it to look at the Kobo automatic sysfs discovery. Also you're ignoring io.open failure, and you should use ffiUtil.writeToSysfs like the other code. And stick the setting in device or taps & gestures or something. If it was all or mostly you, still do that. ;-) But then I might be less terse.

@Frenzie

Frenzie commented Aug 29, 2026

Copy link
Copy Markdown
Member

PS It should say Save or something like it instead of OK. I'm not sure where that last commit came from. :-)

text = _("Taps and gestures"),
}

if Device:hasFancyTaps() then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems subtly different than the tapback_sysfs_path detection. It does look at a glance like the entire sysfs detection can be skipped if this isn't true but at least the way you phrased it, it sounds like adjusting it can only be done on a subset of devices with hasFancyTaps?

Comment on lines +346 to +348
ffiUtil.writeToSysfs(tostring(x), path .. "/threshold_tap_x")
ffiUtil.writeToSysfs(tostring(y), path .. "/threshold_tap_y")
ffiUtil.writeToSysfs(tostring(z), path .. "/threshold_tap_z")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this doesn't really belong in here but should be defined in the Kindle device definition as something like Kindle:setTapbackSensitivity (for example). I figure you can also add hasTapBackSensitivity() while you're at it.

Comment thread frontend/device/kindle/device.lua Outdated
for file in lfs.dir("/sys/bus/iio/devices") do
if file:match("^iio:device%d+$") then
local path = "/sys/bus/iio/devices/" .. file
local name = ffiUtil.readSysfs(path .. "/name")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test it. ;-)

@Frenzie
Frenzie requested a review from NiLuJe August 29, 2026 21:28
@Frenzie Frenzie added the Kindle label Aug 29, 2026
"gesture_manager",
"gesture_overview",
"gesture_intervals",
"tapback_sensitivity", -- if Device:hasFancyTaps()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should to go inside Page Turns, sandwiched between tap zones and Invert page turns and taps with separator at either end


local dialog
dialog = MultiInputDialog:new{
title = _("Tapback sensitivity\n\n1 = Most sensitive | 31 = Hardest | 0 = Disabled"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is 0-31 really the scale?

in any case, I think something like 1 = Lightest tap | 31 = Hardest tap | 0 = Disabled is a little clearer

@mergen3107

Copy link
Copy Markdown
Contributor

I'll take a look in the coming days :D never used it exactly because it is too sensitive.

@vitorroman17

Copy link
Copy Markdown
Author

Thank you for the detailed feedback! I have restructured the implementation to align with KOReader's architecture:

  1. Moved the core logic to the Kindle device abstraction (frontend/device/kindle/device.lua) with hasTapbackSensitivity(), getTapbackSensitivity(), and setTapbackSensitivity().
  2. Implemented Kobo-style automagic sysfs discovery for the lis2du12_tap IIO device node.
  3. Used ffiUtil.writeToSysfs to safely handle any potential io.open failures.
  4. Integrated the UI into the native Taps and gestures -> Page turns menu, properly sandwiched between tap zones and the inverted reading order settings as requested.
  5. Changed the UI text to 1 = Lightest tap | 31 = Hardest tap | 0 = Disabled for better clarity.

Let me know if there's anything else!

@mergen3107

mergen3107 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Let me know if there's anything else!

Have you seen line-comments above?

Ah, sorry, I think yes. But somehow these comments didn't get auto resolved?
I thought they should once you change the code around them?

@Commodore64user

Copy link
Copy Markdown
Member

Let me know if there's anything else!

Yes, answering why the scale is 0-31. Does kernel set those 32 steps? If yes, would it make sense to translate it to a more sensible 0-10 perhaps?

@Frenzie

Frenzie commented Aug 30, 2026

Copy link
Copy Markdown
Member

Ah, sorry, I think yes. But somehow these comments didn't get auto resolved?
I thought they should once you change the code around them?

They're only partially addressed. Possibly because of forgetting to commit a file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants