From 869522b100e8376d2d5e7284aa08a422abf24dec Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 27 Nov 2017 19:29:55 -0600 Subject: [PATCH] remove input_remap in favor of input_merger --- run/cave_story.run | 40 ++-- run/chroot.run | 126 ------------- run/meteor.run | 2 - src/app/retro_frontend/README | 4 +- src/server/chroot/README | 33 ---- src/server/chroot/component.cc | 274 ---------------------------- src/server/chroot/target.mk | 3 - src/server/input_remap/README | 14 -- src/server/input_remap/component.cc | 134 -------------- src/server/input_remap/target.mk | 3 - 10 files changed, 15 insertions(+), 618 deletions(-) delete mode 100644 run/chroot.run delete mode 100644 src/server/chroot/README delete mode 100644 src/server/chroot/component.cc delete mode 100644 src/server/chroot/target.mk delete mode 100644 src/server/input_remap/README delete mode 100644 src/server/input_remap/component.cc delete mode 100644 src/server/input_remap/target.mk diff --git a/run/cave_story.run b/run/cave_story.run index 9726daf..21d685d 100644 --- a/run/cave_story.run +++ b/run/cave_story.run @@ -15,7 +15,6 @@ set build_components { drivers/timer libretro/nxengine server/fb_upscale - server/input_remap } source ${genode_dir}/repos/base/run/platform_drv.inc @@ -109,30 +108,6 @@ append config { - - - - - - - - - - - - - - - - - - - - - - - - @@ -141,6 +116,18 @@ append config { + + + + + + + + + + + + @@ -152,7 +139,7 @@ append config { - + @@ -174,7 +161,6 @@ append boot_modules { core init ld.lib.so } [audio_drv_binary] { fb_upscale - input_remap libc.lib.so libm.lib.so nxengine_libretro.lib.so diff --git a/run/chroot.run b/run/chroot.run deleted file mode 100644 index 49da752..0000000 --- a/run/chroot.run +++ /dev/null @@ -1,126 +0,0 @@ -# -# \brief Chroot test -# \author Emery Hemingway -# \date 2016-12-03 -# - -# -# Build -# - -build { core init server/vfs server/chroot test/libc } - -create_boot_directory - -# -# Generate config -# - -set config { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -install_config $config - -# -# Boot modules -# - -build_boot_image { - core init vfs chroot - ld.lib.so libc.lib.so libm.lib.so posix.lib.so - test-libc -} - -# -# Execute test case -# - -append qemu_args " -nographic " -run_genode_until {child "test-libc-3" exited with exit value 0} 60 - -# vi: set ft=tcl : diff --git a/run/meteor.run b/run/meteor.run index fa26751..361b7dc 100644 --- a/run/meteor.run +++ b/run/meteor.run @@ -17,7 +17,6 @@ set build_components { drivers/audio libretro/meteor server/fb_upscale - server/input_remap } source ${genode_dir}/repos/base/run/platform_drv.inc @@ -165,7 +164,6 @@ if {![file exists bin/game.gba]} { # generic modules append boot_modules { fb_upscale - input_remap libc.lib.so libm.lib.so meteor_libretro.lib.so diff --git a/src/app/retro_frontend/README b/src/app/retro_frontend/README index 09e2400..de4da5c 100644 --- a/src/app/retro_frontend/README +++ b/src/app/retro_frontend/README @@ -114,8 +114,8 @@ The 'from' attribute on a 'map' node indicates a Genode input code and the determined externally using the 'test-input' component and Libretro input codes may be found in 'input' report described later. Mappings may only be made within the base device. Mapping keyboards to joypads is supported -but remapping keyboard keys is not. The 'input_merger' or 'input_remap' -component may be used to externally remap the Libretro keyboard type. +but remapping keyboard keys is not. The 'input_merger' component may be +used to externally remap the Libretro keyboard type. Variables diff --git a/src/server/chroot/README b/src/server/chroot/README deleted file mode 100644 index 50a899b..0000000 --- a/src/server/chroot/README +++ /dev/null @@ -1,33 +0,0 @@ -This component intercepts File_system requests and changes -the root directory of the request using the session label. - -In this example if cli_monitor had a child named "X", every -file system session from "X" would be rooted to the directory -"/cli_monitor/X" at "fs_server". - -! -! -! ... -! -! -! -! -! -! -! -! -! -! -! -! -! ... -! -! -! -! -! -! -! -! -! ... -! \ No newline at end of file diff --git a/src/server/chroot/component.cc b/src/server/chroot/component.cc deleted file mode 100644 index 553a4f6..0000000 --- a/src/server/chroot/component.cc +++ /dev/null @@ -1,274 +0,0 @@ -/* - * \brief Change session root server - * \author Emery Hemingway - * \date 2016-03-10 - */ - -/* - * Copyright (C) 2016 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. - */ - -/* Genode includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Chroot { - using namespace Genode; - struct Main; - - template - static void path_from_label(Path &path, char const *label) - { - char tmp[MAX_LEN]; - size_t len = strlen(label); - - size_t i = 0; - for (size_t j = 1; j < len; ++j) { - if (!strcmp(" -> ", label+j, 4)) { - path.append("/"); - - strncpy(tmp, label+i, (j-i)+1); - /* rewrite any directory seperators */ - for (size_t k = 0; k < MAX_LEN; ++k) - if (tmp[k] == '/') - tmp[k] = '_'; - path.append(tmp); - - j += 4; - i = j; - } - } - path.append("/"); - strncpy(tmp, label+i, MAX_LEN); - /* rewrite any directory seperators */ - for (size_t k = 0; k < MAX_LEN; ++k) - if (tmp[k] == '/') - tmp[k] = '_'; - path.append(tmp); - } -} - - -struct Chroot::Main -{ - enum { PATH_MAX_LEN = 128 }; - typedef Genode::Path Path; - - struct Session : Parent::Server - { - Parent::Client parent_client; - - Id_space::Element client_id; - Id_space::Element server_id; - - Session(Id_space &client_space, - Id_space &server_space, - Parent::Server::Id server_id) - : - client_id(parent_client, client_space), - server_id(*this, server_space, server_id) { } - }; - - Genode::Env &env; - - Id_space server_id_space; - - Heap heap { env.ram(), env.rm() }; - - Allocator_avl fs_tx_block_alloc { &heap }; - File_system::Connection fs { fs_tx_block_alloc, 1 }; - - Attached_rom_dataspace session_requests { env, "session_requests" }; - - Attached_rom_dataspace config_rom { env, "config" }; - - void handle_session_request(Xml_node request); - - void handle_session_requests() - { - if (config_sig_rec.pending()) { - do { config_sig_rec.pending_signal(); } - while (config_sig_rec.pending()); - config_rom.update(); - } - - session_requests.update(); - - Xml_node const requests = session_requests.xml(); - - requests.for_each_sub_node([&] (Xml_node request) { - handle_session_request(request); - }); - } - - Signal_handler
session_request_handler { - env.ep(), *this, &Main::handle_session_requests }; - - Signal_context config_sig_ctx; - Signal_receiver config_sig_rec; - - /** - * Constructor - */ - Main(Genode::Env &env) : env(env) - { - config_rom.sigh(config_sig_rec.manage(&config_sig_ctx)); - session_requests.sigh(session_request_handler); - - /* handle requests that have queued before or during construction */ - handle_session_requests(); - } - - ~Main() { - config_sig_rec.dissolve(&config_sig_ctx); } - - Session_capability request_session(Parent::Client::Id const &id, - Session_state::Args const &args) - { - char tmp[PATH_MAX_LEN]; - Path root_path; - - Session_label label = label_from_args(args.string()); - char const *label_str = label.string(); - - /* if policy specifies a merge, use a truncated label */ - try { - Session_policy policy(label, config_rom.xml()); - - if (policy.has_attribute("label_prefix") - && policy.attribute_value("merge", false)) - { - /* merge at the next element */ - size_t offset = policy.attribute("label_prefix").value_size(); - for (size_t i = offset; i < label.length()-4; ++i) { - if (strcmp(label_str+i, " -> ", 4)) - continue; - - strncpy(tmp, label_str, min(sizeof(tmp), i+1)); - label_str = tmp; - break; - } - } - - } catch (Session_policy::No_policy_defined) { } - - /* create a new path from the label */ - path_from_label(root_path, label_str); - - /* extract and append the orginal root */ - Arg_string::find_arg(args.string(), "root").string( - tmp, sizeof(tmp), "/"); - root_path.append_element(tmp); - root_path.remove_trailing('/'); - - char const *new_root = root_path.base(); - - using namespace File_system; - - /* create the new root directory if it is missing */ - try { fs.close(ensure_dir(fs, new_root)); } - catch (Node_already_exists) { } - catch (Permission_denied) { - Genode::error(new_root,": permission denied"); throw; } - catch (Name_too_long) { - Genode::error(new_root,": new root too long"); throw; } - catch (No_space) { - Genode::error(new_root,": no space"); throw; } - catch (...) { - Genode::error(new_root,": unknown error"); throw; } - - /* rewrite the root session argument */ - enum { ARGS_MAX_LEN = 256 }; - char new_args[ARGS_MAX_LEN]; - - strncpy(new_args, args.string(), ARGS_MAX_LEN); - - /* sacrifice the label to make space for the root argument */ - Arg_string::remove_arg(new_args, "label"); - - Arg_string::set_arg_string(new_args, ARGS_MAX_LEN, "root", new_root); - - Affinity affinity; - return env.session("File_system", id, new_args, affinity); - } -}; - - -void Chroot::Main::handle_session_request(Xml_node request) -{ - if (!request.has_attribute("id")) - return; - - Parent::Server::Id const server_id { request.attribute_value("id", 0UL) }; - - if (request.has_type("create")) { - - if (!request.has_sub_node("args")) - return; - - typedef Session_state::Args Args; - Args const args = request.sub_node("args").decoded_content(); - - Session *session = nullptr; - try { - session = new (heap) - Session(env.id_space(), server_id_space, server_id); - - Session_capability cap = request_session(session->client_id.id(), args); - - env.parent().deliver_session_cap(server_id, cap); - } - - catch (...) { - if (session) - destroy(heap, session); - env.parent().session_response(server_id, Parent::SERVICE_DENIED); - } - } - - if (request.has_type("upgrade")) { - - server_id_space.apply(server_id, [&] (Session &session) { - - size_t ram_quota = request.attribute_value("ram_quota", 0UL); - - String<64> args("ram_quota=", ram_quota); - - env.upgrade(session.client_id.id(), args.string()); - env.parent().session_response(server_id, Parent::SESSION_OK); - }); - } - - if (request.has_type("close")) { - server_id_space.apply(server_id, [&] (Session &session) { - env.close(session.client_id.id()); - destroy(heap, &session); - env.parent().session_response(server_id, Parent::SESSION_CLOSED); - }); - } -} - - -/*************** - ** Component ** - ***************/ - -Genode::size_t Component::stack_size() { - return 2*1024*sizeof(Genode::addr_t); } - -void Component::construct(Genode::Env &env) -{ - static Chroot::Main inst(env); - env.parent().announce("File_system"); -} diff --git a/src/server/chroot/target.mk b/src/server/chroot/target.mk deleted file mode 100644 index 7fd2af6..0000000 --- a/src/server/chroot/target.mk +++ /dev/null @@ -1,3 +0,0 @@ -TARGET = chroot -SRC_CC = component.cc -LIBS = base \ No newline at end of file diff --git a/src/server/input_remap/README b/src/server/input_remap/README deleted file mode 100644 index 00e9aa2..0000000 --- a/src/server/input_remap/README +++ /dev/null @@ -1,14 +0,0 @@ -Input_remap is a small shim server that remaps keys. It was intended for swapping -buttons on game controllers, but is suitable for any key code remapping. - -The configuration is simple, key codes can be discovered using the -'test/input' utility in the Genode os repository. -! -! -! -! -! -! -! -! -! diff --git a/src/server/input_remap/component.cc b/src/server/input_remap/component.cc deleted file mode 100644 index 42e62d7..0000000 --- a/src/server/input_remap/component.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * \brief Input event remapper - * \author Emery Hemingway - * \date 2016-07-10 - */ - -/* - * Copyright (C) 2016 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. - */ - -/* Genode includes */ -#include -#include -#include -#include -#include -#include -#include - -namespace Input { struct Remap; } - -struct Input::Remap -{ - typedef Genode::String<32> Keyname; - - int code_map[Input::Keycode::KEY_MAX]; - - Genode::Env &env; - - Genode::Attached_rom_dataspace config_rom { env, "config" }; - - /* - * Input session provided by our parent - */ - Input::Connection parent_input { env }; - - /* - * Input session provided to our client - */ - Input::Session_component input_session_component { env, env.ram() }; - - /* - * Attach root interface to the entry point - */ - Genode::Static_root input_root - { env.ep().manage(input_session_component) }; - - void event_flush() - { - parent_input.for_each_event([&] (Event const &e) { - if ((e.type() == Event::PRESS) || (e.type() == Event::RELEASE)) - input_session_component.submit(Event( - e.type(), code_map[e.code()], e.ax(), e.ay(), e.rx(), e.ry())); - else - input_session_component.submit(e); - }); - } - - Genode::Signal_handler event_flusher - { env.ep(), *this, &Remap::event_flush }; - - static int lookup_code(Keyname const &name) - { - /* not the fastest way to do this, just the most terse */ - for (int code = 0; code < Input::Keycode::KEY_MAX; ++code) - if (name == key_name((Keycode)code)) return code; - return KEY_UNKNOWN; - } - - void remap() - { - using namespace Genode; - - /* load the default mappings */ - for (int code = 0; code < Input::Keycode::KEY_MAX; ++code) - code_map[code] = code; - - config_rom.xml().for_each_sub_node("map", [&] (Xml_node node) { - Keyname const from = node.attribute_value("from", Keyname()); - Keyname const to = node.attribute_value("to", Keyname()); - - if ((from == "") || (to == "")) { - char tmp[128]; - strncpy(tmp, node.addr(), min(sizeof(tmp), node.size()+1)); - error("ignoring mapping '", Cstring(tmp), "'"); - return; - } - - int from_code = lookup_code(from); - int to_code = lookup_code(to); - - if (from_code == KEY_UNKNOWN) { - error("unknown key ", from.string()); - return; - } - if (to_code == KEY_UNKNOWN) { - error("unknown key ", to.string()); - return; - } - - code_map[from_code] = to_code; - }); - } - - Genode::Signal_handler config_handler - { env.ep(), *this, &Remap::remap }; - - /** - * Constructor - */ - Remap(Genode::Env &env) : env(env) - { - config_rom.sigh(config_handler); - parent_input.sigh(event_flusher); - - remap(); - - input_session_component.event_queue().enabled(true); - - env.parent().announce(env.ep().manage(input_root)); - } -}; - - -/*************** - ** Component ** - ***************/ - -Genode::size_t Component::stack_size() { return 4*1024*sizeof(Genode::addr_t); } - -void Component::construct(Genode::Env &env) { static Input::Remap inst(env); } diff --git a/src/server/input_remap/target.mk b/src/server/input_remap/target.mk deleted file mode 100644 index e08eb0e..0000000 --- a/src/server/input_remap/target.mk +++ /dev/null @@ -1,3 +0,0 @@ -TARGET = input_remap -SRC_CC = component.cc -LIBS = base