Page 1 of 3

Keyboard input...How do I get keys?

Posted: Thu Oct 03, 2002 7:02 pm
by Tom
Hello, I've just got the itoa function in FritzOS working.

Now, how do I get a key in PMode?

Thank you

Re:Keyboard input...How do I get keys?

Posted: Thu Oct 03, 2002 7:08 pm
by dronkit

Re:Keyboard input...How do I get keys?

Posted: Fri Oct 04, 2002 9:05 am
by Tom
in my key handeler...

I do
if ( scan >= ' ' )
putch( scan );

and when I type 'a' a * comes out, and so on.

whats wrong?

Re:Keyboard input...How do I get keys?

Posted: Fri Oct 04, 2002 9:17 am
by Tom
that is, not a* but '*' comes out

Re:Keyboard input...How do I get keys?

Posted: Fri Oct 04, 2002 9:19 am
by Pype.Clicker
:D

well, your keyboard does not send ascii codes but SCANCODES instead (which is just numbers associated to the keys). The mapping from scancodes to ascii codes is keyboard-specific (i.e. different on a US keyboard than on a swiss one or french).

However, the repartition of scancodes along the keyboard is always the same (say, [ESC] will always be 1, left arrow is 75, etc.)

so what you have to do is defining
char charmap[]={ SCAN_1:'1','2','3','4', ... , SCAN_Q:'q','w','e','r','t','y' ... };

and then

Code: Select all

if (scan>128) putch(charmap[scan]);

Re:Keyboard input...How do I get keys?

Posted: Fri Oct 04, 2002 9:25 am
by Tom
oh, that's what I thought...I was thinking Isn't it ASCII?

Ok, ty

Re:Keyboard input...How do I get keys?

Posted: Sat Oct 05, 2002 8:37 pm
by Tom
now I know how to get keys, is there a PMode way of detecting the keyboard scan-code type the user's using?

Re:Keyboard input...How do I get keys?

Posted: Sun Oct 06, 2002 2:31 pm
by Tim
scancode = in(0x60)

Re:Keyboard input...How do I get keys?

Posted: Mon Oct 07, 2002 12:13 am
by Pype.Clicker
I've seen many ppl in this forum sending something on the 61h port after reading the scancode with in al,60h.

That's something i've never done and my code always worked on real hardware (ranging from i386 to PIII), but when i come to BOCHS, the single "in 60,al" thing hangs the virtual PC after a few keystrokes ...

any clue ?

Re:Keyboard input...How do I get keys?

Posted: Mon Oct 07, 2002 1:40 am
by Whatever5k
Hm...
I've seen the 0x61 stuff also in the MINIX source code, so I use it, too...
I have also some problems with Bochs and IRQ1, but I have no idea what's the problem...Bochs seems to suck ;)

Re:Keyboard input...How do I get keys?

Posted: Tue Oct 08, 2002 4:25 pm
by Tom
   char _retchar;

   // Non-Shifted:
   char asciiNonSh[] = { NULL, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', NULL, 'a', 's', 'd', 'f', 'g', 'h',
   'j', 'k', 'l', ';', '\'', '`', NULL, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', NULL,'*',
   NULL, ' ' };

   _retchar = asciiNonSh[ scancode ];

and I can't get keys.
whats wrong? ( I am using the US 104 scancode, but have my kernel loading at 4000h without the a20 )

Thank you,

Re:Keyboard input...How do I get keys?

Posted: Tue Oct 08, 2002 4:45 pm
by Tom
But:

when I do this:
char asciiNonSh[] = { NULL, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t' };

I can get keys.

???

Re:Keyboard input...How do I get keys?

Posted: Tue Oct 08, 2002 8:58 pm
by gtsphere
i'm also having the same trouble, i can make a list of all the scancodes and if else if else if else then all, but i wanted to do the char array. I saw it somewhere once, but i couldn't figure out how it worked.

So basically,
you take your scanCode, put it into the array and it shold figure it out for you??

???

lost! heh. Does it actualyl know which one equals what?

thanks in advanced. And Tom, i hope you get this working cause your OS is really shippin up

Re:Keyboard input...How do I get keys?

Posted: Wed Oct 09, 2002 12:25 am
by Pype.Clicker
i think you should *not* use NULL in your table as this is a void* (and thus it will not fit in a char array ... compiling with -Wall will certainly confirm this). try using '\0' instead ...

Re:Keyboard input...How do I get keys?

Posted: Wed Oct 09, 2002 1:54 pm
by Tom
nope, didn't work. I run out of space I think after I put w in.