GetKeyState syntax

Reply

Join Date: Jan 2005
Posts: 23
Reputation: Khishin is an unknown quantity at this point 
Solved Threads: 0
Khishin Khishin is offline Offline
Newbie Poster

GetKeyState syntax

 
0
  #1
Feb 23rd, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: Khishin is an unknown quantity at this point 
Solved Threads: 0
Khishin Khishin is offline Offline
Newbie Poster

Re: GetKeyState syntax

 
0
  #2
Feb 23rd, 2005
Here is the MSDN entry for the function:
GetKeyState()
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,356
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 237
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: GetKeyState syntax

 
0
  #3
Feb 23rd, 2005
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){
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: Khishin is an unknown quantity at this point 
Solved Threads: 0
Khishin Khishin is offline Offline
Newbie Poster

Re: GetKeyState syntax

 
0
  #4
Feb 23rd, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: Khishin is an unknown quantity at this point 
Solved Threads: 0
Khishin Khishin is offline Offline
Newbie Poster

Re: GetKeyState syntax

 
0
  #5
Feb 24th, 2005
How can I take only the high order bit from that command?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 716
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: GetKeyState syntax

 
0
  #6
Feb 24th, 2005
>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)
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC