static void emit_event(const isdv4_event_t *event) { fibril_mutex_lock(&client_mutex); async_sess_t *sess = client_sess; fibril_mutex_unlock(&client_mutex); if (!sess) return; async_exch_t *exch = async_exchange_begin(sess); if (exch) { unsigned int max_x = state.stylus_max_x; unsigned int max_y = state.stylus_max_y; if (event->source == TOUCH) { max_x = state.touch_max_x; max_y = state.touch_max_y; } async_msg_4(exch, MOUSEEV_ABS_MOVE_EVENT, event->x, event->y, max_x, max_y); if (event->type == PRESS || event->type == RELEASE) { async_msg_2(exch, MOUSEEV_BUTTON_EVENT, event->button, event->type == PRESS); } } async_exchange_end(exch); }
/** Mouse pointer has moved. */ void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz) { async_exch_t *exch = async_exchange_begin(client_sess); if (dx || dy) async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy); if (dz) { // TODO: Implement proper wheel support keycode_t code = dz > 0 ? KC_UP : KC_DOWN; for (int i = 0; i < 3; ++i) { async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0); } async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0); } async_exchange_end(exch); }
/** Mouse button has been pressed. */ void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press) { async_exch_t *exch = async_exchange_begin(client_sess); async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press); async_exchange_end(exch); }