Fixed endless scrolling and removed cursor on rasp

This commit is contained in:
jancoow
2015-07-09 12:30:04 +02:00
parent 61fdeb27c5
commit 713cfaf836
3 changed files with 36 additions and 19 deletions
+24 -7
View File
@@ -17,6 +17,7 @@ public class NetworkHandler implements Runnable{
private String host; private String host;
private int port; private int port;
private long fistpressed;
private boolean running; private boolean running;
private Thread t; private Thread t;
@@ -111,7 +112,7 @@ public class NetworkHandler implements Runnable{
} }
if(control[7] == 0 && control[8] == 0){ 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); JoystickHandler.j.setPosition(Position.UP_LEFT);
jth.onJoystickMoved(JoystickHandler.j); jth.onJoystickMoved(JoystickHandler.j);
@@ -140,10 +141,18 @@ public class NetworkHandler implements Runnable{
} }
else if(control[7] == 0){ else if(control[7] == 0){
if(JoystickHandler.j.getPos() != Position.UP) if(JoystickHandler.j.getPos() != Position.UP || JoystickHandler.REPEAT)
{ {
JoystickHandler.j.setPosition(Position.UP); if(JoystickHandler.j.getPos() != Position.UP)
jth.onJoystickMoved(JoystickHandler.j); {
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){ else if(control[8] == 0){
@@ -161,13 +170,21 @@ public class NetworkHandler implements Runnable{
} }
} }
else if(control[10] == 0){ else if(control[10] == 0){
if(JoystickHandler.j.getPos() != Position.DOWN) if(JoystickHandler.j.getPos() != Position.DOWN || JoystickHandler.REPEAT)
{ {
JoystickHandler.j.setPosition(Position.DOWN); if(JoystickHandler.j.getPos() != Position.DOWN){
jth.onJoystickMoved(JoystickHandler.j); 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 { }else {
if(JoystickHandler.j.getPos() != Position.CENTER){ if(JoystickHandler.j.getPos() != Position.CENTER){
fistpressed = 0;
JoystickHandler.j.setPosition(Position.CENTER); JoystickHandler.j.setPosition(Position.CENTER);
jth.onJoystickMoved(JoystickHandler.j); jth.onJoystickMoved(JoystickHandler.j);
} }
+3 -3
View File
@@ -177,8 +177,8 @@ public class ButtonHandler implements KeyListener{
buttons.add(new Button(1, 2, ntw)); buttons.add(new Button(1, 2, ntw));
buttons.add(new Button(2, 1, ntw)); buttons.add(new Button(2, 1, ntw));
buttons.add(new Button(3, 0, ntw)); buttons.add(new Button(3, 0, ntw));
buttons.add(new Button(4, 3, ntw)); buttons.add(new Button(4, -1, ntw));
buttons.add(new Button(5, 4, ntw)); buttons.add(new Button(5, 3, ntw));
buttons.add(new Button(6, 5, ntw)); buttons.add(new Button(6, 4, ntw));
} }
} }
+8 -8
View File
@@ -36,8 +36,8 @@ public class Window extends JFrame {
setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);
//Create Events //Create Events
// Window.ON_RASP = ON_RASP; Window.ON_RASP = ON_RASP;
// if(ON_RASP){ //Only on the raspberry pi if(ON_RASP){ //Only on the raspberry pi
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); // GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices(); // GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
// //
@@ -47,10 +47,10 @@ public class Window extends JFrame {
// devices[0].setFullScreenWindow(this); // devices[0].setFullScreenWindow(this);
// } // }
// //Remove cursor // //Remove cursor
// BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor"); Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
// this.setCursor(blankCursor); this.setCursor(blankCursor);
// } }
ButtonHandler bth = new ButtonHandler(); ButtonHandler bth = new ButtonHandler();
JoystickHandler jsh = new JoystickHandler(); JoystickHandler jsh = new JoystickHandler();
@@ -85,8 +85,8 @@ public class Window extends JFrame {
}); });
//Create EventListeners //Create EventListeners
addKeyListener(bth); addKeyListener(bth);
addKeyListener(jsh); addKeyListener(jsh);
bth.addButtonListener(control); bth.addButtonListener(control);
jsh.addJoystickListener(control); jsh.addJoystickListener(control);