All Forums
 Microsoft Windows CE
 CE Sample Applications and Utilities
 eVC - Keypad helper class (keyboard mapping)
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

ctacke

877 Posts

Posted - 14 Oct 2003 :  13:37:13  Show Profile  Email Poster
Keypad.cpp

This helper class helps provide keyboard functionality from a digital keypad using the ADSmartIO library. A key map is passed into the class and this map converts keypad button presses to virtual key presses. For virtual key value definitions, see winuser.h.

Notes
The ADSmartIO keypad functions support only one key press at a time. This precludes using key combinations, like shift-a or ctrl-c. As a "workaround" to this problem, this library provides functionality similar to the soft input panel (SIP). If you press a SHIFT key, then the next key will have SHIFT applied. Once the shifted key is sent, the "shift" will be turned back off. This functionality exists for the SHIFT and CONTROL keys only.

This library also depends on the ADS ADSmartIO helper class (720020-1153x).

Key APIs Used

CreateThread
CreateEvent
keybd_event
SIOReadKeypad
SIOSelectOption
SetKeyPadSize
WaitForSingleObject


Lines of Code: 156


Source Download
Rev 1 - Oct 14, 03 (13k zip).


padrino121

8 Posts

Posted - 14 Jun 2004 :  20:33:44  Show Profile  Email Poster
I already setup a polling thread and marshal the key codes to the proper event handlers however I was wondering how you could use the keybd_event method to dispatch messages to a command line app similar to the test app you have here. As I understand it in a GUI application keybd_event would properly inform the top window of the key presses however how would one make this work using a console app like the one provided?

Thanks.
Go to Top of Page

ctacke

877 Posts

Posted - 15 Jun 2004 :  12:31:34  Show Profile  Email Poster
Under CE, the "console" is simply another application running in a window. If it's at the top of the z-order, it should receive key presses just like any other application. Are you not seeing the correct behavior? What Platform and ADS CE Build number are you using?
Go to Top of Page

padrino121

8 Posts

Posted - 16 Jun 2004 :  13:32:06  Show Profile  Email Poster
quote:
[i]Originally posted by ctacke[/i]
[br]Under CE, the "console" is simply another application running in a window. If it's at the top of the z-order, it should receive key presses just like any other application. Are you not seeing the correct behavior? What Platform and ADS CE Build number are you using?



I'm on a BitsyX running 4.1.36. I added a debug statement to the keypad.cpp file to print when a key is received and it is indeed received and the keybd_event is correct run however my app never receives the key press. Maybe I'm missing something but GetMessage should get the message just like it does in my MFC based version and work the same.
Go to Top of Page

timslater

6 Posts

Posted - 08 Oct 2004 :  13:49:03  Show Profile  Email Poster
Is this helper class polling the keyboard?

I am on BitsyX and wondering about conserving battery power (as well as response time if I set the poll timer to large)

Is there a way to get an interrupt to know when to do an SIOReadKeypad() ?


Go to Top of Page

akidder

1519 Posts

Posted - 08 Oct 2004 :  18:06:50  Show Profile  Email Poster
Hi Tim. The SIOReadKeypad function is a blocking call. The SIOSetSSPTimeout function determines how long it should wait before returning.

I can see why you might think the keypad function is polling in this application. While there is a while(true) loop that repeatedly calls the keypad read function, the keypad function itself blocks for several seconds if no key is pressed. What may have been confusing here is that the timeout is not set explicity.

You can set the timeout a number of ways:
  1. Use the default timeout, which is typically set in the built-in registry (consult the reginit.ini that came with your CE build):

      [HKEY_LOCAL_MACHINE\Platform\Smartio]
        "SSPTimeout"=dword:1388 ; 0x1388 = 5000 msec, 0xffffffff "infinite"


  2. You can override the default setting by setting your own timeout in adsload.reg.


  3. Finally, you can call SIOSetSSPTimeout explicitly.


To summarize, use the keypad function in a helper thread, as demonstrated in this application. The timeout gives the effect of an event-driven, block-till-satisfied function call.
Go to Top of Page

timslater

6 Posts

Posted - 11 Oct 2004 :  16:49:15  Show Profile  Email Poster
Thanks. But of course more questions...

I see in the ADSmartio specification that with version 0x8003 I can get KepPressed and KeyRelease codes from SIOReadKeypad().

1. How do I know if I have version 0x8003 ? (From the debug port, all I see is "SMARTIO Detected : PartType=0x8535 Firmware=0x0010 Revision=2"

2. Assuming I can get KeyPressed and KeyReleased codes, does that mean I can
pretty easily implement key combinations (Key1 down, Key2 down before Key1 up implies both keys are down, right ?


Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.03 seconds. Snitz Forums 2000