36 lines
735 B
Kotlin
36 lines
735 B
Kotlin
package net.shadowfacts.cacao.util
|
|
|
|
import org.lwjgl.glfw.GLFW
|
|
|
|
/**
|
|
* A set of modifier keys that are being pressed at given instant.
|
|
*
|
|
* @author shadowfacts
|
|
* @param value The integer representation of the pressed modifiers as received from GLFW.
|
|
*/
|
|
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
|
|
}
|
|
|
|
}
|