OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:36 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re:Keyboard
PostPosted: Fri Sep 03, 2004 8:48 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
what i guess would happen is that your keyboard driver still fills one queue. By some technique (f.i. capturing scancodes before they enter the queue or filtering the queue), the console manager catches combos like CTRL+Fx and switch both display and "current queue" to a given console.

So each process running on a console is bound to an input queue and the console manager decides toward which one characters should be forwarded.

Now when you send a job in the background (? la unix '&'), it actually 'loses' the console's queue and instead receives an always-empty queue ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Sun Sep 05, 2004 11:43 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
So is this a genera; idea of the sequence of events?
Quote:
Keyboard Press(8042) ==> Scancode ==> Keyboard Driver ==> Keyboard Buffer ==> Console Manager ==> Active Process/Console Queue ==> Interpret in any desired way.
Is this right?

How are the input queues identified by the 'console manager'? and isn't each console a separate process?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Sun Sep 05, 2004 11:59 am 
Neo wrote:
How are the input queues identified by the 'console manager'? and isn't each console a separate process?


Not necessarily. Under my own OS, a single process can open multiple consoles. I believe you can do this under Linux, too. Each console is a seperate "file" (device/whatever). Only one has "focus" at any given time, and console events (keyboard/mouse/whatever) get sent to the "focused" console.

This is not terribly different from having multiple TCP/IP connections open -- when data comes in, it just gets stuffed into the appropriate "file" (connection/socket/whatever), save that in this case it's a lot easier to decide which bucket to stuff the bits into, since only one console ever has focus at a given time.

(In my own OS, this analogy is more like a reality, as my console manager rides on top of my TCP/IP implementation, and communicates with applications using RFB protocol.)


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Thu Sep 09, 2004 11:14 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
I'm getting a scancode of 0x81 on releasing (only breakcode presumably no make and repeat codes) the "PrtScr" key, and the "Pause Break" key gives me only a makecode of "0xE0 0x45 0xE0 0xC5" all the other keys give me the correct set1 scancodes, in all 3 scancode sets I can't see these 2 sequences occuring for the given keys. Does anyone know how this is happening?
BTW this happens only in BOCHS.
Also does anyone know what the "keyboard internal numlock" refers to.

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Thu Sep 09, 2004 5:22 pm 
Neo wrote:
...the "Pause Break" key gives me only a makecode of "0xE0 0x45 0xE0 0xC5"...


Take a look at that more carefully -- that's a make code (E0 45) and a break code (E0 C5) for Num Lock.

Quote:
Does anyone know how this is happening?


There are numerous keys on extended keyboards that simulate what were multi-keystroke sequences on basic keyboards (which, among other things, don't have Print Screen keys, it's a modified key from the numeric keypad).

Quote:
Also does anyone know what the "keyboard internal numlock" refers to.


The state within the keyboard that determines what sequence of keystrokes it will simulate when keys like Home (which is keypad '7' on a basic keyboard) are pressed.

Consider: you have numlock on, and you press the Home key. Since home is keypad 7 with the numlock off, the keyboard must send a sequence to toggle off the numlock, send the 7, then toggle on the numlock again. If your numlock was already off, it obviously does NOT want to send those extra numlock toggle sequences. Therefore, the keyboard needs to internally track the state of numlock if it's going to send sensible scancodes.

You were under the misimpression that each key on the keyboard had it's own scancode, weren't you? Bwahahahaha! Welcome to the hell that is the reality of keyboards, where backwards compatibility to the first IBM PC ensures a single keypress can result in a positive flurry of simulated keystrokes. The codes are generated in a way that allows modern programs to distinguish what's really going on, but original IBM PC programs get what they expect.


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Fri Sep 10, 2004 4:57 am 
Can you add a character to a string so the keyboard code returns this to the main function?


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Fri Sep 10, 2004 6:05 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
iirc, the 'pause' key is a bit special due to the use it had in the past. Among other things, (iirc), it doesn't generate any scan code when released ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Fri Sep 10, 2004 2:02 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Dreamsmith wrote:
Take a look at that more carefully -- that's a make code (E0 45) and a break code (E0 C5) for Num Lock.

No thats the makecode i get from the Pause Break Key in BOCHS. on my real PC everything seems normal (if you can call those scancdodes normal ;) )

Quote:
The state within the keyboard that determines what sequence of keystrokes it will simulate when keys like Home (which is keypad '7' on a basic keyboard) are pressed.

Consider: you have numlock on, and you press the Home key. Since home is keypad 7 with the numlock off, the keyboard must send a sequence to toggle off the numlock, send the 7, then toggle on the numlock again. If your numlock was already off, it obviously does NOT want to send those extra numlock toggle sequences. Therefore, the keyboard needs to internally track the state of numlock if it's going to send sensible scancodes.

hmm... that resolves some doubts at least.

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Sat Sep 11, 2004 11:35 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Stephen wrote:
Can you add a character to a string so the keyboard code returns this to the main function?

I don't if its what you want to do, but you couldn append the characters into a string buffer (or char array)?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Tue Sep 14, 2004 2:01 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
How do the SHIFT, ALT and CTRL keys affect the keypress data in most OSes. When using any app such as Windows Notepad (just an example) when we press the ALT+F keys or CTRL+F+S keys the app realises this as a unique code (for the file menu). how?
I mean what does the OS send to the app does it just send 2 scancodes as usual that the app interprets or does it send some unique code to indicate that the 'F' is pressed along with a 'special' key.
.....well I am confused :(

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Tue Sep 14, 2004 4:59 pm 
Neo wrote:
How do the SHIFT, ALT and CTRL keys affect the keypress data in most OSes. When using any app such as Windows Notepad (just an example) when we press the ALT+F keys or CTRL+F+S keys the app realises this as a unique code (for the file menu). how?
I mean what does the OS send to the app does it just send 2 scancodes as usual that the app interprets or does it send some unique code to indicate that the 'F' is pressed along with a 'special' key.
.....well I am confused :(


Under Windows, the answer to your question is, "Yes."

Windows apps receive WM_KEYUP and WM_KEYDOWN messages, which are pretty much raw keycodes, as well as WM_CHAR messages, that are more processed codes, more akin to what you would expect from getchar(). Of course, if you're talking about the menu bar shortcuts, that might be coming in the WM_SYSKEYUP, WM_SYSKEYDOWN, or WM_SYSCHAR messages instead.

Not that this really helps you any. If you think you're confused now, learning how Windows processes keyboard input is only going to make it worse.

All this is irrelevant anyhow, isn't it? Shouldn't you be asking, "How do I want to handle it? What do I want to send to apps?"


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Wed Sep 15, 2004 4:49 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
if i wanted to include support for windows apps, then wouldn't it be good idea to handle them that way? :-\

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Thu Sep 16, 2004 11:55 pm 
Neo wrote:
if i wanted to include support for windows apps, then wouldn't it be good idea to handle them that way? :-\


That depends entirely on what strategy you're going to use to run them. In general, though, the answer would probably be "no". If you start answering "yes" to too many questions like this, there will be no reason for your OS to exist -- you will have simply reimplemented Windows, at which point, you might as well drop it and just run Windows...

If you aren't reimplementing Windows, but actually working on your own OS, you're strategy for supporting Windows apps (good fricking luck, BTW) will be doing something like WINE, which might even be a user-space application. In any case, it's not really an OS issue how you handle things at that point. No matter what you do, you'll have to stick some sort of compatibility layer between your OS and the Windows app, and if you're doing to do that, then you can do whatever you want in your OS without regards to Windows compatibility, as that job will be handled in another layer.

So, yeah, really, no matter how you slice it, the answer to your question would be "No".


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Google [Bot] and 75 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group