MCPcopy Create free account
hub / github.com/agateau/pixelwheels / UiInputMapper

Class UiInputMapper

core/src/com/agateau/ui/UiInputMapper.java:24–64  ·  view source on GitHub ↗

Responds to input from keyboard or gamepad

Source from the content-addressed store, hash-verified

22
23/** Responds to input from keyboard or gamepad */
24public class UiInputMapper implements InputMapper {
25 private final KeyMapper mKeyMapper = KeyMapper.createUiInstance();
26 private final GamepadInputMapper mGamepadInputMapper =
27 GamepadInputMappers.getInstance().getMappers()[0];
28
29 private static UiInputMapper sInstance;
30
31 private UiInputMapper() {}
32
33 public static UiInputMapper getInstance() {
34 if (sInstance == null) {
35 sInstance = new UiInputMapper();
36 }
37 return sInstance;
38 }
39
40 public KeyMapper getKeyMapper() {
41 return mKeyMapper;
42 }
43
44 @Override
45 public boolean isKeyPressed(VirtualKey key) {
46 return mKeyMapper.isKeyPressed(key) || mGamepadInputMapper.isKeyPressed(key);
47 }
48
49 @Override
50 public boolean isKeyJustPressed(VirtualKey key) {
51 return mKeyMapper.isKeyJustPressed(key) || mGamepadInputMapper.isKeyJustPressed(key);
52 }
53
54 @Override
55 public void loadConfig(Preferences preferences, String prefix, int playerIdx) {}
56
57 @Override
58 public void saveConfig(Preferences preferences, String prefix) {}
59
60 @Override
61 public boolean isAvailable() {
62 return true;
63 }
64}

Callers

nothing calls this directly

Calls 3

createUiInstanceMethod · 0.95
getInstanceMethod · 0.95
getMappersMethod · 0.80

Tested by

no test coverage detected