I need to be able to know what is the current state of orange button and be notified if this state has changed on Motorola device MC65. Sadly I can't use Symbol.Keyboard.KeyPad class since it is not supported on MC65
The docos state:
Keyboard Supported feature - Only the following two API’s are supported on MC65.
Symbol.Keyboard.KeyPad.SetKeyState. Symbol.Keyboard.KeyPad.GetKeyStateEx.
Following keys are not supported in MC65. KEYSTATE_ALT, KEYSTATE_CTRL, KEYSTATE_NUMLOCK, KEYSTATE_NUMERIC_LOCK, KEYSTATE_CAPSLOCK
For the MC65, Microsoft APIs cannot be used to get the Orange key states. The Symbol.Keyboard.KeyPad class provides a new GetKeyStateEx() function to get the current state of the modifier keys. Refer to the API function’s page for a description of this API.
And it has this code sample:
// Get the key states
int keyState = keypad.GetKeyStateEx();
bool lockedState = false;
// Checking for a lock state first as it cannot be combined with others
switch (keyState)
{
case KeyStates.KEYSTATE_ORANGE_SHIFT_LOCK:
checkBoxOrangeShiftLock.Checked = true;
lockedState = true;
break;
case KeyStates.KEYSTATE_FUNCTION_LOCK:
checkBoxFuncLock.Checked = true;
lockedState = true;
break;
case KeyStates.KEYSTATE_ORANGE_LOCK:
checkBoxOrangeLock.Checked = true;
lockedState = true;
break;
case KeyStates.KEYSTATE_NUMERIC_LOCK:
checkBoxNumLock.Checked = true;
lockedState = true;
break;
case KeyStates.KEYSTATE_SHIFT_LOCK:
checkBoxShiftLock.Checked = true;
lockedState = true;
break;
default:
break;
}
if (lockedState)
{
// No need to continue if a locked state
this.Update();
return;
}
// Process unlock or temp lock states if any
this.checkBoxUnShift.Checked = (keyState & KeyStates.KEYSTATE_UNSHIFT) != 0;
this.checkBoxShift.Checked = (keyState & KeyStates.KEYSTATE_SHIFT) != 0;
this.checkBoxCtrl.Checked = (keyState & KeyStates.KEYSTATE_CTRL) != 0;
this.checkBoxAlt.Checked = (keyState & KeyStates.KEYSTATE_ALT) != 0;
this.checkBoxNum.Checked = (keyState & KeyStates.KEYSTATE_NUMLOCK) != 0;
this.checkBoxCaps.Checked = (keyState & KeyStates.KEYSTATE_CAPSLOCK) != 0;
this.checkBoxFunc.Checked = (keyState & KeyStates.KEYSTATE_FUNC) != 0;
this.checkBoxOrangeTemp.Checked = (keyState & KeyStates.KEYSTATE_ORANGE_TEMP) != 0;
Hope that helps!
来源:https://stackoverflow.com/questions/13859711/knowing-the-state-of-orange-button-in-motorola-mc65