-
Notifications
You must be signed in to change notification settings - Fork 36
[rmkit][input] copy old mt slots from previous event #77
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
Conversation
mrichards42
left a comment
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.
Seems like this should work -- I haven't tried it out myself, but I'll give it a shot in a little bit on puzzles and let you know if something is obviously wrong.
| def marshal(T ev): | ||
| // marshal can update the event | ||
| def marshal(T &ev): |
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'm not seeing where marshal updates an event. Is this left over from a previous version, or am I missing something (likely since I don't know this code very well)?
|
ok, I did a little testing of my own, just in a mouse.down event.
code I tested with: target->mouse.down += [=](auto &ev) {
auto touch_ev = dynamic_cast<input::TouchEvent*>(ev.original.get());
if (touch_ev) {
int f = 0;
for (auto s : touch_ev->slots)
if (s.left > -1)
f++;
std::cerr << "touch event with "
<< touch_ev->fingers << " fingers"
<< "; " << touch_ev->slot << " slots"
<< "; " << f << " slots with left > -1"
<< std::endl;
if (touch_ev->is_multitouch) {
std::cerr << "skipping multitouch" << std::endl;
return;
}
}
}; |
|
Ah, ok I found https://www.kernel.org/doc/html/v4.18/input/multi-touch-protocol.html (you might already be aware of similar documentation, this is all new to me) which describes what all those ABS_MT_* fields mean. I see we aren't capturing ABS_MT_TOUCH_MAJOR or ABS_MT_TOUCH_MINOR, but those describe the size of the touch on the screen. For me a finger shows up as around major=17;minor=8. The edge of my hand has a lot of different sizes, but it seems like it's always at least major >= 26 OR minor >= 17, so maybe that's a reasonable threshold. |
|
i did know about those docs and have read about the axis minor/major, but didn't think about how to use them for palm detection, nice! it seems like this diff is not behaving like i thought it would - but at least you have ideas for how to fix palm touch :-D i think that holding prev_ev and using it as the base makes a lot of sense, so i'd like to achieve that |
|
ok, i think this works for coalescing the previous event (tested remux, harmony, mines, simple, genie) with touch and stylus. the major piece is in d96ebde. genie gestures work and now use count_fingers() for filtering instead of the in addition to those docs, i also used https://elixir.bootlin.com/linux/latest/source/include/linux/input.h. |
|
was running into strangeness with remux due to remux touch flood, now fixed i'll likely keep testing this and merge it on the weekend, but preliminary tests seem to show its working at least as well as previously |
mrichards42
left a comment
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.
This works great on my end! The only thing that still seems off is the initial finger count (calling count_fingers() does always end up with the right number).
src/rmkit/input/input.cpy
Outdated
| prev_ev = event | ||
| event = prev_ev |
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 the event = prev_ev part is redundant? Also should this have a call to event.finalize() somewhere?
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.
event.finalize() is called on EV_SYN
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.
oh you're totally right, it's like 5 lines above this 🤦
src/rmkit/input/events.cpy
Outdated
| self.x = t.x | ||
| self.y = t.y | ||
| self.left = t.left | ||
| self.lifted = t.lifted |
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'm still seeing fingers=0 in a SynMotionEvent handler when going through dynamic_cast<TouchEvent*>(ev.original().get())->fingers. I think it's b/c that isn't copied here. Does this need an explicit copy constructor, or would the default work?
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 removed explicit constructor, hopefully things improve, but it might be that count_fingers() is always useful to call before checking fingers (and we put that in to main_loop?).
| break | ||
| if self.left == 0: | ||
| self.lifted = true |
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.
When we see tracking_id -1 would we want to reset the slot to its initial -1, -1, -1 values? I assume tracking_id=-1 should mean that any existing x,y coords are invalid.
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.
if the tracking ID is set to -1, next time the slot is used it will get an X and Y coordinate, i believe.
one potential problem with setting to -1 at this point is that this event is still used (i believe) during mainloop's event dispatch.
* remove copy constructor
|
thanks for the help with this - it definitely is better code now. i just glanced at docs again and grepped "palm" and saw MT_TOOL_PALM. i'm curious if we will get this tool type or not. (accidentally put comment in wrong PR a moment ago) UPDATE: nope, i think evtest says MT_TOOL_PALM is not supported (max of ABS_MT_TOOL_TYPE is 1, should be >= 2 when PALM is supported) |
liftedon TouchEvent when a finger is lifted (TRACKING_ID set to -1)