mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Prevent Char-to-code crash (#6392)
This commit is contained in:
parent
cf21ade76e
commit
130fd653a4
@ -64,7 +64,15 @@ data class KeyCharAndCode(val char: Char, val code: Int) {
|
||||
val UNKNOWN = KeyCharAndCode(Input.Keys.UNKNOWN)
|
||||
|
||||
/** mini-factory for control codes - case insensitive */
|
||||
fun ctrl(letter: Char) = KeyCharAndCode(Char(letter.code and 31), 0)
|
||||
fun ctrl(letter: Char) = KeyCharAndCode(Char(
|
||||
try {
|
||||
letter.code and 31
|
||||
} catch (ex: NoSuchMethodError) {
|
||||
// Seems to happen on some Ubuntu systems
|
||||
@Suppress("DEPRECATION")
|
||||
letter.toInt() and 31
|
||||
}
|
||||
), 0)
|
||||
|
||||
/** mini-factory for control codes from keyCodes */
|
||||
fun ctrlFromCode(keyCode: Int): KeyCharAndCode {
|
||||
|
Loading…
x
Reference in New Issue
Block a user