Commit Graph

279 Commits (master)

Author SHA1 Message Date
NiLuJe 72250daba8 UI: Add a verbose debug logging checkbox next to "Report a bug"
@hius07 mentioned something to that effect a while back, makes sense.

Unlike the set of checkmarks in the dev settings, this one flips both
debug + verbose at once, *and* asks for a restart for framebuffer's
sake.

Also update the "Report a bug" spiel to request verbose debug logs.
4 months ago
NiLuJe a2e0642998 Cervantes: Make sure the warmth scaling is accurate
For some mysterious reason, we init fl_warmth_max to 100 on Kobo &
Cervantes, despite this being the case on absolutely none of them.

TL;DR: We update it according to nl_max during init, but this was
missing on Cervantes.
5 months ago
NiLuJe 12bea3b14b
Kindle: Handle the PW5 SE properly (#11049)
Need to poke elsewhere for its Input device

Fix #11048
6 months ago
NiLuJe 2ff60ce04f
Kobo: Deal with some more frontlight edge cases on devices with the AW99703 PWM controller (#10971)
Namely, skip ramping when going to/from <= 2% frontlight, otherwise we just eat the delay for no good reason (1%), or it just stutters and looks bad (2%).

Fix #10970
7 months ago
NiLuJe 55ea10655f
Revert "Kobo: Disable HW inversion on MTK (#10841)" (#10928)
This reverts commit e7e0d2edb6.

Whatever's actually going on with nightmode, this isn't it.
This was independently confirmed to behave as expected,
and the issue that prompted this was *not* fixed by this commit.
8 months ago
zwim bedd422669
AutoSuspend: Handle a few corner-cases better (#10797)
* Enforce a minimal standby timer for the first standby after a resume.
* On Kobo, sleep a bit before standby.

This aims to alleviate race conditions causing visible refresh glitches on sunxi, especially when using an extremely low standby timer (i.e., below the defaults).
8 months ago
NiLuJe e7e0d2edb6
Kobo: Disable HW inversion on MTK (#10841)
Apparently, that doesn't quite work...

Followup to #10719
8 months ago
NiLuJe 5146358605 NetworkManager: Allow backends to report connection failures early
As early as turnOnWifi.
Implement it on hasWifiManager platforms, preventing useless
connectivity checks to run when they're obviously never going to work
because you're out of range of your AP.

Also implemented a flag to notify the backend if the connection attempt
was interactive or not.
Right now, interactive is extremely restricted, it basically means the
menu checkmark, or a gesture.
The intent being that for stuff like the beforeWifiAction framework, we
don't want the backend to spawn extra UI.
Specifically, for hasWifiManager platforms, we no longer spawn the AP
scan list on failure unless the caller was interactive.

TL;DR: beforeWifiAction is now much less obnoxious when you're obviously
not able to connect.
9 months ago
NiLuJe 22678ee5ff Misc: Review pass on the previous commits
* Unbreak the Device test
* Rename a few things
* Tweak a few comments
9 months ago
NiLuJe f44f92a864 Kobo: Run Generic:init dead last, like every other platform
This is semantically more correct, and should prevent platform-specific
weirdness if an ordering concern ever comes up (e.g., like it did for
the viewport stuff).
9 months ago
NiLuJe f4aca567ef Kobo: Allow disabling key repeats
Re #10743

Note that this only makes faulty switches slightly less annoying: for a
stuck switch, instead of a string of page turns, you'll get a single
missed page turn on the tap that actually releases the stuck contact...
9 months ago
NiLuJe 0db7509fe2
Kobo: Fix the input translation on the Elipsa 2E (#10802)
Apparently it mirrors on the Y axis. Or the panel vs. touch rotations are wonkier than expected or ...something.
9 months ago
zwim ac143ca9d6
Add forgotten f:close() (#10796) 9 months ago
NiLuJe 9c8e55b3e5
Kobo: Yet another attempt at working around the hangs on the latest NXP boards (#10771)
* Notification: Drop the fencing from #10083; it never actually helped, and had subtle side-effects we could do without.
* VirtualKeyBoard: Flash on close, otherwise, some of the fast refresh glitches may be burned into the working buffer until a flash. Making sure we flash ourselves prevent it from sticking around on the page ;).
* util: Move `writeToSysfs` to base (i.e., `ffi/util`), as we need it there (and it actually makes more sense there anyway ;p).
* Bump base for https://github.com/koreader/koreader-base/pull/1645, which is where the actual workaround (hopefully) lives.

Re #8414, #9806, #10558
9 months ago
NiLuJe 689d9e2976
Kobo: Initial Elipsa 2E support (#10719)
Untested, but mostly everything should be there ;p.

Bumps base for MTK support (https://github.com/koreader/koreader-base/pull/1642)
9 months ago
NiLuJe 9ceb07a4c6
Kobo: Unbreak Aura One support (#10758)
Regression since #10728, Fix #10757
9 months ago
NiLuJe 21949c5521 Kobo: Apply the AW99703 smooth ramp off fix to all affected devices
e.g., at least the Clara 2E features the same controller & driver,
but it is likely found on a few other models.
10 months ago
NiLuJe d57325aaf6
NetworkManager: Enable "before wifi" action support on every hasWifiToggle platform (#10669)
* Enable before_wifi_action & after_wifi_action on hasWifiToggle platforms (which is basically all of 'em except naked SDL).
* Decouple restoreWifiAsync from hasWifiManger, because we can do that on other platforms (namely, Kindle. Probably PB, too, but WiFi is already a mess there, and I can't test it).
* Implement restoreWifiAsync on Kindle.
* Properly flag rM as hasWifiManager & hasFastWifiStatusQuery, because it is actually both of those (it uses our wpa_supplicant backend).
* Update the KOSync checks to take these changes into account, to properly disable auto_sync if necessary.
* Really made the Network* event signaling consistent. For realz this time.
* In an effort to make the whole beforeWifiAction framework somewhat usable there, we now assume connectivity is always available on !hasWifiToggle platforms...
10 months ago
NiLuJe 55869b82cb
PowerD: Unbreak frontlight toggle notifications outside of Kobo (#10597)
Fix #10588
Regression since #10305

While we're there, rejig the FL toggle callback shenanigans so that implementation details don't leak through to *other* implementations.
(i.e., leave the Kobo mess in Kobo land, with only a minimal impact on the public API and its implementation).
11 months ago
zwim 1ce1fe1780
[plugin] AutoWarmth: Fix resume and frontlight issue (#10557)
Fixes a regression introduced in #10426, when suspending during night and resuming during daylight.
11 months ago
NiLuJe 2797a74a96
Kobo: Handle the newer Nia HW revision (#10520)
Fix #9590, closes #9591
11 months ago
NiLuJe 7e98b9de4b
PM: Minor refactor to suspend/resume code flow (#10426)
Make sure we only send Suspend/Resume events when we *actually* suspend/resume. This is done via the Device `_beforeSuspend`/`_afterResume` methods, and those were called by the *input handlers*, not the PM logic; which means they would fire, while the PM logic could actually take a smarter decision and *not* do what the event just sent implied ;).

(i.e., sleep with a cover -> suspend + actual suspend, OK; but if you then resume with a button -> input assumes resume, but PM will actually suspend again!).

Existing design issue made more apparent by #9448 ;).

Also fixes/generalizes a few corner-cases related to screen_saver_lock handling (e.g., don't allow USBMS during a lock).

And deal with the fallout of the main change to the Kobo frontlight ramp behavior ;).
12 months ago
yparitcher 1102c030fa
Kindle: toggle cover events
Allow disabling the hall efect sensor via the sysfs knob, so the kindle system wont sleep & wake the device

for those of use that stay in koreader, are caseless and have get spurious wakeups
1 year ago
zwim 00b3594d44
Kobo: Refactor frontlight toggle ramp behavior (#10305)
* Rewrite the loop mechanism to use scheduled tasks instead of a single blocking-ish subprocess.
* Change the actual logic to be more pleasing to the eye, especially on newer devices, as those *may* natively ramp on set; and fix a bad interaction with that behavior that could lead to no ramp at all on ramp down.
* Simplify Generic's Suspend handling to deal with the refresh ordering in a saner manner. The screensaver might be visible a tad longer than before this change before the frontlight actually ramps off.
1 year ago
NiLuJe 15b236e3e9
Kobo: Mimic Nickel's poweroff behavior on sunxi (#10122)
It goes through init, unlike on other models.

Re: #10121
1 year ago
NiLuJe 96850c23a0
NetworkMgr: Refine isConnected check (#10098)
Much easier to deal with thanks to the cleanup work done in #10062 ;).

* `carrier` is set to 1 as soon as the device is *administratively* up (in practice, as soon as we run `ifconfig up`). This is perfectly fine for `isWifiOn`, but absolutely not for `isConnected`, because we are not, actually, connected to *anything*, no attempt at associating has even been made at that point. Besides being semantically wrong, in practice, this will horribly break the connectivity check, because it expects that `isConnected` means we can talk to at least the LAN.
* Delving into the Linux docs reveals that `operstate` looks like a better candidate, as it reflects *operational status*; for Wi-Fi, that means associated and successfully authenticated. That's... closer, but still not it, because we still don't have an IP, so we technically can't talk to anything other than the AP.
* So, I've brought out the big guns (`getifaddrs`), and replicated a bit of code that I already use in the USBNetwork hack on Kindle, to detect whether we actually have an IP assigned. (Other approaches, like `/proc/net/route`, may not be entirely fool-proof, and/or get complicated when IPv6 enters the fray (which it does, on Kobo, Mk. 8+ devices are IPv6-enabled)).

TL;DR: Bunch of C via ffi, and `isConnected` now returns true only when the device is operationally up *and* we have an IP assigned.

Pulls in https://github.com/koreader/koreader-base/pull/1579 & https://github.com/koreader/lj-wpaclient/pull/10
1 year ago
yparitcher 0e53631f48 NetworkManager: isWifiOn isConnected consistent usage.
cervantes kindle kobo remarkable: use sysfs carrier file to determine connection state

cleanup hasWifiManager checks

gateway check: use ip if available

Fixes: #10087
Closes: #10092
1 year ago
zwim 50ab620da1
Screen Warmth: Fix a bug with syncing screen warmth on start (#10066) 1 year ago
Jej 198a84a772
Minor updates in comments (#10038) 1 year ago
NiLuJe 16fb32d5a4
Kobo: Unbreak a slew of devices (#10019)
Fix #10020, Regression since #10008

(hasMultiTouch is set by `Generic.init`, but we use it before that;
so just set it properly ourselves in our superclass, because we don't
actually need to rely on Generic's autodetection).
1 year ago
NiLuJe 64af750c6c Kobo: Unbreak input translation when a viewport is active
Generic is responsible for setting up the translation via input hooks;
since our own input hooks involve swapping or mirroring X/Y, we need to
run our own hooks *first*, so that the viewport translation actually
does the right thing...

Probably broken for a good long while, I'd just assumed the inaccuracies
on the H2O were due to the IR grid... :/.

Reported @ https://www.mobileread.com/forums/showthread.php?t=351340
1 year ago
NiLuJe 5c1305719a
Kobo: Unbreak automagic_sysfs on the Libra 2 (#9998)
Regression since #9902, because I'd forgotten that the default Kobo block *does* set those...
Reported by @ptrm on Gitter, thanks!

Take two, essentially revert 8a16518918
We have defaults for most of those in the Kobo superclass, so these can never really be `nil`.
1 year ago
NiLuJe 788ccac561
Input/Device: Refactor Gyro events handling (#9935)
* Get rid of the `canToggleGSensor` Device cap, it's now mandatory for `hasGSensor` devices. (This means Kindles can now toggle the gyro, fix #9136).
* This also means that `Device:toggleGSensor` is now implemented by `Generic`.
* Update the Screen & Gyro rotation constants to be clearer (c.f., https://github.com/koreader/koreader-base/pull/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 43b021d37c. 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.
1 year ago
NiLuJe 8a16518918 Kobo: Only probe necessary entries in automagic_sysfs codepath
e.g., on the Sage, only the power_dev stuff changes between HW revs,
the rest of the hardcoded stuff is still relevant, so skip probing
those.
1 year ago
charlesangus cad4c24118
Kobo: Handle power button input device on new Sage HW revision (#9896)
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: NiLuJe <ninuje@gmail.com>
1 year ago
NiLuJe 58ba4076a8 Kobo: Detect the original Touch "A" variant properly.
Because, of course, it has different input quirks than the B...

Fix #9742
2 years ago
NiLuJe c7f5bfb72a ScreenSaver: Handle Power button presses properly if the screensaver
lock is enabled

Fix #9744
2 years ago
NiLuJe b1504ea718 Kobo: Downgrade some suspend logging messages to debug, and *all*
standby logging messages to debug (except for warnings/errors, of course).
2 years ago
NiLuJe cac37ad018 Kobo: Flag all the boards similar to the Libra 2 as unreliable (Clara 2E
& Nia).

And also disable the jump marker on those, like we did for the Libra 2.
2 years ago
NiLuJe 854cbe9f94 Kobo: Unbreak frontlight toggle for some specific values
Because of floating point computery math stuff.

Regression since #9609
c.f., https://github.com/koreader/koreader/pull/9609#issuecomment-1288187080
2 years ago
NiLuJe d9eb6e9717
Kobo: Always use open/write/close for sysfs writes (#9635)
Also simplifies a few UIManager log messages (re: https://github.com/koreader/koreader-base/pull/1537)
2 years ago
zwim 4969811c08
Optimization: Use constant folding for divisions not a power of two (#9609) 2 years ago
NiLuJe c0dffe2012
Kobo: Add a debug option to turn the charging LED on PM entry failure (#9601)
This should be fairly unintrusive, but still noticeable enough without having to watch the battery gauge like a hawk, or resort to actual monitoring via kernel logs and/or usb meter and/or multimeter...
2 years ago
NiLuJe fadee1f5dc
Clarify our OOP semantics across the codebase (#9586)
Basically:

* Use `extend` for class definitions
* Use `new` for object instantiations

That includes some minor code cleanups along the way:

* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
  * ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2 years ago
NiLuJe 9bf19d1bb3
Assorted bag'o tweaks & fixes (#9569)
* UIManager: Support more specialized update modes for corner-cases:
  * A2, which we'll use for the VirtualKeyboards keys (they'd... inadvertently switched to UI with the highlight refactor).
  * NO_MERGE variants of ui & partial (for sunxi). Use `[ui]` in ReaderHighlight's popup, because of a Sage kernel bug that could otherwise make it translucent, sometimes completely so (*sigh*).
* UIManager: Assorted code cleanups & simplifications.
* Logger & dbg: Unify logging style, and code cleanups.
* SDL: Unbreak suspend/resume outside of the emulator (fix #9567).
* NetworkMgr: Cache the network status, and allow it to be queried. (Used by AutoSuspend to avoid repeatedly poking the system when computing the standby schedule delay).
* OneTimeMigration: Don't forget about `NETWORK_PROXY` & `STARDICT_DATA_DIR` when migrating `defaults.persistent.lua` (fix #9573)
* WakeupMgr: Workaround an apparent limitation of the RTC found on i.MX5 Kobo devices, where setting a wakealarm further than UINT16_MAX seconds in the future would apparently overflow and wraparound... (fix #8039, many thanks to @yfede for the extensive deep-dive and for actually accurately pinpointing the issue!).
* Kobo: Handle standby transitions at full CPU clock speeds, in order to limit the latency hit.
* UIManager: Properly quit on reboot & exit. This ensures our exit code is preserved, as we exit on our own terms (instead of being killed by the init system). This is important on platforms where exit codes are semantically meaningful (e.g., Kobo).
* UIManager: Speaking of reboot & exit, make sure the Screensaver shows in all circumstances (e.g., autoshutdown, re: #9542)), and that there aren't any extraneous refreshes triggered. (Additionally, fix a minor regression since #9448 about tracking this very transient state on Kobo & Cervantes).
* Kindle: ID the upcoming Scribe.
* Bump base (https://github.com/koreader/koreader-base/pull/1524)
2 years ago
NiLuJe 8fcc712c76
Kobo: Clara 2E fixes (#9559)
* Handle the power button input device
* Handle the charging LED properly
* Handle the new Wi-Fi chip properly
* Handle frontlight warmth adjustments
* Handle the battery gauge properly
* Bump base (a lot of third-party updates) [https://github.com/koreader/koreader-base/pull/1523]
* Bump android-luajit-launcher to match the LuaJIT update [https://github.com/koreader/android-luajit-launcher/pull/386]

Fix #9552 (many thanks to @Bartvelp for bearing with my stupid tests ;)).
2 years ago
NiLuJe 62059f8d68
Misc: Get rid of the legacy defaults.lua globals (#9546)
* This removes support for the following deprecated constants: `DTAP_ZONE_FLIPPING`, `DTAP_ZONE_BOOKMARK`, `DCREREADER_CONFIG_DEFAULT_FONT_GAMMA`
* The "Advanced settings" panel now highlights modified values in bold (think about:config in Firefox ;)).
* LuaData: Isolate global table lookup shenanigans, and fix a few issues in unused-in-prod codepaths.
* CodeStyle: Require module locals for Lua/C modules, too.
* ScreenSaver: Actually garbage collect our widget on close (ScreenSaver itself is not an instantiated object).
* DateTimeWidget: Code cleanups to ensure child widgets can be GC'ed.
2 years ago
NiLuJe ab4b4b31bd
Kobo: Initial Clara 2E support (#9545)
Will need an actual tester to confirm FBInk gets the rotation right, as well as the touch input & frontlight situation.

* Bump base

https://github.com/koreader/koreader-base/pull/1519
https://github.com/koreader/koreader-base/pull/1521
2 years ago
NiLuJe 13e8213e0a
A random assortment of fixes (#9513)
* Android: Make sure sdcv can find the STL
* DocCache: Be less greedy when serializing to disk, and only do that for the *current* document ;).
* CanvasContext: Explicitly document API quirks.
* Fontlist: Switch the on-disk Persist format to zstd (it's ever so slightly faster).
* Bump base for https://github.com/koreader/koreader-base/pull/1515 (fix #9506)
2 years ago
zwim 6f5c229c90
[UIManager] Outsource device specific event handlers (was: some nits) (#9448) 2 years ago