1. Win32 (GetAsyncKeyState)
- Posted by Molasses <molasses at ALPHALINK.COM.AU> May 19, 1999
- 576 views
Hi all, I have recently been playing around with the user32.dll function GetAsyncKeyState. I'm using it for moving around in a 3dfx Glide prog. Problems: * GetAsyncKeyState only works after I open a message box. This may be something to do with not opening a standard window, I open a Glide window like this: context = grSstWinOpen( GetDesktopWindow(), GR_RESOLUTION_640x480, ...) * GetAsyncKeyState stops responding if I hit a key that i'm not checking for. Anyone know what I'm doing wrong? Thanks, -molasses
2. Re: Win32 (GetAsyncKeyState)
- Posted by Adam Weeden <theskaman at MINDSPRING.COM> May 19, 1999
- 519 views
It might be this. In C (and its successor) whenever you are testing a variable against many values you use a switch statement like this: // Sorry abou the C code, necessary to show my point. // Assume we have already set value of key to what ASyncKeyState // returns. switch(key) { case VALUE1: { // Do whatever you need to do for VALUE1 } break; case VALUE2: { // Do whatever you need to do for VALUE2 } break; default: { // If key doesnt match any of the above values do this } break; } In Euphoria this could be wriiten as If key = VALUE1 then -- Keep in mind VALUE1 in my example is a -- constant so this is legal. -- Do whatever you need to do for VALUE1 elsif key = VALUE2 then -- Do whatever you need to do for VALUE2 else -- If key doesnt match any of the above values do this end if My point is that maybe you need some sort of function that would parse a return value of GetAsyncKeyState that you do not need. Just a thought. Adam Weeden -----Original Message----- From: Molasses <molasses at ALPHALINK.COM.AU> To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU> Date: Tuesday, May 18, 1999 8:45 PM Subject: Win32 (GetAsyncKeyState) >Hi all, > >I have recently been playing around with the user32.dll function >GetAsyncKeyState. >I'm using it for moving around in a 3dfx Glide prog. > >Problems: > >* GetAsyncKeyState only works after I open a message box. > >This may be something to do with not opening a standard window, I open a >Glide window like this: >context = grSstWinOpen( GetDesktopWindow(), GR_RESOLUTION_640x480, ...) > >* GetAsyncKeyState stops responding if I hit a key that i'm not checking >for. > >Anyone know what I'm doing wrong? > >Thanks, > >-molasses
3. Re: Win32 (GetAsyncKeyState)
- Posted by Molasses <molasses at ALPHALINK.COM.AU> May 20, 1999
- 558 views
Sorry that's not it. GetAsyncKeyState takes a key value and returns true or false. is_pressed = GetAsyncKeyState(VK_ESCAPE) The problem being, if I'm only checking for the arrow keys and escape and the user hits say enter then the arrow keys and escape will stop responding. I suppose after checking for the keys I need I could do this to clear any other keys: for i = 0 to 255 do null = GetAsyncKeyState(i) end for But there's got to be a better way than that. -molasses ----- Original Message ----- From: Adam Weeden <theskaman at MINDSPRING.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Wednesday, 19 May 1999 3:13 pm Subject: Re: Win32 (GetAsyncKeyState) > It might be this. In C (and its successor) whenever you are testing a > variable against many values you use a switch statement like this: > > // Sorry abou the C code, necessary to show my point. > // Assume we have already set value of key to what ASyncKeyState > // returns. > > switch(key) > { > case VALUE1: > { > // Do whatever you need to do for VALUE1 > } break; > case VALUE2: > { > // Do whatever you need to do for VALUE2 > } break; > default: > { > // If key doesnt match any of the above values do this > } break; > } > > In Euphoria this could be wriiten as > If key = VALUE1 then -- Keep in mind VALUE1 in my example is a > -- constant so this is legal. > > -- Do whatever you need to do for VALUE1 > elsif key = VALUE2 then > -- Do whatever you need to do for VALUE2 > else > -- If key doesnt match any of the above values do this > end if > > My point is that maybe you need some sort of function that would parse a > return value of GetAsyncKeyState that you do not need. > Just a thought.
4. Re: Win32 (GetAsyncKeyState)
- Posted by Bernie Ryan <bwryan at PCOM.NET> May 20, 1999
- 556 views
This might help When the MOST significant bit of returned value is set, the key is currently pressed down. When the LEAST significant bit of returned value is set, the key is has been pressed since last call to GetAsyncKeyState function. So you have to monitor these bits as you scan the different keys that you want to use. There is also a GetKeyState function maybe that function would be easier for you to use in your application but the return value bits have different set of meanings. I hope this can be of some help. Bernie