Changes in uspace/srv/hid/input/generic/input.c [99ac5cf:10a5479d] in mainline
- File:
-
- 1 edited
-
uspace/srv/hid/input/generic/input.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/generic/input.c
r99ac5cf r10a5479d 39 39 #include <adt/list.h> 40 40 #include <bool.h> 41 #include <fibril_synch.h> 41 42 #include <ipc/services.h> 42 43 #include <ipc/input.h> … … 47 48 #include <stdio.h> 48 49 #include <ns.h> 49 #include <ns_obsolete.h>50 50 #include <async.h> 51 #include <async_obsolete.h>52 51 #include <errno.h> 53 52 #include <adt/fifo.h> … … 63 62 #include <mouse.h> 64 63 65 // FIXME: remove this header66 #include <abi/ipc/methods.h>67 68 64 #define NUM_LAYOUTS 3 69 65 … … 77 73 static void kbd_devs_reclaim(void); 78 74 79 int client_phone = -1;75 async_sess_t *client_sess = NULL; 80 76 81 77 /** List of keyboard devices */ … … 86 82 87 83 bool irc_service = false; 88 int irc_phone = -1; 84 async_sess_t *irc_sess = NULL; 85 86 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 89 87 90 88 void kbd_push_data(kbd_dev_t *kdev, sysarg_t data) … … 170 168 171 169 ev.c = layout_parse_ev(kdev->active_layout, &ev); 172 async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, ev.type, ev.key, 173 ev.mods, ev.c); 170 171 async_exch_t *exch = async_exchange_begin(client_sess); 172 async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c); 173 async_exchange_end(exch); 174 174 } 175 175 176 176 /** Mouse pointer has moved. */ 177 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy) 178 { 179 async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy); 177 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz) 178 { 179 async_exch_t *exch = async_exchange_begin(client_sess); 180 if (dx || dy) 181 async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy); 182 if (dz) { 183 // TODO: Implement proper wheel support 184 keycode_t code = dz > 0 ? KC_UP : KC_DOWN; 185 for (int i = 0; i < 3; ++i) { 186 async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0); 187 } 188 async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0); 189 } 190 async_exchange_end(exch); 180 191 } 181 192 … … 183 194 void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press) 184 195 { 185 async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press); 196 async_exch_t *exch = async_exchange_begin(client_sess); 197 async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press); 198 async_exchange_end(exch); 186 199 } 187 200 188 201 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 189 202 { 190 ipc_callid_t callid;191 ipc_call_t call;192 int retval;193 194 203 async_answer_0(iid, EOK); 195 204 196 205 while (true) { 197 callid = async_get_call(&call); 206 ipc_call_t call; 207 ipc_callid_t callid = async_get_call(&call); 198 208 199 209 if (!IPC_GET_IMETHOD(call)) { 200 if (client_ phone != -1) {201 async_ obsolete_hangup(client_phone);202 client_ phone = -1;210 if (client_sess != NULL) { 211 async_hangup(client_sess); 212 client_sess = NULL; 203 213 } 204 214 … … 207 217 } 208 218 209 switch (IPC_GET_IMETHOD(call)) { 210 case IPC_M_CONNECT_TO_ME: 211 if (client_phone != -1) { 212 retval = ELIMIT; 219 async_sess_t *sess = 220 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 221 if (sess != NULL) { 222 if (client_sess == NULL) { 223 client_sess = sess; 224 async_answer_0(callid, EOK); 225 } else 226 async_answer_0(callid, ELIMIT); 227 } else { 228 switch (IPC_GET_IMETHOD(call)) { 229 case INPUT_YIELD: 230 kbd_devs_yield(); 231 async_answer_0(callid, EOK); 213 232 break; 233 case INPUT_RECLAIM: 234 kbd_devs_reclaim(); 235 async_answer_0(callid, EOK); 236 break; 237 default: 238 async_answer_0(callid, EINVAL); 214 239 } 215 client_phone = IPC_GET_ARG5(call); 216 retval = 0; 217 break; 218 case INPUT_YIELD: 219 kbd_devs_yield(); 220 retval = 0; 221 break; 222 case INPUT_RECLAIM: 223 kbd_devs_reclaim(); 224 retval = 0; 225 break; 226 default: 227 retval = EINVAL; 228 } 229 230 async_answer_0(callid, retval); 240 } 231 241 } 232 242 } … … 399 409 * them automatically. 400 410 */ 401 #if defined(UARCH_amd64)402 kbd_add_dev(&chardev_port, &pc_ctl);403 #endif404 411 #if defined(UARCH_arm32) && defined(MACHINE_gta02) 405 412 kbd_add_dev(&chardev_port, &stty_ctl); … … 413 420 #if defined(UARCH_arm32) && defined(MACHINE_integratorcp) 414 421 kbd_add_dev(&pl050_port, &pc_ctl); 415 #endif416 #if defined(UARCH_ia32)417 kbd_add_dev(&chardev_port, &pc_ctl);418 #endif419 #if defined(MACHINE_i460GX)420 kbd_add_dev(&chardev_port, &pc_ctl);421 422 #endif 422 423 #if defined(MACHINE_ski) … … 452 453 * them automatically. 453 454 */ 454 #if defined(UARCH_amd64)455 mouse_add_dev(&chardev_mouse_port, &ps2_proto);456 #endif457 #if defined(UARCH_ia32)458 mouse_add_dev(&chardev_mouse_port, &ps2_proto);459 #endif460 #if defined(MACHINE_i460GX)461 mouse_add_dev(&chardev_mouse_port, &ps2_proto);462 #endif463 455 #if defined(UARCH_ppc32) 464 456 mouse_add_dev(&adb_mouse_port, &adb_proto); … … 604 596 int rc; 605 597 598 fibril_mutex_lock(&discovery_lock); 599 606 600 rc = dev_check_new_kbdevs(); 607 if (rc != EOK) 601 if (rc != EOK) { 602 fibril_mutex_unlock(&discovery_lock); 608 603 return rc; 604 } 609 605 610 606 rc = dev_check_new_mousedevs(); 611 if (rc != EOK) 607 if (rc != EOK) { 608 fibril_mutex_unlock(&discovery_lock); 612 609 return rc; 613 610 } 611 612 fibril_mutex_unlock(&discovery_lock); 613 614 614 return EOK; 615 615 } … … 648 648 649 649 if (irc_service) { 650 while (irc_phone < 0) 651 irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0); 650 while (irc_sess == NULL) 651 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 652 SERVICE_IRC, 0, 0); 652 653 } 653 654 … … 659 660 660 661 /* Register driver */ 661 int rc = loc_server_register(NAME, client_connection); 662 async_set_client_connection(client_connection); 663 int rc = loc_server_register(NAME); 662 664 if (rc < 0) { 663 665 printf("%s: Unable to register server (%d)\n", NAME, rc);
Note:
See TracChangeset
for help on using the changeset viewer.
