mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -04:00
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:
parent
f72ade50d9
commit
ea05e5a4d6
@ -225,6 +225,8 @@ local function enter()
|
|||||||
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local controlKeyCombos = {[keyboard.keys.s]=true,[keyboard.keys.w]=true,
|
||||||
|
[keyboard.keys.c]=true,[keyboard.keys.x]=true}
|
||||||
local function onKeyDown(char, code)
|
local function onKeyDown(char, code)
|
||||||
if code == keyboard.keys.back and not readonly then
|
if code == keyboard.keys.back and not readonly then
|
||||||
if left() then
|
if left() then
|
||||||
@ -252,7 +254,7 @@ local function onKeyDown(char, code)
|
|||||||
down(h - 1)
|
down(h - 1)
|
||||||
elseif code == keyboard.keys.enter and not readonly then
|
elseif code == keyboard.keys.enter and not readonly then
|
||||||
enter()
|
enter()
|
||||||
elseif keyboard.isControlDown() then
|
elseif keyboard.isControlDown() and controlKeyCombos[code] then
|
||||||
local cbx, cby = getCursor()
|
local cbx, cby = getCursor()
|
||||||
if code == keyboard.keys.s and not readonly then
|
if code == keyboard.keys.s and not readonly then
|
||||||
local new = not fs.exists(filename)
|
local new = not fs.exists(filename)
|
||||||
|
@ -77,8 +77,10 @@ trait Buffer extends GuiScreen {
|
|||||||
}
|
}
|
||||||
else if (Keyboard.getEventKeyState) {
|
else if (Keyboard.getEventKeyState) {
|
||||||
val char = Keyboard.getEventCharacter
|
val char = Keyboard.getEventCharacter
|
||||||
PacketSender.sendKeyDown(buffer.owner, char, code)
|
if (!pressedKeys.contains(code) || !ignoreRepeat(char, code)) {
|
||||||
pressedKeys += code -> char
|
PacketSender.sendKeyDown(buffer.owner, char, code)
|
||||||
|
pressedKeys += code -> char
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else pressedKeys.remove(code) match {
|
else pressedKeys.remove(code) match {
|
||||||
case Some(char) => PacketSender.sendKeyUp(buffer.owner, char, code)
|
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
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user