Just some ideas for the custom button & joystick event listener
This commit is contained in:
+20
-4
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package control;
|
||||
|
||||
public class Joystickevent {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user