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 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);
}
+3 -3
View File
@@ -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
View File
@@ -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);