2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Input event structure
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2006-08-16
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 20:44:47 +00:00
|
|
|
* Copyright (C) 2006-2013 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__INPUT__EVENT_H_
|
|
|
|
#define _INCLUDE__INPUT__EVENT_H_
|
|
|
|
|
2013-09-06 12:43:12 +00:00
|
|
|
#include <input/keycodes.h>
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
namespace Input {
|
|
|
|
|
|
|
|
class Event
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-01-12 22:34:49 +00:00
|
|
|
enum Type { INVALID, MOTION, PRESS, RELEASE, WHEEL, FOCUS, LEAVE };
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Type _type;
|
2013-01-12 22:34:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For PRESS and RELEASE events, '_code' contains the key code.
|
|
|
|
* For FOCUS events, '_code' is set to 1 (focus) or 0 (unfocus).
|
|
|
|
*/
|
|
|
|
int _code;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Absolute pointer position coordinates
|
|
|
|
*/
|
|
|
|
int _ax, _ay;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Relative pointer motion vector
|
|
|
|
*/
|
|
|
|
int _rx, _ry;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructors
|
|
|
|
*/
|
|
|
|
Event():
|
2013-01-12 22:34:49 +00:00
|
|
|
_type(INVALID), _code(0), _ax(0), _ay(0), _rx(0), _ry(0) { }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2013-01-12 22:34:49 +00:00
|
|
|
Event(Type type, int code, int ax, int ay, int rx, int ry):
|
|
|
|
_type(type), _code(code),
|
2011-12-22 15:19:25 +00:00
|
|
|
_ax(ax), _ay(ay), _rx(rx), _ry(ry) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessors
|
|
|
|
*/
|
2013-01-12 22:34:49 +00:00
|
|
|
Type type() const { return _type; }
|
|
|
|
int code() const { return _code; }
|
|
|
|
int ax() const { return _ax; }
|
|
|
|
int ay() const { return _ay; }
|
|
|
|
int rx() const { return _rx; }
|
|
|
|
int ry() const { return _ry; }
|
2012-01-17 22:06:02 +00:00
|
|
|
|
2013-09-06 12:43:12 +00:00
|
|
|
/**
|
|
|
|
* Return key code for press/release events
|
|
|
|
*/
|
|
|
|
Keycode keycode() const
|
|
|
|
{
|
|
|
|
return _type == PRESS || _type == RELEASE ? (Keycode)_code : KEY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2012-01-17 22:06:02 +00:00
|
|
|
bool is_absolute_motion() const { return _type == MOTION && !_rx && !_ry; }
|
|
|
|
bool is_relative_motion() const { return _type == MOTION && (_rx || _ry); }
|
2011-12-22 15:19:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__INPUT__EVENT_H_ */
|