Implement new jinput version 2.11

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
sigonasr2, Sig, Sigo 2022-06-22 19:34:29 +00:00 committed by GitHub
parent 94bf7406e6
commit 11bf992721
41 changed files with 36 additions and 63 deletions

BIN
bin/RabiClone.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
version=2.10 version=2.11
date=13/05/2021 date=22/06/2022

Binary file not shown.

View File

@ -2,6 +2,7 @@ package sig;
import javax.swing.JFrame; import javax.swing.JFrame;
import net.java.games.input.AbstractController;
import net.java.games.input.Controller; import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment; import net.java.games.input.ControllerEnvironment;
import net.java.games.input.ControllerEvent; import net.java.games.input.ControllerEvent;
@ -30,7 +31,6 @@ import sig.engine.KeyBind;
import sig.engine.PaletteColor; import sig.engine.PaletteColor;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.RenderingHints; import java.awt.RenderingHints;
public class RabiClone implements ControllerListener{ public class RabiClone implements ControllerListener{
@ -67,7 +67,7 @@ public class RabiClone implements ControllerListener{
public static Player player; public static Player player;
public static Maps CURRENT_MAP; public static Maps CURRENT_MAP;
public static Controller[] CONTROLLERS = new Controller[] {}; public static AbstractController[] CONTROLLERS = new AbstractController[] {};
public static long lastControllerScan = System.currentTimeMillis(); public static long lastControllerScan = System.currentTimeMillis();
@ -77,26 +77,11 @@ public class RabiClone implements ControllerListener{
public static long TIME = 0; public static long TIME = 0;
public static long scaleTime; public static long scaleTime;
public static boolean reloadControllerList = false;
public static HashMap<Action,List<KeyBind>> DEFAULT_KEYBINDS = new HashMap<>(); public static HashMap<Action,List<KeyBind>> DEFAULT_KEYBINDS = new HashMap<>();
public static RenderingHints RENDERHINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); public static RenderingHints RENDERHINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
public static void main(String[] args) { public static void main(String[] args) {System.setProperty("sun.java2d.transaccel", "True");
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
RabiClone r = new RabiClone();
ControllerEnvironment.getDefaultEnvironment().addControllerListener(r);
while (true) {
if (System.currentTimeMillis() - lastControllerScan > 5000) {
lastControllerScan=System.currentTimeMillis();
ControllerEnvironment.getDefaultEnvironment().rescanControllers();
}
}
/*System.setProperty("sun.java2d.transaccel", "True");
System.setProperty("sun.java2d.d3d", "True"); System.setProperty("sun.java2d.d3d", "True");
System.setProperty("sun.java2d.ddforcevram", "True"); System.setProperty("sun.java2d.ddforcevram", "True");
System.setProperty("sun.java2d.xrender", "True"); System.setProperty("sun.java2d.xrender", "True");
@ -151,14 +136,9 @@ public class RabiClone implements ControllerListener{
KeyBind.poll(); KeyBind.poll();
if ((Key.isKeyHeld(KeyEvent.VK_F5)||reloadControllerList) && System.currentTimeMillis() - lastControllerScan > 5000) { if (System.currentTimeMillis() - lastControllerScan > 5000) {
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers(); ControllerEnvironment.getDefaultEnvironment().rescanControllers();
System.out.println(Arrays.toString(CONTROLLERS));
lastControllerScan = System.currentTimeMillis(); lastControllerScan = System.currentTimeMillis();
if (reloadControllerList) {
ConfigureControls.LoadControls();
}
reloadControllerList=false;
} }
FRIENDLY_OBJ.clear(); FRIENDLY_OBJ.clear();
@ -192,7 +172,7 @@ public class RabiClone implements ControllerListener{
// System.out.println(TIME); // System.out.println(TIME);
} }
gameUpdateLoopStabilizer(dt); //This is hackish. Removing this slows down the game by about 30%. The timer runs slower. ??? gameUpdateLoopStabilizer(dt); //This is hackish. Removing this slows down the game by about 30%. The timer runs slower. ???
}*/ }
} }
public static void setupDefaultControls() { public static void setupDefaultControls() {
@ -281,7 +261,7 @@ public class RabiClone implements ControllerListener{
ConfigureControls.updateHighlightSections(); ConfigureControls.updateHighlightSections();
} }
} }
Controller[] newArr = new Controller[CONTROLLERS.length - 1]; AbstractController[] newArr = new AbstractController[CONTROLLERS.length - 1];
for (int j = 0; j < CONTROLLERS.length; j++) { for (int j = 0; j < CONTROLLERS.length; j++) {
if (j != i) { if (j != i) {
newArr[(j > i ? j - 1 : j)] = CONTROLLERS[i]; newArr[(j > i ? j - 1 : j)] = CONTROLLERS[i];

View File

@ -43,9 +43,6 @@ public class ConfigureControls extends Object{
public ConfigureControls(Panel panel) { public ConfigureControls(Panel panel) {
super(panel); super(panel);
RabiClone.BACKGROUND_COLOR = PaletteColor.WHITE; RabiClone.BACKGROUND_COLOR = PaletteColor.WHITE;
if (GAME_CONTROLS_FILE.exists()) {
RabiClone.reloadControllerList = true;
}
updateHighlightSections(); updateHighlightSections();
} }
@ -204,7 +201,6 @@ public class ConfigureControls extends Object{
@Override @Override
public void draw(byte[] p) { public void draw(byte[] p) {
if (!RabiClone.reloadControllerList) {
int y = 4; int y = 4;
if (!assigningKey) { if (!assigningKey) {
selectedAction=null; selectedAction=null;
@ -237,9 +233,6 @@ public class ConfigureControls extends Object{
} else { } else {
Draw_Text_Ext(4, 4, new String("Press a key to assign to ").append(selectedAction), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE); Draw_Text_Ext(4, 4, new String("Press a key to assign to ").append(selectedAction), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE);
} }
} else {
Draw_Text_Ext(4, 4, new String("Preparing controller list..."), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE);
}
} }
@Override @Override