Changeset 47a350f in mainline for uspace/srv/kbd/generic/kbd.c


Ignore:
Timestamp:
2009-12-16T01:49:16Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df747bd8
Parents:
4491338
Message:

keyboard is not a single possible human input device, thus don't register the kbd driver as a singleton service to the Naming service, but to the Device mapper

File:
1 edited

Legend:

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

    r4491338 r47a350f  
    5050#include <io/console.h>
    5151#include <io/keycode.h>
     52#include <devmap.h>
    5253
    5354#include <kbd.h>
     
    5657#include <layout.h>
    5758
    58 #define NAME "kbd"
    59 
    60 int cons_connected = 0;
     59#define NAME       "kbd"
     60#define NAMESPACE  "hid_in"
     61
    6162int phone2cons = -1;
    6263
     
    172173        int retval;
    173174
    174         if (cons_connected) {
    175                 ipc_answer_0(iid, ELIMIT);
    176                 return;
    177         }
    178         cons_connected = 1;
    179175        ipc_answer_0(iid, EOK);
    180176
     
    183179                switch (IPC_GET_METHOD(call)) {
    184180                case IPC_M_PHONE_HUNGUP:
    185                         cons_connected = 0;
    186                         ipc_hangup(phone2cons);
    187                         phone2cons = -1;
     181                        if (phone2cons != -1) {
     182                                ipc_hangup(phone2cons);
     183                                phone2cons = -1;
     184                        }
     185                       
    188186                        ipc_answer_0(callid, EOK);
    189187                        return;
     
    216214        printf(NAME ": HelenOS Keyboard service\n");
    217215       
    218         ipcarg_t phonead;
    219        
    220216        if (sysinfo_value("kbd.cir.fhc") == 1)
    221217                cir_service = SERVICE_FHC;
     
    241237        layout[active_layout]->reset();
    242238       
    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)
    247                 return -1;
    248        
     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                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
    249255        printf(NAME ": Accepting connections\n");
    250256        async_manager();
Note: See TracChangeset for help on using the changeset viewer.