Changeset 2e833cf7 in mainline


Ignore:
Timestamp:
2011-06-17T21:22:58Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8bc7f8
Parents:
051f96b
Message:

mkbd quits on Escape key

The actual quit is rather brutal (no letting the main fibril know
about ending) but better than need to run killall ;-).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkbd/main.c

    r051f96b r2e833cf7  
    5252#include <usb/hid/hiddescriptor.h>
    5353#include <usb/hid/usages/consumer.h>
     54#include <io/console.h>
     55#include <io/keycode.h>
    5456#include <assert.h>
    5557
     
    166168       
    167169        usb_hid_report_path_free(path);
     170}
     171
     172static int wait_for_quit_fibril(void *arg)
     173{
     174        console_ctrl_t *con = console_init(stdin, stdout);
     175
     176        printf("Press <ESC> to quit the application.\n");
     177
     178        while (1) {
     179                kbd_event_t ev;
     180                bool ok = console_get_kbd_event(con, &ev);
     181                if (!ok) {
     182                        printf("Connection with console broken: %s.\n",
     183                            str_error(errno));
     184                        break;
     185                }
     186
     187                if (ev.key == KC_ESCAPE) {
     188                        break;
     189                }
     190        }
     191
     192        console_done(con);
     193
     194        exit(0);
     195
     196        return EOK;
    168197}
    169198
     
    242271        }
    243272       
     273        fid_t quit_fibril = fibril_create(wait_for_quit_fibril, NULL);
     274        if (quit_fibril == 0) {
     275                printf("Failed to start extra fibril.\n");
     276                return -1;
     277        }
     278        fibril_add_ready(quit_fibril);
     279
    244280        size_t actual_size;
    245281        int event_nr;
    246        
     282
    247283        while (true) {
    248284                /** @todo Try blocking call. */
Note: See TracChangeset for help on using the changeset viewer.