diff --git a/modules/lwjgl/src/main/kotlin/org/lwjgl/input/Mouse.kt b/modules/lwjgl/src/main/kotlin/org/lwjgl/input/Mouse.kt index 0544f07..a99c7e8 100644 --- a/modules/lwjgl/src/main/kotlin/org/lwjgl/input/Mouse.kt +++ b/modules/lwjgl/src/main/kotlin/org/lwjgl/input/Mouse.kt @@ -21,6 +21,7 @@ object Mouse { @JvmStatic fun getY(): Int = implementation.getY() @JvmStatic fun getDX(): Int = implementation.getDX() @JvmStatic fun getDY(): Int = implementation.getDY() + @JvmStatic fun getDWheel(): Int = implementation.getDWheel() @JvmStatic fun getEventButton(): Int = implementation.getEventButton() @JvmStatic fun getEventButtonState(): Boolean = implementation.getEventButtonState() diff --git a/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/api/input/Mouse.kt b/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/api/input/Mouse.kt index 770ae8d..bcd08ef 100644 --- a/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/api/input/Mouse.kt +++ b/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/api/input/Mouse.kt @@ -8,6 +8,7 @@ interface IMouse { fun getDX(): Int fun getDY(): Int + fun getDWheel(): Int fun getEventButton(): Int fun getEventButtonState(): Boolean diff --git a/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/impl/input/Mouse.kt b/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/impl/input/Mouse.kt index 2a070b1..d842ea7 100644 --- a/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/impl/input/Mouse.kt +++ b/modules/lwjgl/src/main/kotlin/org/polyfrost/lwjgl/impl/input/Mouse.kt @@ -52,7 +52,7 @@ class MouseImpl(private val window: GLFWwindow, private val display: IDisplay) : } fun setRawInput(raw: Boolean) { - glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, raw.toInt()); + glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, raw.toInt()) } override fun destroy() {} @@ -61,6 +61,7 @@ class MouseImpl(private val window: GLFWwindow, private val display: IDisplay) : override fun getY(): Int = display.getHeight() - y override fun getDX(): Int = xDelta.toInt() override fun getDY(): Int = yDelta.toInt() + override fun getDWheel(): Int = scrollDelta override fun getEventButton(): Int = currentEvent?.button ?: -1 override fun getEventButtonState(): Boolean = currentEvent?.buttonState ?: false @@ -87,6 +88,7 @@ class MouseImpl(private val window: GLFWwindow, private val display: IDisplay) : override fun poll() { xDelta = 0.0 yDelta = 0.0 + scrollDelta = 0 } override fun getButtonCount(): Int = size @@ -113,6 +115,8 @@ class MouseImpl(private val window: GLFWwindow, private val display: IDisplay) : @Suppress("UNUSED_PARAMETER") private fun mouseButtonHandler(window: Long, button: Int, action: Int, mods: Int) { + buttonStates[button] = action == GLFW_PRESS + events.addLast( createEvent( button, @@ -154,7 +158,7 @@ class MouseImpl(private val window: GLFWwindow, private val display: IDisplay) : @Suppress("UNUSED_PARAMETER") private fun mouseScrollHandler(window: Long, x: Double, y: Double) { - scrollDelta = y.toInt() + scrollDelta += y.toInt() events.addLast( createEvent(