VOGONS


First post, by nacnud

User metadata
Rank Newbie
Rank
Newbie

Folks,

I can almost guarantee that this is not the way to go about doing this sort of thing, and there will be much more professional approaches to be the standard of C and the implementation of it in the application. However, I have updated, whether they needed it or not, a few of the files that constitute “dosbox”.

Basically I hacked it so that I could get UK keyboard charactaers out of it by adding a line to the dosbox.conf file. This line is in the section [dosbox] and reads

makekeyboarduk=1

To facilitate this, I follows the current standard ( and if you ask me, a bit strange ) way of doing things; that is, I added a call to

secprop->Add_int("makekeyboarduk",0);

in the function DosBox_Init

Then I added some code to the function DosBox_RealInit which just reads that from the file.

/* Added by Duncan Drysdale (nacnud@bigfoot.com) to deal with keyboard translation */
g_intTranslateToUK = section->Get_int("makekeyboarduk");
if ( g_intkeyboarduk )
LOG_MSG("Keyboard Set To Translate To UK...");

When that’s done, of course, you need a variable called g_intTranslateToUK, which is defined as

int g_intTranslateToUK; int CPP file and as

extern int g_intTranslateToUK in the .H file of DOSBOX.CPP/H.

Oh, I also updated the statement, just for the sake of the help thing...

MSG_Add("DOSBOX_CONFIGFILE_HELP",
"language -- Select another language file.\n"
"memsize -- Amount of memory dosbox has in megabytes.\n"
"machine -- The type of machine tries to emulate:hercules,cga,tandy,pcjr,vga.\n"
"captures -- Directory where things like wave,midi,screenshot get captured.\n"
"makekeyboarduk -- Use this to flick the \",@ signs around.\n"
);

Then there was just the wee matter of tranlating the key codes...never go the “£” (uk pound sign ) to work as that would mean doing a proper job of this and doing character sets and stuff...pah...i’m just a drity hacker.

As such all changes were in the function KEYBOARD_AddKey which seems to take SDL keys and stores them in a buffer before making the available to the Int01 keyboard handler via port60 when the “machine is running”. Fair enough.

Just the changed cases are here.
case KBD_2:
/* Duncan Drysdale (nacnud@bigfoot.com) updated this to translate scan code 2 to a quote. for UK keyboards
06/11/2006 */
if ( pressed && ( g_intTranslateToUK && (shifted == 1 )) )
ret=40;
else
ret=3;
break;

case KBD_quote:
/* Duncan Drysdale (nacnud@bigfoot.com) added this to quick hack this keyboard port60 stuffer to be UK-English
7th October 2006 - Translate the _quote scan code to a 3 if needed!
I supose this code will never send a "unpressed,3" command to the keyboard buffer..wonder if this makes any
difference? - Someone with half a brain more than me will be able to work it out.
*/
if ( pressed && ( g_intTranslateToUK && (shifted == 1 )) )
ret=3;
else
ret=40;
break;

case KBD_leftshift:
/* Duncan Drysdale (nacnud@bigfoot.com) added this to quick hack this keyboard port60 stuffer to be UK-English
7th October 2006 - Just track the shifted position.
*/
if ( pressed )
shifted = 1;
else
shifted = 0;
ret=42;
break;

case KBD_backslash:
/* Duncan Drysdale (nacnud@bigfoot.com) added this to hack the keyboard buffer....nasty! 🤣 At lesat it now produces a hash */
if ( pressed && g_intTranslateToUK )
{
if ( shifted )
{
ret=41;
}
else
{
/*Nasty, but fun! Shift, press 3, release 3, release shift, return nothing! */
KEYBOARD_AddKey(KBD_leftshift,true);
KEYBOARD_AddKey(KBD_3,true);
KEYBOARD_AddKey(KBD_3,false);
KEYBOARD_AddKey(KBD_leftshift,false);
pressed = false;
}
}
else
{
ret=43;
}
break;

case KBD_rightshift:
/* Duncan Drysdale (nacnud@bigfoot.com) added this to quick hack this keyboard port60 stuffer to be UK-English
7th October 2006 - Just track the shifted position.
*/
if ( pressed )
shifted = 1;
else
shifted = 0;
ret=54;
break;

case KBD_extra_lt_gt:
/* Duncan Drysdale (nacnud@bigfoot.com) added this to quick hack this keyboard port60 stuffer to be UK-English
7th October 2006 - exlat the #/~ key to be a normal pipe(|/\) key.
*/
if ( g_intTranslateToUK )
ret=43;
else
ret=86;
break;

So, that’s it, really. Oh, by they way, the formatting will be all to pot dude to this messegaing system, I dare say.

You know, this all came about cause I wsnted to use TC on an XP box but it was too resource hungry( something to do with protect mode dos and swaping in and out from real mode???? ). So I thought that I’d try it on DosBox, only to find out, or not be able to work out how I could make the blasted thing to quotes, hashes and tildes. Well, it now does, on my hard disk, at least. I’m sure there are much easier ways, but if anyone wants to discuss with me the finer points of the pumping of SDL keys to the virtual machine, I’d love to have the natter.

Cheers,
Dunk

PS. If I’ve missed antying out, and you want to email me or owt, just put DOSBOX somewhere in the subject...Followed by as many 🤣’s as you like.

PPS. This code, of course, is out there. Make what you will of it. If it makes you laugh, cry, scream, or anything else, or has any of those affects on yir computer, speak to your local deity. Peace.

Last edited by nacnud on 2006-10-07, 20:21. Edited 1 time in total.

Reply 3 of 3, by nacnud

User metadata
Rank Newbie
Rank
Newbie
wd wrote:

I assume UK uses the 437 codepage, so you could try keyb.com from freedos.

Yeah...Their download links were fooked...seem still to be...Did try to get that quickly from there though. I was trying to use the links on this page http://projects.freedos.net/keyb/ . Suppose i could have downloaded the whole suite and just used the one program...hey, that'd not have been as much fun! 😀 Thanks for the advice though 😀 Happy DOSing...