keyboard

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

keyboard

Post by Woellchen »

hi

i have a little problem
i coded a very short keyboard handler and set it to irq1

Code: Select all

void keyboard_handler(struct regs *r)
{
    scancode = inportb(0x60);
    if (scancode & 0x80)
    {
    }
    else
    {
        last_key = kbdus[scancode];
        //putch(last_key);
    }
}
but i am not sure how to deliver the chars
so my question: how to?
my idea was to set a program as "active window" and the handler sends it there
but theres my problem: i dont know how to do so
anyone who could help me with that?
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

what do you mean by "deliver the chars"? if you mean writing the characters to the screen, you must write a video driver/handler, but it looks like you might already have that since you have a commented-out putch function.
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

yea, i already wrote a function to print text on screen
but my problem is that i want to send the chars to the program (maybe with an api?)
i dont know how to do so
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

hmm, I'd suggest giving each 'program' it's own personal char buffer, or begin implementing Inter-Process Communication (IPC) handling.
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

and how could an ipc handler look like?
or could you give me a tutorial which shows how to work with them?
i dont know sorry
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Woellchen wrote:i dont know sorry
I think your knowledge is so limited, you have no chance to succeed making anything even close to an OS. Please do yourself a favour and start with echoing a character to the screen for example, before you start thinking about processes and APIs and the like...


JAL
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

now i think you dont know about me..

i wrote my own bootloader, my own kernel, my own print function(so yes, i already can print a character on the screen (with scroll functions btw..)), i wrote my own irq routines and i wrote a little keyboard handler(with a little shell btw)
in fact i dont think "i have no chance to succeed making anything even close to an OS" because i have already done so

i just asked how to get the pressed buttons to the right "task"
and i think i will do it like 01000101's suggestion by giving each "task" an own char buffer

anyway i thank you
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Woellchen wrote:now i think you dont know about me..

i wrote my own bootloader, my own kernel, my own print function(so yes, i already can print a character on the screen (with scroll functions btw..)), i wrote my own irq routines and i wrote a little keyboard handler(with a little shell btw)
in fact i dont think "i have no chance to succeed making anything even close to an OS" because i have already done so

i just asked how to get the pressed buttons to the right "task"
and i think i will do it like 01000101's suggestion by giving each "task" an own char buffer

anyway i thank you
Before you can dispatch to "tasks" you have to implement "inter process communication". And to implement "inter process communication" you have to implement "multitasking". And to implement "multitasking" you have to implement "memory management"...

And don't flame back, because both myself and jal could cook up exactly what you have in less than a day.

Cheers,

James
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

i dont wanted to look it like a flame sorry

and yes the description "task" is wrong, i just wanted to make it as clear as possible
for tasks its still a long way for me but im already lucky with what i have got :wink:
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Woellchen wrote:i just asked how to get the pressed buttons to the right "task" and i think i will do it like 01000101's suggestion by giving each "task" an own char buffer
And now the $100,000 question: where are you going to put that buffer? And who is going to manage it? How does the application extract key presses from it? Thought about locking access to it? Concurrency problems?


JAL
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

maybe not really a buffer..

my idea was to save the last key by the handler(which is already done) and writing an additional function like get_key()
it returns then the last key and sets the last key to false or something else
in a while loop in the shell script i will write something like this:

Code: Select all

if( get_key() )
{
   //do something (for example print to screen)
}
or is it that wrong?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Woellchen wrote:maybe not really a buffer..

my idea was to save the last key by the handler(which is already done) and writing an additional function like get_key()
it returns then the last key and sets the last key to false or something else
in a while loop in the shell script i will write something like this:

Code: Select all

if( get_key() )
{
   //do something (for example print to screen)
}
or is it that wrong?
But that's not reentrant. How does it tie in with your multitasking ideas?
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

ok sorry maybe i am confusing you so forget the multitasking
my idea is to set the active window as active_window or so
and the get_key function would check this or something like this to not give inactive windows the key->only the active window can get the keys
do u understand now?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Woellchen wrote:ok sorry maybe i am confusing you so forget the multitasking
my idea is to set the active window as active_window or so
and the get_key function would check this or something like this to not give inactive windows the key->only the active window can get the keys
do u understand now?
Yes I understand - it sounds like an adequate solution - doesn't seem particularly extensible or scaleable but if that's what you want...
User avatar
Woellchen
Posts: 19
Joined: Sat Apr 26, 2008 1:19 pm

Post by Woellchen »

hmm.. is it really that bad? :?
how could i do it better then?
i just need some hints on how to make it as good as possible

edit: ok this post wasnt nesessary..
i got some inspirations from the kernel u have linked in your signature
i think i know enough now so thank you all
Post Reply