static void handle_gestures(LocalDevicePtr local, struct Gestures* gs) { struct MTouch *mt = local->private; static bitmask_t buttons_prev = 0U; int i; if(mt->absolute_mode == FALSE){ if (mt->cfg.scroll_smooth){ /* Copy states from button_prev into current buttons state */ MODBIT(gs->buttons, 3, GETBIT(buttons_prev, 3)); MODBIT(gs->buttons, 4, GETBIT(buttons_prev, 4)); MODBIT(gs->buttons, 5, GETBIT(buttons_prev, 5)); MODBIT(gs->buttons, 6, GETBIT(buttons_prev, 6)); set_and_post_mask(mt, local->dev, timertoms(&gs->dt)); } else{ // mt->absolute_mode == FALSE if (gs->move_dx != 0 || gs->move_dy != 0) xf86PostMotionEvent(local->dev, 0, 0, 2, gs->move_dx, gs->move_dy); } } else{ /* Give the HW coordinates to Xserver as absolute coordinates, these coordinates * are not scaled, this is oke if the touchscreen has the same resolution as the display. */ xf86PostMotionEvent(local->dev, 1, 0, 2, mt->state.touch[0].x + get_cap_xmid(&mt->caps), mt->state.touch[0].y + get_cap_ymid(&mt->caps)); } for (i = 0; i < 32; i++) { if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i)) continue; if (GETBIT(gs->buttons, i)) { xf86PostButtonEvent(local->dev, FALSE, i+1, 1, 0, 0); #define DEBUG_DRIVER 0 #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d down\n", i+1); #endif } else { xf86PostButtonEvent(local->dev, FALSE, i+1, 0, 0, 0); #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d up\n", i+1); #endif #undef DEBUG_DRIVER } } buttons_prev = gs->buttons; }
static void CommitScrollEvent(InputInfoPtr pInfo, char value, char button_positive, char button_negative) { while (value) { if (value>0) { xf86PostButtonEvent(pInfo->dev, 0, button_positive, 1, 0, 0); xf86PostButtonEvent(pInfo->dev, 0, button_positive, 0, 0, 0); value--; } else { xf86PostButtonEvent(pInfo->dev, 0, button_negative, 1, 0, 0); xf86PostButtonEvent(pInfo->dev, 0, button_negative, 0, 0, 0); value++; } } }
static unsigned char CommitButtonWithBitField(InputInfoPtr pInfo, char button, unsigned char bitfield) { int i; unsigned char state,oldstate; state=bitfield&128; for (i=1;i<8;i++) { bitfield<<=1; oldstate=state; state=bitfield&128; if (oldstate && !state) xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0); if (!oldstate && state) xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0); } if (bitfield) return 255; else return 0; }
static void handle_gestures(LocalDevicePtr local, const struct Gestures* gs) { const struct MTouch *mt = local->private; static bitmask_t buttons_prev = 0U; int i; int sendMotionEvent = FALSE; for (i = 0; i < 32; i++) { if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i)) continue; if (GETBIT(gs->buttons, i)) { xf86PostButtonEvent(local->dev, FALSE, i+1, 1, 0, 0); sendMotionEvent = TRUE; #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d down\n", i+1); #endif } else { xf86PostButtonEvent(local->dev, FALSE, i+1, 0, 0, 0); sendMotionEvent = TRUE; #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d up\n", i+1); #endif } } buttons_prev = gs->buttons; if (gs->move_dx != 0 || gs->move_dy != 0){ sendMotionEvent = TRUE; if(mt->cfg.absolute_mode == FALSE) xf86PostMotionEvent(local->dev, 0, 0, 2, gs->move_dx, gs->move_dy); } /* Give the HW coordinates to Xserver as absolute coordinates, these coordinates * are not scaled, this is oke if the touchscreen has the same resolution as the display. */ if(mt->cfg.absolute_mode == TRUE && sendMotionEvent == TRUE) xf86PostMotionEvent(local->dev, 1, 0, 2, mt->state.touch[0].x, mt->state.touch[0].y); }
static void CommitResult(InputInfoPtr pInfo, SynaptixResultPtr result) { int i; unsigned char bit; result->left = CommitButtonWithBitField(pInfo,1,result->left); result->right = CommitButtonWithBitField(pInfo,3,result->right); result->middle = CommitButtonWithBitField(pInfo,2,result->middle); if (pInfo->dev->valuator->mode == Relative && ( result->delta_x || result->delta_y )) { xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, result->delta_x, result->delta_y); } else if (pInfo->dev->valuator->mode == Absolute && result->abs_x >= 0 && result->abs_y >= 0) { xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, result->abs_x, result->abs_y); } result->abs_x = result->abs_y = -1; result->delta_x = result->delta_y = 0; CommitScrollEvent(pInfo,result->delta_z,5,4); CommitScrollEvent(pInfo,result->delta_w,7,6); result->delta_z = result->delta_w = 0; bit=1; for (i=0; i<8;i++) { xf86PostButtonEvent(pInfo->dev, FALSE, 0, 8+i, result->extra&bit? 1 : 0, 0, 0); bit<<=1; } result->handled_level=0; // TODO : commit extra buttons. }
static void process_state(InputInfoPtr local, const struct mtev_mtouch *mt) { const struct mtev_touch_point *tp; static int pdown = 0; int valuators[MAX_VALUATORS]; int down; int valix; int contacts; contacts = valix = down = 0; while ((tp = mtouch_get_contact(mt, contacts)) != NULL) { contacts++; // We don't do remapping of tracking id's so // make sure clients don't see too high tracking_id numbers if (tp->tracking_id < MT_NUM_FINGERS) { int x; int y; x = tp->position_x; y = tp->position_y; if (mt->swap_xy) { const int tmp = y; y = x; x = tmp; } if (mt->invert_x) x = mt->max_x - x + mt->min_x; if (mt->invert_y) y = mt->max_y - y + mt->min_y; valuators[valix++] = x; valuators[valix++] = y; valuators[valix++] = tp->touch_major; if (mt->caps.has_touch_minor) valuators[valix++] = tp->touch_minor; else valuators[valix++] = tp->touch_major; valuators[valix++] = tp->tracking_id; down++; } // Don't deliver more than MaxContacts if (down >= MT_NUM_FINGERS) break; } /* Some x-clients assume they get motion events before button down */ if (down) xf86PostMotionEventP(local->dev, TRUE, 0, down * MT_AXIS_PER_FINGER, valuators); if(down && pdown == 0) xf86PostButtonEventP(local->dev, TRUE, 1, 1, 0, down * MT_AXIS_PER_FINGER, valuators); else if (down == 0 && pdown) xf86PostButtonEvent(local->dev, TRUE, 1, 0, 0, 0); pdown = !!down; }