Changeset 433 for trunk/src/gui/kernel


Ignore:
Timestamp:
Dec 20, 2009, 1:25:42 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Added support for numpad keys and for some common multimedia keys recognized by eCS (volume, home, search, favorites).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qkeymapper_pm.cpp

    r379 r433  
    164164    Qt::Key_Insert,     //  26   0x1A   VK_INSERT           | Ins key
    165165    Qt::Key_Delete,     //  27   0x1B   VK_DELETE           | Del key
    166     Qt::Key_NumLock,    //  28   0x1C   VK_SCROLL           | Scroll Lock key
    167     Qt::Key_ScrollLock, //  29   0x1D   VK_NUMLOCK          | Num Lock key
     166    Qt::Key_ScrollLock, //  28   0x1C   VK_SCROLL           | Scroll Lock key
     167    Qt::Key_NumLock,    //  29   0x1D   VK_NUMLOCK          | Num Lock key
    168168    Qt::Key_Enter,      //  30   0x1E   VK_ENTER            | Enter (Numpad) key
    169169    Qt::Key_SysReq,     //  31   0x1F   VK_SYSRQ            | SysReq key
     
    349349            chm.chr = state & Qt::ShiftModifier ? '|' : '\\';
    350350            break;
    351     }
     351        case 0xFA00: // Back
     352            code = Qt::Key_Back;
     353            break;
     354        case 0xF900: // Forward
     355            code = Qt::Key_Forward;
     356            break;
     357        case 0x2064: // Volume Mute
     358            code = Qt::Key_VolumeMute;
     359            break;
     360        case 0x2E63: // Volume Down
     361            code = Qt::Key_VolumeDown;
     362            break;
     363        case 0x3062: // Volume Up
     364            code = Qt::Key_VolumeUp;
     365            break;
     366        case 0x2267: // Play/Pause
     367            code = Qt::Key_MediaPlay;
     368            break;
     369        case 0x326D: // Web/Home
     370            code = Qt::Key_HomePage;
     371            break;
     372        case 0xF500: // Search
     373            code = Qt::Key_Search;
     374            break;
     375        case 0xF600: // Favorites
     376            code = Qt::Key_Favorites;
     377            break;
     378        }
    352379
    353380    // update state after updating extraKeyState
     
    375402    else if (code == Qt::Key_Meta)
    376403        state = state ^ Qt::MetaModifier;
     404
     405    // detect numeric keypad keys
     406    if (chm.vkey == VK_ENTER || chm.vkey == VK_NUMLOCK) {
     407        // these always come from the numpad
     408        state |= Qt::KeypadModifier;
     409    } else if (((chm.vkey >= VK_PAGEUP && chm.vkey <= VK_DOWN) ||
     410                chm.vkey == VK_INSERT || chm.vkey == VK_DELETE)) {
     411        if ((chm.chr & 0xFF) != 0xE0) {
     412            state |= Qt::KeypadModifier;
     413            if ((state & Qt::AltModifier) && chm.vkey != VK_DELETE) {
     414                // hide the key from Qt widgets and let the standard OS/2 Alt+ddd
     415                // shortcut (that composed chars from typed in ASCII codes) work
     416                // correctly. If we don't do that, widgets will see both individual
     417                // digits (or cursor movements if NumLock is off) and the char
     418                // composed by Alt+ddd.
     419                return false;
     420            }
     421        }
     422    }
     423    // detect other numpad keys. OS/2 doesn't assign virtual keys to them
     424    // so use scancodes (it can be device-dependent, is there a better way?)
     425    switch (chm.scancode) {
     426        case 0x4C: // 5
     427            state |= Qt::KeypadModifier;
     428            if (state & Qt::AltModifier) {
     429                // hide the key from Qt (see above)
     430                return false;
     431            } else {
     432                // scancode is zero if Numlock is set
     433                if (!code)
     434                    code = Qt::Key_Clear;
     435            }
     436            break;
     437        case 0x37: // *
     438            // OS/2 assigns VK_PRINTSCRN to it when pressed with Shift, also
     439            // it sets chr to zero when it is released with Alt or Ctrl
     440            // leaving vkey as zero too, and does few other strange things --
     441            // override them all
     442            code = Qt::Key_Asterisk;
     443            state |= Qt::KeypadModifier;
     444            break;
     445        case 0x5C: // /
     446            code = Qt::Key_Slash;
     447            // fall through
     448        case 0x4A: // -
     449        case 0x4E: // +
     450            // the code for the above two is obtained by KbdXlate above
     451            state |= Qt::KeypadModifier;
     452            break;
     453    }
    377454
    378455    // Note: code and/or chm.scancode may be zero here. We cannot ignore such
Note: See TracChangeset for help on using the changeset viewer.