diff --git a/src/itdelatrisu/opsu/GameMod.java b/src/itdelatrisu/opsu/GameMod.java index 60c7c492..8449db60 100644 --- a/src/itdelatrisu/opsu/GameMod.java +++ b/src/itdelatrisu/opsu/GameMod.java @@ -27,39 +27,40 @@ import java.util.Collections; import org.newdawn.slick.Color; import org.newdawn.slick.Image; -import org.newdawn.slick.Input; + +import static org.lwjgl.input.Keyboard.*; /** * Game mods. */ public enum GameMod { - EASY (Category.EASY, 0, GameImage.MOD_EASY, "EZ", 2, Input.KEY_Q, 0.5f, + EASY (Category.EASY, 0, GameImage.MOD_EASY, "EZ", 2, KEY_Q, 0.5f, "Easy", "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required."), - NO_FAIL (Category.EASY, 1, GameImage.MOD_NO_FAIL, "NF", 1, Input.KEY_W, 0.5f, + NO_FAIL (Category.EASY, 1, GameImage.MOD_NO_FAIL, "NF", 1, KEY_W, 0.5f, "NoFail", "You can't fail. No matter what."), - HALF_TIME (Category.EASY, 2, GameImage.MOD_HALF_TIME, "HT", 256, Input.KEY_E, 0.3f, + HALF_TIME (Category.EASY, 2, GameImage.MOD_HALF_TIME, "HT", 256, KEY_E, 0.3f, "HalfTime", "Less zoom."), - HARD_ROCK (Category.HARD, 0, GameImage.MOD_HARD_ROCK, "HR", 16, Input.KEY_A, 1.06f, + HARD_ROCK (Category.HARD, 0, GameImage.MOD_HARD_ROCK, "HR", 16, KEY_A, 1.06f, "HardRock", "Everything just got a bit harder..."), - SUDDEN_DEATH (Category.HARD, 1, GameImage.MOD_SUDDEN_DEATH, "SD", 32, Input.KEY_S, 1f, + SUDDEN_DEATH (Category.HARD, 1, GameImage.MOD_SUDDEN_DEATH, "SD", 32, KEY_S, 1f, "SuddenDeath", "Miss a note and fail."), // PERFECT (Category.HARD, 1, GameImage.MOD_PERFECT, "PF", 64, Input.KEY_S, 1f, // "Perfect", "SS or quit."), - DOUBLE_TIME (Category.HARD, 2, GameImage.MOD_DOUBLE_TIME, "DT", 64, Input.KEY_D, 1.12f, + DOUBLE_TIME (Category.HARD, 2, GameImage.MOD_DOUBLE_TIME, "DT", 64, KEY_D, 1.12f, "DoubleTime", "Zoooooooooom."), // NIGHTCORE (Category.HARD, 2, GameImage.MOD_NIGHTCORE, "NT", 64, Input.KEY_D, 1.12f, // "Nightcore", "uguuuuuuuu"), - HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, Input.KEY_F, 1.06f, + HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, KEY_F, 1.06f, "Hidden", "Play with no approach circles and fading notes for a slight score advantage."), - FLASHLIGHT (Category.HARD, 4, GameImage.MOD_FLASHLIGHT, "FL", 1024, Input.KEY_G, 1.12f, + FLASHLIGHT (Category.HARD, 4, GameImage.MOD_FLASHLIGHT, "FL", 1024, KEY_G, 1.12f, "Flashlight", "Restricted view area."), - RELAX (Category.SPECIAL, 0, GameImage.MOD_RELAX, "RL", 128, Input.KEY_Z, 0f, + RELAX (Category.SPECIAL, 0, GameImage.MOD_RELAX, "RL", 128, KEY_Z, 0f, "Relax", "You don't need to click.\nGive your clicking/tapping finger a break from the heat of things.\n**UNRANKED**"), - AUTOPILOT (Category.SPECIAL, 1, GameImage.MOD_AUTOPILOT, "AP", 8192, Input.KEY_X, 0f, + AUTOPILOT (Category.SPECIAL, 1, GameImage.MOD_AUTOPILOT, "AP", 8192, KEY_X, 0f, "Relax2", "Automatic cursor movement - just follow the rhythm.\n**UNRANKED**"), - SPUN_OUT (Category.SPECIAL, 2, GameImage.MOD_SPUN_OUT, "SO", 4096, Input.KEY_C, 0.9f, + SPUN_OUT (Category.SPECIAL, 2, GameImage.MOD_SPUN_OUT, "SO", 4096, KEY_C, 0.9f, "SpunOut", "Spinners will be automatically completed."), - AUTO (Category.SPECIAL, 3, GameImage.MOD_AUTO, "", 2048, Input.KEY_V, 1f, + AUTO (Category.SPECIAL, 3, GameImage.MOD_AUTO, "", 2048, KEY_V, 1f, "Autoplay", "Watch a perfect automated play through the song."); /** Mod categories. */ diff --git a/src/itdelatrisu/opsu/states/ButtonMenu.java b/src/itdelatrisu/opsu/states/ButtonMenu.java index c0b6ea1c..acc66611 100644 --- a/src/itdelatrisu/opsu/states/ButtonMenu.java +++ b/src/itdelatrisu/opsu/states/ButtonMenu.java @@ -35,6 +35,7 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation; import java.util.ArrayList; import java.util.List; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; @@ -650,7 +651,7 @@ public class ButtonMenu extends BaseOpsuState { return true; } - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { menuState.leave(); return true; } diff --git a/src/itdelatrisu/opsu/states/DownloadsMenu.java b/src/itdelatrisu/opsu/states/DownloadsMenu.java index c9936a57..23fe14b8 100644 --- a/src/itdelatrisu/opsu/states/DownloadsMenu.java +++ b/src/itdelatrisu/opsu/states/DownloadsMenu.java @@ -55,6 +55,7 @@ import org.newdawn.slick.util.Log; import yugecin.opsudance.core.state.ComplexOpsuState; import yugecin.opsudance.events.BarNotifListener; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; /** @@ -888,12 +889,12 @@ public class DownloadsMenu extends ComplexOpsuState { } // block input during beatmap importing - if (importThread != null && key != Input.KEY_ESCAPE) { + if (importThread != null && key != KEY_ESCAPE) { return true; } switch (key) { - case Input.KEY_ESCAPE: + case KEY_ESCAPE: if (importThread != null) { // beatmap importing: stop parsing beatmaps by sending interrupt to BeatmapParser importThread.interrupt(); @@ -908,13 +909,13 @@ public class DownloadsMenu extends ComplexOpsuState { displayContainer.switchState(mainmenuState); } return true; - case Input.KEY_ENTER: + case KEY_RETURN: if (!search.getText().isEmpty()) { pageDir = Page.RESET; resetSearchTimer(); } return true; - case Input.KEY_F5: + case KEY_F5: SoundController.playSound(SoundEffect.MENUCLICK); lastQuery = null; pageDir = Page.CURRENT; @@ -924,7 +925,7 @@ public class DownloadsMenu extends ComplexOpsuState { return true; } // wait for user to finish typing - if (Character.isLetterOrDigit(c) || key == Input.KEY_BACK) { + if (Character.isLetterOrDigit(c) || key == KEY_BACK) { search.keyPressed(key, c); searchTimer = 0; pageDir = Page.RESET; diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 1b242daf..bd0b8bac 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -67,6 +67,7 @@ import yugecin.opsudance.ui.OptionsOverlay; import yugecin.opsudance.ui.StoryboardOverlay; import yugecin.opsudance.utils.GLHelper; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.core.InstanceContainer.*; @@ -1127,7 +1128,7 @@ public class Game extends ComplexOpsuState { } switch (key) { - case Input.KEY_ESCAPE: + case KEY_ESCAPE: // "auto" mod or watching replay: go back to song menu if (GameMod.AUTO.isActive() || isReplay) { onCloseRequest(); @@ -1144,13 +1145,13 @@ public class Game extends ComplexOpsuState { } displayContainer.switchStateInstantly(pauseState); break; - case Input.KEY_SPACE: + case KEY_SPACE: // skip intro skipIntro(); break; - case Input.KEY_R: + case KEY_R: // restart - if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { + if (input.isControlDown()) { if (trackPosition < beatmap.objects[0].getTime()) { retries--; // don't count this retry (cancel out later increment) } @@ -1159,9 +1160,9 @@ public class Game extends ComplexOpsuState { skipIntro(); } break; - case Input.KEY_S: + case KEY_S: // save checkpoint - if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { + if (input.isControlDown()) { if (isLeadIn()) { break; } @@ -1175,9 +1176,9 @@ public class Game extends ComplexOpsuState { } } break; - case Input.KEY_L: + case KEY_L: // load checkpoint - if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { + if (input.isControlDown()) { int checkpoint = OPTION_CHECKPOINT.val * 1000; if (checkpoint == 0 || checkpoint > beatmap.endTime) break; // invalid checkpoint @@ -1186,25 +1187,25 @@ public class Game extends ComplexOpsuState { BarNotifListener.EVENT.make().onBarNotif("Checkpoint loaded."); } break; - case Input.KEY_F: + case KEY_F: // change playback speed if (isReplay || GameMod.AUTO.isActive()) { playbackSpeed = playbackSpeed.next(); MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier()); } break; - case Input.KEY_UP: + case KEY_UP: UI.changeVolume(1); break; - case Input.KEY_DOWN: + case KEY_DOWN: UI.changeVolume(-1); break; - case Input.KEY_TAB: + case KEY_TAB: if (!OPTION_DANCE_HIDE_UI.state) { scoreboardVisible = !scoreboardVisible; } break; - case Input.KEY_M: + case KEY_M: if (OPTION_DANCE_MIRROR.state) { mirrorTo = objectIndex; } else { @@ -1214,7 +1215,7 @@ public class Game extends ComplexOpsuState { } OPTION_DANCE_MIRROR.toggle(); break; - case Input.KEY_P: + case KEY_P: if (OPTION_DANCE_MIRROR.state) { mirrorTo = objectIndex; } else { @@ -1224,12 +1225,12 @@ public class Game extends ComplexOpsuState { } OPTION_DANCE_MIRROR.toggle(); break; - case Input.KEY_MINUS: + case KEY_MINUS: currentMapMusicOffset += 5; BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset); break; } - if (key == Input.KEY_ADD || c == '+') { + if (key == KEY_ADD || c == '+') { currentMapMusicOffset -= 5; BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset); } diff --git a/src/itdelatrisu/opsu/states/GamePauseMenu.java b/src/itdelatrisu/opsu/states/GamePauseMenu.java index f1c4ff15..dc92a060 100644 --- a/src/itdelatrisu/opsu/states/GamePauseMenu.java +++ b/src/itdelatrisu/opsu/states/GamePauseMenu.java @@ -32,6 +32,7 @@ import org.newdawn.slick.Graphics; import org.newdawn.slick.Input; import yugecin.opsudance.core.state.BaseOpsuState; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.options.Options.*; @@ -94,7 +95,7 @@ public class GamePauseMenu extends BaseOpsuState { } } - if (key == Input.KEY_ESCAPE) { + if (key == KEY_ESCAPE) { // 'esc' will normally unpause, but will return to song menu if health is zero if (gameState.getRestart() == Game.Restart.LOSE) { SoundController.playSound(SoundEffect.MENUBACK); @@ -109,7 +110,7 @@ public class GamePauseMenu extends BaseOpsuState { return true; } - if (key == Input.KEY_R && (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL))) { + if (key == KEY_R && input.isControlDown()) { gameState.setRestart(Game.Restart.MANUAL); displayContainer.switchState(gameState); return true; diff --git a/src/itdelatrisu/opsu/states/GameRanking.java b/src/itdelatrisu/opsu/states/GameRanking.java index 70bb0800..eb069a0e 100644 --- a/src/itdelatrisu/opsu/states/GameRanking.java +++ b/src/itdelatrisu/opsu/states/GameRanking.java @@ -32,6 +32,7 @@ import itdelatrisu.opsu.ui.UI; import java.io.FileNotFoundException; import java.io.IOException; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.Input; @@ -121,7 +122,7 @@ public class GameRanking extends BaseOpsuState { return true; } - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { returnToSongMenu(); } return true; diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index d2930ec8..c711e05b 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -51,6 +51,7 @@ import yugecin.opsudance.core.state.OpsuState; import yugecin.opsudance.events.BarNotifListener; import yugecin.opsudance.events.BubNotifListener; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.options.Options.*; @@ -651,8 +652,8 @@ public class MainMenu extends BaseOpsuState { } switch (key) { - case Input.KEY_ESCAPE: - case Input.KEY_Q: + case KEY_ESCAPE: + case KEY_Q: if (logoTimer > 0) { logoState = LogoState.CLOSING; logoClose.setTime(0); @@ -662,7 +663,7 @@ public class MainMenu extends BaseOpsuState { buttonState.setMenuState(MenuState.EXIT); displayContainer.switchState(buttonState); return true; - case Input.KEY_P: + case KEY_P: SoundController.playSound(SoundEffect.MENUHIT); if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) { logoState = LogoState.OPENING; @@ -673,17 +674,17 @@ public class MainMenu extends BaseOpsuState { } else enterSongMenu(); return true; - case Input.KEY_D: + case KEY_D: SoundController.playSound(SoundEffect.MENUHIT); displayContainer.switchState(downloadState); return true; - case Input.KEY_R: + case KEY_R: nextTrack(true); return true; - case Input.KEY_UP: + case KEY_UP: UI.changeVolume(1); return true; - case Input.KEY_DOWN: + case KEY_DOWN: UI.changeVolume(-1); return true; } diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index 07276496..3bb48625 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -55,6 +55,7 @@ import java.nio.file.WatchEvent.Kind; import java.util.Map; import java.util.Stack; +import org.lwjgl.input.Mouse; import org.newdawn.slick.Animation; import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; @@ -67,6 +68,7 @@ import yugecin.opsudance.events.BarNotifListener; import yugecin.opsudance.options.OptionGroups; import yugecin.opsudance.ui.OptionsOverlay; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.options.Options.*; @@ -914,13 +916,13 @@ public class SongMenu extends ComplexOpsuState { // selection buttons if (selectModsButton.contains(x, y)) { - this.keyPressed(Input.KEY_F1, '\0'); + this.keyPressed(KEY_F1, '\0'); return true; } else if (selectRandomButton.contains(x, y)) { - this.keyPressed(Input.KEY_F2, '\0'); + this.keyPressed(KEY_F2, '\0'); return true; } else if (selectMapOptionsButton.contains(x, y)) { - this.keyPressed(Input.KEY_F3, '\0'); + this.keyPressed(KEY_F3, '\0'); return true; } else if (selectOptionsButton.contains(x, y)) { SoundController.playSound(SoundEffect.MENUHIT); @@ -1038,12 +1040,12 @@ public class SongMenu extends ComplexOpsuState { } // block input - if ((reloadThread != null && key != Input.KEY_ESCAPE) || beatmapMenuTimer > -1 || isScrollingToFocusNode) { + if ((reloadThread != null && key != KEY_ESCAPE) || beatmapMenuTimer > -1 || isScrollingToFocusNode) { return true; } switch (key) { - case Input.KEY_ESCAPE: + case KEY_ESCAPE: if (reloadThread != null) { // beatmap reloading: stop parsing beatmaps by sending interrupt to BeatmapParser reloadThread.interrupt(); @@ -1059,16 +1061,16 @@ public class SongMenu extends ComplexOpsuState { displayContainer.switchState(mainmenuState); } return true; - case Input.KEY_F1: + case KEY_F1: SoundController.playSound(SoundEffect.MENUHIT); buttonState.setMenuState(MenuState.MODS); displayContainer.switchState(buttonState); return true; - case Input.KEY_F2: + case KEY_F2: if (focusNode == null) break; SoundController.playSound(SoundEffect.MENUHIT); - if (input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT)) { + if (isKeyDown(KEY_RSHIFT) || isKeyDown(KEY_LSHIFT)) { // shift key: previous random track SongNode prev; if (randomStack.isEmpty() || (prev = randomStack.pop()) == null) @@ -1084,7 +1086,7 @@ public class SongMenu extends ComplexOpsuState { setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true); } return true; - case Input.KEY_F3: + case KEY_F3: if (focusNode == null) break; SoundController.playSound(SoundEffect.MENUHIT); @@ -1093,7 +1095,7 @@ public class SongMenu extends ComplexOpsuState { buttonState.setMenuState(state, focusNode); displayContainer.switchState(buttonState); return true; - case Input.KEY_F5: + case KEY_F5: SoundController.playSound(SoundEffect.MENUHIT); if (songFolderChanged) reloadBeatmaps(false); @@ -1102,10 +1104,10 @@ public class SongMenu extends ComplexOpsuState { displayContainer.switchState(buttonState); } return true; - case Input.KEY_DELETE: + case KEY_DELETE: if (focusNode == null) break; - if (input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT)) { + if (isKeyDown(KEY_RSHIFT) || isKeyDown(KEY_LSHIFT)) { SoundController.playSound(SoundEffect.MENUHIT); MenuState ms = (focusNode.beatmapIndex == -1 || focusNode.getBeatmapSet().size() == 1) ? MenuState.BEATMAP_DELETE_CONFIRM : MenuState.BEATMAP_DELETE_SELECT; @@ -1113,18 +1115,18 @@ public class SongMenu extends ComplexOpsuState { displayContainer.switchState(buttonState); } return true; - case Input.KEY_ENTER: + case KEY_RETURN: if (focusNode == null) break; startGame(); return true; - case Input.KEY_DOWN: + case KEY_DOWN: changeIndex(1); return true; - case Input.KEY_UP: + case KEY_UP: changeIndex(-1); return true; - case Input.KEY_RIGHT: + case KEY_RIGHT: if (focusNode == null) break; BeatmapSetNode next = focusNode.next; @@ -1140,7 +1142,7 @@ public class SongMenu extends ComplexOpsuState { } } return true; - case Input.KEY_LEFT: + case KEY_LEFT: if (focusNode == null) break; BeatmapSetNode prev = focusNode.prev; @@ -1156,25 +1158,25 @@ public class SongMenu extends ComplexOpsuState { } } return true; - case Input.KEY_NEXT: + case KEY_NEXT: changeIndex(MAX_SONG_BUTTONS); return true; - case Input.KEY_PRIOR: + case KEY_PRIOR: changeIndex(-MAX_SONG_BUTTONS); return true; } - if (key == Input.KEY_O && (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL))) { + if (key == KEY_O && input.isControlDown()) { optionsOverlay.show(); return true; } // wait for user to finish typing // TODO: accept all characters (current conditions are from TextField class) - if ((c > 31 && c < 127) || key == Input.KEY_BACK) { + if ((c > 31 && c < 127) || key == KEY_BACK) { searchTimer = 0; searchTextField.keyPressed(key, c); int textLength = searchTextField.getText().length(); if (lastSearchTextLength != textLength) { - if (key == Input.KEY_BACK) { + if (key == KEY_BACK) { if (textLength == 0) searchTransitionTimer = 0; } else if (textLength == 1) @@ -1202,9 +1204,9 @@ public class SongMenu extends ComplexOpsuState { // check mouse button (right click scrolls faster on songs) int multiplier; - if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { + if (Mouse.isButtonDown(Input.MOUSE_RIGHT_BUTTON)) { multiplier = 10; - } else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { + } else if (Mouse.isButtonDown(Input.MOUSE_LEFT_BUTTON)) { multiplier = 1; } else { return false; @@ -1764,9 +1766,8 @@ public class SongMenu extends ComplexOpsuState { } // turn on "auto" mod if holding "ctrl" key - if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { - if (!GameMod.AUTO.isActive()) - GameMod.AUTO.toggle(true); + if (input.isControlDown() && !GameMod.AUTO.isActive()) { + GameMod.AUTO.toggle(true); } SoundController.playSound(SoundEffect.MENUHIT); diff --git a/src/itdelatrisu/opsu/states/Splash.java b/src/itdelatrisu/opsu/states/Splash.java index 76eb12c9..372d0014 100644 --- a/src/itdelatrisu/opsu/states/Splash.java +++ b/src/itdelatrisu/opsu/states/Splash.java @@ -24,6 +24,7 @@ import itdelatrisu.opsu.audio.SoundController; import itdelatrisu.opsu.beatmap.BeatmapSetList; import itdelatrisu.opsu.ui.UI; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; import org.newdawn.slick.Input; @@ -128,7 +129,7 @@ public class Splash extends BaseOpsuState { @Override public boolean keyPressed(int key, char c) { - if (key != Input.KEY_ESCAPE) { + if (key != Keyboard.KEY_ESCAPE) { return false; } if (++escapeCount >= 3) { diff --git a/src/itdelatrisu/opsu/ui/DropdownMenu.java b/src/itdelatrisu/opsu/ui/DropdownMenu.java index 474e36ae..ec56dfd4 100644 --- a/src/itdelatrisu/opsu/ui/DropdownMenu.java +++ b/src/itdelatrisu/opsu/ui/DropdownMenu.java @@ -22,6 +22,7 @@ import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.ui.animations.AnimatedValue; import itdelatrisu.opsu.ui.animations.AnimationEquation; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.Color; import org.newdawn.slick.Font; import org.newdawn.slick.Graphics; @@ -82,7 +83,7 @@ public class DropdownMenu extends Component { @Override public void keyPressed(int key, char c) { - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { this.expanded = false; } } diff --git a/src/org/newdawn/slick/Input.java b/src/org/newdawn/slick/Input.java index 326152ec..ac6fa73b 100644 --- a/src/org/newdawn/slick/Input.java +++ b/src/org/newdawn/slick/Input.java @@ -35,6 +35,8 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; +import static org.lwjgl.input.Keyboard.*; + /** * A wrapped for all keyboard, mouse and controller input * Edited for opsu! @@ -44,131 +46,6 @@ import org.lwjgl.opengl.Display; @SuppressWarnings({"rawtypes", "unchecked", "unused"}) public class Input { - public static final int KEY_ESCAPE = 0x01; - public static final int KEY_1 = 0x02; - public static final int KEY_2 = 0x03; - public static final int KEY_3 = 0x04; - public static final int KEY_4 = 0x05; - public static final int KEY_5 = 0x06; - public static final int KEY_6 = 0x07; - public static final int KEY_7 = 0x08; - public static final int KEY_8 = 0x09; - public static final int KEY_9 = 0x0A; - public static final int KEY_0 = 0x0B; - public static final int KEY_MINUS = 0x0C; /* - on main keyboard */ - public static final int KEY_EQUALS = 0x0D; - public static final int KEY_BACK = 0x0E; /* backspace */ - public static final int KEY_TAB = 0x0F; - public static final int KEY_Q = 0x10; - public static final int KEY_W = 0x11; - public static final int KEY_E = 0x12; - public static final int KEY_R = 0x13; - public static final int KEY_T = 0x14; - public static final int KEY_Y = 0x15; - public static final int KEY_U = 0x16; - public static final int KEY_I = 0x17; - public static final int KEY_O = 0x18; - public static final int KEY_P = 0x19; - public static final int KEY_LBRACKET = 0x1A; - public static final int KEY_RBRACKET = 0x1B; - public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */ - public static final int KEY_ENTER = 0x1C; /* Enter on main keyboard */ - public static final int KEY_LCONTROL = 0x1D; - public static final int KEY_A = 0x1E; - public static final int KEY_S = 0x1F; - public static final int KEY_D = 0x20; - public static final int KEY_F = 0x21; - public static final int KEY_G = 0x22; - public static final int KEY_H = 0x23; - public static final int KEY_J = 0x24; - public static final int KEY_K = 0x25; - public static final int KEY_L = 0x26; - public static final int KEY_SEMICOLON = 0x27; - public static final int KEY_APOSTROPHE = 0x28; - public static final int KEY_GRAVE = 0x29; /* accent grave */ - public static final int KEY_LSHIFT = 0x2A; - public static final int KEY_BACKSLASH = 0x2B; - public static final int KEY_Z = 0x2C; - public static final int KEY_X = 0x2D; - public static final int KEY_C = 0x2E; - public static final int KEY_V = 0x2F; - public static final int KEY_B = 0x30; - public static final int KEY_N = 0x31; - public static final int KEY_M = 0x32; - public static final int KEY_COMMA = 0x33; - public static final int KEY_PERIOD = 0x34; /* . on main keyboard */ - public static final int KEY_SLASH = 0x35; /* / on main keyboard */ - public static final int KEY_RSHIFT = 0x36; - public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */ - public static final int KEY_LMENU = 0x38; /* left Alt */ - public static final int KEY_SPACE = 0x39; - public static final int KEY_CAPITAL = 0x3A; - public static final int KEY_F1 = 0x3B; - public static final int KEY_F2 = 0x3C; - public static final int KEY_F3 = 0x3D; - public static final int KEY_F4 = 0x3E; - public static final int KEY_F5 = 0x3F; - public static final int KEY_F6 = 0x40; - public static final int KEY_F7 = 0x41; - public static final int KEY_F8 = 0x42; - public static final int KEY_F9 = 0x43; - public static final int KEY_F10 = 0x44; - public static final int KEY_NUMLOCK = 0x45; - public static final int KEY_SCROLL = 0x46; /* Scroll Lock */ - public static final int KEY_NUMPAD7 = 0x47; - public static final int KEY_NUMPAD8 = 0x48; - public static final int KEY_NUMPAD9 = 0x49; - public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */ - public static final int KEY_NUMPAD4 = 0x4B; - public static final int KEY_NUMPAD5 = 0x4C; - public static final int KEY_NUMPAD6 = 0x4D; - public static final int KEY_ADD = 0x4E; /* + on numeric keypad */ - public static final int KEY_NUMPAD1 = 0x4F; - public static final int KEY_NUMPAD2 = 0x50; - public static final int KEY_NUMPAD3 = 0x51; - public static final int KEY_NUMPAD0 = 0x52; - public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */ - public static final int KEY_F11 = 0x57; - public static final int KEY_F12 = 0x58; - public static final int KEY_F13 = 0x64; /* (NEC PC98) */ - public static final int KEY_F14 = 0x65; /* (NEC PC98) */ - public static final int KEY_F15 = 0x66; /* (NEC PC98) */ - public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */ - public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */ - public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */ - public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */ - public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */ - public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */ - public static final int KEY_AT = 0x91; /* (NEC PC98) */ - public static final int KEY_COLON = 0x92; /* (NEC PC98) */ - public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */ - public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */ - public static final int KEY_STOP = 0x95; /* (NEC PC98) */ - public static final int KEY_AX = 0x96; /* (Japan AX) */ - public static final int KEY_UNLABELED = 0x97; /* (J3100) */ - public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */ - public static final int KEY_RCONTROL = 0x9D; - public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */ - public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */ - public static final int KEY_SYSRQ = 0xB7; - public static final int KEY_RMENU = 0xB8; /* right Alt */ - public static final int KEY_PAUSE = 0xC5; /* Pause */ - public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */ - public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */ - public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */ - public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */ - public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */ - public static final int KEY_END = 0xCF; /* End on arrow keypad */ - public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */ - public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */ - public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */ - public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */ - public static final int KEY_LWIN = 0xDB; /* Left Windows key */ - public static final int KEY_RWIN = 0xDC; /* Right Windows key */ - public static final int KEY_APPS = 0xDD; /* AppMenu key */ - public static final int KEY_POWER = 0xDE; - public static final int KEY_SLEEP = 0xDF; - /** A helper for left ALT */ public static final int KEY_LALT = KEY_LMENU; /** A helper for right ALT */ @@ -356,17 +233,7 @@ public class Input { lastMouseX = getMouseX(); lastMouseY = getMouseY(); } - - /** - * Get the character representation of the key identified by the specified code - * - * @param code The key code of the key to retrieve the name of - * @return The name or character representation of the key requested - */ - public static String getKeyName(int code) { - return Keyboard.getKeyName(code); - } - + /** * Check if a particular key has been pressed since this method * was last called for the specified key @@ -415,16 +282,6 @@ public class Input { public void clearMousePressedRecord() { Arrays.fill(mousePressed, false); } - - /** - * Check if a particular key is down - * - * @param code The key code of the key to check - * @return True if the key is down - */ - public boolean isKeyDown(int code) { - return Keyboard.isKeyDown(code); - } /** * Get the x position of the mouse cursor @@ -443,23 +300,13 @@ public class Input { public int getMouseY() { return height - Mouse.getY(); } - - /** - * Check if a given mouse button is down - * - * @param button The index of the button to check (starting at 0) - * @return True if the mouse button is down - */ - public boolean isMouseButtonDown(int button) { - return Mouse.isButtonDown(button); - } - + /** * Check if any mouse button is down * * @return True if any mouse button is down */ - private boolean anyMouseDown() { + public boolean anyMouseDown() { for (int i=0;i<3;i++) { if (Mouse.isButtonDown(i)) { return true; @@ -469,6 +316,10 @@ public class Input { return false; } + public boolean isControlDown() { + return Keyboard.isKeyDown(KEY_RCONTROL) || Keyboard.isKeyDown(KEY_LCONTROL); + } + /** * Poll the state of the input * diff --git a/src/org/newdawn/slick/gui/TextField.java b/src/org/newdawn/slick/gui/TextField.java index 6e7fa30b..e2097faf 100644 --- a/src/org/newdawn/slick/gui/TextField.java +++ b/src/org/newdawn/slick/gui/TextField.java @@ -32,11 +32,11 @@ import org.lwjgl.Sys; import org.newdawn.slick.Color; import org.newdawn.slick.Font; import org.newdawn.slick.Graphics; -import org.newdawn.slick.Input; import org.newdawn.slick.geom.Rectangle; import yugecin.opsudance.core.components.ActionListener; import yugecin.opsudance.core.components.Component; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; /** @@ -95,7 +95,7 @@ public class TextField extends Component { public void render(Graphics g) { if (lastKey != -1) { - if (input.isKeyDown(lastKey)) { + if (isKeyDown(lastKey)) { if (repeatTimer < System.currentTimeMillis()) { repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; keyPressed(lastKey, lastChar); @@ -168,10 +168,8 @@ public class TextField extends Component { } public void keyPressed(int key, char c) { - if (key != -1) - { - if ((key == Input.KEY_V) && - ((input.isKeyDown(Input.KEY_LCONTROL)) || (input.isKeyDown(Input.KEY_RCONTROL)))) { + if (key != -1) { + if (key == KEY_V && input.isControlDown()) { String text = Sys.getClipboard(); if (text != null) { doPaste(text); @@ -188,7 +186,7 @@ public class TextField extends Component { } lastChar = c; - if (key == Input.KEY_LEFT) { /* + if (key == KEY_LEFT) { /* if (cursorPos > 0) { cursorPos--; } @@ -196,7 +194,7 @@ public class TextField extends Component { if (consume) { container.getInput().consumeEvent(); } - */ } else if (key == Input.KEY_RIGHT) { /* + */ } else if (key == KEY_RIGHT) { /* if (cursorPos < value.length()) { cursorPos++; } @@ -204,9 +202,9 @@ public class TextField extends Component { if (consume) { container.getInput().consumeEvent(); } - */ } else if (key == Input.KEY_BACK) { + */ } else if (key == KEY_BACK) { if ((cursorPos > 0) && (value.length() > 0)) { - if (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL)) { + if (input.isControlDown()) { int sp = 0; boolean startSpace = Character.isWhitespace(value.charAt(cursorPos - 1)); boolean charSeen = false; @@ -238,7 +236,7 @@ public class TextField extends Component { cursorPos--; } } - } else if (key == Input.KEY_DELETE) { + } else if (key == KEY_DELETE) { if (value.length() > cursorPos) { value = value.substring(0,cursorPos) + value.substring(cursorPos+1); } @@ -250,7 +248,7 @@ public class TextField extends Component { value = value.substring(0, cursorPos) + c; } cursorPos++; - } else if (key == Input.KEY_RETURN) { + } else if (key == KEY_RETURN) { if (listener != null) { listener.onAction(); } diff --git a/src/yugecin/opsudance/core/DisplayContainer.java b/src/yugecin/opsudance/core/DisplayContainer.java index 3d6d5315..e4668033 100644 --- a/src/yugecin/opsudance/core/DisplayContainer.java +++ b/src/yugecin/opsudance/core/DisplayContainer.java @@ -31,6 +31,7 @@ import itdelatrisu.opsu.ui.Cursor; import itdelatrisu.opsu.ui.Fonts; import itdelatrisu.opsu.ui.UI; import org.lwjgl.Sys; +import org.lwjgl.input.Mouse; import org.lwjgl.openal.AL; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; @@ -262,7 +263,8 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene cursor.updateAngle(renderDelta); if (drawCursor) { - cursor.draw(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) || input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)); + cursor.draw(Mouse.isButtonDown(Input.MOUSE_LEFT_BUTTON) || + Mouse.isButtonDown(Input.MOUSE_RIGHT_BUTTON)); } UI.drawTooltip(graphics); diff --git a/src/yugecin/opsudance/core/GlobalInputListener.java b/src/yugecin/opsudance/core/GlobalInputListener.java index d628dc1c..4e57f1b2 100644 --- a/src/yugecin/opsudance/core/GlobalInputListener.java +++ b/src/yugecin/opsudance/core/GlobalInputListener.java @@ -23,6 +23,7 @@ import org.newdawn.slick.Input; import org.newdawn.slick.InputListener; import yugecin.opsudance.events.BarNotifListener; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.options.Options.*; @@ -35,22 +36,22 @@ public class GlobalInputListener implements InputListener { @Override public boolean keyReleased(int key, char c) { - if (key == Input.KEY_F7) { + if (key == KEY_F7) { OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length); BarNotifListener.EVENT.make().onBarNotif(String.format("Frame limiter: %s", OPTION_TARGET_FPS.getValueString())); return true; } - if (key == Input.KEY_F10) { + if (key == KEY_F10) { OPTION_DISABLE_MOUSE_BUTTONS.toggle(); return true; } - if (key == Input.KEY_F12) { + if (key == KEY_F12) { config.takeScreenShot(); return true; } - if (key == Input.KEY_S && input.isKeyDown(Input.KEY_LMENU) && input.isKeyDown(Input.KEY_LSHIFT) && - input.isKeyDown(Input.KEY_LCONTROL) && !displayContainer.isInState(Game.class)) { + if (key == KEY_S && isKeyDown(KEY_LMENU) && isKeyDown(KEY_LSHIFT) && + input.isControlDown() && !displayContainer.isInState(Game.class)) { skinservice.reloadSkin(); } return false; @@ -58,7 +59,7 @@ public class GlobalInputListener implements InputListener { @Override public boolean mouseWheelMoved(int delta) { - if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT)) { + if (isKeyDown(Input.KEY_LALT) || isKeyDown(Input.KEY_RALT)) { UI.changeVolume((delta < 0) ? -1 : 1); return true; } diff --git a/src/yugecin/opsudance/core/state/ComplexOpsuState.java b/src/yugecin/opsudance/core/state/ComplexOpsuState.java index f1967be0..888c6938 100644 --- a/src/yugecin/opsudance/core/state/ComplexOpsuState.java +++ b/src/yugecin/opsudance/core/state/ComplexOpsuState.java @@ -17,8 +17,8 @@ */ package yugecin.opsudance.core.state; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.Graphics; -import org.newdawn.slick.Input; import yugecin.opsudance.core.components.Component; import java.util.LinkedList; @@ -165,7 +165,7 @@ public abstract class ComplexOpsuState extends BaseOpsuState { } } if (focusedComponent != null) { - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { focusedComponent.setFocused(false); focusedComponent = null; return true; @@ -184,7 +184,7 @@ public abstract class ComplexOpsuState extends BaseOpsuState { } } if (focusedComponent != null) { - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { focusedComponent.setFocused(false); focusedComponent = null; return true; diff --git a/src/yugecin/opsudance/options/Options.java b/src/yugecin/opsudance/options/Options.java index be028511..8ef1bbfc 100644 --- a/src/yugecin/opsudance/options/Options.java +++ b/src/yugecin/opsudance/options/Options.java @@ -393,7 +393,7 @@ public class Options { }; public static final ToggleOption OPTION_DISABLE_SOUNDS = new ToggleOption("Disable All Sound Effects", "DisableSound", "May resolve Linux sound driver issues. Requires a restart.", (System.getProperty("os.name").toLowerCase().contains("linux"))); - public static final GenericOption OPTION_KEY_LEFT = new GenericOption("Left Game Key", "keyOsuLeft", "Select this option to input a key.", Input.KEY_Z, null, false) { + public static final GenericOption OPTION_KEY_LEFT = new GenericOption("Left Game Key", "keyOsuLeft", "Select this option to input a key.", Keyboard.KEY_Z, null, false) { @Override public String getValueString () { return Keyboard.getKeyName(intval); @@ -408,12 +408,12 @@ public class Options { public void read(String s){ intval = Keyboard.getKeyIndex(s); if (intval == Keyboard.KEY_NONE) { - intval = Input.KEY_Y; + intval = Keyboard.KEY_Y; } } }; - public static final GenericOption OPTION_KEY_RIGHT = new GenericOption("Right Game Key", "keyOsuRight", "Select this option to input a key.", Input.KEY_X, null, false) { + public static final GenericOption OPTION_KEY_RIGHT = new GenericOption("Right Game Key", "keyOsuRight", "Select this option to input a key.", Keyboard.KEY_X, null, false) { @Override public String getValueString () { return Keyboard.getKeyName(intval); @@ -428,7 +428,7 @@ public class Options { public void read(String s){ intval = Keyboard.getKeyIndex(s); if (intval == Keyboard.KEY_NONE) { - intval = Input.KEY_X; + intval = Keyboard.KEY_X; } } }; diff --git a/src/yugecin/opsudance/ui/OptionsOverlay.java b/src/yugecin/opsudance/ui/OptionsOverlay.java index 0ab3e725..736284e3 100644 --- a/src/yugecin/opsudance/ui/OptionsOverlay.java +++ b/src/yugecin/opsudance/ui/OptionsOverlay.java @@ -23,6 +23,7 @@ import itdelatrisu.opsu.audio.SoundController; import itdelatrisu.opsu.audio.SoundEffect; import itdelatrisu.opsu.ui.*; import itdelatrisu.opsu.ui.animations.AnimationEquation; +import org.lwjgl.input.Keyboard; import org.newdawn.slick.*; import org.newdawn.slick.gui.TextField; import yugecin.opsudance.core.DisplayContainer; @@ -738,7 +739,7 @@ public class OptionsOverlay extends OverlayOpsuState { return true; } - if (key == Input.KEY_ESCAPE) { + if (key == Keyboard.KEY_ESCAPE) { if (openDropdownMenu != null) { openDropdownMenu.keyPressed(key, c); return true; diff --git a/src/yugecin/opsudance/ui/StoryboardOverlay.java b/src/yugecin/opsudance/ui/StoryboardOverlay.java index 14fb1dd6..a9f540ce 100644 --- a/src/yugecin/opsudance/ui/StoryboardOverlay.java +++ b/src/yugecin/opsudance/ui/StoryboardOverlay.java @@ -25,7 +25,6 @@ import yugecin.opsudance.options.OptionGroups; import itdelatrisu.opsu.ui.Fonts; import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; -import org.newdawn.slick.Input; import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.state.OverlayOpsuState; @@ -34,6 +33,7 @@ import yugecin.opsudance.sbv2.MoveStoryboard; import java.util.*; +import static org.lwjgl.input.Keyboard.*; import static yugecin.opsudance.options.Options.*; @SuppressWarnings("unchecked") @@ -108,7 +108,7 @@ public class StoryboardOverlay extends OverlayOpsuState implements OptionsOverla @Override public boolean onKeyPressed(int key, char c) { - if (key == Input.KEY_C) { + if (key == KEY_C) { if (speed > 0) { speed -= 1; } @@ -117,24 +117,24 @@ public class StoryboardOverlay extends OverlayOpsuState implements OptionsOverla } else { MusicController.setPitch(speed / 10f); } - } else if (key == Input.KEY_V && speed < 21) { + } else if (key == KEY_V && speed < 21) { if (speed == 0) { MusicController.resume(); } speed += 1; MusicController.setPitch(speed / 10f); - } else if (key == Input.KEY_H) { + } else if (key == KEY_H) { hide = !hide; - } else if (key == Input.KEY_N) { + } else if (key == KEY_N) { optionsOverlay.show(); if (speed != 0) { MusicController.pause(); } - } else if (key == Input.KEY_J && index > 0) { + } else if (key == KEY_J && index > 0) { index--; goBackOneSBIndex(); setMusicPosition(); - } else if (key == Input.KEY_K && index < gameObjects.length - 1) { + } else if (key == KEY_K && index < gameObjects.length - 1) { index++; updateIndex(index); setMusicPosition();