Changeset 43c3937 in mainline for uspace/srv/hid/console/console.c


Ignore:
Timestamp:
2011-01-07T10:43:15Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5097bed4
Parents:
5f7d96e (diff), 0f191a2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/console.c

    r5f7d96e r43c3937  
    741741}
    742742
     743/** Try to connect to given keyboard, bypassing provided libc routines.
     744 *
     745 * @param devmap_path Path to keyboard without /dev prefix.
     746 * @return Phone or error code.
     747 */
     748static int connect_keyboard_bypass(char *devmap_path)
     749{
     750        int devmap_phone = async_connect_me_to_blocking(PHONE_NS,
     751            SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
     752        if (devmap_phone < 0) {
     753                return devmap_phone;
     754        }
     755        ipc_call_t answer;
     756        aid_t req = async_send_2(devmap_phone, DEVMAP_DEVICE_GET_HANDLE,
     757            0, 0,  &answer);
     758
     759        sysarg_t retval = async_data_write_start(devmap_phone,
     760            devmap_path, str_size(devmap_path));
     761        if (retval != EOK) {
     762                async_wait_for(req, NULL);
     763                ipc_hangup(devmap_phone);
     764                return retval;
     765        }
     766
     767        async_wait_for(req, &retval);
     768
     769        if (retval != EOK) {
     770                ipc_hangup(devmap_phone);
     771                return retval;
     772        }
     773
     774        devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     775
     776        ipc_hangup(devmap_phone);
     777
     778        int phone = async_connect_me_to(PHONE_NS,
     779            SERVICE_DEVMAP, DEVMAP_CONNECT_TO_DEVICE, handle);
     780        if (phone < 0) {
     781                return phone;
     782        }
     783
     784        /* NB: The callback connection is slotted for removal */
     785        sysarg_t phonehash;
     786        int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
     787            0, 0, NULL, NULL, NULL, NULL, &phonehash);
     788        if (rc != EOK) {
     789                printf(NAME ": Failed to create callback from input device\n");
     790                return rc;
     791        }
     792
     793        async_new_connection(phonehash, 0, NULL, keyboard_events);
     794
     795        printf(NAME ": we got a hit (new keyboard \"/dev/%s\").\n",
     796            devmap_path);
     797
     798        return phone;
     799}
     800
    743801
    744802static int check_new_keyboards(void *arg)
     
    751809                async_usleep(1 * 500 * 1000);
    752810                char *path;
    753                 int rc = asprintf(&path, "/dev/class/%s\\%d", class_name, index);
     811                int rc = asprintf(&path, "class/%s\\%d", class_name, index);
    754812                if (rc < 0) {
    755813                        continue;
    756814                }
    757815                rc = 0;
    758                 rc = connect_keyboard(path);
     816                rc = connect_keyboard_bypass(path);
    759817                if (rc > 0) {
    760818                        /* We do not allow unplug. */
Note: See TracChangeset for help on using the changeset viewer.