fix numpad keys on win32
This commit is contained in:
parent
d83804f2cb
commit
aafe219532
|
@ -117,7 +117,6 @@ function Terminal.init()
|
||||||
Hotkeys.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
Hotkeys.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
Hotkeys.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Enter', doCommand, commandLineEdit)
|
Hotkeys.bindKeyDown('Enter', doCommand, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Return', doCommand, commandLineEdit)
|
|
||||||
|
|
||||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||||
Logger.setOnLog(onLog)
|
Logger.setOnLog(onLog)
|
||||||
|
|
|
@ -63,7 +63,6 @@ KeyUnknown = 0
|
||||||
KeyEscape = 1
|
KeyEscape = 1
|
||||||
KeyTab = 2
|
KeyTab = 2
|
||||||
KeyBackspace = 3
|
KeyBackspace = 3
|
||||||
KeyReturn = 4
|
|
||||||
KeyEnter = 5
|
KeyEnter = 5
|
||||||
KeyInsert = 6
|
KeyInsert = 6
|
||||||
KeyDelete = 7
|
KeyDelete = 7
|
||||||
|
@ -183,7 +182,6 @@ KeyCodeDescs = {
|
||||||
[KeyEscape] = 'Escape',
|
[KeyEscape] = 'Escape',
|
||||||
[KeyTab] = 'Tab',
|
[KeyTab] = 'Tab',
|
||||||
[KeyBackspace] = 'Backspace',
|
[KeyBackspace] = 'Backspace',
|
||||||
[KeyReturn] = 'Return',
|
|
||||||
[KeyEnter] = 'Enter',
|
[KeyEnter] = 'Enter',
|
||||||
[KeyInsert] = 'Insert',
|
[KeyInsert] = 'Insert',
|
||||||
[KeyDelete] = 'Delete',
|
[KeyDelete] = 'Delete',
|
||||||
|
|
|
@ -9,7 +9,7 @@ end
|
||||||
function UIWindow:onKeyPress(keyCode, keyboardModifiers, wouldFilter)
|
function UIWindow:onKeyPress(keyCode, keyboardModifiers, wouldFilter)
|
||||||
if wouldFilter then return end
|
if wouldFilter then return end
|
||||||
if keyboardModifiers == KeyboardNoModifier then
|
if keyboardModifiers == KeyboardNoModifier then
|
||||||
if keyCode == KeyReturn or keyCode == KeyEnter then
|
if keyCode == KeyEnter then
|
||||||
signalcall(self.onEnter, self)
|
signalcall(self.onEnter, self)
|
||||||
elseif keyCode == KeyEscape then
|
elseif keyCode == KeyEscape then
|
||||||
signalcall(self.onEscape, self)
|
signalcall(self.onEscape, self)
|
||||||
|
|
|
@ -38,7 +38,7 @@ local SpeakTypes = {
|
||||||
|
|
||||||
local SayModes = {
|
local SayModes = {
|
||||||
[1] = { speakTypeDesc = 'whisper', icon = '/core_styles/icons/whisper.png' },
|
[1] = { speakTypeDesc = 'whisper', icon = '/core_styles/icons/whisper.png' },
|
||||||
[2] = { speakTypeDesc = 'say', icon = '/core_styles/icons/say.png' },
|
[2] = { speakTypeDesc = 'say', icon = '/core_styles/icons/say.png' },
|
||||||
[3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' }
|
[3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,22 +87,21 @@ function Console.create()
|
||||||
|
|
||||||
Console.addChannel('Default', 0)
|
Console.addChannel('Default', 0)
|
||||||
Console.addTab('Server Log', false)
|
Console.addTab('Server Log', false)
|
||||||
|
|
||||||
Hotkeys.bindKeyDown('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
|
Hotkeys.bindKeyDown('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
|
Hotkeys.bindKeyDown('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
Hotkeys.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
Hotkeys.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
Hotkeys.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Return', Console.sendCurrentMessage, consolePanel)
|
|
||||||
|
|
||||||
-- apply buttom functions after loaded
|
-- apply buttom functions after loaded
|
||||||
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
||||||
connect(consolePanel:getChildById('prevChannelButton'), { onClick = function() consoleTabBar:selectPrevTab() end } )
|
connect(consolePanel:getChildById('prevChannelButton'), { onClick = function() consoleTabBar:selectPrevTab() end } )
|
||||||
connect(consoleTabBar, { onTabChange = Console.onTabChange })
|
connect(consoleTabBar, { onTabChange = Console.onTabChange })
|
||||||
|
|
||||||
-- tibia like hotkeys
|
-- tibia like hotkeys
|
||||||
Hotkeys.bindKeyDown('Ctrl+O', Game.requestChannels)
|
Hotkeys.bindKeyDown('Ctrl+O', Game.requestChannels)
|
||||||
Hotkeys.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
|
Hotkeys.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.destroy()
|
function Console.destroy()
|
||||||
|
@ -131,7 +130,7 @@ end
|
||||||
function Console.removeCurrentTab()
|
function Console.removeCurrentTab()
|
||||||
local tab = consoleTabBar:getCurrentTab()
|
local tab = consoleTabBar:getCurrentTab()
|
||||||
if tab:getText() == "Default" or tab:getText() == "Server Log" then return end
|
if tab:getText() == "Default" or tab:getText() == "Server Log" then return end
|
||||||
|
|
||||||
consoleTabBar:removeTab(tab)
|
consoleTabBar:removeTab(tab)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -203,27 +202,27 @@ function Console.sendCurrentMessage()
|
||||||
local chatCommandSayMode
|
local chatCommandSayMode
|
||||||
local chatCommandPrivate
|
local chatCommandPrivate
|
||||||
local chatCommandPrivateReady
|
local chatCommandPrivateReady
|
||||||
|
|
||||||
local chatCommandMessage = message:match("^%#y (.*)")
|
local chatCommandMessage = message:match("^%#y (.*)")
|
||||||
if chatCommandMessage ~= nil then chatCommandSayMode = 'yell' end -- player used yell command
|
if chatCommandMessage ~= nil then chatCommandSayMode = 'yell' end -- player used yell command
|
||||||
message = chatCommandMessage or message
|
message = chatCommandMessage or message
|
||||||
|
|
||||||
local chatCommandMessage = message:match("^%#w (.*)")
|
local chatCommandMessage = message:match("^%#w (.*)")
|
||||||
if chatCommandMessage ~= nil then chatCommandSayMode = 'whisper' end -- player used whisper
|
if chatCommandMessage ~= nil then chatCommandSayMode = 'whisper' end -- player used whisper
|
||||||
message = chatCommandMessage or message
|
message = chatCommandMessage or message
|
||||||
|
|
||||||
local findIni, findEnd, chatCommandInitial, chatCommandPrivate, chatCommandEnd, chatCommandMessage = message:find("([%*%@])(.+)([%*%@])(.*)")
|
local findIni, findEnd, chatCommandInitial, chatCommandPrivate, chatCommandEnd, chatCommandMessage = message:find("([%*%@])(.+)([%*%@])(.*)")
|
||||||
if findIni ~= nil and findIni == 1 then -- player used private chat command
|
if findIni ~= nil and findIni == 1 then -- player used private chat command
|
||||||
if chatCommandInitial == chatCommandEnd then
|
if chatCommandInitial == chatCommandEnd then
|
||||||
chatCommandPrivateRepeat = false
|
chatCommandPrivateRepeat = false
|
||||||
if chatCommandInitial == "*" then
|
if chatCommandInitial == "*" then
|
||||||
consoleLineEdit:setText('*'.. chatCommandPrivate .. '* ')
|
consoleLineEdit:setText('*'.. chatCommandPrivate .. '* ')
|
||||||
end
|
end
|
||||||
message = chatCommandMessage:trim()
|
message = chatCommandMessage:trim()
|
||||||
chatCommandPrivateReady = true
|
chatCommandPrivateReady = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
message = message:gsub("^(%s*)(.*)","%2") -- remove space characters from message init
|
message = message:gsub("^(%s*)(.*)","%2") -- remove space characters from message init
|
||||||
if #message == 0 then return end
|
if #message == 0 then return end
|
||||||
|
|
||||||
|
@ -233,7 +232,7 @@ function Console.sendCurrentMessage()
|
||||||
if #messageHistory > MaxHistory then
|
if #messageHistory > MaxHistory then
|
||||||
table.remove(messageHistory, 1)
|
table.remove(messageHistory, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- when talking on server log, the message goes to default channel
|
-- when talking on server log, the message goes to default channel
|
||||||
local name = tab:getText()
|
local name = tab:getText()
|
||||||
if name == 'Server Log' then
|
if name == 'Server Log' then
|
||||||
|
@ -263,7 +262,7 @@ function Console.sendCurrentMessage()
|
||||||
else
|
else
|
||||||
speaktypedesc = 'privatePlayerToPlayer'
|
speaktypedesc = 'privatePlayerToPlayer'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local speaktype = SpeakTypesSettings[speaktypedesc]
|
local speaktype = SpeakTypesSettings[speaktypedesc]
|
||||||
local player = Game.getLocalPlayer()
|
local player = Game.getLocalPlayer()
|
||||||
|
@ -279,11 +278,11 @@ function Console.sayModeChange(sayMode)
|
||||||
if sayMode == nil then
|
if sayMode == nil then
|
||||||
sayMode = buttom.sayMode + 1
|
sayMode = buttom.sayMode + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if sayMode > #SayModes then sayMode = 1 end
|
if sayMode > #SayModes then sayMode = 1 end
|
||||||
|
|
||||||
buttom:setIcon(SayModes[sayMode].icon)
|
buttom:setIcon(SayModes[sayMode].icon)
|
||||||
buttom.sayMode = sayMode
|
buttom.sayMode = sayMode
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hooked events
|
-- hooked events
|
||||||
|
@ -311,7 +310,7 @@ local function onOpenPrivateChannel(receiver)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function doChannelListSubmit(channelsWindow)
|
local function doChannelListSubmit(channelsWindow)
|
||||||
local channelListPanel = channelsWindow:getChildById('channelList')
|
local channelListPanel = channelsWindow:getChildById('channelList')
|
||||||
local openPrivateChannelWith = channelsWindow:getChildById('openPrivateChannelWith'):getText()
|
local openPrivateChannelWith = channelsWindow:getChildById('openPrivateChannelWith'):getText()
|
||||||
if openPrivateChannelWith ~= '' then
|
if openPrivateChannelWith ~= '' then
|
||||||
|
@ -328,7 +327,7 @@ local function onChannelList(channelList)
|
||||||
local channelsWindow = displayUI('channelswindow.otui')
|
local channelsWindow = displayUI('channelswindow.otui')
|
||||||
local channelListPanel = channelsWindow:getChildById('channelList')
|
local channelListPanel = channelsWindow:getChildById('channelList')
|
||||||
connect(channelsWindow, { onEnter = function () doChannelListSubmit(channelsWindow) end } )
|
connect(channelsWindow, { onEnter = function () doChannelListSubmit(channelsWindow) end } )
|
||||||
|
|
||||||
for k,v in pairs(channelList) do
|
for k,v in pairs(channelList) do
|
||||||
local channelId = v[1]
|
local channelId = v[1]
|
||||||
local channelName = v[2]
|
local channelName = v[2]
|
||||||
|
@ -337,7 +336,7 @@ local function onChannelList(channelList)
|
||||||
local label = createWidget('ChannelListLabel', channelListPanel)
|
local label = createWidget('ChannelListLabel', channelListPanel)
|
||||||
label.channelId = channelId
|
label.channelId = channelId
|
||||||
label:setText(channelName)
|
label:setText(channelName)
|
||||||
|
|
||||||
label:setPhantom(false)
|
label:setPhantom(false)
|
||||||
connect(label, { onMouseDoubleClick = function () doChannelListSubmit(channelsWindow) end } )
|
connect(label, { onMouseDoubleClick = function () doChannelListSubmit(channelsWindow) end } )
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,6 @@ namespace Fw
|
||||||
KeyEscape = 1,
|
KeyEscape = 1,
|
||||||
KeyTab = 2,
|
KeyTab = 2,
|
||||||
KeyBackspace = 3,
|
KeyBackspace = 3,
|
||||||
KeyReturn = 4,
|
|
||||||
KeyEnter = 5,
|
KeyEnter = 5,
|
||||||
KeyInsert = 6,
|
KeyInsert = 6,
|
||||||
KeyDelete = 7,
|
KeyDelete = 7,
|
||||||
|
|
|
@ -41,7 +41,7 @@ WIN32Window::WIN32Window()
|
||||||
|
|
||||||
m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
|
m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
|
||||||
m_keyMap[VK_TAB] = Fw::KeyTab;
|
m_keyMap[VK_TAB] = Fw::KeyTab;
|
||||||
m_keyMap[VK_RETURN] = Fw::KeyReturn;
|
m_keyMap[VK_RETURN] = Fw::KeyEnter;
|
||||||
m_keyMap[VK_BACK] = Fw::KeyBackspace;
|
m_keyMap[VK_BACK] = Fw::KeyBackspace;
|
||||||
m_keyMap[VK_SPACE] = Fw::KeySpace;
|
m_keyMap[VK_SPACE] = Fw::KeySpace;
|
||||||
|
|
||||||
|
@ -162,7 +162,6 @@ WIN32Window::WIN32Window()
|
||||||
m_keyMap[VK_DECIMAL] = Fw::KeyPeriod;
|
m_keyMap[VK_DECIMAL] = Fw::KeyPeriod;
|
||||||
m_keyMap[VK_DIVIDE] = Fw::KeySlash;
|
m_keyMap[VK_DIVIDE] = Fw::KeySlash;
|
||||||
m_keyMap[VK_MULTIPLY] = Fw::KeyAsterisk;
|
m_keyMap[VK_MULTIPLY] = Fw::KeyAsterisk;
|
||||||
m_keyMap[VK_SEPARATOR] = Fw::KeyEnter;
|
|
||||||
|
|
||||||
// keypad with numlock off
|
// keypad with numlock off
|
||||||
m_keyMap[VK_NUMPAD0] = Fw::KeyNumpad0;
|
m_keyMap[VK_NUMPAD0] = Fw::KeyNumpad0;
|
||||||
|
@ -423,6 +422,51 @@ void WIN32Window::poll()
|
||||||
updateUnmaximizedCoords();
|
updateUnmaximizedCoords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fw::Key WIN32Window::retranslateVirtualKey(WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if(!(((HIWORD(lParam) >> 8) & 0xFF) & 1)) {
|
||||||
|
// ignore numpad keys when numlock is on
|
||||||
|
if((wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9) || wParam == VK_SEPARATOR)
|
||||||
|
return Fw::KeyUnknown;
|
||||||
|
|
||||||
|
// retranslate numpad keys
|
||||||
|
switch(wParam) {
|
||||||
|
case VK_INSERT:
|
||||||
|
wParam = VK_NUMPAD0;
|
||||||
|
break;
|
||||||
|
case VK_END:
|
||||||
|
wParam = VK_NUMPAD1;
|
||||||
|
break;
|
||||||
|
case VK_DOWN:
|
||||||
|
wParam = VK_NUMPAD2;
|
||||||
|
break;
|
||||||
|
case VK_NEXT:
|
||||||
|
wParam = VK_NUMPAD3;
|
||||||
|
break;
|
||||||
|
case VK_LEFT:
|
||||||
|
wParam = VK_NUMPAD4;
|
||||||
|
break;
|
||||||
|
case VK_CLEAR:
|
||||||
|
wParam = VK_NUMPAD5;
|
||||||
|
break;
|
||||||
|
case VK_RIGHT:
|
||||||
|
wParam = VK_NUMPAD6;
|
||||||
|
break;
|
||||||
|
case VK_HOME:
|
||||||
|
wParam = VK_NUMPAD7;
|
||||||
|
break;
|
||||||
|
case VK_UP:
|
||||||
|
wParam = VK_NUMPAD8;
|
||||||
|
break;
|
||||||
|
case VK_PRIOR:
|
||||||
|
wParam = VK_NUMPAD9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_keyMap[wParam];
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
|
@ -452,11 +496,11 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_KEYDOWN: {
|
case WM_KEYDOWN: {
|
||||||
processKeyDown(m_keyMap[wParam]);
|
processKeyDown(retranslateVirtualKey(wParam, lParam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_KEYUP: {
|
case WM_KEYUP: {
|
||||||
processKeyUp(m_keyMap[wParam]);
|
processKeyUp(retranslateVirtualKey(wParam, lParam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_LBUTTONDOWN: {
|
case WM_LBUTTONDOWN: {
|
||||||
|
@ -641,7 +685,6 @@ void WIN32Window::setTitle(const std::string& title)
|
||||||
|
|
||||||
void WIN32Window::setMinimumSize(const Size& minimumSize)
|
void WIN32Window::setMinimumSize(const Size& minimumSize)
|
||||||
{
|
{
|
||||||
dump << "set minimum";
|
|
||||||
m_minimumSize = minimumSize;
|
m_minimumSize = minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,3 +813,4 @@ std::string WIN32Window::getPlatformType()
|
||||||
{
|
{
|
||||||
return "WIN32-WGL";
|
return "WIN32-WGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ class WIN32Window : public PlatformWindow
|
||||||
LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
friend class WindowProcProxy;
|
friend class WindowProcProxy;
|
||||||
|
|
||||||
|
Fw::Key retranslateVirtualKey(WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WIN32Window();
|
WIN32Window();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ X11Window::X11Window()
|
||||||
|
|
||||||
m_keyMap[XK_Escape] = Fw::KeyEscape;
|
m_keyMap[XK_Escape] = Fw::KeyEscape;
|
||||||
m_keyMap[XK_Tab] = Fw::KeyTab;
|
m_keyMap[XK_Tab] = Fw::KeyTab;
|
||||||
m_keyMap[XK_Return] = Fw::KeyReturn;
|
m_keyMap[XK_Return] = Fw::KeyEnter;
|
||||||
m_keyMap[XK_BackSpace] = Fw::KeyBackspace;
|
m_keyMap[XK_BackSpace] = Fw::KeyBackspace;
|
||||||
|
|
||||||
m_keyMap[XK_Page_Up] = Fw::KeyPageUp;
|
m_keyMap[XK_Page_Up] = Fw::KeyPageUp;
|
||||||
|
|
Loading…
Reference in New Issue