Page 2 of 3
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 2:04 am
by Pype.Clicker
damn! this is veryveryvery weird ... maybe you should check it has no problem with compiling/linking/loading (for instance, print your array on the screen in the kernel or something alike ...
another trick would be to enter it as a string (" 1234567890-qwertyuiop ...")
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 6:16 am
by Whatever5k
try
char *keymap[] = {NULL, '1', ...};
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 6:24 am
by Pype.Clicker
abless wrote:
try
char *keymap[] = {NULL, '1', ...};
does this have chances to work ?? the [ESC] key has scancode #1, so i don't see where this will lead ...
Now something you should take care of is to map only key presses (not key releases
), thus something like
if (scancode & 0x80) {
// the key is released
} else {
putch(keymap[scancode]);
}
I also suggest you search in previous post, there was some explaination of how to handle extended scancodes (grey keys) like print screen, pause, num lock, etc. which have a 0xe0 prefix (if i remember well
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 7:03 am
by Whatever5k
Code: Select all
char *keymap[] = {NULL, '1', ...};
This is wrong, of course. I do not know which devil drove me there
This here should work:
Code: Select all
char keymap[][2]={
{NULL, NULL},
{ESC, NULL},
{'1', '!'},
.
.
};
This array holds the value for the non-shifted and the shifted scancodes...
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 7:14 am
by Tom
;D Ok, Got my scancode to work, ( all the stuff you posted didn't help )
Now, all I have to do is work on the shifted keys, and release the code.
To all the people who want the code, it should be in
./include/keys.h
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 8:03 am
by Pype.Clicker
and what was wrong, finally ??
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 2:53 pm
by Tom
I had to make it a static const unsigned char
Re:Keyboard input...How do I get keys?
Posted: Thu Oct 10, 2002 8:56 pm
by Tom
now, how do I do shift?
I have all the keys for non-shifted and shifted defined, now just need to know how to detect a shift key is pressed when a letter or num is pressed.
How?
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 12:20 am
by Whatever5k
I cannot find your include/keys.h. Where is it?
Answer to your question:
Check if the key press is the SHIFT key:
Code: Select all
void kbd_handler(void)
{
int scan = scan_keyboard();
int key;
static int shift = 0;
if (scan == LSHIFT || scan == RSHIFT)
{
shift = 1;
return;
}
if (shift)
key = keymap[scan][1];
else
key = keymap[scan][0];
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 1:12 am
by Pype.Clicker
oooh ... right . sorry, i didn't see you had a char* [] ... i thought it was a char []
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 5:15 am
by Tom
I didn't release pk0.7 yet, that's why you can't fine the keys file
I'll try the code, if it works i'lll release pk0.7
Thank you,
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 6:48 am
by Tom
didn't work, abless.
Anyone else have code?
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 7:05 am
by Tom
DUH forgot to use inportb :-[
trying abless's code now
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 7:24 am
by Whatever5k
[attachment deleted by admin]
Re:Keyboard input...How do I get keys?
Posted: Fri Oct 11, 2002 7:25 am
by Whatever5k
[attachment deleted by admin]