mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
parent
8bcf540915
commit
0011dd1623
@ -1,5 +1,5 @@
|
|||||||
content: drivers.config fb_drv.config input_filter.config en_us.chargen \
|
content: drivers.config fb_drv.config input_filter.config en_us.chargen \
|
||||||
numlock_remap.config
|
special.chargen numlock_remap.config
|
||||||
|
|
||||||
drivers.config numlock_remap.config:
|
drivers.config numlock_remap.config:
|
||||||
cp $(REP_DIR)/recipes/raw/drivers_managed-pc/$@ $@
|
cp $(REP_DIR)/recipes/raw/drivers_managed-pc/$@ $@
|
||||||
@ -7,5 +7,5 @@ drivers.config numlock_remap.config:
|
|||||||
fb_drv.config input_filter.config:
|
fb_drv.config input_filter.config:
|
||||||
cp $(GENODE_DIR)/repos/os/recipes/raw/drivers_interactive-pc/$@ $@
|
cp $(GENODE_DIR)/repos/os/recipes/raw/drivers_interactive-pc/$@ $@
|
||||||
|
|
||||||
en_us.chargen:
|
en_us.chargen special.chargen:
|
||||||
cp $(GENODE_DIR)/repos/os/src/server/input_filter/$@ $@
|
cp $(GENODE_DIR)/repos/os/src/server/input_filter/$@ $@
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
</mod3>
|
</mod3>
|
||||||
<repeat delay_ms="230" rate_ms="90"/>
|
<repeat delay_ms="230" rate_ms="90"/>
|
||||||
<include rom="en_us.chargen"/>
|
<include rom="en_us.chargen"/>
|
||||||
|
<include rom="special.chargen"/>
|
||||||
</chargen>
|
</chargen>
|
||||||
</output>
|
</output>
|
||||||
</config>
|
</config>
|
||||||
|
@ -110,6 +110,7 @@ install_config {
|
|||||||
<rom name="input_filter.config"/>
|
<rom name="input_filter.config"/>
|
||||||
<rom name="en_us.chargen"/>
|
<rom name="en_us.chargen"/>
|
||||||
<rom name="de.chargen"/>
|
<rom name="de.chargen"/>
|
||||||
|
<rom name="special.chargen"/>
|
||||||
<rom name="numlock_remap.config"/>
|
<rom name="numlock_remap.config"/>
|
||||||
<rom name="vimrc"/>
|
<rom name="vimrc"/>
|
||||||
<rom name="wlan.config"/>
|
<rom name="wlan.config"/>
|
||||||
@ -467,11 +468,9 @@ file copy -force [genode_dir]/repos/gems/run/sculpt/machine.vbox [run_dir]/genod
|
|||||||
file copy -force [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/drivers.config \
|
file copy -force [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/drivers.config \
|
||||||
[run_dir]/genode/drivers.config
|
[run_dir]/genode/drivers.config
|
||||||
|
|
||||||
file copy -force [genode_dir]/repos/os/src/server/input_filter/en_us.chargen \
|
foreach file { en_us.chargen de.chargen special.chargen } {
|
||||||
[run_dir]/genode/en_us.chargen
|
file copy -force [genode_dir]/repos/os/src/server/input_filter/$file \
|
||||||
|
[run_dir]/genode/$file }
|
||||||
file copy -force [genode_dir]/repos/os/src/server/input_filter/de.chargen \
|
|
||||||
[run_dir]/genode/de.chargen
|
|
||||||
|
|
||||||
file copy -force [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/input_filter.config \
|
file copy -force [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/input_filter.config \
|
||||||
[run_dir]/genode/input_filter.config
|
[run_dir]/genode/input_filter.config
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
/* terminal includes */
|
/* terminal includes */
|
||||||
#include <terminal/decoder.h>
|
#include <terminal/decoder.h>
|
||||||
#include <terminal/types.h>
|
#include <terminal/types.h>
|
||||||
#include <terminal/scancode_tracker.h>
|
|
||||||
#include <terminal/keymaps.h>
|
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include "text_screen_surface.h"
|
#include "text_screen_surface.h"
|
||||||
@ -59,10 +57,6 @@ struct Terminal::Main : Character_consumer
|
|||||||
|
|
||||||
Reconstructible<Font_family> _font_family { *_font };
|
Reconstructible<Font_family> _font_family { *_font };
|
||||||
|
|
||||||
unsigned char *_keymap = Terminal::usenglish_keymap;
|
|
||||||
unsigned char *_shift = Terminal::usenglish_shift;
|
|
||||||
unsigned char *_altgr = nullptr;
|
|
||||||
|
|
||||||
Color_palette _color_palette { };
|
Color_palette _color_palette { };
|
||||||
|
|
||||||
void _handle_config();
|
void _handle_config();
|
||||||
@ -130,29 +124,11 @@ struct Terminal::Main : Character_consumer
|
|||||||
/* create root interface for service */
|
/* create root interface for service */
|
||||||
Root_component _root { _env, _heap, _read_buffer, *this };
|
Root_component _root { _env, _heap, _read_buffer, *this };
|
||||||
|
|
||||||
/*
|
|
||||||
* builtin keyboard-layout handling
|
|
||||||
*
|
|
||||||
* \deprecated The keyboard layout should be handled by the input-filter
|
|
||||||
* component.
|
|
||||||
*/
|
|
||||||
Constructible<Scancode_tracker> _scancode_tracker { };
|
|
||||||
|
|
||||||
/* state needed for key-repeat handling */
|
|
||||||
unsigned const _repeat_delay = 250;
|
|
||||||
unsigned const _repeat_rate = 25;
|
|
||||||
unsigned _repeat_next = 0;
|
|
||||||
|
|
||||||
void _handle_input();
|
void _handle_input();
|
||||||
|
|
||||||
Signal_handler<Main> _input_handler {
|
Signal_handler<Main> _input_handler {
|
||||||
_env.ep(), *this, &Main::_handle_input };
|
_env.ep(), *this, &Main::_handle_input };
|
||||||
|
|
||||||
void _handle_key_repeat(Duration);
|
|
||||||
|
|
||||||
Timer::One_shot_timeout<Main> _key_repeat_timeout {
|
|
||||||
_timer, *this, &Main::_handle_key_repeat };
|
|
||||||
|
|
||||||
Main(Env &env) : _env(env)
|
Main(Env &env) : _env(env)
|
||||||
{
|
{
|
||||||
_handle_config();
|
_handle_config();
|
||||||
@ -209,32 +185,6 @@ void Terminal::Main::_handle_config()
|
|||||||
_terminal_size = _text_screen_surface->size();
|
_terminal_size = _text_screen_surface->size();
|
||||||
_root.notify_resized(_terminal_size);
|
_root.notify_resized(_terminal_size);
|
||||||
_schedule_flush();
|
_schedule_flush();
|
||||||
|
|
||||||
/*
|
|
||||||
* Read keyboard layout from config file
|
|
||||||
*/
|
|
||||||
|
|
||||||
_keymap = Terminal::usenglish_keymap;
|
|
||||||
_shift = Terminal::usenglish_shift;
|
|
||||||
_altgr = nullptr;
|
|
||||||
|
|
||||||
if (config.has_sub_node("keyboard")) {
|
|
||||||
|
|
||||||
if (config.sub_node("keyboard").attribute("layout").has_value("de")) {
|
|
||||||
_keymap = Terminal::german_keymap;
|
|
||||||
_shift = Terminal::german_shift;
|
|
||||||
_altgr = Terminal::german_altgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.sub_node("keyboard").attribute("layout").has_value("none")) {
|
|
||||||
_keymap = nullptr;
|
|
||||||
_shift = nullptr;
|
|
||||||
_altgr = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_scancode_tracker.constructed())
|
|
||||||
_scancode_tracker.construct(_keymap, _shift, _altgr, Terminal::control);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -242,53 +192,61 @@ void Terminal::Main::_handle_input()
|
|||||||
{
|
{
|
||||||
_input.for_each_event([&] (Input::Event const &event) {
|
_input.for_each_event([&] (Input::Event const &event) {
|
||||||
|
|
||||||
if (event.type() == Input::Event::CHARACTER) {
|
if (event.type() == Input::Event::CHARACTER) {
|
||||||
Input::Event::Utf8 const utf8 = event.utf8();
|
Input::Event::Utf8 const utf8 = event.utf8();
|
||||||
_read_buffer.add(utf8.b0);
|
|
||||||
if (utf8.b1) _read_buffer.add(utf8.b1);
|
char const sequence[] { (char)utf8.b0, (char)utf8.b1,
|
||||||
if (utf8.b2) _read_buffer.add(utf8.b2);
|
(char)utf8.b2, (char)utf8.b3, 0 };
|
||||||
if (utf8.b3) _read_buffer.add(utf8.b3);
|
|
||||||
|
/* function-key unicodes */
|
||||||
|
enum {
|
||||||
|
CODEPOINT_UP = 0xf700, CODEPOINT_DOWN = 0xf701,
|
||||||
|
CODEPOINT_LEFT = 0xf702, CODEPOINT_RIGHT = 0xf703,
|
||||||
|
CODEPOINT_F1 = 0xf704, CODEPOINT_F2 = 0xf705,
|
||||||
|
CODEPOINT_F3 = 0xf706, CODEPOINT_F4 = 0xf707,
|
||||||
|
CODEPOINT_F5 = 0xf708, CODEPOINT_F6 = 0xf709,
|
||||||
|
CODEPOINT_F7 = 0xf70a, CODEPOINT_F8 = 0xf70b,
|
||||||
|
CODEPOINT_F9 = 0xf70c, CODEPOINT_F10 = 0xf70d,
|
||||||
|
CODEPOINT_F11 = 0xf70e, CODEPOINT_F12 = 0xf70f,
|
||||||
|
CODEPOINT_HOME = 0xf729, CODEPOINT_INSERT = 0xf727,
|
||||||
|
CODEPOINT_DELETE = 0xf728, CODEPOINT_END = 0xf72b,
|
||||||
|
CODEPOINT_PAGEUP = 0xf72c, CODEPOINT_PAGEDOWN = 0xf72d,
|
||||||
|
};
|
||||||
|
|
||||||
|
Codepoint const codepoint = Utf8_ptr(sequence).codepoint();
|
||||||
|
|
||||||
|
char const *special_sequence = nullptr;
|
||||||
|
switch (codepoint.value) {
|
||||||
|
case CODEPOINT_UP: special_sequence = "\EOA"; break;
|
||||||
|
case CODEPOINT_DOWN: special_sequence = "\EOB"; break;
|
||||||
|
case CODEPOINT_LEFT: special_sequence = "\EOD"; break;
|
||||||
|
case CODEPOINT_RIGHT: special_sequence = "\EOC"; break;
|
||||||
|
case CODEPOINT_F1: special_sequence = "\EOP"; break;
|
||||||
|
case CODEPOINT_F2: special_sequence = "\EOQ"; break;
|
||||||
|
case CODEPOINT_F3: special_sequence = "\EOR"; break;
|
||||||
|
case CODEPOINT_F4: special_sequence = "\EOS"; break;
|
||||||
|
case CODEPOINT_F5: special_sequence = "\E[15~"; break;
|
||||||
|
case CODEPOINT_F6: special_sequence = "\E[17~"; break;
|
||||||
|
case CODEPOINT_F7: special_sequence = "\E[18~"; break;
|
||||||
|
case CODEPOINT_F8: special_sequence = "\E[19~"; break;
|
||||||
|
case CODEPOINT_F9: special_sequence = "\E[20~"; break;
|
||||||
|
case CODEPOINT_F10: special_sequence = "\E[21~"; break;
|
||||||
|
case CODEPOINT_F11: special_sequence = "\E[23~"; break;
|
||||||
|
case CODEPOINT_F12: special_sequence = "\E[24~"; break;
|
||||||
|
case CODEPOINT_HOME: special_sequence = "\E[1~"; break;
|
||||||
|
case CODEPOINT_INSERT: special_sequence = "\E[2~"; break;
|
||||||
|
case CODEPOINT_DELETE: special_sequence = "\E[3~"; break;
|
||||||
|
case CODEPOINT_END: special_sequence = "\E[4~"; break;
|
||||||
|
case CODEPOINT_PAGEUP: special_sequence = "\E[5~"; break;
|
||||||
|
case CODEPOINT_PAGEDOWN: special_sequence = "\E[6~"; break;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (special_sequence)
|
||||||
|
_read_buffer.add(special_sequence);
|
||||||
|
else
|
||||||
|
_read_buffer.add(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* apply the terminal's built-in character map if configured */
|
|
||||||
if (!_scancode_tracker.constructed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool press = (event.type() == Input::Event::PRESS ? true : false);
|
|
||||||
bool release = (event.type() == Input::Event::RELEASE ? true : false);
|
|
||||||
int keycode = event.code();
|
|
||||||
|
|
||||||
if (press || release)
|
|
||||||
_scancode_tracker->submit(keycode, press);
|
|
||||||
|
|
||||||
if (press) {
|
|
||||||
_scancode_tracker->emit_current_character(_read_buffer);
|
|
||||||
|
|
||||||
/* setup first key repeat */
|
|
||||||
_repeat_next = _repeat_delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (release)
|
|
||||||
_repeat_next = 0;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_repeat_next)
|
|
||||||
_key_repeat_timeout.schedule(Microseconds{1000*_repeat_next});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Terminal::Main::_handle_key_repeat(Duration)
|
|
||||||
{
|
|
||||||
if (_repeat_next) {
|
|
||||||
|
|
||||||
/* repeat current character or sequence */
|
|
||||||
if (_scancode_tracker.constructed())
|
|
||||||
_scancode_tracker->emit_current_character(_read_buffer);
|
|
||||||
|
|
||||||
_repeat_next = _repeat_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
_handle_input();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <util/utf8.h>
|
#include <util/utf8.h>
|
||||||
#include <root/component.h>
|
#include <root/component.h>
|
||||||
#include <terminal_session/terminal_session.h>
|
#include <terminal_session/terminal_session.h>
|
||||||
|
#include <terminal/read_buffer.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Key mappings of scancodes to characters
|
|
||||||
* \author Norman Feske
|
|
||||||
* \date 2011-06-06
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2011-2017 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TERMINAL__KEYMAPS_H_
|
|
||||||
#define _TERMINAL__KEYMAPS_H_
|
|
||||||
|
|
||||||
namespace Terminal {
|
|
||||||
|
|
||||||
enum {
|
|
||||||
BS = 8,
|
|
||||||
ESC = 27,
|
|
||||||
TAB = 9,
|
|
||||||
LF = 10,
|
|
||||||
UE = 252, /* 'ü' */
|
|
||||||
AE = 228, /* 'ä' */
|
|
||||||
OE = 246, /* 'ö' */
|
|
||||||
PAR = 167, /* '§' */
|
|
||||||
DEG = 176, /* '°' */
|
|
||||||
SS = 223, /* 'ß' */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char usenglish_keymap[128] = {
|
|
||||||
0 ,ESC,'1','2','3','4','5','6','7','8','9','0','-','=', BS,TAB,
|
|
||||||
'q','w','e','r','t','y','u','i','o','p','[',']', LF, 0 ,'a','s',
|
|
||||||
'd','f','g','h','j','k','l',';','\'','`', 0, '\\' ,'z','x','c','v',
|
|
||||||
'b','n','m',',','.','/', 0 , 0 , 0 ,' ', 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
0 , 0 , 0 , 0 , 0 , 0 , 0 ,'7','8','9','-','4','5','6','+','1',
|
|
||||||
'2','3','0',',', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
LF, 0 ,'/', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from ASCII value to another ASCII value when shift is pressed
|
|
||||||
*
|
|
||||||
* The table does not contain mappings for control characters. The table
|
|
||||||
* entry 0 corresponds to ASCII value 32.
|
|
||||||
*/
|
|
||||||
static unsigned char usenglish_shift[256 - 32] = {
|
|
||||||
/* 32 */ ' ', 0 , 0, 0 , 0 , 0 , 0 ,'"', 0 , 0 , 0 , 0 ,'<','_','>','?',
|
|
||||||
/* 48 */ ')','!','@','#','$','%','^','&','*','(', 0 ,':', 0 ,'+', 0 , 0 ,
|
|
||||||
/* 64 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 80 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,'{','|','}', 0 , 0 ,
|
|
||||||
/* 96 */ '~','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
|
|
||||||
/* 112 */ 'P','Q','R','S','T','U','V','W','X','Y','Z', 0 ,'\\', 0 , 0 , 0 ,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char german_keymap[128] = {
|
|
||||||
0 ,ESC,'1','2','3','4','5','6','7','8','9','0', SS, 39, BS,TAB,
|
|
||||||
'q','w','e','r','t','z','u','i','o','p', UE,'+', LF, 0 ,'a','s',
|
|
||||||
'd','f','g','h','j','k','l', OE, AE,'^', 0 ,'#','y','x','c','v',
|
|
||||||
'b','n','m',',','.','-', 0 ,'*', 0 ,' ', 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
0 , 0 , 0 , 0 , 0 , 0 , 0 ,'7','8','9','-','4','5','6','+','1',
|
|
||||||
'2','3','0',',', 0 , 0 ,'<', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
LF, 0 ,'/', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from ASCII value to another ASCII value when shift is pressed
|
|
||||||
*
|
|
||||||
* The table does not contain mappings for control characters. The table
|
|
||||||
* entry 0 corresponds to ASCII value 32.
|
|
||||||
*/
|
|
||||||
static unsigned char german_shift[256 - 32] = {
|
|
||||||
/* 32 */ ' ', 0 , 0, 39 , 0 , 0 , 0 ,'`', 0 , 0 , 0 ,'*',';','_',':', 0 ,
|
|
||||||
/* 48 */ '=','!','"',PAR,'$','%','&','/','(',')', 0 , 0 ,'>', 0 , 0 , 0 ,
|
|
||||||
/* 64 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 80 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,DEG, 0 ,
|
|
||||||
/* 96 */ 0 ,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
|
|
||||||
/* 112 */ 'P','Q','R','S','T','U','V','W','X','Y','Z', 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 128 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 144 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 160 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 176 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 192 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 208 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,'?',
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from ASCII value to another ASCII value when altgr is pressed
|
|
||||||
*/
|
|
||||||
static unsigned char german_altgr[256 - 32] = {
|
|
||||||
/* 32 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,'~', 0 , 0 , 0 , 0 ,
|
|
||||||
/* 48 */'}', 0 ,178,179, 0 , 0 , 0 ,'{','[',']', 0 , 0 ,'|', 0 , 0 , 0 ,
|
|
||||||
/* 64 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 80 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 96 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 112 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 128 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 144 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 160 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 176 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 192 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
|
||||||
/* 208 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,'\\',
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from ASCII value to value reported when control is pressed
|
|
||||||
*
|
|
||||||
* The table starts with ASCII value 32.
|
|
||||||
*/
|
|
||||||
static unsigned char control[256 - 32] = {
|
|
||||||
/* 32 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
/* 48 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
/* 64 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
/* 80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
/* 96 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
||||||
/* 112 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _TERMINAL__KEYMAPS_H_ */
|
|
@ -1,204 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief State machine for translating scan codes to characters
|
|
||||||
* \author Norman Feske
|
|
||||||
* \date 2011-06-06
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2011-2017 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TERMINAL__SCANCODE_TRACKER_H_
|
|
||||||
#define _TERMINAL__SCANCODE_TRACKER_H_
|
|
||||||
|
|
||||||
#include <input/keycodes.h>
|
|
||||||
#include <terminal/read_buffer.h>
|
|
||||||
|
|
||||||
namespace Terminal { class Scancode_tracker; }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* State machine that translates keycode sequences to terminal characters
|
|
||||||
*/
|
|
||||||
class Terminal::Scancode_tracker
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tables containing the scancode-to-character mapping
|
|
||||||
*/
|
|
||||||
unsigned char const *_keymap;
|
|
||||||
unsigned char const *_shift;
|
|
||||||
unsigned char const *_altgr;
|
|
||||||
unsigned char const *_control;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current state of modifer keys
|
|
||||||
*/
|
|
||||||
bool _mod_shift;
|
|
||||||
bool _mod_control;
|
|
||||||
bool _mod_altgr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently pressed key, or 0 if no normal key (one that can be
|
|
||||||
* encoded in a single 'char') is pressed
|
|
||||||
*/
|
|
||||||
unsigned char _last_character;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently pressed special key (a key that corresponds to an escape
|
|
||||||
* sequence), or no if no special key is pressed
|
|
||||||
*/
|
|
||||||
char const *_last_sequence;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert keycode to terminal character
|
|
||||||
*/
|
|
||||||
unsigned char _keycode_to_latin1(int keycode)
|
|
||||||
{
|
|
||||||
if (keycode >= 112) return 0;
|
|
||||||
|
|
||||||
unsigned ch = _keymap[keycode];
|
|
||||||
|
|
||||||
if (ch < 32)
|
|
||||||
return ch;
|
|
||||||
|
|
||||||
/* all ASCII-to-ASCII table start at index 32 */
|
|
||||||
if (_mod_shift || _mod_control || _mod_altgr) {
|
|
||||||
ch -= 32;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 'ch' is guaranteed to be in the range 0..223. So it is safe to
|
|
||||||
* use it as index into the ASCII-to-ASCII tables.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (_mod_shift)
|
|
||||||
return _shift[ch];
|
|
||||||
|
|
||||||
if (_mod_control)
|
|
||||||
return _control[ch];
|
|
||||||
|
|
||||||
if (_altgr && _mod_altgr)
|
|
||||||
return _altgr[ch];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* \param keymap table for keycode-to-character mapping
|
|
||||||
* \param shift table for character-to-character mapping used when
|
|
||||||
* Shift is pressed
|
|
||||||
* \param altgr table for character-to-character mapping with AltGr
|
|
||||||
* is pressed
|
|
||||||
*/
|
|
||||||
Scancode_tracker(unsigned char const *keymap,
|
|
||||||
unsigned char const *shift,
|
|
||||||
unsigned char const *altgr,
|
|
||||||
unsigned char const *control)
|
|
||||||
:
|
|
||||||
_keymap(keymap),
|
|
||||||
_shift(shift),
|
|
||||||
_altgr(altgr),
|
|
||||||
_control(control),
|
|
||||||
_mod_shift(false),
|
|
||||||
_mod_control(false),
|
|
||||||
_mod_altgr(false),
|
|
||||||
_last_character(0),
|
|
||||||
_last_sequence(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Submit key event to state machine
|
|
||||||
*
|
|
||||||
* \param press true on press event, false on release event
|
|
||||||
*/
|
|
||||||
void submit(int keycode, bool press)
|
|
||||||
{
|
|
||||||
/* track modifier keys */
|
|
||||||
switch (keycode) {
|
|
||||||
case Input::KEY_LEFTSHIFT:
|
|
||||||
case Input::KEY_RIGHTSHIFT:
|
|
||||||
_mod_shift = press;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Input::KEY_LEFTCTRL:
|
|
||||||
case Input::KEY_RIGHTCTRL:
|
|
||||||
_mod_control = press;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Input::KEY_RIGHTALT:
|
|
||||||
_mod_altgr = press;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reset information about the currently pressed key */
|
|
||||||
_last_character = 0;
|
|
||||||
_last_sequence = 0;
|
|
||||||
|
|
||||||
if (!press) return;
|
|
||||||
|
|
||||||
/* convert key codes to ASCII */
|
|
||||||
if (_keymap)
|
|
||||||
_last_character = _keycode_to_latin1(keycode);
|
|
||||||
|
|
||||||
/* handle special key to be represented by an escape sequence */
|
|
||||||
if (!_last_character) {
|
|
||||||
switch (keycode) {
|
|
||||||
case Input::KEY_DOWN: _last_sequence = "\EOB"; break;
|
|
||||||
case Input::KEY_UP: _last_sequence = "\EOA"; break;
|
|
||||||
case Input::KEY_RIGHT: _last_sequence = "\EOC"; break;
|
|
||||||
case Input::KEY_LEFT: _last_sequence = "\EOD"; break;
|
|
||||||
case Input::KEY_HOME: _last_sequence = "\E[1~"; break;
|
|
||||||
case Input::KEY_INSERT: _last_sequence = "\E[2~"; break;
|
|
||||||
case Input::KEY_DELETE: _last_sequence = "\E[3~"; break;
|
|
||||||
case Input::KEY_END: _last_sequence = "\E[4~"; break;
|
|
||||||
case Input::KEY_PAGEUP: _last_sequence = "\E[5~"; break;
|
|
||||||
case Input::KEY_PAGEDOWN: _last_sequence = "\E[6~"; break;
|
|
||||||
case Input::KEY_F1: _last_sequence = "\EOP"; break;
|
|
||||||
case Input::KEY_F2: _last_sequence = "\EOQ"; break;
|
|
||||||
case Input::KEY_F3: _last_sequence = "\EOR"; break;
|
|
||||||
case Input::KEY_F4: _last_sequence = "\EOS"; break;
|
|
||||||
case Input::KEY_F5: _last_sequence = "\E[15~"; break;
|
|
||||||
case Input::KEY_F6: _last_sequence = "\E[17~"; break;
|
|
||||||
case Input::KEY_F7: _last_sequence = "\E[18~"; break;
|
|
||||||
case Input::KEY_F8: _last_sequence = "\E[19~"; break;
|
|
||||||
case Input::KEY_F9: _last_sequence = "\E[20~"; break;
|
|
||||||
case Input::KEY_F10: _last_sequence = "\E[21~"; break;
|
|
||||||
case Input::KEY_F11: _last_sequence = "\E[23~"; break;
|
|
||||||
case Input::KEY_F12: _last_sequence = "\E[24~"; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output currently pressed key to read buffer
|
|
||||||
*/
|
|
||||||
void emit_current_character(Read_buffer &read_buffer)
|
|
||||||
{
|
|
||||||
if (_last_character)
|
|
||||||
read_buffer.add(_last_character);
|
|
||||||
|
|
||||||
if (_last_sequence)
|
|
||||||
read_buffer.add(_last_sequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if there is a currently pressed key
|
|
||||||
*/
|
|
||||||
bool valid() const
|
|
||||||
{
|
|
||||||
return (_last_sequence || _last_character);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _TERMINAL__SCANCODE_TRACKER_H_ */
|
|
@ -1,7 +1,7 @@
|
|||||||
content: drivers.config input_filter.config en_us.chargen
|
content: drivers.config input_filter.config en_us.chargen special.chargen
|
||||||
|
|
||||||
drivers.config input_filter.config:
|
drivers.config input_filter.config:
|
||||||
cp $(REP_DIR)/recipes/raw/drivers_interactive-linux/$@ $@
|
cp $(REP_DIR)/recipes/raw/drivers_interactive-linux/$@ $@
|
||||||
|
|
||||||
en_us.chargen:
|
en_us.chargen special.chargen:
|
||||||
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
</mod3>
|
</mod3>
|
||||||
<repeat delay_ms="230" rate_ms="90"/>
|
<repeat delay_ms="230" rate_ms="90"/>
|
||||||
<include rom="en_us.chargen"/>
|
<include rom="en_us.chargen"/>
|
||||||
|
<include rom="special.chargen"/>
|
||||||
</chargen>
|
</chargen>
|
||||||
</output>
|
</output>
|
||||||
</config>
|
</config>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
content: drivers.config input_filter.config en_us.chargen
|
content: drivers.config input_filter.config en_us.chargen special.chargen
|
||||||
|
|
||||||
drivers.config input_filter.config:
|
drivers.config input_filter.config:
|
||||||
cp $(REP_DIR)/recipes/raw/drivers_interactive-pbxa9/$@ $@
|
cp $(REP_DIR)/recipes/raw/drivers_interactive-pbxa9/$@ $@
|
||||||
|
|
||||||
en_us.chargen:
|
en_us.chargen special.chargen:
|
||||||
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
</mod3>
|
</mod3>
|
||||||
<repeat delay_ms="230" rate_ms="90"/>
|
<repeat delay_ms="230" rate_ms="90"/>
|
||||||
<include rom="en_us.chargen"/>
|
<include rom="en_us.chargen"/>
|
||||||
|
<include rom="special.chargen"/>
|
||||||
</chargen>
|
</chargen>
|
||||||
</output>
|
</output>
|
||||||
</config>
|
</config>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
content: drivers.config fb_drv.config input_filter.config en_us.chargen
|
content: drivers.config fb_drv.config input_filter.config en_us.chargen special.chargen
|
||||||
|
|
||||||
drivers.config fb_drv.config input_filter.config:
|
drivers.config fb_drv.config input_filter.config:
|
||||||
cp $(REP_DIR)/recipes/raw/drivers_interactive-pc/$@ $@
|
cp $(REP_DIR)/recipes/raw/drivers_interactive-pc/$@ $@
|
||||||
|
|
||||||
en_us.chargen:
|
en_us.chargen special.chargen:
|
||||||
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
cp $(REP_DIR)/src/server/input_filter/$@ $@
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
</mod3>
|
</mod3>
|
||||||
<repeat delay_ms="230" rate_ms="90"/>
|
<repeat delay_ms="230" rate_ms="90"/>
|
||||||
<include rom="en_us.chargen"/>
|
<include rom="en_us.chargen"/>
|
||||||
|
<include rom="special.chargen"/>
|
||||||
</chargen>
|
</chargen>
|
||||||
</output>
|
</output>
|
||||||
</config>
|
</config>
|
||||||
|
27
repos/os/src/server/input_filter/special.chargen
Normal file
27
repos/os/src/server/input_filter/special.chargen
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<chargen>
|
||||||
|
<!-- mappings corresponding to function-key unicodes as defined by Apple -->
|
||||||
|
<map>
|
||||||
|
<key name="KEY_UP" b0="239" b1="156" b2="128"/>
|
||||||
|
<key name="KEY_DOWN" b0="239" b1="156" b2="129"/>
|
||||||
|
<key name="KEY_LEFT" b0="239" b1="156" b2="130"/>
|
||||||
|
<key name="KEY_RIGHT" b0="239" b1="156" b2="131"/>
|
||||||
|
<key name="KEY_F1" b0="239" b1="156" b2="132"/>
|
||||||
|
<key name="KEY_F2" b0="239" b1="156" b2="133"/>
|
||||||
|
<key name="KEY_F3" b0="239" b1="156" b2="134"/>
|
||||||
|
<key name="KEY_F4" b0="239" b1="156" b2="135"/>
|
||||||
|
<key name="KEY_F5" b0="239" b1="156" b2="136"/>
|
||||||
|
<key name="KEY_F6" b0="239" b1="156" b2="137"/>
|
||||||
|
<key name="KEY_F7" b0="239" b1="156" b2="138"/>
|
||||||
|
<key name="KEY_F8" b0="239" b1="156" b2="139"/>
|
||||||
|
<key name="KEY_F9" b0="239" b1="156" b2="140"/>
|
||||||
|
<key name="KEY_F10" b0="239" b1="156" b2="141"/>
|
||||||
|
<key name="KEY_F11" b0="239" b1="156" b2="142"/>
|
||||||
|
<key name="KEY_F12" b0="239" b1="156" b2="143"/>
|
||||||
|
<key name="KEY_HOME" b0="239" b1="156" b2="169"/>
|
||||||
|
<key name="KEY_INSERT" b0="239" b1="156" b2="167"/>
|
||||||
|
<key name="KEY_DELETE" b0="239" b1="156" b2="168"/>
|
||||||
|
<key name="KEY_END" b0="239" b1="156" b2="171"/>
|
||||||
|
<key name="KEY_PAGEUP" b0="239" b1="156" b2="172"/>
|
||||||
|
<key name="KEY_PAGEDOWN" b0="239" b1="156" b2="173"/>
|
||||||
|
</map>
|
||||||
|
</chargen>
|
Loading…
Reference in New Issue
Block a user