If you are using the .NET wrappers, you could call the following method defined in TreqKeypadDriver.cs:
Code:
TreqKeypadDriver.SetKeypadKey(TreqKeys.TREQ_KEY0, exampleseq1, false);
Where:
TreqKeys.TREQ_KEY0 - is an enum also defined in TreqKeypadDriver.cs (where the other key defines exist also)
exampleseq1 - an array of 16-bit unsigned shorts you could use any of the following:
ushort[] exampleseq1 = { 0x70 }; //F1 key
(standard ce virtual key defines come from the SDK, or C:\Program Files\Windows CE Tools\wce600\TREQ-M4\Include\Armv4i\winuser.h starting at line 2956)
false - specifies to map the UNSHIFTED key to your value. For explation on shifted key state see M4 guide section 3.3)
For your sequence you can use other mappings also, for example you could use these:
Code:
ushort[] exampleseq2 = { (ushort)TreqVKCodes.VK_SEQ,(ushort)'B' }; //type the LOWERCASE character 'b'
ushort[] exampleseq2 = constructRunAppSeq("\\Windows\\explorer.exe");
The constructRunAppSeq method called is explained here:
Code:
protected static ushort[] constructRunAppSeq(string program)
{
ushort[] runApp = new ushort[program.Length + 2];
runApp[0] = (ushort)TreqVKCodes.VK_RUN_APP; //prepend runapp code
runApp[program.Length + 1] = 0; //append null terminator
program.ToCharArray().CopyTo(runApp, 1); //put string in the middle of the two
return runApp;
}
Please note that in order to assign a button to type the UPPERCASE character 'B' you would have to create a sequence which will press the virtual shift key, just as you would on a keyboard.
Finally, if you recall the C++ examples on page 50-51 of the M4 userguide, I've created a comparable version example in C#, the following method is a slice of that code:
Code:
private void chooseAssignment(int index, TreqKeys key, ref ushort[] keyval, bool shift)
{
switch (index)
{
case 0: //default
switch (key)
{
case TreqKeys.TREQ_KEY0:
if (shift) keyval = defaultKey1s; else keyval = defaultKey1; break;
case TreqKeys.TREQ_KEY1:
if (shift) keyval = defaultKey2s; else keyval = defaultKey2; break;
case TreqKeys.TREQ_KEY2:
if (shift) keyval = defaultKey3s; else keyval = defaultKey3; break;
case TreqKeys.TREQ_KEY3:
if (shift) keyval = defaultKey4s; else keyval = defaultKey4; break;
}
break;
case 1: //runApp
// runApp launches MinTermCE.exe
keyval = constructRunAppSeq("\\HardDisk\\bin\\MinTermCE.exe");
break;
case 2: //runSeq
// runSeq launches MinTermCE.exe, then types "done"
// Can't use string initializer when data follows the path in
// the sequence (compiler limitation)
ushort[] runSeq = { (ushort)TreqVKCodes.VK_SEQ | (ushort)TreqVKCodes.TREQ_KEY_REPEAT, (ushort)TreqVKCodes.VK_RUN_APP, '\\', 'H', 'a', 'r', 'd', 'D', 'i', 's', 'k', '\\', 'b', 'i', 'n', '\\', 'M', 'i', 'n', 'T', 'e', 'r', 'm', 'C', 'E', '.', 'e', 'x', 'e', 0, (ushort)'D', (ushort)'O', (ushort)'N', (ushort)'E' | (ushort)TreqVKCodes.TREQ_KEY_RELEASE };
keyval = runSeq;
break;
case 3: //otherSeq
ushort[] otherSeq = { (ushort)TreqVKCodes.VK_SEQ | (ushort)TreqVKCodes.TREQ_KEY_REPEAT, (ushort)VKeys.VK_LSHIFT, (ushort)'H' | (ushort)TreqVKCodes.TREQ_KEY_RELEASE, (ushort)'E', (ushort)'L', (ushort)'L', (ushort)'O', (ushort)VKeys.VK_SPACE, (ushort)VKeys.VK_LSHIFT, (ushort)'W' | (ushort)TreqVKCodes.TREQ_KEY_RELEASE, (ushort)'O', (ushort)'R', (ushort)'L', (ushort)'D', (ushort)VKeys.VK_RETURN | (ushort)TreqVKCodes.TREQ_KEY_RELEASE };
keyval = otherSeq;
break;
}
}
Hopefully this helps.