Ignore:
Timestamp:
2011-06-14T21:40:28Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
662da50, e3a46c2
Parents:
ecb692a2
Message:

Route mouse input through input server. Remove device-handling code from
console server.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/generic/input.c

    recb692a2 r854eddd6  
    5454#include <io/keycode.h>
    5555#include <devmap.h>
     56#include <input.h>
    5657#include <kbd.h>
    5758#include <kbd_port.h>
    5859#include <kbd_ctl.h>
    5960#include <layout.h>
     61#include <mouse.h>
    6062
    6163// FIXME: remove this header
     
    6870static void kbd_devs_reclaim(void);
    6971
     72static void input_event_key(int, unsigned int, unsigned, wchar_t);
     73
    7074int client_phone = -1;
    7175
    7276/** List of keyboard devices */
    7377static link_t kbd_devs;
     78
     79/** List of mouse devices */
     80link_t mouse_devs;
    7481
    7582bool irc_service = false;
     
    166173
    167174        ev.c = layout_parse_ev(kdev->active_layout, &ev);
    168 
    169         async_obsolete_msg_4(client_phone, INPUT_EVENT, ev.type, ev.key, ev.mods, ev.c);
     175        input_event_key(ev.type, ev.key, ev.mods, ev.c);
     176}
     177
     178/** Key has been pressed or released. */
     179static 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);
     184}
     185
     186/** Mouse pointer has moved. */
     187void input_event_move(int dx, int dy)
     188{
     189        async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy);
     190}
     191
     192/** Mouse button has been pressed. */
     193void input_event_button(int bnum, int press)
     194{
     195        async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press);
    170196}
    171197
     
    221247        kdev = calloc(1, sizeof(kbd_dev_t));
    222248        if (kdev == NULL) {
    223                 printf(NAME ": Allocating keyboard device. Out of memory.\n");
     249                printf(NAME ": Error allocating keyboard device. "
     250                    "Out of memory.\n");
    224251                return NULL;
    225252        }
     
    374401}
    375402
    376 /** Periodically check for new kbdev devices in /dev/class/keyboard.
     403/** Periodically check for new input devices.
     404 *
     405 * Looks under /dev/class/keyboard and /dev/class/mouse.
    377406 *
    378407 * @param arg   Ignored
     
    381410{
    382411        char *dev_path;
    383         size_t id = 1;
     412        size_t kbd_id = 1;
     413        size_t mouse_id = 1;
    384414        int rc;
    385415
     
    387417                async_usleep(DISCOVERY_POLL_INTERVAL);
    388418
    389                 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", id);
     419                /*
     420                 * Check for new keyboard device
     421                 */
     422                rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id);
    390423                if (rc < 0)
    391424                        continue;
    392425
    393426                if (kbd_add_kbdev(dev_path) == EOK) {
    394                         printf(NAME ": Connected kbdev device '%s'\n",
     427                        printf(NAME ": Connected keyboard device '%s'\n",
    395428                            dev_path);
    396429
    397430                        /* XXX Handle device removal */
    398                         ++id;
     431                        ++kbd_id;
    399432                }
    400433
    401434                free(dev_path);
     435
     436                /*
     437                 * Check for new mouse device
     438                 */
     439                rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id);
     440                if (rc < 0)
     441                        continue;
     442
     443                if (mouse_add_dev(dev_path) == EOK) {
     444                        printf(NAME ": Connected mouse device '%s'\n",
     445                            dev_path);
     446
     447                        /* XXX Handle device removal */
     448                        ++mouse_id;
     449                }
     450
     451                free(dev_path);
    402452        }
    403453
     
    406456
    407457/** Start a fibril for discovering new devices. */
    408 static void kbd_start_dev_discovery(void)
     458static void input_start_dev_discovery(void)
    409459{
    410460        fid_t fid;
     
    427477       
    428478        list_initialize(&kbd_devs);
     479        list_initialize(&mouse_devs);
    429480       
    430481        if (((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc))
     
    437488        }
    438489       
    439         /* Add legacy devices. */
     490        /* Add legacy keyboard devices. */
    440491        kbd_add_legacy_devs();
    441492
     493        /* Add legacy (devmap-style) mouse device. */
     494        (void) mouse_add_dev("/dev/hid_in/mouse");
    442495       
    443496        /* Register driver */
     
    457510        }
    458511
    459         /* Start looking for new kbdev devices */
    460         kbd_start_dev_discovery();
     512        /* Start looking for new input devices */
     513        input_start_dev_discovery();
    461514
    462515        printf(NAME ": Accepting connections\n");
Note: See TracChangeset for help on using the changeset viewer.