Changeset 1875a0c in mainline
- Timestamp:
- 2011-06-21T19:10:20Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 022d9f67
- Parents:
- a9d85df
- Files:
-
- 6 deleted
- 34 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/amd64/Makefile.inc
ra9d85df r1875a0c 35 35 36 36 RD_SRVS_NON_ESSENTIAL += \ 37 $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \ 38 $(USPACE_PATH)/srv/hid/char_mouse/char_ms 37 $(USPACE_PATH)/srv/bd/ata_bd/ata_bd 39 38 40 39 RD_DRVS += \ -
boot/arch/ppc32/Makefile.inc
ra9d85df r1875a0c 43 43 $(USPACE_PATH)/srv/hw/bus/cuda_adb/cuda_adb 44 44 45 RD_SRVS_NON_ESSENTIAL += \46 $(USPACE_PATH)/srv/hid/adb_mouse/adb_ms47 48 45 RD_DRVS += \ 49 46 infrastructure/rootmac -
uspace/Makefile
ra9d85df r1875a0c 81 81 srv/fs/devfs \ 82 82 srv/fs/ext2fs \ 83 srv/hid/adb_mouse \84 srv/hid/char_mouse \85 83 srv/hid/s3c24xx_ts \ 86 84 srv/hid/fb \ -
uspace/app/init/init.c
ra9d85df r1875a0c 275 275 srv_start("/srv/i8042"); 276 276 srv_start("/srv/s3c24ser"); 277 srv_start("/srv/adb_ms");278 srv_start("/srv/char_ms");279 277 srv_start("/srv/s3c24ts"); 280 278 281 279 spawn("/srv/fb"); 282 280 spawn("/srv/input"); 283 console("hid _in/input");281 console("hid/input"); 284 282 285 283 spawn("/srv/clip"); -
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
ra9d85df r1875a0c 44 44 #include <async_obsolete.h> 45 45 #include <str_error.h> 46 #include <ipc/mouse .h>46 #include <ipc/mouseev.h> 47 47 #include <io/console.h> 48 48 … … 270 270 if ((shift_x != 0) || (shift_y != 0)) { 271 271 async_obsolete_req_2_0(mouse_dev->mouse_phone, 272 M EVENT_MOVE, shift_x, shift_y);272 MOUSEEV_MOVE_EVENT, shift_x, shift_y); 273 273 } 274 274 … … 296 296 && field->value != 0) { 297 297 async_obsolete_req_2_0(mouse_dev->mouse_phone, 298 M EVENT_BUTTON, field->usage, 1);298 MOUSEEV_BUTTON_EVENT, field->usage, 1); 299 299 mouse_dev->buttons[field->usage - field->usage_minimum] 300 300 = field->value; 301 } else if ( 302 mouse_dev->buttons[field->usage - field->usage_minimum] != 0 301 } else if (mouse_dev->buttons[field->usage - field->usage_minimum] != 0 303 302 && field->value == 0) { 304 305 M EVENT_BUTTON, field->usage, 0);306 mouse_dev->buttons[field->usage - field->usage_minimum]307 =field->value;308 303 async_obsolete_req_2_0(mouse_dev->mouse_phone, 304 MOUSEEV_BUTTON_EVENT, field->usage, 0); 305 mouse_dev->buttons[field->usage - field->usage_minimum] = 306 field->value; 307 } 309 308 310 309 field = usb_hid_report_get_sibling( -
uspace/drv/bus/usb/usbmouse/mouse.c
ra9d85df r1875a0c 38 38 #include <errno.h> 39 39 #include <str_error.h> 40 #include <ipc/mouse .h>40 #include <ipc/mouseev.h> 41 41 #include <async.h> 42 42 #include "mouse.h" … … 86 86 87 87 async_exch_t *exch = async_exchange_begin(mouse->console_sess); 88 async_req_2_0(exch, M EVENT_MOVE, -shift_x / 10, -shift_y / 10);88 async_req_2_0(exch, MOUSEEV_MOVE_EVENT, -shift_x / 10, -shift_y / 10); 89 89 async_exchange_end(exch); 90 90 } … … 93 93 94 94 async_exch_t *exch = async_exchange_begin(mouse->console_sess); 95 async_req_2_0(exch, M EVENT_BUTTON, 1, 1);96 async_req_2_0(exch, M EVENT_BUTTON, 1, 0);95 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, 1, 1); 96 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, 1, 0); 97 97 async_exchange_end(exch); 98 98 } -
uspace/lib/c/include/ipc/mouseev.h
ra9d85df r1875a0c 34 34 */ 35 35 36 #ifndef LIBC_IPC_MOUSE _H_37 #define LIBC_IPC_MOUSE _H_36 #ifndef LIBC_IPC_MOUSEEV_H_ 37 #define LIBC_IPC_MOUSEEV_H_ 38 38 39 39 #include <ipc/common.h> 40 #include <ipc/dev_iface.h> 40 41 41 42 typedef enum { 42 MEVENT_BUTTON = IPC_FIRST_USER_METHOD, 43 MEVENT_MOVE 44 } mouse_notif_t; 43 MOUSEEV_YIELD = DEV_FIRST_CUSTOM_METHOD, 44 MOUSEEV_RECLAIM 45 } mouseev_request_t; 46 47 typedef enum { 48 MOUSEEV_MOVE_EVENT = IPC_FIRST_USER_METHOD, 49 MOUSEEV_BUTTON_EVENT 50 } mouseev_notif_t; 45 51 46 52 #endif -
uspace/srv/hid/console/console.c
ra9d85df r1875a0c 482 482 retval = ENOENT; 483 483 } 484 484 485 async_answer_0(callid, retval); 485 486 } -
uspace/srv/hid/input/Makefile
ra9d85df r1875a0c 36 36 generic/input.c \ 37 37 generic/layout.c \ 38 generic/mouse.c \39 38 generic/stroke.c \ 40 39 layout/cz.c \ … … 42 41 layout/us_dvorak.c \ 43 42 port/adb.c \ 43 port/adb_mouse.c \ 44 44 port/chardev.c \ 45 port/chardev_mouse.c \ 45 46 port/gxemul.c \ 46 47 port/msim.c \ … … 51 52 port/ski.c \ 52 53 port/z8530.c \ 54 proto/adb.c \ 55 proto/mousedev.c \ 56 proto/ps2.c \ 53 57 ctl/apple.c \ 54 58 ctl/gxe_fb.c \ -
uspace/srv/hid/input/ctl/apple.c
ra9d85df r1875a0c 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Apple ADB keyboard controller driver. 36 36 */ 37 37 … … 42 42 #include <kbd_port.h> 43 43 44 static void apple_ctl_parse _scancode(int);44 static void apple_ctl_parse(sysarg_t); 45 45 static int apple_ctl_init(kbd_dev_t *); 46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned );46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned int); 47 47 48 48 kbd_ctl_ops_t apple_ctl = { 49 .parse _scancode = apple_ctl_parse_scancode,49 .parse = apple_ctl_parse, 50 50 .init = apple_ctl_init, 51 51 .set_ind = apple_ctl_set_ind … … 64 64 } 65 65 66 static void apple_ctl_parse _scancode(int scancode)66 static void apple_ctl_parse(sysarg_t scancode) 67 67 { 68 68 kbd_event_type_t type; 69 69 unsigned int key; 70 70 71 if (scancode < 0 || scancode>= 0x100)71 if (scancode >= 0x100) 72 72 return; 73 73 … … 81 81 key = scanmap[scancode]; 82 82 if (key != 0) 83 kbd_push_ev (kbd_dev, type, key);83 kbd_push_event(kbd_dev, type, key); 84 84 } 85 85 -
uspace/srv/hid/input/ctl/gxe_fb.c
ra9d85df r1875a0c 44 44 #include <stroke.h> 45 45 46 static void gxe_fb_ctl_parse _scancode(int);46 static void gxe_fb_ctl_parse(sysarg_t); 47 47 static int gxe_fb_ctl_init(kbd_dev_t *); 48 static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned );48 static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned int); 49 49 50 50 kbd_ctl_ops_t gxe_fb_ctl = { 51 .parse _scancode = gxe_fb_ctl_parse_scancode,51 .parse = gxe_fb_ctl_parse, 52 52 .init = gxe_fb_ctl_init, 53 53 .set_ind = gxe_fb_ctl_set_ind … … 229 229 } 230 230 231 static void gxe_fb_ctl_parse _scancode(int scancode)231 static void gxe_fb_ctl_parse(sysarg_t scancode) 232 232 { 233 233 unsigned mods, key; -
uspace/srv/hid/input/ctl/kbdev.c
ra9d85df r1875a0c 53 53 54 54 static int kbdev_ctl_init(kbd_dev_t *); 55 static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned );55 static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned int); 56 56 57 57 static void kbdev_callback_conn(ipc_callid_t, ipc_call_t *, void *arg); 58 58 59 59 kbd_ctl_ops_t kbdev_ctl = { 60 .parse _scancode= NULL,60 .parse = NULL, 61 61 .init = kbdev_ctl_init, 62 62 .set_ind = kbdev_ctl_set_ind … … 116 116 sess = fd_session(EXCHANGE_SERIALIZE, fd); 117 117 if (sess == NULL) { 118 printf( NAME ": Failed starting session with '%s'\n", pathname);118 printf("%s: Failed starting session with '%s'\n", NAME, pathname); 119 119 close(fd); 120 120 return -1; … … 123 123 kbdev = kbdev_new(kdev); 124 124 if (kbdev == NULL) { 125 printf( NAME ": Failed allocating device structure for '%s'.\n",126 pathname);125 printf("%s: Failed allocating device structure for '%s'.\n", 126 NAME, pathname); 127 127 return -1; 128 128 } … … 133 133 exch = async_exchange_begin(sess); 134 134 if (exch == NULL) { 135 printf( NAME ": Failed starting exchange with '%s'.\n", pathname);135 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 136 136 kbdev_destroy(kbdev); 137 137 return -1; … … 140 140 rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev); 141 141 if (rc != EOK) { 142 printf( NAME ": Failed creating callback connection from '%s'.\n",143 pathname);142 printf("%s: Failed creating callback connection from '%s'.\n", 143 NAME, pathname); 144 144 async_exchange_end(exch); 145 145 kbdev_destroy(kbdev); … … 193 193 type = IPC_GET_ARG1(call); 194 194 key = IPC_GET_ARG2(call); 195 kbd_push_ev (kbdev->kbd_dev, type, key);195 kbd_push_event(kbdev->kbd_dev, type, key); 196 196 break; 197 197 default: -
uspace/srv/hid/input/ctl/pc.c
ra9d85df r1875a0c 43 43 #include <gsp.h> 44 44 45 static void pc_ctl_parse _scancode(int);45 static void pc_ctl_parse(sysarg_t); 46 46 static int pc_ctl_init(kbd_dev_t *); 47 static void pc_ctl_set_ind(kbd_dev_t *, unsigned );47 static void pc_ctl_set_ind(kbd_dev_t *, unsigned int); 48 48 49 49 kbd_ctl_ops_t pc_ctl = { 50 .parse _scancode = pc_ctl_parse_scancode,50 .parse = pc_ctl_parse, 51 51 .init = pc_ctl_init, 52 52 .set_ind = pc_ctl_set_ind … … 215 215 } 216 216 217 static void pc_ctl_parse _scancode(int scancode)217 static void pc_ctl_parse(sysarg_t scancode) 218 218 { 219 219 kbd_event_type_t type; … … 257 257 } 258 258 259 if ((s cancode < 0) || ((size_t) scancode >= map_length))259 if ((size_t) scancode >= map_length) 260 260 return; 261 261 262 262 key = map[scancode]; 263 263 if (key != 0) 264 kbd_push_ev (kbd_dev, type, key);264 kbd_push_event(kbd_dev, type, key); 265 265 } 266 266 -
uspace/srv/hid/input/ctl/stty.c
ra9d85df r1875a0c 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Serial TTY-like keyboard controller driver. 36 36 */ 37 37 … … 43 43 #include <stroke.h> 44 44 45 static void stty_ctl_parse _scancode(int);45 static void stty_ctl_parse(sysarg_t); 46 46 static int stty_ctl_init(kbd_dev_t *); 47 static void stty_ctl_set_ind(kbd_dev_t *, unsigned );47 static void stty_ctl_set_ind(kbd_dev_t *, unsigned int); 48 48 49 49 kbd_ctl_ops_t stty_ctl = { 50 .parse _scancode = stty_ctl_parse_scancode,50 .parse = stty_ctl_parse, 51 51 .init = stty_ctl_init, 52 52 .set_ind = stty_ctl_set_ind … … 228 228 } 229 229 230 static void stty_ctl_parse _scancode(int scancode)230 static void stty_ctl_parse(sysarg_t scancode) 231 231 { 232 232 unsigned mods, key; -
uspace/srv/hid/input/ctl/sun.c
ra9d85df r1875a0c 34 34 /** 35 35 * @file 36 * @brief 36 * @brief Sun keyboard controller driver. 37 37 */ 38 38 … … 43 43 #include <kbd_port.h> 44 44 45 static void sun_ctl_parse _scancode(int);45 static void sun_ctl_parse(sysarg_t); 46 46 static int sun_ctl_init(kbd_dev_t *); 47 static void sun_ctl_set_ind(kbd_dev_t *, unsigned );47 static void sun_ctl_set_ind(kbd_dev_t *, unsigned int); 48 48 49 49 kbd_ctl_ops_t sun_ctl = { 50 .parse _scancode = sun_ctl_parse_scancode,50 .parse = sun_ctl_parse, 51 51 .init = sun_ctl_init, 52 52 .set_ind = sun_ctl_set_ind … … 66 66 } 67 67 68 static void sun_ctl_parse _scancode(int scancode)68 static void sun_ctl_parse(sysarg_t scancode) 69 69 { 70 70 kbd_event_type_t type; 71 71 unsigned int key; 72 72 73 if (scancode < 0 || scancode>= 0x100)73 if (scancode >= 0x100) 74 74 return; 75 75 … … 86 86 key = scanmap_simple[scancode]; 87 87 if (key != 0) 88 kbd_push_ev (kbd_dev, type, key);88 kbd_push_event(kbd_dev, type, key); 89 89 } 90 90 -
uspace/srv/hid/input/generic/input.c
ra9d85df r1875a0c 58 58 #include <kbd_port.h> 59 59 #include <kbd_ctl.h> 60 #include <mouse_proto.h> 60 61 #include <layout.h> 61 62 #include <mouse.h> … … 65 66 66 67 /* In microseconds */ 67 #define DISCOVERY_POLL_INTERVAL (10*1000*1000) 68 69 static void kbd_devs_yield(void); 70 static void kbd_devs_reclaim(void); 71 72 static void input_event_key(int, unsigned int, unsigned, wchar_t); 73 74 int client_phone = -1; 75 76 /** List of keyboard devices */ 77 static list_t kbd_devs; 78 79 /** List of mouse devices */ 80 list_t mouse_devs; 81 82 bool irc_service = false; 83 int irc_phone = -1; 84 85 #define NUM_LAYOUTS 3 68 #define DISCOVERY_POLL_INTERVAL (10 * 1000 * 1000) 69 70 #define NUM_LAYOUTS 3 86 71 87 72 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 91 76 }; 92 77 93 void kbd_push_scancode(kbd_dev_t *kdev, int scancode) 94 { 95 /* printf("scancode: 0x%x\n", scancode);*/ 96 (*kdev->ctl_ops->parse_scancode)(scancode); 97 } 98 99 void kbd_push_ev(kbd_dev_t *kdev, int type, unsigned int key) 78 static void kbd_devs_yield(void); 79 static void kbd_devs_reclaim(void); 80 81 int client_phone = -1; 82 83 /** List of keyboard devices */ 84 static list_t kbd_devs; 85 86 /** List of mouse devices */ 87 static list_t mouse_devs; 88 89 bool irc_service = false; 90 int irc_phone = -1; 91 92 void kbd_push_data(kbd_dev_t *kdev, sysarg_t data) 93 { 94 (*kdev->ctl_ops->parse)(data); 95 } 96 97 void mouse_push_data(mouse_dev_t *mdev, sysarg_t data) 98 { 99 (*mdev->proto_ops->parse)(data); 100 } 101 102 void kbd_push_event(kbd_dev_t *kdev, int type, unsigned int key) 100 103 { 101 104 kbd_event_t ev; 102 unsigned mod_mask;103 105 unsigned int mod_mask; 106 104 107 switch (key) { 105 108 case KC_LCTRL: mod_mask = KM_LCTRL; break; … … 111 114 default: mod_mask = 0; break; 112 115 } 113 116 114 117 if (mod_mask != 0) { 115 118 if (type == KEY_PRESS) … … 118 121 kdev->mods = kdev->mods & ~mod_mask; 119 122 } 120 123 121 124 switch (key) { 122 125 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; … … 125 128 default: mod_mask = 0; break; 126 129 } 127 130 128 131 if (mod_mask != 0) { 129 132 if (type == KEY_PRESS) { … … 135 138 kdev->mods = kdev->mods ^ (mod_mask & ~kdev->lock_keys); 136 139 kdev->lock_keys = kdev->lock_keys | mod_mask; 137 140 138 141 /* Update keyboard lock indicator lights. */ 139 142 (*kdev->ctl_ops->set_ind)(kdev, kdev->mods); … … 142 145 } 143 146 } 144 /* 145 printf("type: %d\n", type); 146 printf("mods: 0x%x\n", mods); 147 printf("keycode: %u\n", key); 148 */ 147 149 148 if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) && 150 149 key == KC_F1) { 151 150 layout_destroy(kdev->active_layout); 152 151 kdev->active_layout = layout_create(layout[0]); 153 152 return; 154 153 } 155 154 156 155 if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) && 157 156 key == KC_F2) { 158 157 layout_destroy(kdev->active_layout); 159 158 kdev->active_layout = layout_create(layout[1]); 160 159 return; 161 160 } 162 161 163 162 if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) && 164 163 key == KC_F3) { 165 164 layout_destroy(kdev->active_layout); 166 165 kdev->active_layout = layout_create(layout[2]); 167 166 return; 168 167 } 169 168 170 169 ev.type = type; 171 170 ev.key = key; 172 171 ev.mods = kdev->mods; 173 172 174 173 ev.c = layout_parse_ev(kdev->active_layout, &ev); 175 input_event_key(ev.type, ev.key, ev.mods, ev.c); 176 } 177 178 /** Key has been pressed or released. */ 179 static void input_event_key(int type, unsigned int key, unsigned mods, 180 wchar_t c) 181 { 182 async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, type, key, 183 mods, c); 174 async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, ev.type, ev.key, 175 ev.mods, ev.c); 184 176 } 185 177 186 178 /** Mouse pointer has moved. */ 187 void input_event_move(int dx, int dy)179 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy) 188 180 { 189 181 async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy); … … 191 183 192 184 /** Mouse button has been pressed. */ 193 void input_event_button(int bnum, int press)185 void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press) 194 186 { 195 187 async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press); … … 201 193 ipc_call_t call; 202 194 int retval; 203 195 204 196 async_answer_0(iid, EOK); 205 197 206 198 while (true) { 207 199 callid = async_get_call(&call); … … 237 229 retval = EINVAL; 238 230 } 231 239 232 async_answer_0(callid, retval); 240 } 233 } 241 234 } 242 235 243 236 static kbd_dev_t *kbd_dev_new(void) 244 237 { 245 kbd_dev_t *kdev; 246 247 kdev = calloc(1, sizeof(kbd_dev_t)); 238 kbd_dev_t *kdev = calloc(1, sizeof(kbd_dev_t)); 248 239 if (kdev == NULL) { 249 printf( NAME ": Error allocating keyboard device. "250 "Out of memory.\n" );240 printf("%s: Error allocating keyboard device. " 241 "Out of memory.\n", NAME); 251 242 return NULL; 252 243 } 253 244 254 245 link_initialize(&kdev->kbd_devs); 255 246 256 247 kdev->mods = KM_NUM_LOCK; 257 248 kdev->lock_keys = 0; 258 249 kdev->active_layout = layout_create(layout[0]); 259 250 260 251 return kdev; 252 } 253 254 static mouse_dev_t *mouse_dev_new(void) 255 { 256 mouse_dev_t *mdev = calloc(1, sizeof(mouse_dev_t)); 257 if (mdev == NULL) { 258 printf("%s: Error allocating keyboard device. " 259 "Out of memory.\n", NAME); 260 return NULL; 261 } 262 263 link_initialize(&mdev->mouse_devs); 264 265 return mdev; 261 266 } 262 267 … … 264 269 static void kbd_add_dev(kbd_port_ops_t *port, kbd_ctl_ops_t *ctl) 265 270 { 266 kbd_dev_t *kdev; 267 268 kdev = kbd_dev_new(); 271 kbd_dev_t *kdev = kbd_dev_new(); 269 272 if (kdev == NULL) 270 273 return; 271 274 272 275 kdev->port_ops = port; 273 276 kdev->ctl_ops = ctl; 274 277 kdev->dev_path = NULL; 275 278 276 279 /* Initialize port driver. */ 277 280 if ((*kdev->port_ops->init)(kdev) != 0) 278 281 goto fail; 279 282 280 283 /* Initialize controller driver. */ 281 284 if ((*kdev->ctl_ops->init)(kdev) != 0) { … … 283 286 goto fail; 284 287 } 285 288 286 289 list_append(&kdev->kbd_devs, &kbd_devs); 287 290 return; 291 288 292 fail: 289 293 free(kdev); 290 294 } 291 295 296 /** Add new legacy mouse device. */ 297 static void mouse_add_dev(mouse_port_ops_t *port, mouse_proto_ops_t *proto) 298 { 299 mouse_dev_t *mdev = mouse_dev_new(); 300 if (mdev == NULL) 301 return; 302 303 mdev->port_ops = port; 304 mdev->proto_ops = proto; 305 mdev->dev_path = NULL; 306 307 /* Initialize port driver. */ 308 if ((*mdev->port_ops->init)(mdev) != 0) 309 goto fail; 310 311 /* Initialize protocol driver. */ 312 if ((*mdev->proto_ops->init)(mdev) != 0) { 313 /* XXX Uninit port */ 314 goto fail; 315 } 316 317 list_append(&mdev->mouse_devs, &mouse_devs); 318 return; 319 320 fail: 321 free(mdev); 322 } 323 292 324 /** Add new kbdev device. 293 325 * 294 * @param dev_path Filesystem path to the device (/dev/class/...) 326 * @param dev_path Filesystem path to the device (/dev/class/...) 327 * 295 328 */ 296 329 static int kbd_add_kbdev(const char *dev_path) 297 330 { 298 kbd_dev_t *kdev; 299 300 kdev = kbd_dev_new(); 331 kbd_dev_t *kdev = kbd_dev_new(); 301 332 if (kdev == NULL) 302 333 return -1; 303 334 304 335 kdev->dev_path = dev_path; 305 336 kdev->port_ops = NULL; 306 337 kdev->ctl_ops = &kbdev_ctl; 307 338 308 339 /* Initialize controller driver. */ 309 340 if ((*kdev->ctl_ops->init)(kdev) != 0) { 310 341 goto fail; 311 342 } 312 343 313 344 list_append(&kdev->kbd_devs, &kbd_devs); 314 345 return EOK; 346 315 347 fail: 316 348 free(kdev); 349 return -1; 350 } 351 352 /** Add new mousedev device. 353 * 354 * @param dev_path Filesystem path to the device (/dev/class/...) 355 * 356 */ 357 static int mouse_add_mousedev(const char *dev_path) 358 { 359 mouse_dev_t *mdev = mouse_dev_new(); 360 if (mdev == NULL) 361 return -1; 362 363 mdev->dev_path = dev_path; 364 mdev->port_ops = NULL; 365 mdev->proto_ops = &mousedev_proto; 366 367 /* Initialize controller driver. */ 368 if ((*mdev->proto_ops->init)(mdev) != 0) { 369 goto fail; 370 } 371 372 list_append(&mdev->mouse_devs, &mouse_devs); 373 return EOK; 374 375 fail: 376 free(mdev); 317 377 return -1; 318 378 } … … 375 435 } 376 436 437 /** Add legacy drivers/devices. */ 438 static void mouse_add_legacy_devs(void) 439 { 440 /* 441 * Need to add these drivers based on config unless we can probe 442 * them automatically. 443 */ 444 #if defined(UARCH_amd64) 445 mouse_add_dev(&chardev_mouse_port, &ps2_proto); 446 #endif 447 #if defined(UARCH_ia32) 448 mouse_add_dev(&chardev_mouse_port, &ps2_proto); 449 #endif 450 #if defined(MACHINE_i460GX) 451 mouse_add_dev(&chardev_mouse_port, &ps2_proto); 452 #endif 453 #if defined(UARCH_ppc32) 454 mouse_add_dev(&adb_mouse_port, &adb_proto); 455 #endif 456 /* Silence warning on abs32le about mouse_add_dev() being unused */ 457 (void) mouse_add_dev; 458 } 459 377 460 static void kbd_devs_yield(void) 378 461 { … … 381 464 kbd_dev_t *kdev = list_get_instance(kdev_link, kbd_dev_t, 382 465 kbd_devs); 383 466 384 467 /* Yield port */ 385 468 if (kdev->port_ops != NULL) … … 394 477 kbd_dev_t *kdev = list_get_instance(kdev_link, kbd_dev_t, 395 478 kbd_devs); 396 479 397 480 /* Reclaim port */ 398 481 if (kdev->port_ops != NULL) … … 405 488 * Looks under /dev/class/keyboard and /dev/class/mouse. 406 489 * 407 * @param arg Ignored 490 * @param arg Ignored 491 * 408 492 */ 409 493 static int dev_discovery_fibril(void *arg) … … 413 497 size_t mouse_id = 1; 414 498 int rc; 415 499 416 500 while (true) { 417 501 async_usleep(DISCOVERY_POLL_INTERVAL); 418 502 419 503 /* 420 504 * Check for new keyboard device … … 423 507 if (rc < 0) 424 508 continue; 425 509 426 510 if (kbd_add_kbdev(dev_path) == EOK) { 427 printf( NAME ": Connected keyboard device '%s'\n",428 dev_path);429 511 printf("%s: Connected keyboard device '%s'\n", 512 NAME, dev_path); 513 430 514 /* XXX Handle device removal */ 431 515 ++kbd_id; 432 516 } 433 517 434 518 free(dev_path); 435 519 436 520 /* 437 521 * Check for new mouse device … … 440 524 if (rc < 0) 441 525 continue; 442 443 if (mouse_add_ dev(dev_path) == EOK) {444 printf( NAME ": Connected mouse device '%s'\n",445 dev_path);446 526 527 if (mouse_add_mousedev(dev_path) == EOK) { 528 printf("%s: Connected mouse device '%s'\n", 529 NAME, dev_path); 530 447 531 /* XXX Handle device removal */ 448 532 ++mouse_id; 449 533 } 450 534 451 535 free(dev_path); 452 536 } 453 537 454 538 return EOK; 455 539 } … … 458 542 static void input_start_dev_discovery(void) 459 543 { 460 fid_t fid; 461 462 fid = fibril_create(dev_discovery_fibril, NULL); 544 fid_t fid = fibril_create(dev_discovery_fibril, NULL); 463 545 if (!fid) { 464 printf(NAME ": Failed to create device discovery fibril.\n"); 546 printf("%s: Failed to create device discovery fibril.\n", 547 NAME); 465 548 return; 466 549 } 467 550 468 551 fibril_add_ready(fid); 469 552 } … … 490 573 /* Add legacy keyboard devices. */ 491 574 kbd_add_legacy_devs(); 492 493 /* Add legacy (devmap-style) mouse device. */494 (void) mouse_add_dev("/dev/hid_in/mouse");575 576 /* Add legacy mouse devices. */ 577 mouse_add_legacy_devs(); 495 578 496 579 /* Register driver */ … … 509 592 return -1; 510 593 } 511 594 512 595 /* Start looking for new input devices */ 513 596 input_start_dev_discovery(); 514 515 printf( NAME ": Accepting connections\n");597 598 printf("%s: Accepting connections\n", NAME); 516 599 async_manager(); 517 600 518 601 /* Not reached. */ 519 602 return 0; -
uspace/srv/hid/input/generic/layout.c
ra9d85df r1875a0c 48 48 layout = calloc(1, sizeof(layout_t)); 49 49 if (layout == NULL) { 50 printf( NAME ": Out of memory.\n");50 printf("%s: Out of memory.\n", NAME); 51 51 return NULL; 52 52 } -
uspace/srv/hid/input/generic/stroke.c
ra9d85df r1875a0c 60 60 while (mods_keys[i][0] != 0) { 61 61 if (mod & mods_keys[i][0]) { 62 kbd_push_ev (kdev, KEY_PRESS, mods_keys[i][1]);62 kbd_push_event(kdev, KEY_PRESS, mods_keys[i][1]); 63 63 } 64 64 ++i; … … 67 67 /* Simulate key press and release. */ 68 68 if (key != 0) { 69 kbd_push_ev (kdev, KEY_PRESS, key);70 kbd_push_ev (kdev, KEY_RELEASE, key);69 kbd_push_event(kdev, KEY_PRESS, key); 70 kbd_push_event(kdev, KEY_RELEASE, key); 71 71 } 72 72 … … 75 75 while (mods_keys[i][0] != 0) { 76 76 if (mod & mods_keys[i][0]) { 77 kbd_push_ev (kdev, KEY_RELEASE, mods_keys[i][1]);77 kbd_push_event(kdev, KEY_RELEASE, mods_keys[i][1]); 78 78 } 79 79 ++i; -
uspace/srv/hid/input/include/input.h
ra9d85df r1875a0c 42 42 43 43 #define NAME "input" 44 #define NAMESPACE "hid _in"44 #define NAMESPACE "hid" 45 45 46 46 extern bool irc_service; 47 47 extern int irc_phone; 48 49 extern list_t mouse_devs;50 51 void input_event_move(int, int);52 void input_event_button(int bnum, int press);53 48 54 49 #endif -
uspace/srv/hid/input/include/kbd.h
ra9d85df r1875a0c 71 71 } kbd_dev_t; 72 72 73 extern void kbd_push_ scancode(kbd_dev_t *, int);74 extern void kbd_push_ev (kbd_dev_t *, int, unsigned int);73 extern void kbd_push_data(kbd_dev_t *, sysarg_t); 74 extern void kbd_push_event(kbd_dev_t *, int, unsigned int); 75 75 76 76 #endif -
uspace/srv/hid/input/include/kbd_ctl.h
ra9d85df r1875a0c 28 28 29 29 /** @addtogroup inputgen generic 30 * @brief 31 * @ingroup 30 * @brief Keyboard controller driver interface. 31 * @ingroup input 32 32 * @{ 33 33 */ … … 43 43 44 44 typedef struct kbd_ctl_ops { 45 void (*parse _scancode)(int);45 void (*parse)(sysarg_t); 46 46 int (*init)(struct kbd_dev *); 47 void (*set_ind)(struct kbd_dev *, unsigned );47 void (*set_ind)(struct kbd_dev *, unsigned int); 48 48 } kbd_ctl_ops_t; 49 49 … … 59 59 /** 60 60 * @} 61 */ 62 61 */ -
uspace/srv/hid/input/include/kbd_port.h
ra9d85df r1875a0c 28 28 29 29 /** @addtogroup inputgen generic 30 * @brief 31 * @ingroup 30 * @brief Keyboard port driver interface. 31 * @ingroup input 32 32 * @{ 33 33 */ … … 51 51 extern kbd_port_ops_t adb_port; 52 52 extern kbd_port_ops_t chardev_port; 53 extern kbd_port_ops_t dummy_port;54 53 extern kbd_port_ops_t gxemul_port; 55 54 extern kbd_port_ops_t msim_port; … … 65 64 /** 66 65 * @} 67 */ 68 66 */ -
uspace/srv/hid/input/include/mouse.h
ra9d85df r1875a0c 40 40 #include <adt/list.h> 41 41 42 struct mouse_port_ops; 43 struct mouse_proto_ops; 44 42 45 typedef struct mouse_dev { 43 46 /** Link to mouse_devs list */ 44 47 link_t mouse_devs; 45 46 /** Path to the device */48 49 /** Path to the device (only for mouseev devices) */ 47 50 const char *dev_path; 51 52 /** Port ops */ 53 struct mouse_port_ops *port_ops; 54 55 /** Protocol ops */ 56 struct mouse_proto_ops *proto_ops; 48 57 } mouse_dev_t; 49 58 50 int mouse_add_dev(const char *dev_path); 59 extern void mouse_push_data(mouse_dev_t *, sysarg_t); 60 extern void mouse_push_event_move(mouse_dev_t *, int, int); 61 extern void mouse_push_event_button(mouse_dev_t *, int, int); 51 62 52 63 #endif -
uspace/srv/hid/input/include/mouse_port.h
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup inputgen generic 30 * @brief Mouse port driver interface. 31 * @ingroup input 31 32 * @{ 32 33 */ … … 39 40 #include <sys/types.h> 40 41 41 extern int mouse_port_init(void); 42 extern void mouse_port_yield(void); 43 extern void mouse_port_reclaim(void); 44 extern void mouse_port_write(uint8_t); 42 struct mouse_dev; 43 44 typedef struct mouse_port_ops { 45 int (*init)(struct mouse_dev *); 46 void (*yield)(void); 47 void (*reclaim)(void); 48 void (*write)(uint8_t); 49 } mouse_port_ops_t; 50 51 extern mouse_port_ops_t adb_mouse_port; 52 extern mouse_port_ops_t chardev_mouse_port; 45 53 46 54 #endif … … 48 56 /** 49 57 * @} 50 */ 51 58 */ -
uspace/srv/hid/input/include/mouse_proto.h
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup inputgen generic 30 * @brief Mouse protocol driver interface. 31 * @ingroup input 31 32 * @{ 32 33 */ … … 37 38 #define MOUSE_PROTO_H_ 38 39 39 extern void mouse_proto_parse_byte(int); 40 extern int mouse_proto_init(void); 40 #include <mouse_port.h> 41 42 struct mouse_dev; 43 44 typedef struct mouse_proto_ops { 45 void (*parse)(sysarg_t); 46 int (*init)(struct mouse_dev *); 47 } mouse_proto_ops_t; 48 49 extern mouse_proto_ops_t adb_proto; 50 extern mouse_proto_ops_t ps2_proto; 51 extern mouse_proto_ops_t mousedev_proto; 41 52 42 53 #endif -
uspace/srv/hid/input/layout/cz.c
ra9d85df r1875a0c 391 391 cz_state = malloc(sizeof(layout_cz_t)); 392 392 if (cz_state == NULL) { 393 printf( NAME ": Out of memory.\n");393 printf("%s: Out of memory.\n", NAME); 394 394 return ENOMEM; 395 395 } -
uspace/srv/hid/input/port/adb.c
ra9d85df r1875a0c 93 93 async_exchange_end(exch); 94 94 if (rc != EOK) { 95 printf( NAME ": Failed to create callback from device\n");95 printf("%s: Failed to create callback from device\n", NAME); 96 96 async_hangup(dev_sess); 97 97 return rc; … … 142 142 static void adb_kbd_reg0_data(uint16_t data) 143 143 { 144 uint8_t b0, b1; 145 146 b0 = (data >> 8) & 0xff; 147 b1 = data & 0xff; 148 144 uint8_t b0 = (data >> 8) & 0xff; 145 uint8_t b1 = data & 0xff; 146 149 147 if (b0 != 0xff) 150 kbd_push_scancode(kbd_dev, b0); 148 kbd_push_data(kbd_dev, b0); 149 151 150 if (b1 != 0xff) 152 kbd_push_ scancode(kbd_dev, b1);151 kbd_push_data(kbd_dev, b1); 153 152 } 154 153 -
uspace/srv/hid/input/port/adb_mouse.c
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_port 30 * @ingroup mouse 30 31 * @{ 31 */ 32 */ 32 33 /** @file 33 * @brief 34 * @brief ADB mouse port driver. 34 35 */ 35 36 36 #include <ipc/ char.h>37 #include <ipc/adb.h> 37 38 #include <async.h> 38 #include <vfs/vfs.h> 39 #include <fcntl.h> 39 #include <input.h> 40 #include <mouse_port.h> 41 #include <mouse.h> 40 42 #include <errno.h> 41 43 #include <devmap.h> 42 #include <char_mouse.h>43 #include <mouse_port.h>44 44 45 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 46 45 static mouse_dev_t *mouse_dev; 47 46 static async_sess_t *dev_sess; 48 47 49 #define NAME "char_mouse" 50 51 int mouse_port_init(void) 52 { 53 devmap_handle_t handle; 54 async_exch_t *exch; 55 int rc; 56 57 rc = devmap_device_get_handle("char/ps2b", &handle, 58 IPC_FLAG_BLOCKING); 59 60 if (rc != EOK) { 61 printf("%s: Failed resolving PS/2\n", NAME); 62 return rc; 63 } 64 65 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 66 IPC_FLAG_BLOCKING); 67 if (dev_sess == NULL) { 68 printf("%s: Failed connecting to PS/2\n", NAME); 69 return ENOENT; 70 } 71 72 exch = async_exchange_begin(dev_sess); 73 if (exch == NULL) { 74 printf("%s: Failed starting exchange with PS/2\n", NAME); 75 async_hangup(dev_sess); 76 return ENOMEM; 77 } 78 79 /* NB: The callback connection is slotted for removal */ 80 rc = async_connect_to_me(exch, 0, 0, 0, chardev_events, NULL); 81 async_exchange_end(exch); 82 83 if (rc != 0) { 84 printf(NAME ": Failed to create callback from device\n"); 85 async_hangup(dev_sess); 86 return false; 87 } 88 89 return 0; 90 } 91 92 void mouse_port_yield(void) 93 { 94 } 95 96 void mouse_port_reclaim(void) 97 { 98 } 99 100 void mouse_port_write(uint8_t data) 101 { 102 async_exch_t *exch = async_exchange_begin(dev_sess); 103 if (exch == NULL) { 104 printf("%s: Failed starting exchange with PS/2\n", NAME); 105 return; 106 } 107 108 async_msg_1(exch, CHAR_WRITE_BYTE, data); 109 110 async_exchange_end(exch); 111 } 112 113 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 48 static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 114 49 { 115 50 /* Ignore parameters, the connection is already opened */ 116 51 while (true) { 117 118 52 ipc_call_t call; 119 53 ipc_callid_t callid = async_get_call(&call); 120 54 121 55 int retval; 122 56 … … 125 59 return; 126 60 } 127 61 128 62 switch (IPC_GET_IMETHOD(call)) { 129 case IPC_FIRST_USER_METHOD:130 mouse_ handle_byte(IPC_GET_ARG1(call));63 case ADB_REG_NOTIF: 64 mouse_push_data(mouse_dev, IPC_GET_ARG1(call)); 131 65 break; 132 66 default: 133 67 retval = ENOENT; 134 68 } 69 135 70 async_answer_0(callid, retval); 136 71 } 137 72 } 138 73 74 static int adb_port_init(mouse_dev_t *mdev) 75 { 76 const char *dev = "adb/mouse"; 77 78 mouse_dev = mdev; 79 80 devmap_handle_t handle; 81 int rc = devmap_device_get_handle(dev, &handle, 0); 82 if (rc != EOK) 83 return rc; 84 85 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 86 if (dev_sess == NULL) { 87 printf("%s: Failed to connect to device\n", NAME); 88 return ENOENT; 89 } 90 91 async_exch_t *exch = async_exchange_begin(dev_sess); 92 if (exch == NULL) { 93 printf("%s: Failed starting exchange with device\n", NAME); 94 async_hangup(dev_sess); 95 return ENOMEM; 96 } 97 98 /* NB: The callback connection is slotted for removal */ 99 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL); 100 async_exchange_end(exch); 101 if (rc != EOK) { 102 printf("%s: Failed to create callback from device\n", NAME); 103 async_hangup(dev_sess); 104 return rc; 105 } 106 107 return EOK; 108 } 109 110 static void adb_port_yield(void) 111 { 112 } 113 114 static void adb_port_reclaim(void) 115 { 116 } 117 118 static void adb_port_write(uint8_t data) 119 { 120 } 121 122 mouse_port_ops_t adb_mouse_port = { 123 .init = adb_port_init, 124 .yield = adb_port_yield, 125 .reclaim = adb_port_reclaim, 126 .write = adb_port_write 127 }; 128 139 129 /** 140 130 * @} -
uspace/srv/hid/input/port/chardev.c
ra9d85df r1875a0c 108 108 109 109 if (rc != 0) { 110 printf( NAME ": Failed to create callback from device\n");110 printf("%s: Failed to create callback from device\n", NAME); 111 111 async_hangup(dev_sess); 112 112 return -1; … … 153 153 switch (IPC_GET_IMETHOD(call)) { 154 154 case CHAR_NOTIF_BYTE: 155 kbd_push_ scancode(kbd_dev, IPC_GET_ARG1(call));155 kbd_push_data(kbd_dev, IPC_GET_ARG1(call)); 156 156 break; 157 157 default: -
uspace/srv/hid/input/port/chardev_mouse.c
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 201 0 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_port 30 * @ingroup mouse 30 31 * @{ 31 */ 32 */ 32 33 /** @file 33 * @brief 34 * @brief Chardev mouse port driver. 34 35 */ 35 36 36 #include <ipc/adb.h> 37 #include <ipc/char.h> 38 #include <stdio.h> 37 39 #include <async.h> 38 #include <vfs/vfs.h>39 #include <fcntl.h>40 40 #include <errno.h> 41 41 #include <devmap.h> 42 #include <async.h> 43 #include <kernel/ipc/ipc_methods.h> 42 #include <input.h> 43 #include <mouse_port.h> 44 #include <mouse.h> 44 45 45 #include "adb_mouse.h" 46 #include "adb_dev.h" 46 static mouse_dev_t *mouse_dev; 47 static async_sess_t *dev_sess; 47 48 48 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 49 /** List of devices to try connecting to. */ 50 static const char *in_devs[] = { 51 "char/ps2b", 52 }; 49 53 50 int adb_dev_init(void) 54 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 55 56 static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 57 { 58 /* Ignore parameters, the connection is already opened */ 59 while (true) { 60 ipc_call_t call; 61 ipc_callid_t callid = async_get_call(&call); 62 63 if (!IPC_GET_IMETHOD(call)) { 64 /* TODO: Handle hangup */ 65 return; 66 } 67 68 int retval; 69 70 switch (IPC_GET_IMETHOD(call)) { 71 case CHAR_NOTIF_BYTE: 72 mouse_push_data(mouse_dev, IPC_GET_ARG1(call)); 73 break; 74 default: 75 retval = ENOENT; 76 } 77 78 async_answer_0(callid, retval); 79 } 80 } 81 82 static int chardev_port_init(mouse_dev_t *mdev) 51 83 { 52 84 devmap_handle_t handle; 53 async_exch_t *exch;85 unsigned int i; 54 86 int rc; 55 87 56 rc = devmap_device_get_handle("adb/mouse", &handle, 57 IPC_FLAG_BLOCKING); 58 if (rc != EOK) { 59 printf("%s: Failed resolving ADB\n", NAME); 60 return rc; 88 mouse_dev = mdev; 89 90 for (i = 0; i < num_devs; i++) { 91 rc = devmap_device_get_handle(in_devs[i], &handle, 0); 92 if (rc == EOK) 93 break; 61 94 } 62 95 63 async_sess_t *dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 96 if (i >= num_devs) { 97 printf("%s: Could not find any suitable input device\n", NAME); 98 return -1; 99 } 100 101 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 64 102 IPC_FLAG_BLOCKING); 65 103 if (dev_sess == NULL) { 66 printf("%s: Failed connecting to ADB\n", NAME);104 printf("%s: Failed connecting to device\n", NAME); 67 105 return ENOENT; 68 106 } 69 107 70 exch = async_exchange_begin(dev_sess);108 async_exch_t *exch = async_exchange_begin(dev_sess); 71 109 if (exch == NULL) { 72 printf("%s: Failed starting exchange with ADB\n", NAME);110 printf("%s: Failed starting exchange with device\n", NAME); 73 111 async_hangup(dev_sess); 74 112 return ENOMEM; … … 76 114 77 115 /* NB: The callback connection is slotted for removal */ 78 rc = async_connect_to_me(exch, 0, 0, 0, adb_dev_events, NULL);116 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL); 79 117 async_exchange_end(exch); 80 118 81 119 if (rc != 0) { 82 printf( NAME ": Failed to create callback from device\n");120 printf("%s: Failed to create callback from device\n", NAME); 83 121 async_hangup(dev_sess); 84 return ENOENT;122 return -1; 85 123 } 86 124 … … 88 126 } 89 127 90 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)128 static void chardev_port_yield(void) 91 129 { 92 /* Ignore parameters, the connection is already opened */ 93 while (true) { 130 } 94 131 95 ipc_call_t call; 96 ipc_callid_t callid = async_get_call(&call); 132 static void chardev_port_reclaim(void) 133 { 134 } 97 135 98 int retval; 99 100 if (!IPC_GET_IMETHOD(call)) { 101 /* TODO: Handle hangup */ 102 return; 103 } 136 static void chardev_port_write(uint8_t data) 137 { 138 async_exch_t *exch = async_exchange_begin(dev_sess); 139 if (exch == NULL) { 140 printf("%s: Failed starting exchange with device\n", NAME); 141 return; 142 } 104 143 105 switch (IPC_GET_IMETHOD(call)) { 106 case IPC_FIRST_USER_METHOD: 107 mouse_handle_data(IPC_GET_ARG1(call)); 108 break; 109 default: 110 retval = ENOENT; 111 } 112 async_answer_0(callid, retval); 113 } 144 async_msg_1(exch, CHAR_WRITE_BYTE, data); 145 async_exchange_end(exch); 114 146 } 147 148 mouse_port_ops_t chardev_mouse_port = { 149 .init = chardev_port_init, 150 .yield = chardev_port_yield, 151 .reclaim = chardev_port_reclaim, 152 .write = chardev_port_write 153 }; 115 154 116 155 /** -
uspace/srv/hid/input/port/gxemul.c
ra9d85df r1875a0c 108 108 109 109 /** Process data sent when a key is pressed. 110 *111 * @param keybuffer Buffer of pressed keys.112 * @param call IPC call.113 110 * 114 * @return Always 1. 111 * @param keybuffer Buffer of pressed keys. 112 * @param call IPC call. 113 * 115 114 */ 116 115 static void gxemul_irq_handler(ipc_callid_t iid, ipc_call_t *call) 117 116 { 118 int scan_code = IPC_GET_ARG2(*call); 119 120 kbd_push_scancode(kbd_dev, scan_code); 117 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 121 118 } 122 119 -
uspace/srv/hid/input/port/msim.c
ra9d85df r1875a0c 109 109 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call) 110 110 { 111 int scan_code = IPC_GET_ARG2(*call); 112 kbd_push_scancode(kbd_dev, scan_code); 111 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 113 112 } 114 113 115 114 /** @} 116 */115 */ -
uspace/srv/hid/input/port/niagara.c
ra9d85df r1875a0c 148 148 c = input_buffer->data[input_buffer->read_ptr]; 149 149 input_buffer->read_ptr = 150 151 kbd_push_ scancode(kbd_dev, c);150 ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE; 151 kbd_push_data(kbd_dev, c); 152 152 } 153 153 } -
uspace/srv/hid/input/port/ns16550.c
ra9d85df r1875a0c 156 156 static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call) 157 157 { 158 int scan_code = IPC_GET_ARG2(*call); 159 kbd_push_scancode(kbd_dev, scan_code); 158 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 160 159 161 160 if (irc_service) -
uspace/srv/hid/input/port/pl050.c
ra9d85df r1875a0c 137 137 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call) 138 138 { 139 int scan_code = IPC_GET_ARG2(*call); 140 141 kbd_push_scancode(kbd_dev, scan_code); 142 return; 139 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 143 140 } 144 141 145 142 /** 146 143 * @} 147 */ 144 */ -
uspace/srv/hid/input/port/sgcn.c
ra9d85df r1875a0c 183 183 *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; 184 184 buf_ptr = (volatile char *) 185 186 kbd_push_ scancode(kbd_dev, c);185 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 186 kbd_push_data(kbd_dev, c); 187 187 } 188 188 } -
uspace/srv/hid/input/port/ski.c
ra9d85df r1875a0c 110 110 if (c == 0) 111 111 break; 112 kbd_push_ scancode(kbd_dev, c);112 kbd_push_data(kbd_dev, c); 113 113 } 114 114 -
uspace/srv/hid/input/port/z8530.c
ra9d85df r1875a0c 142 142 static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call) 143 143 { 144 int scan_code = IPC_GET_ARG2(*call); 145 kbd_push_scancode(kbd_dev, scan_code); 144 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 146 145 147 146 if (irc_service) -
uspace/srv/hid/input/proto/adb.c
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 201 0 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @ brief29 /** @addtogroup mouse_proto 30 * @ingroup input 31 31 * @{ 32 32 */ 33 /** @file 33 /** 34 * @file 35 * @brief ADB protocol driver. 34 36 */ 35 37 36 #ifndef ADB_MOUSE_H_ 37 #define ADB_MOUSE_H_ 38 #include <bool.h> 39 #include <mouse.h> 40 #include <mouse_port.h> 41 #include <mouse_proto.h> 38 42 39 #include <sys/types.h> 43 static mouse_dev_t *mouse_dev; 44 static bool b1_pressed; 45 static bool b2_pressed; 40 46 41 #define NAME "adb_ms" 42 #define NAMESPACE "hid_in" 47 static int adb_proto_init(mouse_dev_t *mdev) 48 { 49 mouse_dev = mdev; 50 b1_pressed = false; 51 b2_pressed = false; 52 53 return 0; 54 } 43 55 44 extern void mouse_handle_data(uint16_t); 56 /** Process mouse data */ 57 static void adb_proto_parse(sysarg_t data) 58 { 59 bool b1, b2; 60 uint16_t udx, udy; 61 int dx, dy; 62 63 /* Extract fields. */ 64 b1 = ((data >> 15) & 1) == 0; 65 udy = (data >> 8) & 0x7f; 66 b2 = ((data >> 7) & 1) == 0; 67 udx = data & 0x7f; 68 69 /* Decode 7-bit two's complement signed values. */ 70 dx = (udx & 0x40) ? (udx - 0x80) : udx; 71 dy = (udy & 0x40) ? (udy - 0x80) : udy; 72 73 if (b1 != b1_pressed) { 74 mouse_push_event_button(mouse_dev, 1, b1); 75 b1_pressed = b1; 76 } 77 78 if (b2 != b2_pressed) { 79 mouse_push_event_button(mouse_dev, 2, b2); 80 b1_pressed = b1; 81 } 82 83 if (dx != 0 || dy != 0) 84 mouse_push_event_move(mouse_dev, dx, dy); 85 } 45 86 46 #endif 87 mouse_proto_ops_t adb_proto = { 88 .parse = adb_proto_parse, 89 .init = adb_proto_init 90 }; 47 91 48 92 /** -
uspace/srv/hid/input/proto/mousedev.c
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 2011 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** 30 * @addtogroup inputgen generic 31 * @brief Mouse device handling. 29 /** @addtogroup mouse_proto 32 30 * @ingroup input 33 31 * @{ 34 32 */ 35 /** @file 33 /** 34 * @file 35 * @brief Mouse device connector controller driver. 36 36 */ 37 37 38 #include <adt/list.h> 38 #include <stdio.h> 39 #include <fcntl.h> 40 #include <vfs/vfs_sess.h> 41 #include <malloc.h> 39 42 #include <async.h> 40 43 #include <errno.h> 41 #include < fcntl.h>44 #include <ipc/mouseev.h> 42 45 #include <input.h> 43 #include <ipc/mouse.h>44 46 #include <mouse.h> 45 #include <stdio.h> 46 #include <stdlib.h> 47 #include <vfs/vfs_sess.h> 47 #include <mouse_port.h> 48 #include <mouse_proto.h> 48 49 49 static void mouse_callback_conn(ipc_callid_t, ipc_call_t *, void *); 50 /** Mousedev softstate */ 51 typedef struct { 52 /** Link to generic mouse device */ 53 mouse_dev_t *mouse_dev; 54 55 /** Session to mouse device */ 56 async_sess_t *sess; 57 58 /** File descriptor of open mousedev device */ 59 int fd; 60 } mousedev_t; 50 61 51 static mouse _dev_t *mouse_dev_new(void)62 static mousedev_t *mousedev_new(mouse_dev_t *mdev) 52 63 { 53 mouse_dev_t *mdev; 54 55 mdev = calloc(1, sizeof(mouse_dev_t)); 56 if (mdev == NULL) { 57 printf(NAME ": Error allocating mouse device. " 58 "Out of memory.\n"); 64 mousedev_t *mousedev = calloc(1, sizeof(mousedev_t)); 65 if (mousedev == NULL) 59 66 return NULL; 60 } 61 62 link_initialize(&mdev->mouse_devs); 63 return mdev; 67 68 mousedev->mouse_dev = mdev; 69 mousedev->fd = -1; 70 71 return mousedev; 64 72 } 65 73 66 static int mouse_dev_connect(mouse_dev_t *mdev, const char *dev_path)74 static void mousedev_destroy(mousedev_t *mousedev) 67 75 { 68 async_sess_t *sess; 69 async_exch_t *exch; 70 int fd; 71 int rc; 72 73 fd = open(dev_path, O_RDWR); 74 if (fd < 0) { 75 return -1; 76 } 77 78 sess = fd_session(EXCHANGE_SERIALIZE, fd); 79 if (sess == NULL) { 80 printf(NAME ": Failed starting session with '%s'\n", dev_path); 81 close(fd); 82 return -1; 83 } 84 85 exch = async_exchange_begin(sess); 86 if (exch == NULL) { 87 printf(NAME ": Failed starting exchange with '%s'.\n", dev_path); 88 return -1; 89 } 90 91 rc = async_connect_to_me(exch, 0, 0, 0, mouse_callback_conn, mdev); 92 if (rc != EOK) { 93 printf(NAME ": Failed creating callback connection from '%s'.\n", 94 dev_path); 95 async_exchange_end(exch); 96 return -1; 97 } 98 99 async_exchange_end(exch); 100 101 mdev->dev_path = dev_path; 102 return 0; 76 if (mousedev->sess != NULL) 77 async_hangup(mousedev->sess); 78 79 if (mousedev->fd >= 0) 80 close(mousedev->fd); 81 82 free(mousedev); 103 83 } 104 84 105 /** Add new mouse device. 106 * 107 * @param dev_path Filesystem path to the device (/dev/class/...) 108 */ 109 int mouse_add_dev(const char *dev_path) 85 static void mousedev_callback_conn(ipc_callid_t iid, ipc_call_t *icall, 86 void *arg) 110 87 { 111 mouse_dev_t *mdev; 112 int rc; 113 114 mdev = mouse_dev_new(); 115 if (mdev == NULL) 116 return -1; 117 118 rc = mouse_dev_connect(mdev, dev_path); 119 if (rc != EOK) { 120 free(mdev); 121 return -1; 122 } 123 124 list_append(&mdev->mouse_devs, &mouse_devs); 125 return EOK; 126 } 127 128 /** Mouse device callback connection handler. */ 129 static void mouse_callback_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 130 { 131 int retval; 132 88 /* Mousedev device structure */ 89 mousedev_t *mousedev = (mousedev_t *) arg; 90 133 91 while (true) { 134 92 ipc_call_t call; 135 ipc_callid_t callid; 136 137 callid = async_get_call(&call); 93 ipc_callid_t callid = async_get_call(&call); 94 138 95 if (!IPC_GET_IMETHOD(call)) { 139 96 /* XXX Handle hangup */ 140 97 return; 141 98 } 142 99 100 int retval; 101 143 102 switch (IPC_GET_IMETHOD(call)) { 144 case M EVENT_BUTTON:145 input_event_button(IPC_GET_ARG1(call),103 case MOUSEEV_MOVE_EVENT: 104 mouse_push_event_move(mousedev->mouse_dev, IPC_GET_ARG1(call), 146 105 IPC_GET_ARG2(call)); 147 retval = 0;106 retval = EOK; 148 107 break; 149 case M EVENT_MOVE:150 input_event_move(IPC_GET_ARG1(call),108 case MOUSEEV_BUTTON_EVENT: 109 mouse_push_event_button(mousedev->mouse_dev, IPC_GET_ARG1(call), 151 110 IPC_GET_ARG2(call)); 152 retval = 0;111 retval = EOK; 153 112 break; 154 113 default: … … 156 115 break; 157 116 } 158 117 159 118 async_answer_0(callid, retval); 160 119 } 161 120 } 162 121 122 static int mousedev_proto_init(mouse_dev_t *mdev) 123 { 124 const char *pathname = mdev->dev_path; 125 126 int fd = open(pathname, O_RDWR); 127 if (fd < 0) 128 return -1; 129 130 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 131 if (sess == NULL) { 132 printf("%s: Failed starting session with '%s'\n", NAME, pathname); 133 close(fd); 134 return -1; 135 } 136 137 mousedev_t *mousedev = mousedev_new(mdev); 138 if (mousedev == NULL) { 139 printf("%s: Failed allocating device structure for '%s'.\n", 140 NAME, pathname); 141 return -1; 142 } 143 144 mousedev->fd = fd; 145 mousedev->sess = sess; 146 147 async_exch_t *exch = async_exchange_begin(sess); 148 if (exch == NULL) { 149 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 150 mousedev_destroy(mousedev); 151 return -1; 152 } 153 154 int rc = async_connect_to_me(exch, 0, 0, 0, mousedev_callback_conn, mousedev); 155 async_exchange_end(exch); 156 157 if (rc != EOK) { 158 printf("%s: Failed creating callback connection from '%s'.\n", 159 NAME, pathname); 160 mousedev_destroy(mousedev); 161 return -1; 162 } 163 164 return 0; 165 } 166 167 mouse_proto_ops_t mousedev_proto = { 168 .init = mousedev_proto_init 169 }; 170 163 171 /** 164 172 * @} -
uspace/srv/hid/input/proto/ps2.c
ra9d85df r1875a0c 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_proto 30 * @ingroup input 30 31 * @{ 31 32 */ 32 33 /** 33 34 * @file 34 * @brief PS/2 mouseprotocol driver.35 * @brief PS/2 protocol driver. 35 36 */ 36 37 37 #include < stdio.h>38 #include <mouse.h> 38 39 #include <mouse_port.h> 39 #include <char_mouse.h>40 40 #include <mouse_proto.h> 41 42 #define BUFSIZE 343 41 44 42 #define PS2_MOUSE_OUT_INIT 0xf4 45 43 #define PS2_MOUSE_ACK 0xfa 44 45 #define BUFSIZE 3 46 46 47 47 typedef struct { … … 49 49 unsigned char data[BUFSIZE]; 50 50 struct { 51 unsigned leftbtn : 1;52 unsigned rightbtn : 1;53 unsigned middlebtn : 1;54 unsigned i sone : 1; /* Always one */55 unsigned xsign : 1;56 unsigned ysign : 1;57 unsigned xovfl : 1;58 unsigned yovfl : 1;51 unsigned int leftbtn : 1; 52 unsigned int rightbtn : 1; 53 unsigned int middlebtn : 1; 54 unsigned int isone : 1; /* Always one */ 55 unsigned int xsign : 1; 56 unsigned int ysign : 1; 57 unsigned int xovfl : 1; 58 unsigned int yovfl : 1; 59 59 unsigned char x; 60 60 unsigned char y; … … 64 64 65 65 static ps2packet_t buf; 66 static int bufpos = 0;67 static int leftbtn = 0;68 static int rightbtn = 0;69 static int middlebtn = 0;66 static unsigned int bufpos; 67 static unsigned int leftbtn; 68 static unsigned int rightbtn; 69 static unsigned int middlebtn; 70 70 71 int mouse_proto_init(void) 71 static mouse_dev_t *mouse_dev; 72 73 static int ps2_proto_init(mouse_dev_t *mdev) 72 74 { 73 mouse_port_write(PS2_MOUSE_OUT_INIT); 75 mouse_dev = mdev; 76 bufpos = 0; 77 leftbtn = 0; 78 rightbtn = 0; 79 80 mouse_dev->port_ops->write(PS2_MOUSE_OUT_INIT); 74 81 return 0; 75 82 } … … 79 86 { 80 87 int tmp; 81 88 82 89 if (!sign) 83 90 return data; 84 85 tmp = ((unsigned char) ~data) + 1;91 92 tmp = ((unsigned char) ~data) + 1; 86 93 return -tmp; 87 94 } 88 95 89 96 /** Process mouse data */ 90 void mouse_proto_parse_byte(int data)97 static void ps2_proto_parse(sysarg_t data) 91 98 { 92 99 int x, y; 93 100 94 101 /* Check that we have not lost synchronization */ 95 102 if (bufpos == 0 && !(data & 0x8)) 96 103 return; /* Synchro lost, ignore byte */ 97 104 98 105 buf.u.data[bufpos++] = data; 99 106 if (bufpos == BUFSIZE) { 100 107 bufpos = 0; 101 108 102 109 if (buf.u.val.leftbtn ^ leftbtn) { 103 110 leftbtn = buf.u.val.leftbtn; 104 mouse_ ev_btn(1, leftbtn);111 mouse_push_event_button(mouse_dev, 1, leftbtn); 105 112 } 106 113 107 114 if (buf.u.val.rightbtn ^ rightbtn) { 108 115 rightbtn = buf.u.val.rightbtn; 109 mouse_ ev_btn(2, rightbtn);116 mouse_push_event_button(mouse_dev, 2, rightbtn); 110 117 } 111 118 112 119 if (buf.u.val.middlebtn ^ middlebtn) { 113 120 middlebtn = buf.u.val.middlebtn; 114 mouse_ ev_btn(3, middlebtn);121 mouse_push_event_button(mouse_dev, 3, middlebtn); 115 122 } 123 124 x = bit9toint(buf.u.val.xsign, buf.u.val.x); 125 y = -bit9toint(buf.u.val.ysign, buf.u.val.y); 126 127 if (x != 0 || y != 0) 128 mouse_push_event_move(mouse_dev, x, y); 129 } 130 } 116 131 117 x = bit9toint(buf.u.val.xsign, buf.u.val.x); 118 y = - bit9toint(buf.u.val.ysign, buf.u.val.y); 119 120 if (x != 0 || y != 0) { 121 mouse_ev_move(x, y); 122 } 123 } 124 125 return; 126 } 132 mouse_proto_ops_t ps2_proto = { 133 .parse = ps2_proto_parse, 134 .init = ps2_proto_init 135 }; 127 136 128 137 /** -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
ra9d85df r1875a0c 57 57 58 58 #define NAME "s3c24ser" 59 #define NAMESPACE "hid _in"59 #define NAMESPACE "hid" 60 60 61 61 static irq_cmd_t ts_irq_cmds[] = {
Note:
See TracChangeset
for help on using the changeset viewer.