-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(indev) Add crown support to pointer input device #5057
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks really clean. I'll try it later. Thank you.
@kisvegabor I used this patch to run on a Mac environment, but there are crashes related to scrolling animation when using the scroll wheel. I will try it on Ubuntu later. |
I'm using on Linux as well, but SDL should be the same on both places. |
@kisvegabor I try to run it on Ubuntu and it works well. Regarding implementation, there is a suggestion: for the operation of the digital crown, LVGL only need to report the corresponding event device type and scroll event, without the need for conversion to key events. If the upper layer application or component needs to respond to such scroll events to change button status or adjust progress, it should be handled by the upper layer application logic. While on Apple WatchOS it reports digital crown rotation event : |
You can get the event device type by
What would be the advantage of approaching from the direction of scroll? I understand that it used in Android, however we haven't followed Android's approach so far and selectively picking a few things might cause conflicts. |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
From the meeting conclusion, using a 32bit number for key event together with its repeat count can eliminate the loop to send key event one by one. However, the crown or rotary encoder has its own feature differs with keyboard. For example the sensitivity when scrolling list and roller. For roller, press keyboard LEFT or RIGHT should focus next item. However, using rotary encoder, we may say rotate 10 steps will trigger a refocus to next item in roller. Android and IOS have treated rotary encoder differently than keyboard, they must have reasons. It would be better we investigate the usage further. |
As the feature doesn't any API we don't need to merge it for v9. It means we have some more time think about it. The sensitivity of the roller is a great example for why we need to treat it separately. Where shall we store this sensitivity value? As a style property? Or a normal widget property? Probably we need a similar sensitivity for scrolling too. |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
Not stale. |
In summary what we should do is
I think it's a good idea to merge this functionality into the pointer input device type as they share the focused object and the crown is usually used in together with a touch pad. |
7d72f5c
to
3d54d13
Compare
I added the ROTARY event. Finally added these to /**< Rotary diff count will be divided by this value when widgets are adjusted*/
int32_t rotary_adjust_divider;
/**< Rotary diff count will be multiples by this value when scrolling to get scroll throw size*/
int32_t rotary_scroll_sensitvity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Gabor. I just have few comments want to confirm.
@@ -1314,6 +1328,36 @@ static void indev_proc_release(lv_indev_t * indev) | |||
} | |||
} | |||
|
|||
static void indev_proc_pointer_diff(lv_indev_t * indev) | |||
{ | |||
lv_obj_t * obj = indev->pointer.last_pressed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lv_obj_t * obj = indev->pointer.last_pressed;
Should the user manually click the screen when a new page is loaded, in order to make the rotary works by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it too. What about setting it automatically to the screen when a new screen is loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about searching a scrollable obj instead if last_pressed
is NULL?
d36b52e
to
9e276ca
Compare
I've slightly reworked it:
The final diff is calculated like: uint32_t indev_sensitivity = indev->rotary_sensitvity;
uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(indev_obj_act, 0);
int32_t diff = (int32_t)((int32_t)indev->pointer.diff * indev_sensitivity * obj_sensitivity + 32768) >> 16; |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
7132c10
to
b3d239e
Compare
src/drivers/sdl/lv_sdl_mouse.c
Outdated
if(event->wheel.y > 0) dsc->diff--; | ||
#else | ||
indev_dev->diff = -event->wheel.y; | ||
#endif /*LV_SDL_MOUSEWHEEL_MODE*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif /*LV_SDL_MOUSEWHEEL_MODE*/ | |
#endif /* __EMSCRIPTEN__ */ |
src/drivers/sdl/lv_sdl_mouse.c
Outdated
@@ -35,6 +35,9 @@ typedef struct { | |||
int16_t last_x; | |||
int16_t last_y; | |||
bool left_button_down; | |||
#if LV_SDL_MOUSEWHEEL_MODE == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using "constants" (in our case new SD_MOUSEWHEEL_MODE_ENCODER
and SDL_MOUSEWHEEL_MODE_CROWN
macros) is better and more descriptive than repeating the values 0
and 1
in files.
Now we know what 0
and 1
mean, but later we will forget, and have to remember, or investigate what they mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I'll fix these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Gabor! All looks good to me.
I've updated the docs and added |
@PGNetHun |
Description of the feature or fix
It nicely integrates the the typical watch crown features with the pointer input device. To test it with SDL change
LV_SDL_MOUSEWHEEL_MODE
to1
.cc @XuNeo @bjsylvia
Checkpoints
code-format.py
from the scripts folder. astyle needs to be installed.lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.Be sure the following conventions are followed:
enum
s instead of macros. If inevitable to usedefine
s export them withLV_EXPORT_CONST_INT(defined_value)
right after thedefine
.type name[]
declaration for array parameters instead oftype * name
void *
pointersmalloc
into a static or global variables. Instead declare the variable inlv_global_t
structure inlv_global.h
and mark the variable with(LV_GLOBAL_DEFAULT()->variable)
when it's used. See a detailed description here.lv_<widget_name>_create(lv_obj_t * parent)
pattern.lv_<module_name>
and should receivelv_obj_t *
as first argument which is a pointer to widget object itself.struct
s should be used via an API and not modified directly via their elements.struct
APIs should follow the widgets' conventions. That is to receive a pointer to thestruct
as the first argument, and the prefix of thestruct
name should be used as the prefix of the function name too (e.g.lv_disp_set_default(lv_disp_t * disp)
)struct
s which are not part of the public API must begin with underscore in order to mark them as "private".struct
as the first argument. Thestruct
must containvoid * user_data
field.void * user_data
and the sameuser_data
needs to be passed as the last argument of the callback.xcb_t
.