mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-19 03:49:12 +00:00
Add Mouse Binding (#1092)
This commit is contained in:
1 parent
ebe83f970f
commit
e9a3a494d5
24 files changed
+303
-43
No files matched your search
@@ -56,18 +56,24 @@ public class NEIKeyboardUtils {
|
||||
return keyText.toString();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind) {
|
||||
keyBind = keyHashMap.getOrDefault(keyBind, keyBind);
|
||||
StringJoiner keyText = new StringJoiner(" + ");
|
||||
String hashText = getHashName(keyBind);
|
||||
int keyID = unhash(keyBind);
|
||||
/**
|
||||
* Mouse buttons are negative key codes, so the hash can not be packed into them and is passed separately.
|
||||
*/
|
||||
public static String getKeyName(int keyCode, int hash) {
|
||||
if (hash == 0 && keyHashMap.containsKey(keyCode)) {
|
||||
hash = keyHashMap.get(keyCode);
|
||||
keyCode = Keyboard.CHAR_NONE;
|
||||
}
|
||||
|
||||
final StringJoiner keyText = new StringJoiner(" + ");
|
||||
final String hashText = getHashName(hash);
|
||||
|
||||
if (!hashText.isEmpty()) {
|
||||
keyText.add(hashText);
|
||||
}
|
||||
|
||||
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
|
||||
keyText.add(keyID < 0 ? NEIMouseUtils.getKeyName(keyID + 100) : Keyboard.getKeyName(keyID));
|
||||
if (keyCode != Keyboard.CHAR_NONE || hashText.isEmpty()) {
|
||||
keyText.add(keyCode < 0 ? NEIMouseUtils.getKeyName(keyCode + 100) : Keyboard.getKeyName(keyCode));
|
||||
}
|
||||
|
||||
return keyText.toString();
|
||||
|
||||
Reference in new issue
Block a user