Fixed endless scrolling and removed cursor on rasp
This commit is contained in:
@@ -17,6 +17,7 @@ public class NetworkHandler implements Runnable{
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private long fistpressed;
|
||||
|
||||
private boolean running;
|
||||
private Thread t;
|
||||
@@ -111,7 +112,7 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
|
||||
if(control[7] == 0 && control[8] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.UP_LEFT)
|
||||
if(JoystickHandler.j.getPos() != Position.UP_LEFT )
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.UP_LEFT);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
@@ -140,10 +141,18 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
|
||||
else if(control[7] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.UP)
|
||||
if(JoystickHandler.j.getPos() != Position.UP || JoystickHandler.REPEAT)
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
if(JoystickHandler.j.getPos() != Position.UP)
|
||||
{
|
||||
fistpressed = System.currentTimeMillis();
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
if((fistpressed + 500) < System.currentTimeMillis()){
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(control[8] == 0){
|
||||
@@ -161,13 +170,21 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
}
|
||||
else if(control[10] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN)
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN || JoystickHandler.REPEAT)
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN){
|
||||
fistpressed = System.currentTimeMillis();
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
if((fistpressed + 500) < System.currentTimeMillis()){
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(JoystickHandler.j.getPos() != Position.CENTER){
|
||||
fistpressed = 0;
|
||||
JoystickHandler.j.setPosition(Position.CENTER);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ public class ButtonHandler implements KeyListener{
|
||||
buttons.add(new Button(1, 2, ntw));
|
||||
buttons.add(new Button(2, 1, ntw));
|
||||
buttons.add(new Button(3, 0, ntw));
|
||||
buttons.add(new Button(4, 3, ntw));
|
||||
buttons.add(new Button(5, 4, ntw));
|
||||
buttons.add(new Button(6, 5, ntw));
|
||||
buttons.add(new Button(4, -1, ntw));
|
||||
buttons.add(new Button(5, 3, ntw));
|
||||
buttons.add(new Button(6, 4, ntw));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -36,8 +36,8 @@ public class Window extends JFrame {
|
||||
setSize(WIDTH, HEIGHT);
|
||||
|
||||
//Create Events
|
||||
// Window.ON_RASP = ON_RASP;
|
||||
// if(ON_RASP){ //Only on the raspberry pi
|
||||
Window.ON_RASP = ON_RASP;
|
||||
if(ON_RASP){ //Only on the raspberry pi
|
||||
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
//
|
||||
@@ -47,15 +47,15 @@ public class Window extends JFrame {
|
||||
// devices[0].setFullScreenWindow(this);
|
||||
// }
|
||||
// //Remove cursor
|
||||
// BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
// Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
// this.setCursor(blankCursor);
|
||||
// }
|
||||
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
this.setCursor(blankCursor);
|
||||
}
|
||||
|
||||
ButtonHandler bth = new ButtonHandler();
|
||||
JoystickHandler jsh = new JoystickHandler();
|
||||
|
||||
|
||||
|
||||
final SQLConnector sql = new SQLConnector();
|
||||
|
||||
NetworkHandler ntw = new NetworkHandler("10.42.0.5", 1113, bth, jsh);
|
||||
@@ -85,8 +85,8 @@ public class Window extends JFrame {
|
||||
});
|
||||
|
||||
//Create EventListeners
|
||||
addKeyListener(bth);
|
||||
addKeyListener(jsh);
|
||||
addKeyListener(bth);
|
||||
addKeyListener(jsh);
|
||||
bth.addButtonListener(control);
|
||||
jsh.addJoystickListener(control);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user