Skip to content

Commit ac40899

Browse files
committed
only care if the specified modifiers are pressed while ignoring extras
1 parent 1e8b1df commit ac40899

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

src/main/kotlin/com/lambda/event/events/KeyboardEvent.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ package com.lambda.event.events
2020
import com.lambda.config.settings.complex.Bind
2121
import com.lambda.event.Event
2222
import com.lambda.util.KeyCode
23-
import org.lwjgl.glfw.GLFW.GLFW_MOD_ALT
24-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CAPS_LOCK
25-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CONTROL
26-
import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
27-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
28-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
2923
import org.lwjgl.glfw.GLFW.GLFW_PRESS
3024
import org.lwjgl.glfw.GLFW.GLFW_RELEASE
3125

@@ -55,7 +49,7 @@ sealed class KeyboardEvent {
5549
val isPressed = action >= GLFW_PRESS
5650
val isReleased = action == GLFW_RELEASE
5751

58-
fun satisfies(bind: Bind) = bind.key == keyCode && bind.modifiers == modifiers
52+
fun satisfies(bind: Bind) = bind.key == keyCode && bind.modifiers and modifiers == bind.modifiers
5953
}
6054

6155
/**

src/main/kotlin/com/lambda/event/events/MouseEvent.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@ package com.lambda.event.events
2020
import com.lambda.config.settings.complex.Bind
2121
import com.lambda.event.callback.Cancellable
2222
import com.lambda.event.callback.ICancellable
23-
import com.lambda.util.Mouse
2423
import com.lambda.util.math.Vec2d
25-
import org.lwjgl.glfw.GLFW.GLFW_MOD_ALT
26-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CAPS_LOCK
27-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CONTROL
28-
import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
29-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
30-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
3124

3225
sealed class MouseEvent {
3326
/**
@@ -45,9 +38,7 @@ sealed class MouseEvent {
4538
val isReleased = action == 0
4639
val isPressed = action == 1
4740

48-
fun satisfies(bind: Bind) = bind.modifiers == modifiers && bind.mouse == button
49-
50-
fun hasModifier(mod: Int) = modifiers and mod == mod
41+
fun satisfies(bind: Bind) = bind.modifiers and modifiers == bind.modifiers && bind.mouse == button
5142
}
5243

5344
/**

0 commit comments

Comments
 (0)