Beispiel #1
0
Datei: main.cpp Projekt: s50/mona
int main(int argc, char* argv[])
{
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    syscall_get_io();
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    intptr_t ret = monapi_enable_stacktrace("/SERVERS/KEYBDMNG.map");
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (ret != M_OK) {
        monapi_warn("syscall_stack_trace_enable error %d\n", ret);
        exit(-1);
    }
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    /* initilize KeyBoardManager */
    KeyBoardManager manager;
    manager.init();

  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (monapi_notify_server_start("MONITOR.BIN") != M_OK) {
        exit(-1);
    }
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    syscall_set_irq_receiver(1, 0);
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (monapi_name_add("/servers/keyboard") != M_OK) {
        monapi_fatal("monapi_name_add failed");
    }
    KeyboardServer server;
    server.messageLoop(manager);
    return 0;
}
Beispiel #2
0
Datei: main.cpp Projekt: s50/mona
    void sendKeyInformation(KeyBoardManager& manager, uint8_t scancode)
    {
        MessageInfo message;
        KeyInfo keyinfo;

        /* scan code to virtual key information */
        if(manager.setKeyScanCode(scancode) == 0) {
            return;
        }
        manager.getKeyInfo(&keyinfo);

        memset(&message, 0, sizeof(MessageInfo));
        Message::create(&message, MSG_KEY_VIRTUAL_CODE, keyinfo.keycode, keyinfo.modifiers, keyinfo.charcode, NULL);

        sendToClients(&message);
    }
Beispiel #3
0
int main(int argc, char* argv[])
{
    /* user mode I/O */
    syscall_get_io();

    const char* MAP_FILE_PATH = "/SERVERS/KEYBDMNG.map";
    uint32_t pid = syscall_get_pid();
    intptr_t ret = syscall_stack_trace_enable(pid, MAP_FILE_PATH);
    if (ret != M_OK) {
        monapi_warn("syscall_stack_trace_enable error %d\n", ret);
        exit(-1);
    }

    /* initilize KeyBoardManager */
    KeyBoardManager* manager = new KeyBoardManager();
    manager->init();

    /* initilize destination list */
    List<uint32_t>* destList = new HList<uint32_t>();
    MessageInfo info;

    if (monapi_notify_server_start("MONITOR.BIN") != M_OK)
    {
        exit(-1);
    }

    syscall_set_irq_receiver(1, 0);

    if (monapi_name_add("/servers/keyboard") != M_OK) {
        monapi_fatal("monapi_name_add failed");
    }

    /* Message loop */
    for (;;)
    {
        /* receive */
        if (!Message::receive(&info))
        {
            switch(info.header)
            {
            case MSG_INTERRUPTED:

                sendKeyInformation(manager, destList, inp8(0x60));

                break;

            case MSG_ADD:

                regist(destList, &info);
                Message::reply(&info);
                break;

            case MSG_REMOVE:

                unregist(destList, &info);
                Message::reply(&info);
                break;

            default:
                /* igonore this message */

                break;
            }
        }
    }
    return 0;
}