fixed right alt for certain keyboard layouts not working as a modifier to input characters (e.g. the German layout, where it's needed for a couple of chars mainly in the numbers row), since it's actually emitting Alt+Ctrl, and when ctrl was pressed everything was treated like a key-combo; not resending control keys that are usually held down, to avoid packet spam (ctrl, alt, shift, meta)

This commit is contained in:
Florian Nücke 2013-12-16 21:32:31 +01:00
parent f72ade50d9
commit ea05e5a4d6
2 changed files with 18 additions and 3 deletions

View File

@ -225,6 +225,8 @@ local function enter()
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
end
local controlKeyCombos = {[keyboard.keys.s]=true,[keyboard.keys.w]=true,
[keyboard.keys.c]=true,[keyboard.keys.x]=true}
local function onKeyDown(char, code)
if code == keyboard.keys.back and not readonly then
if left() then
@ -252,7 +254,7 @@ local function onKeyDown(char, code)
down(h - 1)
elseif code == keyboard.keys.enter and not readonly then
enter()
elseif keyboard.isControlDown() then
elseif keyboard.isControlDown() and controlKeyCombos[code] then
local cbx, cby = getCursor()
if code == keyboard.keys.s and not readonly then
local new = not fs.exists(filename)

View File

@ -77,8 +77,10 @@ trait Buffer extends GuiScreen {
}
else if (Keyboard.getEventKeyState) {
val char = Keyboard.getEventCharacter
PacketSender.sendKeyDown(buffer.owner, char, code)
pressedKeys += code -> char
if (!pressedKeys.contains(code) || !ignoreRepeat(char, code)) {
PacketSender.sendKeyDown(buffer.owner, char, code)
pressedKeys += code -> char
}
}
else pressedKeys.remove(code) match {
case Some(char) => PacketSender.sendKeyUp(buffer.owner, char, code)
@ -94,4 +96,15 @@ trait Buffer extends GuiScreen {
}
protected def changeSize(w: Double, h: Double): Double
private def ignoreRepeat(char: Char, code: Int) = {
code == Keyboard.KEY_LCONTROL ||
code == Keyboard.KEY_RCONTROL ||
code == Keyboard.KEY_LMENU ||
code == Keyboard.KEY_RMENU ||
code == Keyboard.KEY_LSHIFT ||
code == Keyboard.KEY_RSHIFT ||
code == Keyboard.KEY_LMETA ||
code == Keyboard.KEY_RMETA
}
}