API update for input_normalizer, depot recipes
Update the input_normalizer to use new input event and timer APIs. Add a depot package and a test. Fix #103
This commit is contained in:
committed by
Norman Feske
parent
e6c31ccc3e
commit
fa9b94e377
2
recipes/src/input_normalizer/content.mk
Normal file
2
recipes/src/input_normalizer/content.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
SRC_DIR = src/server/input_normalizer
|
||||
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
||||
1
recipes/src/input_normalizer/hash
Normal file
1
recipes/src/input_normalizer/hash
Normal file
@@ -0,0 +1 @@
|
||||
2018-05-04 684010e420025fbff56c55549e5988bee357a9c9
|
||||
4
recipes/src/input_normalizer/used_apis
Normal file
4
recipes/src/input_normalizer/used_apis
Normal file
@@ -0,0 +1,4 @@
|
||||
base
|
||||
input_session
|
||||
timer_session
|
||||
os
|
||||
179
run/input_normalizer.run
Normal file
179
run/input_normalizer.run
Normal file
@@ -0,0 +1,179 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
assert_spec x86
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
server/dynamic_rom
|
||||
server/input_normalizer
|
||||
test/input
|
||||
}
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
lappend_if [have_spec ps2] build_components drivers/input/spec/ps2
|
||||
lappend_if [have_spec sdl] build_components drivers/framebuffer/spec/sdl
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route/>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
<route>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="IO_MEM"> <parent/> </service>
|
||||
<service name="IRQ"> <parent/> </service>
|
||||
<service name="IO_PORT"> <parent/> </service>
|
||||
</route>
|
||||
</start>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec ps2] config {
|
||||
<start name="ps2_drv">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides><service name="Input"/></provides>
|
||||
<config verbose_keyboard="no" verbose_mouse="no" verbose_scancodes="no"
|
||||
capslock_led="rom" numlock_led="rom" scrlock_led="rom"/>
|
||||
<route>
|
||||
<service name="ROM" label="capslock"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM" label="numlock"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM" label="scrlock"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="IO_PORT"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Platform"> <any-child/> </service>
|
||||
</route>
|
||||
</start>
|
||||
<alias name="input_drv" child="ps2_drv"/>}
|
||||
|
||||
append_if [have_spec sdl] config {
|
||||
<start name="fb_sdl">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="Input"/> <service name="Framebuffer"/> </provides>
|
||||
<route>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
</route>
|
||||
</start>
|
||||
<alias name="input_drv" child="fb_sdl"/>}
|
||||
|
||||
append config {
|
||||
|
||||
<start name="dynamic_rom">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="ROM"/> </provides>
|
||||
<config verbose="no">
|
||||
<rom name="capslock">
|
||||
<inline> <capslock enabled="no"/> </inline>
|
||||
<sleep milliseconds="250" />
|
||||
<inline> <capslock enabled="yes"/> </inline>
|
||||
<sleep milliseconds="250" />
|
||||
</rom>
|
||||
<rom name="numlock">
|
||||
<inline> <numlock enabled="no"/> </inline>
|
||||
<sleep milliseconds="500" />
|
||||
<inline> <numlock enabled="yes"/> </inline>
|
||||
<sleep milliseconds="500" />
|
||||
</rom>
|
||||
<rom name="scrlock">
|
||||
<inline> <scrlock enabled="no"/> </inline>
|
||||
<sleep milliseconds="1000" />
|
||||
<inline> <scrlock enabled="yes"/> </inline>
|
||||
<sleep milliseconds="1000" />
|
||||
</rom>
|
||||
</config>
|
||||
<route>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="input_normalizer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Input"/> </provides>
|
||||
<route>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
<service name="Input"> <child name="input_drv"/> </service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="test-input">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<route>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
<service name="Input"> <child name="input_normalizer"/> </service>
|
||||
</route>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
</config>}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
# generic modules
|
||||
set boot_modules {
|
||||
core ld.lib.so init
|
||||
timer dynamic_rom
|
||||
input_normalizer
|
||||
test-input
|
||||
}
|
||||
|
||||
# platform-specific modules
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
lappend_if [have_spec ps2] boot_modules ps2_drv
|
||||
lappend_if [have_spec sdl] boot_modules fb_sdl
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
|
||||
run_genode_until forever
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2018 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.
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
@@ -47,7 +47,8 @@ struct Input_normalizer::Main
|
||||
return value;
|
||||
}
|
||||
|
||||
unsigned const period_us = config_period_ms() * 1000;
|
||||
Microseconds const period_us =
|
||||
Microseconds{config_period_ms() * 1000};
|
||||
|
||||
/* input session provided by our parent */
|
||||
Input::Connection parent_input { env };
|
||||
@@ -64,48 +65,46 @@ struct Input_normalizer::Main
|
||||
/* Timer session for delaying events */
|
||||
Timer::Connection timer { env };
|
||||
|
||||
enum { STAY_ACTIVE = 10 };
|
||||
int timer_active = 0;
|
||||
/* submit after delay */
|
||||
void handle_timeout(Duration)
|
||||
{
|
||||
if (!queue.empty())
|
||||
queue.submit_signal();
|
||||
}
|
||||
|
||||
/* signaled by input */
|
||||
Timer::One_shot_timeout<Main> burst_timeout =
|
||||
{ timer, *this, &Main::handle_timeout };
|
||||
|
||||
/* signaled by input signal */
|
||||
void handle_input()
|
||||
{
|
||||
using namespace Input;
|
||||
|
||||
/* forward the queue */
|
||||
/*
|
||||
* laggy pointing is upleasant, so signal downstream if
|
||||
* there is anything other than button presses upstream,
|
||||
* otherwise notify downstream after a timeout
|
||||
*/
|
||||
bool notify = false;
|
||||
|
||||
parent_input.for_each_event([&] (Event const &e) {
|
||||
/*
|
||||
* laggy pointing is upleasant, so signal the client if
|
||||
* there is anything other than button presses queued,
|
||||
* otherwise notify the client when the timer fires
|
||||
*/
|
||||
queue.add(e, (e.type() != Event::PRESS) && (e.type() != Event::RELEASE));
|
||||
if (!e.press() && !e.release())
|
||||
notify = true;
|
||||
enum { SUBMIT_NOW = false };
|
||||
queue.add(e, SUBMIT_NOW);
|
||||
});
|
||||
|
||||
if (timer_active < 1) /* wake up the timer */
|
||||
timer.trigger_periodic(period_us);
|
||||
|
||||
timer_active = STAY_ACTIVE;
|
||||
if (notify) {
|
||||
queue.submit_signal();
|
||||
burst_timeout.discard();
|
||||
} else if (!burst_timeout.scheduled()) {
|
||||
burst_timeout.schedule(period_us);
|
||||
}
|
||||
}
|
||||
|
||||
Signal_handler<Main> input_handler =
|
||||
{ env.ep(), *this, &Main::handle_input };
|
||||
|
||||
/* signaled by timer */
|
||||
void handle_timer()
|
||||
{
|
||||
if (queue.empty()) {
|
||||
--timer_active;
|
||||
/* stop the timer if nothing is happening */
|
||||
if (timer_active < 1)
|
||||
timer.trigger_periodic(0);
|
||||
} else
|
||||
queue.submit_signal();
|
||||
}
|
||||
|
||||
Signal_handler<Main> timer_handler =
|
||||
{ env.ep(), *this, &Main::handle_timer };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -116,9 +115,6 @@ struct Input_normalizer::Main
|
||||
/* register input handler */
|
||||
parent_input.sigh(input_handler);
|
||||
|
||||
/* register timeout handler */
|
||||
timer.sigh(timer_handler);
|
||||
|
||||
/* announce service */
|
||||
env.parent().announce(env.ep().manage(input_root));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user