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 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user