mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-09-26 20:11:28 +08:00
internal/ui: bug fix: move handling mod keys to ui.InputState
Closes #3320
This commit is contained in:
@@ -51,20 +51,7 @@ func (i *inputState) AppendInputChars(runes []rune) []rune {
|
||||
func (i *inputState) IsKeyPressed(key ui.Key) bool {
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
|
||||
tick := ui.Get().Tick()
|
||||
switch key {
|
||||
case ui.KeyAlt:
|
||||
return i.state.IsKeyPressed(ui.KeyAltLeft, tick) || i.state.IsKeyPressed(ui.KeyAltRight, tick)
|
||||
case ui.KeyControl:
|
||||
return i.state.IsKeyPressed(ui.KeyControlLeft, tick) || i.state.IsKeyPressed(ui.KeyControlRight, tick)
|
||||
case ui.KeyShift:
|
||||
return i.state.IsKeyPressed(ui.KeyShiftLeft, tick) || i.state.IsKeyPressed(ui.KeyShiftRight, tick)
|
||||
case ui.KeyMeta:
|
||||
return i.state.IsKeyPressed(ui.KeyMetaLeft, tick) || i.state.IsKeyPressed(ui.KeyMetaRight, tick)
|
||||
default:
|
||||
return i.state.IsKeyPressed(key, tick)
|
||||
}
|
||||
return i.state.IsKeyPressed(key, ui.Get().Tick())
|
||||
}
|
||||
|
||||
func (i *inputState) IsKeyJustPressed(key ui.Key) bool {
|
||||
|
@@ -95,6 +95,17 @@ func (i *InputState) releaseAllButtons(t InputTime) {
|
||||
}
|
||||
|
||||
func (i *InputState) IsKeyPressed(key Key, tick int64) bool {
|
||||
switch key {
|
||||
case KeyAlt:
|
||||
return i.IsKeyPressed(KeyAltLeft, tick) || i.IsKeyPressed(KeyAltRight, tick)
|
||||
case KeyControl:
|
||||
return i.IsKeyPressed(KeyControlLeft, tick) || i.IsKeyPressed(KeyControlRight, tick)
|
||||
case KeyShift:
|
||||
return i.IsKeyPressed(KeyShiftLeft, tick) || i.IsKeyPressed(KeyShiftRight, tick)
|
||||
case KeyMeta:
|
||||
return i.IsKeyPressed(KeyMetaLeft, tick) || i.IsKeyPressed(KeyMetaRight, tick)
|
||||
}
|
||||
|
||||
if key < 0 || KeyMax < key {
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user