View previous topic :: View next topic |
Author |
Message |
MikeV
Joined: 20 Feb 2004 Posts: 4
|
How to determine if TWO keys are hit at the same time |
Posted: Mon Feb 23, 2004 10:03 am |
|
|
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
|
|
Posted: Mon Feb 23, 2004 10:23 am |
|
|
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
|
|
Posted: Mon Feb 23, 2004 6:16 pm |
|
|
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 |
|
|
|