PhysicalConnectivity/src/main/kotlin/net/shadowfacts/cacao/util/KeyModifiers.kt

36 lines
735 B
Kotlin
Raw Normal View History

2021-02-27 19:02:30 +00:00
package net.shadowfacts.cacao.util
import org.lwjgl.glfw.GLFW
/**
2021-02-28 17:19:09 +00:00
* A set of modifier keys that are being pressed at given instant.
*
2021-02-27 19:02:30 +00:00
* @author shadowfacts
2021-02-28 17:19:09 +00:00
* @param value The integer representation of the pressed modifiers as received from GLFW.
2021-02-27 19:02:30 +00:00
*/
class KeyModifiers(val value: Int) {
val shift: Boolean
get() = this[GLFW.GLFW_MOD_SHIFT]
val control: Boolean
get() = this[GLFW.GLFW_MOD_CONTROL]
val alt: Boolean
get() = this[GLFW.GLFW_MOD_ALT]
val command: Boolean
get() = this[GLFW.GLFW_MOD_SUPER]
val capsLock: Boolean
get() = this[GLFW.GLFW_MOD_CAPS_LOCK]
val numLock: Boolean
get() = this[GLFW.GLFW_MOD_NUM_LOCK]
private operator fun get(mod: Int): Boolean {
return (value and mod) == mod
}
2021-02-28 17:19:09 +00:00
}