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

Input/Device: Refactor Gyro events handling #9935

Merged
merged 32 commits into from Dec 21, 2022

Conversation

NiLuJe
Copy link
Member

@NiLuJe NiLuJe commented Dec 20, 2022

Handle a single, custom protocol in Input, and move the platform-specific translation to Device implementations.

This allows us to get rid of a whole bunch of nastiness from Input, as the Kindle handling in particular was... not pretty ;).

Also, tweak how input events hooks can be built to allow for a single composite hook on Kobo, instead of repeating and nesting calls.

Only tested on Kobo so far (I don't have any other gyro-enabled device anyway ;p).

Depends on koreader/koreader-base#1568 (re: #9873)


  • Get rid of the canToggleGSensor Device cap, it's now mandatory for hasGSensor devices. (This means Kindles can now toggle the gyro, fix "Lock auto rotation to current orientation" is unchecked, grayed out #9136).
  • This means that Device:toggleGSensor is now implemented by Generic.
  • Update the Screen & Gyro rotation constants to be clearer (c.f., Groundwork for a refactor of gyro handling koreader-base#1568) (/!\ This might conceivably break some rotation_map user-patches).
  • Input: Move the platform-specific gyro handling to Device implementations, and let Input only handle a single, custom protocol (EV_MSC:MSC_GYRO).
  • Input: Refine the rotation_map disable method implemented in 43b021d. Instead of directly poking at the internal field, use a new method, disableRotationMap (/!\ Again, this might break some rotation_map user-patches).
  • Input: Minor tweaks to event adjust hooks to make them more modular, allowing the Kobo implementation to build and use a single composite hook. API compatibility maintained with wrappers.

This change is Reviewable

frontend/device/input.lua Outdated Show resolved Hide resolved
Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

(approval relates to the principle, no opinion as to whether the Kindle stuff was correctly transplanted :-P)

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 12 files at r1, 16 of 16 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pazos, @poire-z, and @rjd22)

Copy link
Contributor

@rjd22 rjd22 left a comment

Choose a reason for hiding this comment

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

Looks good to me. After this is merged I will make and new PR for the PocketBook gyro detection. For enabling and disabling the gyro I will let users do that in the config menu of PocketBook itself. That will require less supporting code from our side.

@NiLuJe
Copy link
Member Author

NiLuJe commented Dec 20, 2022

For enabling and disabling the gyro I will let users do that in the config menu of PocketBook itself.

If all goes well, the standard "ignore the events" approach implemented here should Just Work (TM) anyway ;).

We're unlikely to confuse them with KEY_ evdev constants,
and those are in the FFI C namespace anyway.
Get rid of the gyro toggle flag, use pointer comparisons to infer the
state instead
It's meaningless, the translation is now mandatory.
Comment it instead it's just here for documentation anyway
anything platform-specific in there once I'm done
There are only a couple platforms where this will matter anyway ;).
It's only used by the debug codepath, which sits *before* translation
It's now mandatory if hasGSensor

Move toggleGSensor to Generic, as it now *is* platform-agnostic ;).
(Still needs the hasGSensor cap, though. Left for koreader#9873 to deal with
;)).
But am going to write compat wrappers instead of doing this ;p
Make sure it always exist (again), and instead move disabling it to an
actual method, instead of having to fiddle with internal instance
objects directly.

Will break some user patches \o/.
We'll see them on PB, because event mangling happens before waitEvent
(the whole thing is synthetic, instead of mutating a real live evdev
feed via event hooks).
them.

"rotated" doesn't mean anything (in fact, "portrait rotated" sounds like
landscape to me :s), and doesn't actually tell you *which way* it's been
rotated.
The fact that UR happens to be Portrait on almost every platform we care
about is a quirk of fate, that wouldn't be true on a TV, so, get rid of
that assumption, at least from the names ;o). (the code... still does
^^).

TL;DR: As usual, LinuxFB had it right, so, follow its inspiration, but
be more wordy to make it clear we're talking about how the *device* is
physically rotated in the real world.
Let's hope for the best, I guess? :D.
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.

"Lock auto rotation to current orientation" is unchecked, grayed out
3 participants