Menu Content/Inhalt

Online

No Users Online

Login

Syndicate

feed image

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285

Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
GetKeys() PDF Print E-mail
Computers - Development
Written by Dave Thorup   
Friday, 08 June 2007
I was looking for the Mac equivalent of the Windows GetAsyncKeyState() function so that I could check to see if certain keys were pressed when launching Bibble.  I ran across a helpful post here that tells you how to do it using the GetKeys() function (scroll to the end to find the useful stuff).  It looks like that was taken from an Apple example, SampleButtonPlugin , found here
 
This post is a bit technical and is mainly for my own future reference.  Read on for more... 
 
Here is the relevant code listing:
 
  1. UInt8 PushButtonStatus()
  2. {
  3. KeyMap theKeys;
  4. KeyMap f5Key = { 0x00000000, 0x0000000C, 0x00000000, 0x00000000 };
  5. GetKeys(theKeys);
  6. return (0 == memcmp(theKeys, f5Key, sizeof(KeyMap)));
  7. }
 
 
The Apple docs for GetKeys states the following:
 
The KeyMap type is interpreted as an array of 128 elements, each having a Boolean value. Each key on the keyboard or keypad corresponds to an element in the KeyMap array. The index for a particular key is the same as the key’s virtual key code minus 1. For example, the key with virtual key code 38 (the “J” key on the Apple Keyboard II) is the 38th element in the returned array. A KeyMap element is true if the corresponding key is down and false if it isn’t. The maximum number of keys that can be down simultaneously is two character keys plus any combination of the five modifier keys.
I'm not sure where to find the virtual key code definitions so the easiest way to find the KeyMap that you're after is to just run the GetKeys function while holding down the keys that you're after and save the returned KeyMap.  FYI, the KeyMap for the Shift key is 0x00000000, 0x01000000, 0x00000000, 0x00000000.  Also, the function is noted as Legacy but it works.  If anyone knows of a newer function that does the same thing then please let me know.
 

Related Items:


Add as favourites (88) | Quote this article on your site | Views: 743

Be first to comment this article
RSS comments

Write Comment
  • Please keep the topic of messages relevant to the subject of the article.
  • Personal verbal attacks will be deleted.
  • Please don't use comments to plug your web site. Such material will be removed.
  • Just ensure to *Refresh* your browser for a new security code to be displayed prior to clicking on the 'Send' button.
  • Keep in mind that the above process only applies if you simply entered the wrong security code.
Name:
E-mail
Homepage
Title:
BBCode:Web AddressEmail AddressBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
Comment:



Code:* Code
I wish to be contacted by email regarding additional comments

Powered by AkoComment Tweaked Special Edition v.1.4.3

Last Updated ( Friday, 08 June 2007 )
 
Next >
designed by www.madeyourweb.com | joomla templates