Explorar el Código

Just some ideas for the custom button & joystick event listener

jancoow hace 10 años
padre
commit
d8dbcc0719

+ 20 - 4
.classpath

@@ -2,9 +2,25 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-service.jar"/>
-	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-gpio-extension.jar"/>
-	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-device.jar"/>
-	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-core.jar"/>
+	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-service.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="http://pi4j.com/apidocs/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-gpio-extension.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="http://pi4j.com/apidocs/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-device.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="http://pi4j.com/apidocs/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="/home/janco/Documenten/github/Arcade-controls/pi4j-core.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="http://pi4j.com/apidocs/"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 16 - 0
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();
+	}
+}

+ 28 - 0
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;
+	}	
+	
+	
+	
+}

+ 21 - 0
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); 
+}

+ 3 - 0
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;

+ 10 - 0
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);
+}

+ 5 - 0
src/control/Joystickevent.java

@@ -0,0 +1,5 @@
+package control;
+
+public class Joystickevent {
+
+}