CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to determine if TWO keys are hit at the same time

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MikeV



Joined: 20 Feb 2004
Posts: 4

View user's profile Send private message

How to determine if TWO keys are hit at the same time
PostPosted: Mon Feb 23, 2004 10:03 am     Reply with quote

using kbhit() and getc(), I have no problems if one key is hit.

How can I determine if TWO keys are hit at the same time? Do I simply need to do two kbhit() instructions back to back with no delay?

-Mike
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 23, 2004 10:23 am     Reply with quote

Um, not sure what you are doing here but the kbhit() and getc() work with the UART on the PIC.

The sending UART is going to serialize your data for you. If you are receiving data from a PC and somebody with very good reflexes presses the "A" and "S" keys at the same time, the PC will follow its own rules for sending you either "AS", "SA" or just "A" or just "S".

And if you are looking for the ability to receive Alt-A or Ctrl-S, again it will depend on how your sending software works but probably you will get two key codes, one for "Alt" followed by "A".

If you need to see more than one character on the PIC, your best bet is to set up the receive data interrupt and a software FIFO. Then you can either check for single characters in the FIFO or if multiple characters in the FIFO.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
jds-pic2
Guest







PostPosted: Mon Feb 23, 2004 6:16 pm     Reply with quote

rwyoung wrote:
And if you are looking for the ability to receive Alt-A or Ctrl-S, again it will depend on how your sending software works but probably you will get two key codes, one for "Alt" followed by "A".


correction on this part...

all CTRL-<> codes are represented in ASCII by single bytes, in the range 0x00 to 0x1F. however, there is no "standard" ASCII equivalent for the ALT-<> codes. what the PC application does with an ALT-<> keypress is entirely application dependent. but the application can not translate ALT-<> into an equivalent ASCII code and send it down the wire -- whereas that is precisely possible and typically fully implemented with the CTRL-<> codes.

http://asciitable.com/

jds-pic
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group