int test_gesture(short length, unsigned short tolerance) { int ipc_status; message msg; int receive; int validation = 1; sumOfX = 0; int irq_set = mouse_subscribe(); unsigned long clean; counter = 0; interrupts = 0; while (validation) { receive = driver_receive(ANY, &msg, &ipc_status); if (receive != 0) { printf("driver_receive failed with: %d", receive); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { validation = gesture_handler(length, tolerance); } break; default: break; } } else { } } mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&clean); //Clean the buffer return 0; }
int test_gesture(short length, unsigned short tolerance) { int ipc_status; message msg; int request; unsigned long irq_set; int stop=0; counter = 0; X = 0; Y = 0; LENGTH = length; TOLERANCE = tolerance; irq_set = subscribe_mouse(); while(!stop) { request = driver_receive(ANY, &msg, &ipc_status); if (request != 0 ) { printf("driver_receive failed with: %d", request); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { stop=gesture_handler(); if(abs(Y) > tolerance){ X=0; Y=0; } } break; default: break; } } } mouse_write_byte(DISABLE_DATA_PACKETS); unsubscribe_mouse(); printf("\nExit gesture!\n"); return 0; }
static int handle_gestures (struct input_event *e) { static int silence = 0; static int goSilent = 0; static int trackID[MAXSLOTS] = { -1, -1, -1 }; static int x[MAXSLOTS] = { -1, -1, -1 }; static int y[MAXSLOTS] = { -1, -1, -1 }; static int slot = -1; static int distance = 0; static int track_change = 0; int new_slot = -1; if ((e->type == EV_SYN) && (e->code == SYN_DROPPED)) { // Drop state distance = 0; track_change = 0; return 1; } if ((e->type == EV_ABS) && (e->code == ABS_MT_SLOT)) new_slot = e->value; if (slot < MAXSLOTS) { if (e->type == EV_ABS) { switch (e->code) { case ABS_MT_POSITION_X: distance += abs (x[slot] - e->value); x[slot] = e->value; break; case ABS_MT_POSITION_Y: distance += abs (y[slot] - e->value); y[slot] = e->value; break; case ABS_MT_TRACKING_ID: if ((trackID[slot] < 0) != (e->value < 0)) { track_change = 1; trackID[slot] = e->value; } break; } } if (((new_slot != -1) || ((e->type == EV_SYN) && (e->code == SYN_REPORT))) && ((slot < MAXSLOTS) && (slot >= 0))) { if (track_change || (distance > 1)) { goSilent = gesture_handler (slot, x[slot], y[slot], (track_change) ? ((trackID[slot] >= 0) ? 1 : 0) : -1); } /* reset vars for next set */ distance = 0; track_change = 0; } /* end new slot or syn_report */ } if (new_slot != -1) slot = new_slot; if ((e->type == EV_SYN) && (e->code == SYN_REPORT)) silence = goSilent; return (!silence); } /* endproc */