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

Keeps track of each multi-touch coordinate state #285

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/platform/evdev/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ static const char* envopts[] = {
*/
#define MAX_DEVICES 256

#define MAX_MT_SLOTS 5

struct devnode;
#include "device_db.h"

Expand Down Expand Up @@ -199,8 +201,8 @@ struct devnode {
struct {
bool active;
bool pending;
int x;
int y;
int x[MAX_MT_SLOTS];
int y[MAX_MT_SLOTS];
int pressure;
int size;
int ind;
Expand Down Expand Up @@ -1588,8 +1590,8 @@ static void flush_pending(
verbose_print("kind=touch:device=%d:base=%d", node->devnum, node->touch.ind);

newev.io.input.touch.active = node->touch.active;
newev.io.input.touch.x = node->touch.x;
newev.io.input.touch.y = node->touch.y;
newev.io.input.touch.x = node->touch.x[MIN(MAX_MT_SLOTS-1, node->touch.ind)];
newev.io.input.touch.y = node->touch.y[MIN(MAX_MT_SLOTS-1, node->touch.ind)];
newev.io.input.touch.pressure = node->touch.pressure;
newev.io.input.touch.size = node->touch.size;

Expand All @@ -1604,34 +1606,32 @@ static void decode_mt(struct arcan_evctx* ctx,
/* there are multiple protocols and mappings for this that we don't
* account for here, move it to a toch event with the basic information
* and let higher layers deal with it */
int newind = -1;

switch(code){
case ABS_X:
if (node->touch.ind != 0 && node->touch.pending)
flush_pending(ctx, node);

node->touch.ind = 0;
node->touch.x = val;
node->touch.x[0] = val;
node->touch.pending = true;
break;
case ABS_Y:
if (node->touch.ind != 0 && node->touch.pending)
flush_pending(ctx, node);

node->touch.ind = 0;
node->touch.y = val;
node->touch.y[0] = val;
node->touch.pending = true;
break;
case ABS_MT_PRESSURE:
node->touch.pressure = val;
break;
case ABS_MT_POSITION_X:
node->touch.x = val;
node->touch.x[MIN(MAX_MT_SLOTS-1, node->touch.ind)] = val;
node->touch.pending = true;
break;
case ABS_MT_POSITION_Y:
node->touch.y = val;
node->touch.y[MIN(MAX_MT_SLOTS-1, node->touch.ind)] = val;
node->touch.pending = true;
break;
case ABS_DISTANCE:
Expand Down
Loading