Exemplo n.º 1
0
void setKeypad(unsigned int keymap_id, bool state)
{
    int col = keymap_id % KEYPAD_COLS, row = keymap_id / KEYPAD_COLS;
    assert(row < KEYPAD_ROWS);
    //assert(col < KEYPAD_COLS); Not needed.

    ::keypad_set_key(row, col, state);
    notifyKeypadStateChanged(row, col, state);
}
Exemplo n.º 2
0
void QtKeypadBridge::keyPressEvent(QKeyEvent *event)
{
    Qt::Key key = static_cast<Qt::Key>(event->key());

    switch(key)
    {
    case Qt::Key_Down:
        keypad.touchpad_x = TOUCHPAD_X_MAX / 2;
        keypad.touchpad_y = 0;
        break;
    case Qt::Key_Up:
        keypad.touchpad_x = TOUCHPAD_X_MAX / 2;
        keypad.touchpad_y = TOUCHPAD_Y_MAX;
        break;
    case Qt::Key_Left:
        keypad.touchpad_y = TOUCHPAD_Y_MAX / 2;
        keypad.touchpad_x = 0;
        break;
    case Qt::Key_Right:
        keypad.touchpad_y = TOUCHPAD_Y_MAX / 2;
        keypad.touchpad_x = TOUCHPAD_X_MAX;
        break;
    case Qt::Key_Return:
        key = Qt::Key_Enter;

    default:
        auto& keymap = keymap_tp;
        for(unsigned int row = 0; row < sizeof(keymap)/sizeof(*keymap); ++row)
        {
            for(unsigned int col = 0; col < sizeof(*keymap)/sizeof(**keymap); ++col)
            {
                if(key == keymap[row][col].key && keymap[row][col].alt == (bool(event->modifiers() & Qt::AltModifier) || bool(event->modifiers() & Qt::MetaModifier)))
                {
                    if(row == 0 && col == 9)
                        keypad_on_pressed();

                    keypad.key_map[row] |= 1 << col;
                    notifyKeypadStateChanged(row, col, true);
                    keypad_int_check();
                    return;
                }
            }
        }
        return;
    }

    keypad.touchpad_contact = keypad.touchpad_down = true;
    notifyTouchpadStateChanged();
    keypad.kpc.gpio_int_active |= 0x800;

    keypad_int_check();
}
Exemplo n.º 3
0
void QtKeypadBridge::keyReleaseEvent(QKeyEvent *event)
{
    Qt::Key key = static_cast<Qt::Key>(event->key());

    switch(key)
    {
    case Qt::Key_Down:
        if(touchpad_x == TOUCHPAD_X_MAX / 2
            && touchpad_y == 0)
            touchpad_contact = touchpad_down = false;
        break;
    case Qt::Key_Up:
        if(touchpad_x == TOUCHPAD_X_MAX / 2
            && touchpad_y == TOUCHPAD_Y_MAX)
            touchpad_contact = touchpad_down = false;
        break;
    case Qt::Key_Left:
        if(touchpad_y == TOUCHPAD_Y_MAX / 2
            && touchpad_x == 0)
            touchpad_contact = touchpad_down = false;
        break;
    case Qt::Key_Right:
        if(touchpad_y == TOUCHPAD_Y_MAX / 2
            && touchpad_x == TOUCHPAD_X_MAX)
            touchpad_contact = touchpad_down = false;
        break;
    case Qt::Key_Return:
        key = Qt::Key_Enter;
    default:
        auto& keymap = keymap_tp;
        for(unsigned int row = 0; row < sizeof(keymap)/sizeof(*keymap); ++row)
        {
            for(unsigned int col = 0; col < sizeof(*keymap)/sizeof(**keymap); ++col)
            {
                if(key == keymap[row][col].key && keymap[row][col].alt == (bool(event->modifiers() & Qt::AltModifier) || bool(event->modifiers() & Qt::MetaModifier)))
                {
                    key_map[row] &= ~(1 << col);
                    notifyKeypadStateChanged(row, col, false);
                    keypad_int_check();
                    return;
                }
            }
        }
        return;
    }

    notifyTouchpadStateChanged();
    kpc.gpio_int_active |= 0x800;
    keypad_int_check();
}
Exemplo n.º 4
0
void QtKeypadBridge::keyEvent(QKeyEvent *event, bool press)
{
    Qt::Key key = static_cast<Qt::Key>(event->key());

    auto& keymap = keymap_tp;
    for(unsigned int row = 0; row < sizeof(keymap)/sizeof(*keymap); ++row)
    {
        for(unsigned int col = 0; col < sizeof(*keymap)/sizeof(**keymap); ++col)
        {
            for(unsigned int index = 0; index < sizeof((**keymap).key)/sizeof(*(**keymap).key); ++index)
            {
                if(key == keymap[row][col].key[index] && keymap[row][col].alt == (bool(event->modifiers() & Qt::AltModifier) || bool(event->modifiers() & Qt::MetaModifier)))
                {
                    keypad_key_event(row, col, press);
                    notifyKeypadStateChanged(row, col, press);
                    return;
                }
            }
        }
    }

    keypad.gpio_enable |= 0x800;
    keypad_intrpt_check();
}