Page 1 of 1
Half of keyboard not inputing to 0x60
Posted: Sun Aug 15, 2010 10:42 pm
by tech2077
I had gone through the barebones tutorial, and implemented a printk for debugging, so i moved on to very basic input, attempting to map out to keyboard and get input, but when I would load up my image in qemu, keys q to ] and 'a' 's' along with a few other no printing chararacters would not show up, even though i had it outputting raw hex to the screen, this is the source i'm using for the reading from the keyboard, and i have tested the d_printf enough to know it isn't it, and have tried two virtual machines.
Code: Select all
for(;;)
{
outb(0x20, 0x20);
char c = inb(0x60);
if((!(c&80)))
d_printf("%x", c);
}
Re: Half of keyboard not inputing to 0x60
Posted: Sun Aug 15, 2010 11:23 pm
by Brendan
Hi,
The keyboard gives you "scancodes", which are not ASCII.
You need to convert the scancodes into ASCII. This is typically done with a set of lookup tables - one normal lookup table, one for when a shift key is held down, one for when capslock is active, etc).
Cheers,
Brendan
Re: Half of keyboard not inputing to 0x60
Posted: Sun Aug 15, 2010 11:25 pm
by tech2077
Brendan wrote:Hi,
The keyboard gives you "scancodes", which are not ASCII.
You need to convert the scancodes into ASCII. This is typically done with a set of lookup tables - one normal lookup table, one for when a shift key is held down, one for when capslock is active, etc).
Cheers,
Brendan
Yes, this was for debugging, as you could see, if i was to press a key, it should print out a long repeat of the hex scancode for the key, but for those fey keys it doesn't, and i have tried on 2 vms, and will soon try on another computer, is there any other method, similarly easy, to get input from the keyboard?
edit: it also doesn't work on the other computer i have tried it on.
Re: Half of keyboard not inputing to 0x60
Posted: Sun Aug 15, 2010 11:37 pm
by Brendan
Hi,
tech2077 wrote:Yes, this was for debugging, as you could see, if i was to press a key, it should print out a long repeat of the hex scancode for the key, but for those fey keys it doesn't, and i have tried on 2 vms, and will soon try on another computer, is there any other method, similarly easy, to get input from the keyboard?
edit: it also doesn't work on the other computer i have tried it on.
Doh - sorry. I thought you meant it worked for printing in hex but not when printing as characters. The only thing I can think of that might cause the problem is a broken "d_printf()".
For "similarly easy" you could try playing Quake instead. If you want to do something that's actually useful, start by forgetting about "easy"...
Cheers,
Brendan
Re: Half of keyboard not inputing to 0x60
Posted: Sun Aug 15, 2010 11:40 pm
by tech2077
Brendan wrote:Hi,
tech2077 wrote:Yes, this was for debugging, as you could see, if i was to press a key, it should print out a long repeat of the hex scancode for the key, but for those fey keys it doesn't, and i have tried on 2 vms, and will soon try on another computer, is there any other method, similarly easy, to get input from the keyboard?
edit: it also doesn't work on the other computer i have tried it on.
Doh - sorry. I thought you meant it worked for printing in hex but not when printing as characters. The only thing I can think of that might cause the problem is a broken "d_printf()".
For "similarly easy" you could try playing Quake instead. If you want to do something that's actually useful, start by forgetting about "easy"...
Cheers,
Brendan
Ok, i'll try dirrectly writting to vid memory without the bypass, and i never liked Quake , guess i'll just forget about easy
, this is, as you can see, my first attempt into OS dev after a long will used to C api's and asm ontop of the kernel.
Thanks for the help anyway.
I just wrote a program to test if my keyboard has a standard setup for key scancodes, and it came back perfect, so now i have no idea whats going on, i may just boot to a cd now to test if it's the vm's fault.
Re: Half of keyboard not inputing to 0x60
Posted: Mon Aug 16, 2010 1:52 am
by gerryg400
The problem is that you're typoed 80 instead of 0x80. Because 80 is 0x50 you are ignoring any key with bit 4 set in its scan code. That includes all the keys that start with 0x1_ (q->],a,s) etc.
Re: Half of keyboard not inputing to 0x60
Posted: Mon Aug 16, 2010 7:19 am
by tech2077
gerryg400 wrote:The problem is that you're typoed 80 instead of 0x80. Because 80 is 0x50 you are ignoring any key with bit 4 set in its scan code. That includes all the keys that start with 0x1_ (q->],a,s) etc.
Wow, thank you, i completely forgot to declare it as hex.
Re: Half of keyboard not inputing to 0x60
Posted: Mon Aug 16, 2010 1:35 pm
by Candy
tech2077 wrote:gerryg400 wrote:The problem is that you're typoed 80 instead of 0x80. Because 80 is 0x50 you are ignoring any key with bit 4 set in its scan code. That includes all the keys that start with 0x1_ (q->],a,s) etc.
Wow, thank you, i completely forgot to declare it as hex.
Try putting stuff in an if in only one pair of brackets:
instead of
If you make an accidental assignment in the first, GCC will warn you. In the second, it won't.