genode/os/src/test/input/test.cc
Norman Feske af66043b79 New Input::Event::FOCUS, rename keycode to code
This patch introduces keyboard-focus events to the 'Input::Event' class
and changes the name 'Input::Event::keycode' to 'code'. The 'code'
represents the key code for PRESS/RELEASE events, and the focus state
for FOCUS events (0 - unfocused, 1 - focused).

Furthermore, nitpicker has been adapted to deliver FOCUS events to its
clients.

Fixes #609
2013-01-15 10:18:11 +01:00

62 lines
1.3 KiB
C++

/*
* \brief Input service test program
* \author Christian Helmuth
* \date 2010-06-15
*/
/*
* Copyright (C) 2010-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#include <base/env.h>
#include <base/printf.h>
#include <timer_session/connection.h>
#include <input_session/connection.h>
#include <input/event.h>
#include "key_strings.h"
using namespace Genode;
int main(int argc, char **argv)
{
/*
* Init sessions to the required external services
*/
static Input::Connection input;
static Timer::Connection timer;
PLOG("--- Input test is up ---");
Input::Event *ev_buf = (env()->rm_session()->attach(input.dataspace()));
PLOG("input buffer at %p", ev_buf);
/*
* Handle input events
*/
int key_cnt = 0;
while (1) {
/* poll input service every 20 ms */
while (!input.is_pending()) timer.msleep(20);
for (int i = 0, num_ev = input.flush(); i < num_ev; ++i) {
Input::Event *ev = &ev_buf[i];
if (ev->type() == Input::Event::PRESS) key_cnt++;
if (ev->type() == Input::Event::RELEASE) key_cnt--;
/* log event */
PLOG("Input event type=%d\tcode=%d\trx=%d\try=%d\tkey_cnt=%d\t%s",
ev->type(), ev->code(), ev->rx(), ev->ry(), key_cnt,
key_strings[ev->code()]);
}
}
return 0;
}