2012-04-17 18:46:14 +02:00
|
|
|
/*
|
|
|
|
* \brief Virtualized input session
|
|
|
|
* \author Christian Prochaska
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2010-09-02
|
|
|
|
*
|
|
|
|
* This input service implementation is used by the virtualized nitpicker
|
|
|
|
* service to translate the input coordinate system from the coordinates
|
|
|
|
* seen by the user of the virtualized session and the physical coordinates
|
|
|
|
* dictated by the loader-session client.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-01-13 15:20:30 +01:00
|
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
2012-04-17 18:46:14 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-04-17 18:46:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INPUT_H_
|
|
|
|
#define _INPUT_H_
|
|
|
|
|
|
|
|
#include <base/rpc_server.h>
|
|
|
|
#include <input/event.h>
|
|
|
|
#include <input/keycodes.h>
|
|
|
|
#include <input_session/client.h>
|
|
|
|
|
|
|
|
namespace Input {
|
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
2014-06-30 17:47:43 +02:00
|
|
|
typedef Genode::Point<> Motion_delta;
|
2012-04-17 18:46:14 +02:00
|
|
|
|
2014-06-30 17:47:43 +02:00
|
|
|
class Session_component;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Input::Session_component : public Rpc_object<Session>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2017-01-04 15:05:37 +01:00
|
|
|
Session_client _real_input;
|
|
|
|
Motion_delta &_motion_delta;
|
|
|
|
Attached_dataspace _ev_ds;
|
|
|
|
Event * const _ev_buf;
|
2014-06-30 17:47:43 +02:00
|
|
|
|
2016-01-29 10:36:33 +01:00
|
|
|
Genode::Signal_context_capability _sigh;
|
|
|
|
|
2014-06-30 17:47:43 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2017-01-04 15:05:37 +01:00
|
|
|
Session_component(Region_map &rm,
|
|
|
|
Session_capability real_input,
|
2014-06-30 17:47:43 +02:00
|
|
|
Motion_delta &motion_delta)
|
|
|
|
:
|
2017-01-13 15:20:30 +01:00
|
|
|
_real_input(rm, real_input), _motion_delta(motion_delta),
|
2017-01-04 15:05:37 +01:00
|
|
|
_ev_ds(rm, _real_input.dataspace()),
|
|
|
|
_ev_buf(_ev_ds.local_addr<Event>())
|
2014-06-30 17:47:43 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
** Input session interface **
|
|
|
|
*****************************/
|
2014-05-07 10:33:20 +02:00
|
|
|
|
2014-06-30 17:47:43 +02:00
|
|
|
Dataspace_capability dataspace() override { return _real_input.dataspace(); }
|
|
|
|
|
2016-05-11 18:21:47 +02:00
|
|
|
bool pending() const override { return _real_input.pending(); }
|
2014-06-30 17:47:43 +02:00
|
|
|
|
|
|
|
int flush() override
|
|
|
|
{
|
|
|
|
/* translate mouse position to child's coordinate system */
|
|
|
|
Motion_delta const delta = _motion_delta;
|
|
|
|
|
|
|
|
int const num_ev = _real_input.flush();
|
|
|
|
for (int i = 0; i < num_ev; i++) {
|
|
|
|
|
|
|
|
Input::Event &ev = _ev_buf[i];
|
|
|
|
|
|
|
|
if ((ev.type() == Input::Event::MOTION)
|
|
|
|
|| (ev.type() == Input::Event::WHEEL)
|
|
|
|
|| (ev.code() == Input::BTN_LEFT)
|
|
|
|
|| (ev.code() == Input::BTN_RIGHT)
|
|
|
|
|| (ev.code() == Input::BTN_MIDDLE)) {
|
|
|
|
|
|
|
|
ev = Input::Event(ev.type(),
|
|
|
|
ev.code(),
|
|
|
|
ev.ax() + delta.x(),
|
|
|
|
ev.ay() + delta.y(),
|
|
|
|
ev.rx(),
|
|
|
|
ev.ry());
|
|
|
|
}
|
2014-05-07 10:33:20 +02:00
|
|
|
}
|
2014-06-30 17:47:43 +02:00
|
|
|
|
|
|
|
return num_ev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sigh(Signal_context_capability sigh) override
|
|
|
|
{
|
2016-01-29 10:36:33 +01:00
|
|
|
/*
|
|
|
|
* Maintain local copy of signal-context capability to keep
|
|
|
|
* NOVA from flushing transitive delegations of the capability.
|
|
|
|
*/
|
|
|
|
_sigh = sigh;
|
|
|
|
|
2014-06-30 17:47:43 +02:00
|
|
|
_real_input.sigh(sigh);
|
|
|
|
}
|
|
|
|
};
|
2012-04-17 18:46:14 +02:00
|
|
|
|
|
|
|
#endif /* _INPUT_H_ */
|