USBC_Keyboard

Hi,

Is it possible to take a char from an array and use it when writing code for a key tap.

 kb.KeyTap(USBC_Key ... ); 

Thanks

Can you explain a little bit more?

I think the question is:
How can I access the USBC_Key Enumerations from software:

GHI example of sending the letter A via HID keyboard:
USBC_Keyboard kb = USBClientController.StandardDevices.StartKeyboard();
kb.KeyTap(USBC_Key.A);

Currently, if I need to send a bunch of unknown characters, I would have to do something like this:

If(char x == ‘A’)
kb.KeyTap(USBC_Key.A);
if(char x == ‘B’)
kb.KeyTap(USBC_Key.B);

and that will be a lot of ifs, if you get my meaning.

Well, what if you need to read a file and transmit the data via HID keystrokes to a host ?

The USBC_Key Enumeration for A is 4.

this table has all the values for the USBC_Key Enumerations
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation%20v4.1/html/3029fdb4-c664-4a08-ef7f-10cf2a7f9f09.htm

so, if I read a file, and I need to send the data out as keystrokes, then the original question:

Is it possible to take a char from an array and use it when writing code for a key tap.

is asking if there is some way of storing the value for each key in an array, so that there could be an efficient way of sending every letter in the alphabet using some sort of lookup/compare.

You can use something like this:

kb.KeyTap((USBC_Key)(ch - 61));

Where ch is upper case of the character you want to send keytap for.

Thanks for the insight!

I tried this approach, and I get lower case letters as output,

here is the test code:

USBC_Keyboard kb = USBClientController.StandardDevices.StartKeyboard();

if (USBClientController.GetState() ==USBClientController.State.Running)
{
for(int j = 65; j<68; J++)
{
kb.KeyTap((USBC_Key) (j-61));
}
}

Output: abc

I’ve done this test several times, power cycle in between, so the USBizi should be in a default state. I’m sending the data over a USB port to NotePad on XP

I think the state of the CapsLock has something to do with this,
how would I read the the state of the CapsLock?

Keyboards does not send upper or lower case letters.
They only send a key, which is for axample the ‘A’ key.
The OS or driver then checks the shift state as well as other states to decide which character the key ‘A’ will generate.
If shift or shift lock is active, then you get an upper case character, if not the it’s lower case.

So you need to simulate a shift key down, then key ‘A’, then shift key up to get an upper case ‘A’ character (don’t know if this possible in NETMF).

Hope this helps.

It is supported, and the following code will do just that:


kb.KeyDown(USBC_Key.LeftShift);

kb.KeyTap(USBC_Key.A);

kb.KeyUp(USBC_Key.LeftShift);