some keyboard bochsrc option changes

- moved 'user_shortcut' option to the keyboard option
- added new bx_param_c option value BOCHSRC_HIDDEN for parameters that should
  only be available in the config interface. The new bochsrc option save and
  parser function skip parameters with this flag set. This is useful for
  parameters that will be set from the parser in a different way.
- save keyboard bochsrc line using the parameter list directly
- parse keyboard bochsrc options (except 'keymap') using the parameter list
- user shortcut: old-style syntax has already been removed
- increased minimum value for the keyboard's 'serial_delay'
This commit is contained in:
Volker Ruppert 2013-01-27 19:09:24 +00:00
parent a86b91d7a1
commit f9dca3c76b
6 changed files with 70 additions and 98 deletions

View File

@ -797,9 +797,19 @@ parport1: enabled=1, file="parport.out"
# This enables a remap of a physical localized keyboard to a
# virtualized us keyboard, as the PC architecture expects.
#
# USER_SHORTCUT:
# This defines the keyboard shortcut to be sent when you press the "user"
# button in the headerbar. The shortcut string is a combination of maximum
# 3 key names (listed below) separated with a '-' character.
# Valid key names:
# "alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
# "f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup",
# "plus", "right", "shift", "space", "tab", "up", "win", "print" and "power".
# Examples:
# keyboard: type=mf, serial_delay=200, paste_delay=100000
# keyboard: keymap=gui/keymaps/x11-pc-de.map
# keyboard: user_shortcut=ctrl-alt-del
#=======================================================================
#keyboard: type=mf, serial_delay=250
@ -941,21 +951,6 @@ private_colormap: enabled=0
#=======================================================================
#e1000: enabled=1, mac=52:54:00:12:34:56, ethmod=slirp, script=/usr/local/bin/slirp
#=======================================================================
# USER_SHORTCUT:
# This defines the keyboard shortcut to be sent when you press the "user"
# button in the headerbar. The shortcut string is a combination of maximum
# 3 key names (listed below) separated with a '-' character.
# Valid key names:
# "alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
# "f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup",
# "plus", "right", "shift", "space", "tab", "up", "win", "print" and "power".
#
# Example:
# user_shortcut: keys=ctrl-alt-del
#=======================================================================
#user_shortcut: keys=ctrl-alt-del
#=======================================================================
# PCI:
# This option controls the presence of a PCI chipset in Bochs. Currently it only

View File

@ -382,18 +382,21 @@ void bx_init_options()
1, BX_CPU_PROCESSORS_LIMIT,
1);
nprocessors->set_enabled(BX_CPU_PROCESSORS_LIMIT > 1);
nprocessors->set_options(bx_param_c::BOCHSRC_HIDDEN);
bx_param_num_c *ncores = new bx_param_num_c(cpu_param,
"n_cores", "Number of cores in each processor in SMP mode",
"Sets the number of cores per processor for multiprocessor emulation",
1, BX_CPU_CORES_LIMIT,
1);
ncores->set_enabled(BX_CPU_CORES_LIMIT > 1);
ncores->set_options(bx_param_c::BOCHSRC_HIDDEN);
bx_param_num_c *nthreads = new bx_param_num_c(cpu_param,
"n_threads", "Number of HT threads per each core in SMP mode",
"Sets the number of HT (Intel(R) HyperThreading Technology) threads per core for multiprocessor emulation",
1, BX_CPU_HT_THREADS_LIMIT,
1);
nthreads->set_enabled(BX_CPU_HT_THREADS_LIMIT > 1);
nthreads->set_options(bx_param_c::BOCHSRC_HIDDEN);
new bx_param_num_c(cpu_param,
"ips", "Emulated instructions per second (IPS)",
"Emulated instructions per second, used to calibrate bochs emulated time with wall clock time.",
@ -955,7 +958,7 @@ void bx_init_options()
new bx_param_num_c(keyboard,
"serial_delay", "Keyboard serial delay",
"Approximate time in microseconds that it takes one character to be transferred from the keyboard to controller over the serial path.",
1, BX_MAX_BIT32U,
5, BX_MAX_BIT32U,
250);
new bx_param_num_c(keyboard,
"paste_delay", "Keyboard paste delay",
@ -966,6 +969,7 @@ void bx_init_options()
"use_mapping", "Use keyboard mapping",
"Controls whether to use the keyboard mapping feature",
0);
use_kbd_mapping->set_options(bx_param_c::BOCHSRC_HIDDEN);
bx_param_filename_c *keymap = new bx_param_filename_c(keyboard,
"keymap", "Keymap filename",
"Pathname of the keymap file used",
@ -2059,6 +2063,11 @@ int bx_parse_param_from_list(const char *context, const char *input, bx_list_c *
free(propval);
return -1;
}
if ((param->get_options() & param->BOCHSRC_HIDDEN) > 0) {
PARSE_WARN(("%s: ignoring hidden parameter '%s'", context, property));
free(propval);
return -1;
}
switch (param->get_type()) {
case BXT_PARAM_NUM:
if (value != NULL) {
@ -2606,24 +2615,10 @@ static int parse_line_formatted(const char *context, int num_params, char *param
PARSE_ERR(("%s: keyboard directive malformed.", context));
}
for (i=1; i<num_params; i++) {
if (!strncmp(params[i], "serial_delay=", 13)) {
SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->set(atol(&params[i][13]));
if (SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->get() < 5) {
PARSE_ERR (("%s: keyboard serial delay not big enough!", context));
}
} else if (!strncmp(params[i], "paste_delay=", 12)) {
SIM->get_param_num(BXPN_KBD_PASTE_DELAY)->set(atol(&params[i][12]));
if (SIM->get_param_num(BXPN_KBD_PASTE_DELAY)->get() < 1000) {
PARSE_ERR (("%s: keyboard paste delay not big enough!", context));
}
} else if (!strncmp(params[i], "type=", 5)) {
if (!SIM->get_param_enum(BXPN_KBD_TYPE)->set_by_name(&params[i][5])) {
PARSE_ERR(("%s: keyboard_type directive: wrong arg '%s'.", context,params[1]));
}
} else if (!strncmp(params[i], "keymap=", 7)) {
if (!strncmp(params[i], "keymap=", 7)) {
SIM->get_param_bool(BXPN_KBD_USEMAPPING)->set(strlen(params[i]) > 7);
SIM->get_param_string(BXPN_KBD_KEYMAP)->set(&params[i][7]);
} else {
} else if (bx_parse_param_from_list(context, params[i], (bx_list_c*) SIM->get_param(BXPN_KEYBOARD)) < 0) {
PARSE_ERR(("%s: keyboard directive malformed.", context));
}
}
@ -2914,11 +2909,10 @@ static int parse_line_formatted(const char *context, int num_params, char *param
}
if(!strncmp(params[1], "keys=", 4)) {
SIM->get_param_string(BXPN_USER_SHORTCUT)->set(&params[1][5]);
if ((strchr(&params[1][5], '-') == NULL) && (strlen(&params[1][5]) > 5))
PARSE_WARN(("user_shortcut: old-style syntax detected"));
} else {
PARSE_ERR(("%s: user_shortcut directive malformed.", context));
}
PARSE_WARN(("%s: 'user_shortcut' will be replaced by new 'keyboard' option.", context));
}
else if (!strcmp(params[0], "config_interface"))
{
@ -3012,7 +3006,7 @@ int bx_write_param_list(FILE *fp, bx_list_c *base, const char *optname, bx_bool
}
for (int i = 0; i < base->get_size(); i++) {
bx_param_c *param = base->get(i);
if (param->get_enabled()) {
if (param->get_enabled() && ((param->get_options() & param->BOCHSRC_HIDDEN) == 0)) {
if (p > 0) {
strcat(bxrcline, ", ");
}
@ -3209,21 +3203,6 @@ int bx_write_log_options(FILE *fp, bx_list_c *base)
return 0;
}
int bx_write_keyboard_options(FILE *fp)
{
fprintf(fp, "keyboard: type=%s, serial_delay=%u, paste_delay=%u, ",
SIM->get_param_enum(BXPN_KBD_TYPE)->get_selected(),
SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->get(),
SIM->get_param_num(BXPN_KBD_PASTE_DELAY)->get());
if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) {
fprintf(fp, "keymap=%s\n", SIM->get_param_string(BXPN_KBD_KEYMAP)->getptr());
} else {
fprintf(fp, "keymap=\n");
}
fprintf(fp, "user_shortcut: keys=%s\n", SIM->get_param_string(BXPN_USER_SHORTCUT)->getptr());
return 0;
}
int bx_write_debugger_options(FILE *fp)
{
#if BX_DEBUGGER
@ -3400,7 +3379,7 @@ int bx_write_configuration(const char *rc, int overwrite)
bx_write_clock_cmos_options(fp);
bx_write_loader_options(fp);
bx_write_log_options(fp, (bx_list_c*) SIM->get_param("log"));
bx_write_keyboard_options(fp);
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_KEYBOARD), NULL, 0);
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_MOUSE), NULL, 0);
SIM->save_addon_options(fp);
fclose(fp);

View File

@ -3991,12 +3991,13 @@ parameter of the SB16 soundcard. The emulation supports recording and playback
</para>
</section>
<section><title>keyboard</title>
<section id="bochsopt-keyboard"><title>keyboard</title>
<para>
Examples:
<screen>
keyboard: type=mf, serial_delay=200, paste_delay=100000
keyboard: keymap=gui/keymaps/x11-pc-de.map
keyboard: user_shortcut=ctrl-alt-del
</screen>
This defines parameters related to the emulated keyboard.
</para>
@ -4035,6 +4036,20 @@ Keyboard mapping is available for the display libraries x, sdl (Linux port) and
wx (GTK port). For SDL you have to use keymaps designed for SDL, the wxWidgets GUI
uses the keymaps for X11.
</para>
<para><command>user_shortcut</command></para>
<para>
This defines the keyboard shortcut to be sent when you press the "user" button
in the <link linkend="headerbar">headerbar</link>. The shortcut string is a
combination of maximum 3 key names (listed below) separated with a '-' character.
</para>
<para>
Valid key names:
</para>
<para>
"alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
"f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup", "plus",
"right", "shift", "space", "tab", "up", "win", "print" and "power".
</para>
</section>
<section id="bochsopt-clock"><title>clock</title>
@ -4453,27 +4468,6 @@ as the NE2000 adapter.
</para>
</section>
<section id="bochsopt-user-shortcut"><title>user_shortcut</title>
<para>
Examples:
<screen>
user_shortcut: keys=ctrl-alt-del
user_shortcut: keys=ctrl-alt-esc
</screen>
This defines the keyboard shortcut to be sent when you press the "user" button
in the <link linkend="headerbar">headerbar</link>. The shortcut string is a
combination of maximum 3 key names (listed below) separated with a '-' character.
</para>
<para>
Valid key names:
</para>
<para>
"alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
"f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup", "plus",
"right", "shift", "space", "tab", "up", "win", "print" and "power".
</para>
</section>
<section><title>cmosimage</title>
<para>
Example:
@ -5193,8 +5187,8 @@ behavoiur of Bochs at runtime if you click on one of these buttons:
<para>user button</para>
<para>
Press this button if you want to send the keyboard shortcut defined with the
<link linkend="bochsopt-user-shortcut">user_shortcut option</link> to the guest.
Depending on the used <link linkend="bochsopt-displaylibrary">display_library option</link>,
<command>user_shortcut</command> parameter of the <link linkend="bochsopt-keyboard">keyboard</link>
option to the guest. Depending on the used <link linkend="bochsopt-displaylibrary">display_library option</link>,
it may even be possible to edit the shortcut before sending it.
</para>
</listitem>
@ -7634,9 +7628,10 @@ the cursor back in the Bochs window and press <keycap>delete</keycap>.
This should work for any key combination.
</para>
<para>
If you need one key combination frequently, set it up as <link linkend="bochsopt-user-shortcut">user key combination</link>
in your configuration file. This key combination is sent to the guest OS
when you press the user button in the <link linkend="headerbar">headerbar</link>.
If you need one key combination frequently, set it up as user key combination
with the <link linkend="bochsopt-keyboard">keyboard</link> option in your
configuration file. This key combination is sent to the guest OS when you press
the user button in the <link linkend="headerbar">headerbar</link>.
Depending on the used <link linkend="bochsopt-displaylibrary">display_library option</link>,
it may even be possible to edit the shortcut before sending it.
</para>
@ -8955,7 +8950,7 @@ will trap this key combination. You can either use the trick described in
(callable through the user short-cut gui button)
in you configuration file, for example:
<programlisting>
user_shortcut: keys=ctrl-alt-del
keyboard: user_shortcut=ctrl-alt-del
</programlisting>
</para>
</listitem>
@ -9123,8 +9118,7 @@ panic: action=ask
error: action=report
info: action=report
debug: action=ignore
keyboard: type=mf, keymap=
user_shortcut: keys=none
keyboard: type=mf, keymap=, user_shortcut=none
config_interface: textconfig
display_library: x
</programlisting>

View File

@ -1,5 +1,5 @@
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
.TH bochsrc 5 "28 Oct 2012" "bochsrc" "The Bochs Project"
.TH bochsrc 5 "27 Jan 2013" "bochsrc" "The Bochs Project"
.\"SKIP_SECTION"
.SH NAME
bochsrc \- Configuration file for Bochs.
@ -844,9 +844,22 @@ keymap:
This enables a remap of a physical localized keyboard to a
virtualized us keyboard, as the PC architecture expects.
user_shortcut:
This defines the keyboard shortcut to be sent when you press the "user"
button in the header bar. The shortcut string is a combination of maximum
3 key names (listed below) separated with a '-' character.
Valid key names:
"alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
"f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup", "plus",
"right", "shift", "space", "tab", "up", "win", "print" and "power".
Examples:
keyboard: type=mf, serial_delay=200, paste_delay=100000
keyboard: keymap=gui/keymaps/x11-pc-de.map
keyboard: user_shortcut=ctrl-alt-del
.TP
.I "clock:"
@ -1044,21 +1057,6 @@ modules as the NE2000 adapter.
Example:
e1000: enabled=1, mac=52:54:00:12:34:56, ethmod=slirp, script=/usr/local/bin/slirp
.TP
.I "user_shortcut:"
This defines the keyboard shortcut to be sent when you press the "user"
button in the header bar. The shortcut string is a combination of maximum
3 key names (listed below) separated with a '-' character.
Valid key names:
"alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc",
"f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup", "plus",
"right", "shift", "space", "tab", "up", "win", "print" and "power".
Example:
user_shortcut: keys=ctrl-alt-del
.TP
.I "cmosimage:"
This defines image file that can be loaded into the CMOS RAM at startup.

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2010 The Bochs Project
// Copyright (C) 2010-2013 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -111,6 +111,11 @@ protected:
bx_list_c *dependent_list;
void *device;
public:
enum {
// If set, this parameter is not available as a bochsrc option, but in CI only.
// In that case, it is set by another (e.g. combined) option
BOCHSRC_HIDDEN = (1<<31)
} bx_param_opt_bits;
bx_param_c(Bit32u id, const char *name, const char *description);
bx_param_c(Bit32u id, const char *name, const char *label, const char *description);
virtual ~bx_param_c();

View File

@ -114,6 +114,7 @@
#define BXPN_SCREENMODE "display.screenmode"
#define BXPN_VGA_EXTENSION "display.vga_extension"
#define BXPN_VGA_UPDATE_FREQUENCY "display.vga_update_frequency"
#define BXPN_KEYBOARD "keyboard_mouse.keyboard"
#define BXPN_KBD_TYPE "keyboard_mouse.keyboard.type"
#define BXPN_KBD_SERIAL_DELAY "keyboard_mouse.keyboard.serial_delay"
#define BXPN_KBD_PASTE_DELAY "keyboard_mouse.keyboard.paste_delay"