Added option for PC/RASP

This commit is contained in:
2015-05-21 21:21:23 +02:00
parent f7175aa70a
commit 36cbc2b012
3 changed files with 23 additions and 5 deletions
+4
View File
@@ -2,6 +2,7 @@ package control.button;
import java.awt.Color; import java.awt.Color;
import main.Window;
import control.LedHandler; import control.LedHandler;
public class Button { public class Button {
@@ -21,10 +22,13 @@ public class Button {
} }
private void setLed() private void setLed()
{
if(Window.ON_RASP)
{ {
led.setLed(ledID, color.getGreen(), color.getRed(), color.getBlue()); led.setLed(ledID, color.getGreen(), color.getRed(), color.getBlue());
led.show(); led.show();
} }
}
public void setColor(Color newColor) public void setColor(Color newColor)
{ {
+5
View File
@@ -5,6 +5,7 @@ import java.awt.event.KeyListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import main.Window;
import control.LedHandler; import control.LedHandler;
public class ButtonHandler implements KeyListener{ public class ButtonHandler implements KeyListener{
@@ -71,6 +72,10 @@ public class ButtonHandler implements KeyListener{
case KeyEvent.VK_6: case KeyEvent.VK_6:
buttonPress(buttons.get(6)); buttonPress(buttons.get(6));
break; break;
case KeyEvent.VK_ESCAPE:
if(!Window.ON_RASP)
System.exit(0);
break;
} }
} }
+12 -3
View File
@@ -13,6 +13,9 @@ import control.button.ButtonHandler;
import control.joystick.JoystickHandler; import control.joystick.JoystickHandler;
public class Window extends JFrame { public class Window extends JFrame {
public static boolean ON_RASP = false;
public Window() public Window()
{ {
//Create window //Create window
@@ -32,9 +35,15 @@ public class Window extends JFrame {
setUndecorated(true); setUndecorated(true);
//Create Events //Create Events
LedHandler led = new LedHandler(); LedHandler led = null;
if(Window.ON_RASP) //TODO REMOVE
{
led = new LedHandler();
}
ButtonHandler bth = new ButtonHandler(led); ButtonHandler bth = new ButtonHandler(led);
JoystickHandler jsh = new JoystickHandler(led); JoystickHandler jsh = new JoystickHandler();
//Create Instances //Create Instances
GameView view = new GameView(led); GameView view = new GameView(led);
@@ -46,7 +55,7 @@ public class Window extends JFrame {
addKeyListener(bth); addKeyListener(bth);
addKeyListener(jsh); addKeyListener(jsh);
bth.addButtonListener(control); bth.addButtonListener(control);
jsh.addJoyStickListener(control); jsh.addJoystickListener(control);
//Display //Display
pack(); pack();