|
@@ -1,6 +1,8 @@
|
|
package me.shedaniel.clothconfig2.api;
|
|
package me.shedaniel.clothconfig2.api;
|
|
|
|
|
|
import me.shedaniel.clothconfig2.impl.ModifierKeyCodeImpl;
|
|
import me.shedaniel.clothconfig2.impl.ModifierKeyCodeImpl;
|
|
|
|
+import me.shedaniel.clothconfig2.mixin.MouseHooks;
|
|
|
|
+import net.minecraft.client.MinecraftClient;
|
|
import net.minecraft.client.util.InputUtil;
|
|
import net.minecraft.client.util.InputUtil;
|
|
|
|
|
|
public interface ModifierKeyCode {
|
|
public interface ModifierKeyCode {
|
|
@@ -13,10 +15,12 @@ public interface ModifierKeyCode {
|
|
Modifier getModifier();
|
|
Modifier getModifier();
|
|
|
|
|
|
default boolean matchesMouse(int button) {
|
|
default boolean matchesMouse(int button) {
|
|
- return getType() == InputUtil.Type.MOUSE && getKeyCode().getKeyCode() == button && getModifier().matchesCurrent();
|
|
|
|
|
|
+ return !isUnknown() && getType() == InputUtil.Type.MOUSE && getKeyCode().getKeyCode() == button && getModifier().matchesCurrent();
|
|
}
|
|
}
|
|
|
|
|
|
default boolean matchesKey(int keyCode, int scanCode) {
|
|
default boolean matchesKey(int keyCode, int scanCode) {
|
|
|
|
+ if (isUnknown())
|
|
|
|
+ return false;
|
|
if (keyCode == InputUtil.UNKNOWN_KEYCODE.getKeyCode()) {
|
|
if (keyCode == InputUtil.UNKNOWN_KEYCODE.getKeyCode()) {
|
|
return getType() == InputUtil.Type.SCANCODE && getKeyCode().getKeyCode() == scanCode && getModifier().matchesCurrent();
|
|
return getType() == InputUtil.Type.SCANCODE && getKeyCode().getKeyCode() == scanCode && getModifier().matchesCurrent();
|
|
} else {
|
|
} else {
|
|
@@ -24,6 +28,24 @@ public interface ModifierKeyCode {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ default boolean matchesCurrentMouse() {
|
|
|
|
+ if (!isUnknown() && getType() == InputUtil.Type.MOUSE && getModifier().matchesCurrent()) {
|
|
|
|
+ switch (getKeyCode().getKeyCode()) {
|
|
|
|
+ case 0:
|
|
|
|
+ return MinecraftClient.getInstance().mouse.wasLeftButtonClicked();
|
|
|
|
+ case 1:
|
|
|
|
+ return MinecraftClient.getInstance().mouse.wasRightButtonClicked();
|
|
|
|
+ case 2:
|
|
|
|
+ return ((MouseHooks) MinecraftClient.getInstance().mouse).middleButtonClicked();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ default boolean matchesCurrentKey() {
|
|
|
|
+ return !isUnknown() && getType() == InputUtil.Type.KEYSYM && getModifier().matchesCurrent() && InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), getKeyCode().getKeyCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
ModifierKeyCode setKeyCode(InputUtil.KeyCode keyCode);
|
|
ModifierKeyCode setKeyCode(InputUtil.KeyCode keyCode);
|
|
|
|
|
|
ModifierKeyCode setModifier(Modifier modifier);
|
|
ModifierKeyCode setModifier(Modifier modifier);
|