Closed Johennes closed 3 years ago
Interesting idea but I like it. It sounds like a generic method to shout down a device.
Alternatively, we could just use LV_INDEV_TYPE_KEYPAD for power button devices and handle the key in indev_keypad_proc. It'll feel a little odd to refer to the device as "keypad" but after all the kernel treats it as a keyboard, too, because it can send keys so maybe that's the best approach.
It's really invasive a little but I have and other idea too. :slightly_smiling_face: We can treat it as LV_KEY_POWER
. If the user registers a feedback_cb on hte input device the callback will be called on every event generated by that indev. The great thing in that feedback_cb
is called regardless to the focused widget.
What do you think?
Ah, I wasn't aware of feedback_cb
. Agreed, that seems much better. This way the client code can decide what to do with power key presses. :+1:
Do you think we still should have LV_KEY_POWER
in LVGL?
Yeah, I think that's a good idea. :+1:
I can send a PR when I have time.
Following the discussion on #163, there seems to be no good / non-invasive way to add this into lv_drivers at the moment. Since this is only a very small use case for my app, I'll close it for now. Thanks for helping to brainstorm it.
Thank you too! :slightly_smiling_face:
Some devices have dedicated power buttons that emit the
KEY_POWER
scan code. Here's an example from the power button on my laptop:As an addendum to #153 and #155, it would be nice if:
KEY_POWER
For 1, we'd just have to add another case to the
libinput_capability
enum and a corresponding capability check (just like we do for the other device types in #157).For 2, performing the shutdown is as easy as
However, I am not sure how to best integrate this into the existing drivers. :thinking:
We could add a new case to
LV_INDEV_TYPE_POWER
to thelv_indev_type_t
enum in lvgl but that might mean quite invasive changes.Alternatively, we could just use
LV_INDEV_TYPE_KEYPAD
for power button devices and handle the key inindev_keypad_proc
. It'll feel a little odd to refer to the device as "keypad" but after all the kernel treats it as a keyboard, too, because it can send keys so maybe that's the best approach.