Bran's kernel keyboard
Bran's kernel keyboard
hi guys...
I,ve been trying to write a "getch()" to Bran's kernel tutorial but
when i print out this char using the "putch(char c)"
it is printed on the whole screen with out stop could you tell me how can i write this function?
I,ve been trying to write a "getch()" to Bran's kernel tutorial but
when i print out this char using the "putch(char c)"
it is printed on the whole screen with out stop could you tell me how can i write this function?
Re:Bran's kernel keyboard
well the way i did it, you have an array with is your key buffer, now every time you get a key () put the ascii key in the table, but you need to know were in the table, so make a variable (top) and do this and remeber to move up top every key so you dont write over other keys in the table, now if the table fills up reset top to zero. now you may be thinking what happens when top starts over it will overwrite keys, so make a new variable (bottom) to keep track of the start of the key string and dont do anything. now to get the keys out just read from put it all together you get:
Code: Select all
#define STDINSZ 1024
unsigned char currentStdin[STDINSZ];
Code: Select all
void keyboard_handler(struct regs *r)
Code: Select all
currentStdin[top] = key;
Code: Select all
top++;
Code: Select all
if(top > STDINSZ)
Code: Select all
if((Top + 1) == Bottom)
Code: Select all
currentTop[bottom]
Re:Bran's kernel keyboard
my code:
unsigned char getch()
{
unsigned char scancode='\0';
while(scancode=='\0')
{
scancode = inportb(0x60);
}
return kbdus[scancode];
}
and now :
unsigned char c=getch();
putch(c);
where is my wrong
unsigned char getch()
{
unsigned char scancode='\0';
while(scancode=='\0')
{
scancode = inportb(0x60);
}
return kbdus[scancode];
}
and now :
unsigned char c=getch();
putch(c);
where is my wrong
Re:Bran's kernel keyboard
okay guys...
let us keep it simple...
i need your feedback...
where are you?
let us keep it simple...
i need your feedback...
where are you?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Bran's kernel keyboard
out for lunch ... sleeping ... at work ... who knows.abuashraf wrote: okay guys...
let us keep it simple...
i need your feedback...
where are you?
btw, i'm not much surprised to see your character being painted all over the screen. I/O port 0x60 is a "whiteboard" between you and the keyboard controller. When you read it, you do not remove what was there previously, so if you poll it continuously, you'll get the same value continuously. And no, reading it doesn't turn it back to 0.
Moreover, you should make the distinction between "keypress" and "keybreak" codes you find there.
What you need to do here is to use an interrupt handler. Whenever something new has been placed on the "whiteboard", the keyboard controller rises an interrupt. Just watch that and only read the I/O port after you received an interrupt.
That and more in the FAQ.
Re:Bran's kernel keyboard
If you need timely response of a specified level and with a minimum of help, you should consider hiring somebody to help you. It's expensive.abuashraf wrote: okay guys...
let us keep it simple...
i need your feedback...
where are you?
We're in no way obliged to even read what you type, let alone answer your question. Realise that everybody here is doing this in their free time. You don't tell anybody what to do with their free time.
Re:Bran's kernel keyboard
thanx for your reply!!!
but... you did not help me
give me some code...
but... you did not help me
give me some code...
Re:Bran's kernel keyboard
If you are going to succeed at OS dev you need to be competent enough to be able take the pointers and advice given here and work with them, code isn't going to be delivered to you pre-written.
Re:Bran's kernel keyboard
hello
I worte the "getch()" function and my problem is:
when i call this function for the first time it works normally,but
when i call it agin it prints the previous char without any
input from me so...
first time i call getch(),i press some key it prints the asciikey
second time call getch(),prints the previous asciikey without
any input from me!!!
you get it?
please note:
I installed the keyboard handler into IRQ1
thanx
I worte the "getch()" function and my problem is:
when i call this function for the first time it works normally,but
when i call it agin it prints the previous char without any
input from me so...
first time i call getch(),i press some key it prints the asciikey
second time call getch(),prints the previous asciikey without
any input from me!!!
you get it?
Code: Select all
void getch()
{
unsigned char c='\0';
while(c=='\0'){
c=inportb(0x60);
}
switch(c)
{
case 0x1e:{putch('a');break;}
case 0x30:{putch('b');break;}
.
.
.
.
case 0x2c:{putch('z');break;}
}
}
I installed the keyboard handler into IRQ1
thanx
Re:Bran's kernel keyboard
Did you clear the keyboard buffer?
Re:Bran's kernel keyboard
omg
but on topic
iirc the keyboard keeps the keypressed in the port so that you can read it more than once hence why you have to use interrupts so try using ints
lol closely resembles "gimme teh codez!!11" lolgive me some code...
but on topic
iirc the keyboard keeps the keypressed in the port so that you can read it more than once hence why you have to use interrupts so try using ints
Re:Bran's kernel keyboard
instead of peeking at the keyboard buffer, read the keyboard buffer.abuashraf wrote: No i didn't clear the keyboard buffer.
how can i do that?
Short answer: RTFM.