Indent changes

This commit is contained in:
Stanislav Shwartsman 2006-04-10 19:02:30 +00:00
parent 0396a9d86f
commit df70fa0a2f
2 changed files with 129 additions and 175 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.93 2006-03-04 12:43:47 vruppert Exp $ // $Id: gui.cc,v 1.94 2006-04-10 19:02:30 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -110,8 +110,7 @@ bx_gui_c::~bx_gui_c()
} }
} }
void void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
{ {
BX_GUI_THIS new_gfx_api = 0; BX_GUI_THIS new_gfx_api = 0;
BX_GUI_THIS host_xres = 640; BX_GUI_THIS host_xres = 640;
@ -232,8 +231,8 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
show_headerbar(); show_headerbar();
} }
void void bx_gui_c::update_drive_status_buttons (void)
bx_gui_c::update_drive_status_buttons (void) { {
BX_GUI_THIS floppyA_status = BX_GUI_THIS floppyA_status =
DEV_floppy_get_media_status(0) DEV_floppy_get_media_status(0)
&& (SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->get() == BX_INSERTED); && (SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->get() == BX_INSERTED);
@ -252,7 +251,7 @@ bx_gui_c::update_drive_status_buttons (void) {
DiskEject(1); DiskEject(1);
#endif #endif
replace_bitmap(BX_GUI_THIS floppyA_hbar_id, BX_GUI_THIS floppyA_eject_bmap_id); replace_bitmap(BX_GUI_THIS floppyA_hbar_id, BX_GUI_THIS floppyA_eject_bmap_id);
} }
if (BX_GUI_THIS floppyB_status) if (BX_GUI_THIS floppyB_status)
replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_bmap_id); replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_bmap_id);
else { else {
@ -263,16 +262,15 @@ bx_gui_c::update_drive_status_buttons (void) {
DiskEject(1); DiskEject(1);
#endif #endif
replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_eject_bmap_id); replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_eject_bmap_id);
} }
if (BX_GUI_THIS cdromD_status) if (BX_GUI_THIS cdromD_status)
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_bmap_id); replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_bmap_id);
else { else {
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_eject_bmap_id); replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_eject_bmap_id);
} }
} }
void void bx_gui_c::floppyA_handler(void)
bx_gui_c::floppyA_handler(void)
{ {
if (SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE)->get() == BX_FLOPPY_NONE) if (SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE)->get() == BX_FLOPPY_NONE)
return; // no primary floppy device present return; // no primary floppy device present
@ -290,8 +288,7 @@ bx_gui_c::floppyA_handler(void)
BX_GUI_THIS update_drive_status_buttons(); BX_GUI_THIS update_drive_status_buttons();
} }
void void bx_gui_c::floppyB_handler(void)
bx_gui_c::floppyB_handler(void)
{ {
if (SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE)->get() == BX_FLOPPY_NONE) if (SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE)->get() == BX_FLOPPY_NONE)
return; // no secondary floppy device present return; // no secondary floppy device present
@ -309,8 +306,7 @@ bx_gui_c::floppyB_handler(void)
BX_GUI_THIS update_drive_status_buttons(); BX_GUI_THIS update_drive_status_buttons();
} }
void void bx_gui_c::cdromD_handler(void)
bx_gui_c::cdromD_handler(void)
{ {
Bit32u handle = DEV_hd_get_first_cd_handle(); Bit32u handle = DEV_hd_get_first_cd_handle();
if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_CDROM) { if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_CDROM) {
@ -332,15 +328,13 @@ bx_gui_c::cdromD_handler(void)
BX_GUI_THIS update_drive_status_buttons(); BX_GUI_THIS update_drive_status_buttons();
} }
void void bx_gui_c::reset_handler(void)
bx_gui_c::reset_handler(void)
{ {
BX_INFO(( "system RESET callback." )); BX_INFO(("system RESET callback"));
bx_pc_system.Reset( BX_RESET_HARDWARE ); bx_pc_system.Reset(BX_RESET_HARDWARE);
} }
void void bx_gui_c::power_handler(void)
bx_gui_c::power_handler(void)
{ {
// the user pressed power button, so there's no doubt they want bochs // the user pressed power button, so there's no doubt they want bochs
// to quit. Change panics to fatal for the GUI and then do a panic. // to quit. Change panics to fatal for the GUI and then do a panic.
@ -352,8 +346,7 @@ bx_gui_c::power_handler(void)
BX_EXIT (1); BX_EXIT (1);
} }
Bit32s Bit32s bx_gui_c::make_text_snapshot(char **snapshot, Bit32u *length)
bx_gui_c::make_text_snapshot (char **snapshot, Bit32u *length)
{ {
Bit8u* raw_snap = NULL; Bit8u* raw_snap = NULL;
char *clean_snap; char *clean_snap;
@ -384,8 +377,7 @@ bx_gui_c::make_text_snapshot (char **snapshot, Bit32u *length)
// create a text snapshot and copy to the system clipboard. On guis that // create a text snapshot and copy to the system clipboard. On guis that
// we haven't figured out how to support yet, dump to a file instead. // we haven't figured out how to support yet, dump to a file instead.
void void bx_gui_c::copy_handler(void)
bx_gui_c::copy_handler(void)
{ {
Bit32u len; Bit32u len;
char *text_snapshot; char *text_snapshot;
@ -403,8 +395,7 @@ bx_gui_c::copy_handler(void)
} }
// Check the current text snapshot against file snapchk.txt. // Check the current text snapshot against file snapchk.txt.
void void bx_gui_c::snapshot_checker(void *this_ptr)
bx_gui_c::snapshot_checker(void * this_ptr)
{ {
char filename[BX_PATHNAME_LEN]; char filename[BX_PATHNAME_LEN];
strcpy(filename,"snapchk.txt"); strcpy(filename,"snapchk.txt");
@ -451,8 +442,7 @@ bx_gui_c::snapshot_checker(void * this_ptr)
} }
// create a text snapshot and dump it to a file // create a text snapshot and dump it to a file
void void bx_gui_c::snapshot_handler(void)
bx_gui_c::snapshot_handler(void)
{ {
char *text_snapshot; char *text_snapshot;
Bit32u len; Bit32u len;
@ -481,8 +471,7 @@ bx_gui_c::snapshot_handler(void)
// Read ASCII chars from the system clipboard and paste them into bochs. // Read ASCII chars from the system clipboard and paste them into bochs.
// Note that paste cannot work with the key mapping tables loaded. // Note that paste cannot work with the key mapping tables loaded.
void void bx_gui_c::paste_handler(void)
bx_gui_c::paste_handler(void)
{ {
Bit32s nbytes; Bit32s nbytes;
Bit8u *bytes; Bit8u *bytes;
@ -498,17 +487,14 @@ bx_gui_c::paste_handler(void)
DEV_kbd_paste_bytes (bytes, nbytes); DEV_kbd_paste_bytes (bytes, nbytes);
} }
void bx_gui_c::config_handler(void)
void
bx_gui_c::config_handler(void)
{ {
if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_RUNTIME) { if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_RUNTIME) {
SIM->configuration_interface (NULL, CI_RUNTIME_CONFIG); SIM->configuration_interface (NULL, CI_RUNTIME_CONFIG);
} }
} }
void void bx_gui_c::toggle_mouse_enable(void)
bx_gui_c::toggle_mouse_enable(void)
{ {
int old = SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get(); int old = SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get();
BX_DEBUG (("toggle mouse_enabled, now %d", !old)); BX_DEBUG (("toggle mouse_enabled, now %d", !old));
@ -527,8 +513,7 @@ Bit32u get_user_key(char *key)
return BX_KEY_UNKNOWN; return BX_KEY_UNKNOWN;
} }
void void bx_gui_c::userbutton_handler(void)
bx_gui_c::userbutton_handler(void)
{ {
Bit32u shortcut[4]; Bit32u shortcut[4];
Bit32u symbol; Bit32u symbol;
@ -599,8 +584,7 @@ bx_gui_c::userbutton_handler(void)
} }
} }
void void bx_gui_c::mouse_enabled_changed (bx_bool val)
bx_gui_c::mouse_enabled_changed (bx_bool val)
{ {
// This is only called when SIM->get_init_done is 1. Note that VAL // This is only called when SIM->get_init_done is 1. Note that VAL
// is the new value of mouse_enabled, which may not match the old // is the new value of mouse_enabled, which may not match the old
@ -616,8 +600,7 @@ bx_gui_c::mouse_enabled_changed (bx_bool val)
BX_GUI_THIS mouse_enabled_changed_specific (val); BX_GUI_THIS mouse_enabled_changed_specific (val);
} }
void void bx_gui_c::init_signal_handlers()
bx_gui_c::init_signal_handlers ()
{ {
#if BX_GUI_SIGHANDLER #if BX_GUI_SIGHANDLER
if (bx_gui_sighandler) if (bx_gui_sighandler)
@ -632,37 +615,31 @@ bx_gui_c::init_signal_handlers ()
#endif #endif
} }
void void bx_gui_c::set_text_charmap(Bit8u *fbuffer)
bx_gui_c::set_text_charmap(Bit8u *fbuffer)
{ {
memcpy(& BX_GUI_THIS vga_charmap, fbuffer, 0x2000); memcpy(& BX_GUI_THIS vga_charmap, fbuffer, 0x2000);
for (unsigned i=0; i<256; i++) BX_GUI_THIS char_changed[i] = 1; for (unsigned i=0; i<256; i++) BX_GUI_THIS char_changed[i] = 1;
BX_GUI_THIS charmap_updated = 1; BX_GUI_THIS charmap_updated = 1;
} }
void void bx_gui_c::set_text_charbyte(Bit16u address, Bit8u data)
bx_gui_c::set_text_charbyte(Bit16u address, Bit8u data)
{ {
BX_GUI_THIS vga_charmap[address] = data; BX_GUI_THIS vga_charmap[address] = data;
BX_GUI_THIS char_changed[address >> 5] = 1; BX_GUI_THIS char_changed[address >> 5] = 1;
BX_GUI_THIS charmap_updated = 1; BX_GUI_THIS charmap_updated = 1;
} }
void void bx_gui_c::beep_on(float frequency)
bx_gui_c::beep_on(float frequency)
{ {
BX_INFO(( "GUI Beep ON (frequency=%.2f)",frequency)); BX_INFO(("GUI Beep ON (frequency=%.2f)", frequency));
} }
void void bx_gui_c::beep_off()
bx_gui_c::beep_off()
{ {
BX_INFO(( "GUI Beep OFF")); BX_INFO(("GUI Beep OFF"));
} }
int int bx_gui_c::register_statusitem(const char *text)
bx_gui_c::register_statusitem(const char *text)
{ {
if (statusitem_count < BX_MAX_STATUSITEMS) { if (statusitem_count < BX_MAX_STATUSITEMS) {
strncpy(statusitem_text[statusitem_count], text, 8); strncpy(statusitem_text[statusitem_count], text, 8);
@ -673,16 +650,14 @@ bx_gui_c::register_statusitem(const char *text)
} }
} }
void void bx_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
bx_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
{ {
*xres = 1024; *xres = 1024;
*yres = 768; *yres = 768;
*bpp = 32; *bpp = 32;
} }
bx_svga_tileinfo_t * bx_svga_tileinfo_t *bx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
bx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
{ {
if (!info) { if (!info) {
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t)); info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
@ -732,8 +707,7 @@ bx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
return info; return info;
} }
Bit8u * Bit8u *bx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
bx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
unsigned *w, unsigned *h) unsigned *w, unsigned *h)
{ {
if (x0+X_TILESIZE > BX_GUI_THIS host_xres) { if (x0+X_TILESIZE > BX_GUI_THIS host_xres) {
@ -754,8 +728,7 @@ bx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
x0 * ((BX_GUI_THIS host_bpp + 1) >> 3); x0 * ((BX_GUI_THIS host_bpp + 1) >> 3);
} }
void void bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
bx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
unsigned w, unsigned h) unsigned w, unsigned h)
{ {
Bit8u tile[X_TILESIZE * Y_TILESIZE * 4]; Bit8u tile[X_TILESIZE * Y_TILESIZE * 4];

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: keymap.cc,v 1.18 2006-02-22 19:18:28 vruppert Exp $ // $Id: keymap.cc,v 1.19 2006-04-10 19:02:30 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -70,7 +70,7 @@ char *bx_key_symbol[BX_KEY_NBKEYS] = {
"BX_KEY_INT_SEARCH", "BX_KEY_INT_FAV", "BX_KEY_INT_HOME", "BX_KEY_INT_SEARCH", "BX_KEY_INT_FAV", "BX_KEY_INT_HOME",
"BX_KEY_POWER_MYCOMP", "BX_KEY_POWER_CALC", "BX_KEY_POWER_SLEEP", "BX_KEY_POWER_MYCOMP", "BX_KEY_POWER_CALC", "BX_KEY_POWER_SLEEP",
"BX_KEY_POWER_POWER", "BX_KEY_POWER_WAKE", "BX_KEY_POWER_POWER", "BX_KEY_POWER_WAKE",
}; };
bx_keymap_c bx_keymap; bx_keymap_c bx_keymap;
@ -82,7 +82,6 @@ bx_keymap_c::bx_keymap_c(void)
keymapCount = 0; keymapCount = 0;
keymapTable = (BXKeyEntry *)NULL; keymapTable = (BXKeyEntry *)NULL;
} }
bx_keymap_c::~bx_keymap_c(void) bx_keymap_c::~bx_keymap_c(void)
@ -90,21 +89,18 @@ bx_keymap_c::~bx_keymap_c(void)
if(keymapTable != NULL) { if(keymapTable != NULL) {
free(keymapTable); free(keymapTable);
keymapTable = (BXKeyEntry *)NULL; keymapTable = (BXKeyEntry *)NULL;
} }
keymapCount = 0; keymapCount = 0;
} }
void void bx_keymap_c::loadKeymap(Bit32u stringToSymbol(const char*))
bx_keymap_c::loadKeymap(Bit32u stringToSymbol(const char*))
{ {
if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) { if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) {
loadKeymap(stringToSymbol, SIM->get_param_string(BXPN_KBD_KEYMAP)->getptr()); loadKeymap(stringToSymbol, SIM->get_param_string(BXPN_KBD_KEYMAP)->getptr());
} }
} }
bx_bool bx_keymap_c::isKeymapLoaded ()
bx_bool
bx_keymap_c::isKeymapLoaded ()
{ {
return (keymapCount > 0); return (keymapCount > 0);
} }
@ -115,14 +111,12 @@ bx_keymap_c::isKeymapLoaded ()
static unsigned char *lineptr = NULL; static unsigned char *lineptr = NULL;
static int lineCount; static int lineCount;
static void static void init_parse()
init_parse ()
{ {
lineCount = 0; lineCount = 0;
} }
static void static void init_parse_line(char *line_to_parse)
init_parse_line (char *line_to_parse)
{ {
// chop off newline // chop off newline
lineptr = (unsigned char *)line_to_parse; lineptr = (unsigned char *)line_to_parse;
@ -132,19 +126,18 @@ init_parse_line (char *line_to_parse)
} }
} }
static Bit32s static Bit32s get_next_word(char *output)
get_next_word (char *output)
{ {
char *copyp = output; char *copyp = output;
// find first nonspace // find first nonspace
while (*lineptr && isspace (*lineptr)) while (*lineptr && isspace(*lineptr))
lineptr++; lineptr++;
if (!*lineptr) if (!*lineptr)
return -1; // nothing but spaces until end of line return -1; // nothing but spaces until end of line
if (*lineptr == '#') if (*lineptr == '#')
return -1; // nothing but a comment return -1; // nothing but a comment
// copy nonspaces into the output // copy nonspaces into the output
while (*lineptr && !isspace (*lineptr)) while (*lineptr && !isspace(*lineptr))
*copyp++ = *lineptr++; *copyp++ = *lineptr++;
*copyp=0; // null terminate the copy *copyp=0; // null terminate the copy
// there must be at least one nonspace, since that's why we stopped the // there must be at least one nonspace, since that's why we stopped the
@ -153,8 +146,7 @@ get_next_word (char *output)
return 0; return 0;
} }
static Bit32s static Bit32s get_next_keymap_line (FILE *fp, char *bxsym, char *modsym, Bit32s *ascii, char *hostsym)
get_next_keymap_line (FILE *fp, char *bxsym, char *modsym, Bit32s *ascii, char *hostsym)
{ {
char line[256]; char line[256];
char buf[256]; char buf[256];
@ -202,129 +194,118 @@ get_next_keymap_line (FILE *fp, char *bxsym, char *modsym, Bit32s *ascii, char *
} }
} }
void void bx_keymap_c::loadKeymap(Bit32u stringToSymbol(const char*), const char* filename)
bx_keymap_c::loadKeymap(Bit32u stringToSymbol(const char*), const char* filename)
{ {
FILE *keymapFile; FILE *keymapFile;
char baseSym[256], modSym[256], hostSym[256]; char baseSym[256], modSym[256], hostSym[256];
Bit32s ascii; Bit32s ascii;
Bit32u baseKey, modKey, hostKey; Bit32u baseKey, modKey, hostKey;
struct stat status; struct stat status;
if (stat(filename, &status)) { if (stat(filename, &status)) {
BX_PANIC(("Can not stat keymap file '%s'.",filename)); BX_PANIC(("Can not stat keymap file '%s'.",filename));
} }
if (!(S_ISREG(status.st_mode))) { if (!(S_ISREG(status.st_mode))) {
BX_PANIC(("Keymap file '%s' is not a file",filename)); BX_PANIC(("Keymap file '%s' is not a file",filename));
} }
if((keymapFile = fopen(filename,"r"))==NULL) { if((keymapFile = fopen(filename,"r"))==NULL) {
BX_PANIC(("Can not open keymap file '%s'.",filename)); BX_PANIC(("Can not open keymap file '%s'.",filename));
} }
BX_INFO(("Loading keymap from '%s'",filename)); BX_INFO(("Loading keymap from '%s'",filename));
init_parse (); init_parse();
// Read keymap file one line at a time // Read keymap file one line at a time
while(1) { while(1) {
if (get_next_keymap_line (keymapFile, if (get_next_keymap_line (keymapFile,
baseSym, modSym, &ascii, hostSym) < 0) { break; } baseSym, modSym, &ascii, hostSym) < 0) { break; }
// convert X_KEY_* symbols to values
baseKey = convertStringToBXKey(baseSym);
modKey = convertStringToBXKey(modSym);
hostKey = 0;
if (stringToSymbol != NULL)
hostKey = stringToSymbol(hostSym);
// convert X_KEY_* symbols to values BX_DEBUG(("baseKey='%s' (%d), modSym='%s' (%d), ascii=%d, guisym='%s' (%d)", baseSym, baseKey, modSym, modKey, ascii, hostSym, hostKey));
baseKey = convertStringToBXKey(baseSym);
modKey = convertStringToBXKey(modSym);
hostKey = 0;
if (stringToSymbol != NULL)
hostKey = stringToSymbol(hostSym);
BX_DEBUG (("baseKey='%s' (%d), modSym='%s' (%d), ascii=%d, guisym='%s' (%d)", baseSym, baseKey, modSym, modKey, ascii, hostSym, hostKey));
// Check if data is valid // Check if data is valid
if( baseKey==BX_KEYMAP_UNKNOWN ) { if (baseKey==BX_KEYMAP_UNKNOWN) {
BX_PANIC (("line %d: unknown BX_KEY constant '%s'",lineCount,baseSym)); BX_PANIC (("line %d: unknown BX_KEY constant '%s'",lineCount,baseSym));
continue; continue;
} }
if( hostKey==BX_KEYMAP_UNKNOWN ) { if (hostKey==BX_KEYMAP_UNKNOWN) {
BX_PANIC (("line %d: unknown host key name '%s' (wrong keymap ?)",lineCount,hostSym)); BX_PANIC (("line %d: unknown host key name '%s' (wrong keymap ?)",lineCount,hostSym));
continue; continue;
} }
keymapTable=(BXKeyEntry*)realloc(keymapTable,(keymapCount+1) * sizeof(BXKeyEntry)); keymapTable=(BXKeyEntry*)realloc(keymapTable,(keymapCount+1) * sizeof(BXKeyEntry));
if(keymapTable==NULL) if (keymapTable==NULL)
BX_PANIC(("Can not allocate memory for keymap table.")); BX_PANIC(("Can not allocate memory for keymap table."));
keymapTable[keymapCount].baseKey=baseKey; keymapTable[keymapCount].baseKey=baseKey;
keymapTable[keymapCount].modKey=modKey; keymapTable[keymapCount].modKey=modKey;
keymapTable[keymapCount].ascii=ascii; keymapTable[keymapCount].ascii=ascii;
keymapTable[keymapCount].hostKey=hostKey; keymapTable[keymapCount].hostKey=hostKey;
keymapCount++; keymapCount++;
} }
BX_INFO(("Loaded %d symbols",keymapCount)); BX_INFO(("Loaded %d symbols",keymapCount));
fclose(keymapFile); fclose(keymapFile);
} }
Bit32u Bit32u bx_keymap_c::convertStringToBXKey(const char* string)
bx_keymap_c::convertStringToBXKey(const char* string)
{ {
Bit16u i; // We look through the bx_key_symbol table to find the searched string
for (Bit16u i=0; i<BX_KEY_NBKEYS; i++) {
// We look through the bx_key_symbol table to find the searched string if (strcmp(string,bx_key_symbol[i])==0) {
for (i=0; i<BX_KEY_NBKEYS; i++) { return i;
if (strcmp(string,bx_key_symbol[i])==0) { }
return i; }
}
}
// Key is not known // Key is not known
return BX_KEYMAP_UNKNOWN; return BX_KEYMAP_UNKNOWN;
} }
BXKeyEntry * BXKeyEntry *bx_keymap_c::findHostKey(Bit32u key)
bx_keymap_c::findHostKey(Bit32u key)
{ {
Bit16u i; // We look through the keymap table to find the searched key
for (Bit16u i=0; i<keymapCount; i++) {
if (keymapTable[i].hostKey == key) {
BX_DEBUG (("key 0x%02x matches hostKey for entry #%d", key, i));
return &keymapTable[i];
}
}
BX_DEBUG(("key %02x matches no entries", key));
// We look through the keymap table to find the searched key // Return default
for (i=0; i<keymapCount; i++) { return NULL;
if (keymapTable[i].hostKey == key) {
BX_DEBUG (("key 0x%02x matches hostKey for entry #%d", key, i));
return &keymapTable[i];
}
}
BX_DEBUG (("key %02x matches no entries", key));
// Return default
return NULL;
} }
BXKeyEntry * BXKeyEntry *bx_keymap_c::findAsciiChar(Bit8u ch)
bx_keymap_c::findAsciiChar(Bit8u ch)
{ {
Bit16u i; BX_DEBUG (("findAsciiChar (0x%02x)", ch));
BX_DEBUG (("findAsciiChar (0x%02x)", ch));
// We look through the keymap table to find the searched key // We look through the keymap table to find the searched key
for (i=0; i<keymapCount; i++) { for (Bit16u i=0; i<keymapCount; i++) {
if (keymapTable[i].ascii == ch) { if (keymapTable[i].ascii == ch) {
BX_DEBUG (("key %02x matches ascii for entry #%d", ch, i)); BX_DEBUG (("key %02x matches ascii for entry #%d", ch, i));
return &keymapTable[i]; return &keymapTable[i];
} }
} }
BX_DEBUG (("key 0x%02x matches no entries", ch)); BX_DEBUG (("key 0x%02x matches no entries", ch));
// Return default // Return default
return NULL; return NULL;
} }
char * char *bx_keymap_c::getBXKeyName(Bit32u key)
bx_keymap_c::getBXKeyName(Bit32u key)
{ {
return bx_key_symbol[key & 0x7fffffff]; return bx_key_symbol[key & 0x7fffffff];
} }