Click here to Skip to main content
15,914,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
simon wan17-Jun-05 14:44
simon wan17-Jun-05 14:44 
AnswerRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
David Crow17-Jun-05 3:31
David Crow17-Jun-05 3:31 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
BlackDice17-Jun-05 4:54
BlackDice17-Jun-05 4:54 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
David Crow17-Jun-05 5:14
David Crow17-Jun-05 5:14 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
BlackDice17-Jun-05 5:20
BlackDice17-Jun-05 5:20 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
David Crow17-Jun-05 5:24
David Crow17-Jun-05 5:24 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
BlackDice17-Jun-05 5:32
BlackDice17-Jun-05 5:32 
GeneralRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
Toby Opferman23-Jun-05 10:44
Toby Opferman23-Jun-05 10:44 
Uniprocessor really has nothing to do with it. Yes, the message is sent one at a time to an application, but the same happens if it's multi-processor. The message the window gets is serialized because the message queue and a single threaded window proc make it that way.


The keyboard interrupt is free to generate another scan code/send the next byte when the the interrupt handler sends the EOI (End Of Interrupt) control. This happens almost immediately after you've read the key scan code from the port.

Then the key is put into the keyboard buffer and sent off to generate the message. While that is going on, the keyboard is still a hardware device that can interrupt a thread's processing (just like anything else) based on it's current IRQL. So, even on a single processor, the next key press could be retrieved and processed all before the application ever gets dispatched the first key.

The only thing the multi-processor could do is if the first processor got caught on a disk I/O and is at high IRQL, the other processor could handle the next keyboard interrupt at the same time.

However, after the Disk I/O was done the keyboard would have gone and done it's turn before the thread was allowed to reschedule to a lower IRQL anyway. The other funny thing is that actually one processor could be delievering the current key while the other one is processing the next, so it actually could make the situation worse since if it was single processor the hardware interrupt would definately interrupt the keystroke delivery while processing the other key. This is a minor detail though, processing a scan code is farily quick.

Pressing multiple keys the keyboard ends up continously generating one of the keys usually, the last one pressed. So a series of keystrokes could be:

(Make Code) UP (Make Code) DOWN (Make Code) DOWN (Make Code) DOWN (Break Code) UP (Break Code) DOWN

So, even though both keys are pressed the second action is continous so depending on how the application handles this it could move the cursor up then continously down because the application doesn't track the UP key's state. The UP key never provided a break code (key unpress) yet.

So, it depends on how the application tracks the keyboard state. There are also special keys, I don't remember if the keyboard itself handles these or it if was solely a process done by the BIOS, but as you know certain keys maintain a "shift" type state, such as Alt, Control and Shift.

It's been a while since I wrote a keyboard filter driver though or messed with the keyboard locations in bios.



8bc7c0ec02c0e404c0cc0680f7018827ebee
AnswerRe: How to respond VK_LEFT and VK_DOWN at the same time? Pin
Bob Stanneveld17-Jun-05 3:38
Bob Stanneveld17-Jun-05 3:38 
GeneralMapping a network drive programmatically Pin
Still learning how to code17-Jun-05 2:15
Still learning how to code17-Jun-05 2:15 
GeneralRe: Mapping a network drive programmatically Pin
David Crow17-Jun-05 2:22
David Crow17-Jun-05 2:22 
GeneralNon MFC X-Y Plots Pin
jerry1211a17-Jun-05 1:59
jerry1211a17-Jun-05 1:59 
GeneralRe: Non MFC X-Y Plots Pin
toxcct17-Jun-05 2:01
toxcct17-Jun-05 2:01 
GeneralRe: Non MFC X-Y Plots Pin
Ravi Bhavnani17-Jun-05 4:50
professionalRavi Bhavnani17-Jun-05 4:50 
QuestionHow to call VB DLL in C code ( VC environment) Pin
Tuscon17-Jun-05 1:04
Tuscon17-Jun-05 1:04 
AnswerRe: How to call VB DLL in C code ( VC environment) Pin
David Crow17-Jun-05 2:23
David Crow17-Jun-05 2:23 
AnswerRe: How to call VB DLL in C code ( VC environment) Pin
Mike Dimmick17-Jun-05 2:28
Mike Dimmick17-Jun-05 2:28 
GeneralShared data problem, use of #pragma data_seg() Pin
Vaibhav Sanghavi17-Jun-05 0:55
Vaibhav Sanghavi17-Jun-05 0:55 
GeneralRe: Shared data problem, use of #pragma data_seg() Pin
Blake Miller17-Jun-05 6:53
Blake Miller17-Jun-05 6:53 
GeneralRe: Shared data problem, use of #pragma data_seg() Pin
Vaibhav Sanghavi20-Jun-05 2:27
Vaibhav Sanghavi20-Jun-05 2:27 
GeneralC++ file I/O Pin
Hachaso17-Jun-05 0:49
Hachaso17-Jun-05 0:49 
GeneralRe: C++ file I/O Pin
toxcct17-Jun-05 0:59
toxcct17-Jun-05 0:59 
GeneralRe: C++ file I/O Pin
xiaohe52117-Jun-05 1:14
xiaohe52117-Jun-05 1:14 
GeneralRe: C++ file I/O Pin
toxcct17-Jun-05 1:24
toxcct17-Jun-05 1:24 
GeneralRe: C++ file I/O Pin
Bob Stanneveld17-Jun-05 1:44
Bob Stanneveld17-Jun-05 1:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.