Skip to content

Commit d46cd29

Browse files
use system properties to specify input preference
1 parent bacddb0 commit d46cd29

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/uk/co/electronstudio/sdl2gdx/SDL2ControllerManager.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.badlogic.gdx.utils.IntArray;
1111
import org.libsdl.*;
1212

13-
import static uk.co.electronstudio.sdl2gdx.SDL2ControllerManager.InputPreference.XINPUT;
13+
import static uk.co.electronstudio.sdl2gdx.SDL2ControllerManager.InputPreference.*;
1414

1515
public class SDL2ControllerManager implements ControllerManager {
1616

@@ -22,7 +22,18 @@ public class SDL2ControllerManager implements ControllerManager {
2222
private boolean running = true;
2323

2424
public SDL2ControllerManager() {
25-
this(XINPUT);
25+
this(getInputPreferenceProperty());
26+
}
27+
28+
private static InputPreference getInputPreferenceProperty() {
29+
String ip = System.getProperty("SDL.input");
30+
if(ip==null) return XINPUT;
31+
switch (ip){
32+
case "XINPUT": return XINPUT;
33+
case "RAW_INPUT": return RAW_INPUT;
34+
case "DIRECT_INPUT": return DIRECT_INPUT;
35+
default: return XINPUT;
36+
}
2637
}
2738

2839
public enum InputPreference{

src/uk/co/electronstudio/sdl2gdx/tests/SDLTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public static void main(String[] args) {
4040
}
4141

4242
private static void init() {
43-
43+
//System.setProperty("SDL.input","DIRECT_INPUT");
44+
//controllerManager = new SDL2ControllerManager();
4445
controllerManager = new SDL2ControllerManager((SDL2ControllerManager.InputPreference) inputPref.getSelectedItem());
4546
}
4647

0 commit comments

Comments
 (0)