MacOS Command key accessibility (#354)

* MacOS Command key accessibility

* MacOS Command key accessibility

* Fixed spotless violation build error

* Fixed RMENU key to RMETA as CTRL on MacOS
This commit is contained in:
r1tsuu authored and GitHub committed 2023-02-28 15:53:59 +01:00
1 parent 89cc203875
commit 9df6ab0232
2 files changed
+12 -2

No files matched your search

@@ -359,11 +359,18 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
this.icons[2] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 64, 0, 16, 16).build();
}
private boolean getIsAccessibleControlEventKey() {
if (Minecraft.isRunningOnMac) {
return Keyboard.getEventKey() == Keyboard.KEY_LMETA || Keyboard.getEventKey() == Keyboard.KEY_RMETA;
}
return Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL;
}
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL)) {
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) {
NEIClientConfig.cycleSetting("inventory.cheatmode", 3);
} else {
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
@@ -251,6 +251,9 @@ public class NEIClientUtils extends NEIServerUtils {
}
public static boolean controlKey() {
if (Minecraft.isRunningOnMac) {
return Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA);
}
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
}