[CLOSED] Keyboard commandline
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
[CLOSED] Keyboard commandline
Hi
I'm trying to write a keyboard commandline but it just won't work my idea is:
save a scancode in char
check if a new key is pressed(or the same key is pressed again)
if so i++, save the new scancode
else check again.
check if the scan code is enter if so break and return the string
How do i check if a new key(or the same key is pressed again) is pressed.
Or does someone have a sample function that a could look at? Or could someone be so kind to code a quick sample?:)
Thanks
I'm trying to write a keyboard commandline but it just won't work my idea is:
save a scancode in char
check if a new key is pressed(or the same key is pressed again)
if so i++, save the new scancode
else check again.
check if the scan code is enter if so break and return the string
How do i check if a new key(or the same key is pressed again) is pressed.
Or does someone have a sample function that a could look at? Or could someone be so kind to code a quick sample?:)
Thanks
Last edited by LegendDairy on Fri Nov 12, 2010 10:55 am, edited 1 time in total.
Re: Keyboard commandline
I'm not sure where you're having a problem. Wouldn't this just be a 'while (1)' loop with a 'break;' if the key '==' the 'Enter' key ?Legendmythe wrote:Hi
I'm trying to write a keyboard commandline but it just won't work my idea is:
save a scancode in char
check if a new key is pressed(or the same key is pressed again)
if so i++, save the new scancode
else check again.
check if the scan code is enter if so break and return the string
How do i check if a new key(or the same key is pressed again) is pressed.
Or does someone have a sample function that a could look at? Or could someone be so kind to code a quick sample?:)
Thanks
If a trainstation is where trains stop, what is a workstation ?
Re: Keyboard commandline
A lack of required knowlegde, perhaps?gerryg400 wrote:I'm not sure where you're having a problem.
JAL
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: Keyboard commandline
I know this is off-topic but I can't continue with this topic unless this gets fixed.
I was working on my Keyboard driver and when I tried to link it I get this "kb.c:(.text+0x5f): undefined reference to `__stack_chk_fail'
" I've have that nowhere in my code?Can some help me?
Anyway here's the handler
I was working on my Keyboard driver and when I tried to link it I get this "kb.c:(.text+0x5f): undefined reference to `__stack_chk_fail'
" I've have that nowhere in my code?Can some help me?
Anyway here's the handler
Code: Select all
void keyboard_handler(struct regs *r)
{
unsigned char scancode;
unsigned int i;
unsigned char string[60];
for(i=0;i<59;i++)
{
scancode=inportb(0x60);
if((kbdus[scancode])=1) {//enter='1'
break;
} else if (i<59) {
string[i]=(kbdus[scancode]);
}
}
puts(string);//test it
}
Re: Keyboard commandline
You're using c not pascal. Use to compare.
With regards the other problem, google will help. It's a very common problem solved with a gcc option. Can't remember the exact syntax.
Code: Select all
==
With regards the other problem, google will help. It's a very common problem solved with a gcc option. Can't remember the exact syntax.
If a trainstation is where trains stop, what is a workstation ?
Re: Keyboard commandline
Again, you demonstrate a total lack of required knowledge, and not knowing your tools.Legendmythe wrote: I was working on my Keyboard driver and when I tried to link it I get this "kb.c:(.text+0x5f): undefined reference to `__stack_chk_fail'
" I've have that nowhere in my code?Can some help me?
JAL
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: Keyboard commandline
Thanks but as I thought I need a code to check if a key is pressed again because now it just keep using the old scancode so when i type "9" he types "999999999999999999999999999999999" then I he enter he types "111111111111111111"gerryg400 wrote:You're using c not pascal. Useto compare.Code: Select all
==
With regards the other problem, google will help. It's a very common problem solved with a gcc option. Can't remember the exact syntax.
Btw I had to add "-fno-stack-protector" but it's weird I never had to do that before even on the same code.
Perhaps that is why I asked it?A lack of required knowlegde, perhaps?
BTW No one can know every possible error code and what to do. Also the first time you quoted the wrong post. And last but not least it is "Knowledge" and not "Knowlegde".
Last edited by LegendDairy on Thu Nov 11, 2010 7:57 am, edited 1 time in total.
Re: Keyboard commandline
The thing is, you are supposed to have looked for the information yourself first, and not ask questions that indicate that you're in no way up to making an OS. Unfortunately for you, all your posts on this board indicate that you are just a beginning programmer, with little to no knowledge on, well, anything OS related.Legendmythe wrote:Perhaps that is why I asked it?A lack of required knowlegde, perhaps?
No indeed it isn't, you don't seem to have any of the required skills.BTW It is just "not knowing your tools".
JAL
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: Keyboard commandline
I was searching here for the last bits of information here that I couldn't find anywhere else, so do you want to help me or notThe thing is, you are supposed to have looked for the information yourself first, and not ask questions that indicate that you're in no way up to making an OS. Unfortunately for you, all your posts on this board indicate that you are just a beginning programmer, with little to no knowledge on, well, anything OS related.
No indeed it isn't, you don't seem to have any of the required skills.BTW It is just "not knowing your tools".
JAL
-if so here's my question:
how should I check if a key is pressed again and it isn't just the scancode from the last time.
-if not:
I'd rather like it if you just wouldn't comment, because the reason of a help forum is to help fill that "lack of knowledge", some of them are quit easy to fill others (like mine) take patient or else just ignore them and saying "This shows a lack of knowledge" won't help anyone.
-
- Member
- Posts: 68
- Joined: Thu May 28, 2009 11:46 pm
Re: Keyboard commandline
You don't understand how interrupts work.
The function:
void keyboard_handler(struct regs *r)
is not your string input function. This function (if set up properly) should be launched every time you press a key, like an event.
Here is an idea how this might work:
Global variables: (don't forget volatile keyword) NewInterruptFired, ScanCode
String input function: set NewInterruptFired variable to 0
Wait until its value is changes.
Parse scancode
If it is a character, add it to your string
Keyboard Handler:
Set NewInterruptFired=1
Read from port 0x60, put in ScanCode variable
Tell PIC you are done
Again, don't forget 'volatile', otherwise the compiler will think you want to do an infinite loop, and replace it with while(1)
The function:
void keyboard_handler(struct regs *r)
is not your string input function. This function (if set up properly) should be launched every time you press a key, like an event.
Here is an idea how this might work:
Global variables: (don't forget volatile keyword) NewInterruptFired, ScanCode
String input function: set NewInterruptFired variable to 0
Wait until its value is changes.
Parse scancode
If it is a character, add it to your string
Keyboard Handler:
Set NewInterruptFired=1
Read from port 0x60, put in ScanCode variable
Tell PIC you are done
Again, don't forget 'volatile', otherwise the compiler will think you want to do an infinite loop, and replace it with while(1)
Last edited by chibicitiberiu on Thu Nov 11, 2010 11:00 am, edited 1 time in total.
Tibi,
Currently working on the Lux Operating System
Currently working on the Lux Operating System
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: Keyboard commandline
It worked, ty for the help evryone
Re: Keyboard commandline
As long as you haven't received a break, the key hasn't been released yet, right?Legendmythe wrote:I was searching here for the last bits of information here that I couldn't find anywhere else, so do you want to help me or not
-if so here's my question: how should I check if a key is pressed again and it isn't just the scancode from the last time.
Yes, but this forum is not for spoon-feeding newbies that do not have the required skills. We aren't teachers!I'd rather like it if you just wouldn't comment, because the reason of a help forum is to help fill that "lack of knowledge"
JAL
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Keyboard commandline
It's not the complete truth: The required knowledge exists to protect newbies from themselves, and to protect us from slipping standards. The required knowledge is not completely about things you must know, it represents a set of skills and abilities you need to have to have a chance of success in OS development (where success does not involve copy and paste)jal wrote:this forum is not for spoon-feeding newbies that do not have the required skills. We aren't teachers!
A forum can not fill a lack of skill, effort or intelligence. Any knowledge you seek is useless without it as it can not be applied later. And apparently you lack the skill (not finding the = vs == error), the effort (no visible attempt to debug), so what's helping you to just give you the answer? You'd bug us with an incomprehensible bug in the next 10 lines of code you'll write(?).Legendmythe wrote:the reason of a help forum is to help fill that "lack of knowledge"
Your C and problem solving skills are below par, practice them. You really do not want to annoy us into being hostile (you succeeded doing that with at least one person already).
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: Keyboard commandline
The "=" wasn't an error it was just a quick code that a made and I couldn't test it. Of course I know the differnce between "=" and "==" I'm not that retarded.-_-' And sorry I wasted your "precious" time but ofcours ty to that one guy that help who didn't had to make 10 000 comment on how stupid I am and just made 1 post and solved the code and he didn't gave a code he explained how to code it.
Now let's close this topic so no1 will get annoyed anymore (this topic was solved 4 post ago -_-')
Now let's close this topic so no1 will get annoyed anymore (this topic was solved 4 post ago -_-')
Re: Keyboard commandline
It was an error. If you honestly intended to perform an assignment inside that if statement, there was no comment to suggest such to the reviewer. So this in itself is a bug.Legendmythe wrote:The "=" wasn't an error it was just a quick code that a made and I couldn't test it. Of course I know the differnce between "=" and "==" I'm not that retarded.-_-' And sorry I wasted your "precious" time but ofcours ty to that one guy that help who didn't had to make 10 000 comment on how stupid I am and just made 1 post and solved the code and he didn't gave a code he explained how to code it.
Now let's close this topic so no1 will get annoyed anymore (this topic was solved 4 post ago -_-')
As to your questions - have you read the wiki page on the keyboard controller? bit 0 of inb(0x64) will be 1 when there is data available.