From 6617557973a227445e5ac89624523e97ed2eb389 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Thu, 2 Jan 2014 14:31:40 +0000 Subject: hotkey plugin: fixed special keys support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3996 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/hotkey/hotkeymanager_win.cpp | 40 ++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/General/hotkey/hotkeymanager_win.cpp b/src/plugins/General/hotkey/hotkeymanager_win.cpp index 3e074d941..b6b373010 100644 --- a/src/plugins/General/hotkey/hotkeymanager_win.cpp +++ b/src/plugins/General/hotkey/hotkeymanager_win.cpp @@ -36,6 +36,26 @@ #include #include "hotkeymanager.h" +static struct +{ + unsigned int key; //virtual key + unsigned long code; //scan code +} keyMap [] = { + { VK_LEFT, 0x14b }, + { VK_UP, 0x148 }, + { VK_RIGHT, 0x14d }, + { VK_DOWN, 0x150 }, + { VK_PRIOR, 0x149 }, + { VK_NEXT, 0x151 }, + { VK_END, 0x14F }, + { VK_HOME, 0x147 }, + { VK_INSERT, 0x152 }, + { VK_DELETE, 0x153 }, + { VK_DIVIDE, 0x135 }, + { VK_NUMLOCK, 0x145 }, +{ 0, 0 } +}; + quint32 Hotkey::defaultKey() { return defaultKey(action); @@ -207,11 +227,20 @@ const QString HotkeyManager::getKeyString(quint32 key, quint32 modifiers) keyStr.append(strModList[j] + "+"); } - LONG lScan = MapVirtualKey(key, 0) << 16; - if(key == VK_SHIFT || key == VK_CONTROL || key == VK_LWIN || key == VK_RWIN || key == VK_MENU) return keyStr; + LONG lScan = MapVirtualKey(key, 0) << 16; + + for(int i = 0; i < 12; ++i) + { + if(keyMap[i].key == key) + { + lScan |= 0x1000000; // set extended bit + break; + } + } + int nBufferLen = 64; std::wstring str; int nLen; @@ -235,6 +264,13 @@ QList HotkeyManager::ignModifiersList() quint32 HotkeyManager::keycodeToKeysym(quint32 keycode) { + //MapVirtualKey does not work with some scan codes + //using hardcoded key map instead + for(int i = 0; i < 12; ++i) + { + if(keyMap[i].code == keycode) + return keyMap[i].key; + } return MapVirtualKey(keycode, 1); } #endif -- cgit v1.2.3-13-gbd6f