diff --git a/.classpath b/.classpath index 656214e..b512be0 100644 --- a/.classpath +++ b/.classpath @@ -2,9 +2,25 @@ - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/src/control/Button.java b/src/control/Button.java new file mode 100644 index 0000000..1ff3bbc --- /dev/null +++ b/src/control/Button.java @@ -0,0 +1,16 @@ +package control; + +import com.pi4j.io.gpio.GpioFactory; +import com.pi4j.io.gpio.GpioPinDigitalInput; +import com.pi4j.io.gpio.Pin; + +public class Button { + private GpioPinDigitalInput input; + + public Button(int buttonId, Pin pin){ + input = GpioFactory.getInstance().provisionDigitalInputPin(pin , "Button:"+buttonId); + } + public boolean getState(){ + return input.getState().isLow(); + } +} diff --git a/src/control/ButtonEvent.java b/src/control/ButtonEvent.java new file mode 100644 index 0000000..791ad3e --- /dev/null +++ b/src/control/ButtonEvent.java @@ -0,0 +1,28 @@ +package control; + +public class ButtonEvent { + private Button button; + private Long now; + + public ButtonEvent(Button button, Long now){ + this.button = button; + this.now = now; + } + + /** + * @return the button + */ + public Button getButton() { + return button; + } + + /** + * @return the time when event was triggered + */ + public Long getNow() { + return now; + } + + + +} diff --git a/src/control/ButtonsListener.java b/src/control/ButtonsListener.java new file mode 100644 index 0000000..dc70b34 --- /dev/null +++ b/src/control/ButtonsListener.java @@ -0,0 +1,21 @@ +package control; + +import java.util.EventListener; + +public interface ButtonsListener extends EventListener { + + /** + * Invoked when a button has been pressed. + */ + public void buttonPressed(ButtonEvent e); + + /** + * Invoked when a button has been released. + */ + public void buttonReleased(ButtonEvent e); + + /** + * Invoked when a button is held down. + */ + public void buttonHeld(ButtonEvent e); +} diff --git a/src/control/Buttontest.java b/src/control/Buttontest.java index 2c7d38c..472b5a4 100644 --- a/src/control/Buttontest.java +++ b/src/control/Buttontest.java @@ -1,5 +1,8 @@ package control; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyListener; + import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; diff --git a/src/control/JoystickListener.java b/src/control/JoystickListener.java new file mode 100644 index 0000000..56e8d4b --- /dev/null +++ b/src/control/JoystickListener.java @@ -0,0 +1,10 @@ +package control; + +import java.util.EventListener; + +public interface JoystickListener extends EventListener { + /** + * Invoked when the joystick has been moved. + */ + public void joystickMoved(Joystickevent e); +} diff --git a/src/control/Joystickevent.java b/src/control/Joystickevent.java new file mode 100644 index 0000000..a683447 --- /dev/null +++ b/src/control/Joystickevent.java @@ -0,0 +1,5 @@ +package control; + +public class Joystickevent { + +}