Knowing the state of orange button in motorola MC65

空扰寡人 提交于 2019-12-04 19:39:49

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!