mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-12 19:06:09 +00:00
Work in progress: fixing gamepad to work on all OSs and be customizable
This commit is contained in:
31
src/com/limelight/input/ControllerComponent.java
Normal file
31
src/com/limelight/input/ControllerComponent.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.limelight.input;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public enum ControllerComponent {
|
||||
BTN_A("Button 1 (A)"), BTN_X("Button 2 (X)"), BTN_Y("Button 3 (Y)"), BTN_B("Button 4 (B)"),
|
||||
DPAD_UP("D-pad Up"), DPAD_DOWN("D-pad Down"), DPAD_LEFT("D-pad Left"), DPAD_RIGHT("D-pad Right"),
|
||||
LS_X("Left Stick X"), LS_Y("Left Stick X"), RS_X("Right Stick X"), RS_Y("Left Stick Y"),
|
||||
LS_THUMB("Left Stick Button"), RS_THUMB("Right Stick Button"),
|
||||
LT("Left Trigger"), RT("Right Trigger"), LB("Left Bumper"), RB("Right Bumper"),
|
||||
BTN_START("Start Button"), BTN_BACK("Back Button"), BTN_SPECIAL("Special Button");
|
||||
|
||||
private JLabel label;
|
||||
private JTextField textBox;
|
||||
|
||||
private ControllerComponent(String name) {
|
||||
this.label = new JLabel(name);
|
||||
this.textBox = new JTextField();
|
||||
this.textBox.setEditable(false);
|
||||
this.textBox.setName(this.name());
|
||||
}
|
||||
|
||||
public JLabel getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public JTextField getTextField() {
|
||||
return textBox;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ public abstract class Gamepad {
|
||||
protected short leftStickX = 0x0000;
|
||||
protected short leftStickY = 0x0000;
|
||||
|
||||
protected GamepadSettings configuration;
|
||||
|
||||
public enum ControllerType { XBOX, PS3 };
|
||||
|
||||
|
||||
@@ -37,12 +39,18 @@ public abstract class Gamepad {
|
||||
this.conn = conn;
|
||||
this.pad = pad;
|
||||
|
||||
configuration = new GamepadSettings();
|
||||
|
||||
for (Component comp : pad.getComponents()) {
|
||||
initValue(comp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GamepadSettings getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private void initValue(Component comp) {
|
||||
handleComponent(comp, comp.getPollData());
|
||||
}
|
||||
@@ -56,6 +64,10 @@ public abstract class Gamepad {
|
||||
leftStickX, leftStickY, rightStickX, rightStickY);
|
||||
}
|
||||
|
||||
public EventQueue getEvents() {
|
||||
return pad.getEventQueue();
|
||||
}
|
||||
|
||||
public void handleEvents() {
|
||||
EventQueue queue = pad.getEventQueue();
|
||||
Event event = new Event();
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.limelight.input;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
|
||||
import com.limelight.input.Gamepad.ControllerType;
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
|
||||
@@ -37,6 +40,10 @@ public class GamepadHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Gamepad> getGamepads() {
|
||||
return Collections.unmodifiableList(gamepads);
|
||||
}
|
||||
|
||||
private void startUp() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
||||
17
src/com/limelight/input/GamepadSettings.java
Normal file
17
src/com/limelight/input/GamepadSettings.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.limelight.input;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.java.games.input.Component;
|
||||
|
||||
public class GamepadSettings {
|
||||
private HashMap<ControllerComponent, Component> mapping;
|
||||
|
||||
public void insertSetting(ControllerComponent contComp, Component comp) {
|
||||
mapping.put(contComp, comp);
|
||||
}
|
||||
|
||||
public Component getComponent(ControllerComponent contComp) {
|
||||
return mapping.get(contComp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user