943,989 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 9584
  • C RSS
Feb 23rd, 2005
0

GetKeyState syntax

Expand Post »
At the beginning of an "IF" statement, I have:
  1. if (SHORT GetKeyState(int 48)==1){

When compiling I get a syntax error just before the constant, and I've played around with it a bit, but haven't found what to do.

Could someone fix this or explain to me why it's not working?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Khishin is offline Offline
23 posts
since Jan 2005
Feb 23rd, 2005
0

Re: GetKeyState syntax

Here is the MSDN entry for the function:
GetKeyState()
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Khishin is offline Offline
23 posts
since Jan 2005
Feb 23rd, 2005
0

Re: GetKeyState syntax

Prototypes tell you the expected types, but when you call a function you don't include the type -- the type is inherently part of the variable or literal being used in the call. That is,
  1. if (GetKeyState(48)==1){
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Feb 23rd, 2005
0

Re: GetKeyState syntax

I had realized that a bit after I posted, but I seem to be getting the low bit instead of the high bit, which is the one I need.

Isn't there a HIGH() operator or something?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Khishin is offline Offline
23 posts
since Jan 2005
Feb 24th, 2005
0

Re: GetKeyState syntax

How can I take only the high order bit from that command?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Khishin is offline Offline
23 posts
since Jan 2005
Feb 24th, 2005
0

Re: GetKeyState syntax

>How can I take only the high order bit from that command?
Here's a slight push in the direction of a solution:
  1. #define bit(i) (1UL << (i))
You can use it to test a certain bit by ANDing the result of bit(n) with the value:
  1. if ((GetKeyState(48) & bit(7)) != 0)
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Linked Lists
Next Thread in C Forum Timeline: need help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC