Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/kbd/generic/kbd.c

    r47a350f re795203  
    5050#include <io/console.h>
    5151#include <io/keycode.h>
    52 #include <devmap.h>
    5352
    5453#include <kbd.h>
     
    5756#include <layout.h>
    5857
    59 #define NAME       "kbd"
    60 #define NAMESPACE  "hid_in"
    61 
     58#define NAME "kbd"
     59
     60int cons_connected = 0;
    6261int phone2cons = -1;
    6362
     
    173172        int retval;
    174173
     174        if (cons_connected) {
     175                ipc_answer_0(iid, ELIMIT);
     176                return;
     177        }
     178        cons_connected = 1;
    175179        ipc_answer_0(iid, EOK);
    176180
     
    179183                switch (IPC_GET_METHOD(call)) {
    180184                case IPC_M_PHONE_HUNGUP:
    181                         if (phone2cons != -1) {
    182                                 ipc_hangup(phone2cons);
    183                                 phone2cons = -1;
    184                         }
    185                        
     185                        cons_connected = 0;
     186                        ipc_hangup(phone2cons);
     187                        phone2cons = -1;
    186188                        ipc_answer_0(callid, EOK);
    187189                        return;
     
    214216        printf(NAME ": HelenOS Keyboard service\n");
    215217       
     218        ipcarg_t phonead;
     219       
    216220        if (sysinfo_value("kbd.cir.fhc") == 1)
    217221                cir_service = SERVICE_FHC;
     
    237241        layout[active_layout]->reset();
    238242       
    239         /* Register driver */
    240         int rc = devmap_driver_register(NAME, console_connection);
    241         if (rc < 0) {
    242                 printf(NAME ": Unable to register driver (%d)\n", rc);
     243        async_set_client_connection(console_connection);
     244
     245        /* Register service at nameserver. */
     246        if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0)
    243247                return -1;
    244         }
    245        
    246         char kbd[DEVMAP_NAME_MAXLEN + 1];
    247         snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
    248        
    249         dev_handle_t dev_handle;
    250         if (devmap_device_register(kbd, &dev_handle) != EOK) {
    251                 printf(NAME ": Unable to register device %s\n", kbd);
    252                 return -1;
    253         }
    254 
     248       
    255249        printf(NAME ": Accepting connections\n");
    256250        async_manager();
Note: See TracChangeset for help on using the changeset viewer.