@@ -42,6 +42,7 @@ public enum ControllerType {
42
42
}
43
43
44
44
public static ControllerType lastUsedType = ControllerType .OTHER ;
45
+ public static boolean controllerActive = false ;
45
46
46
47
private static void setControllerType (Controller controller ){
47
48
if (controller .getName ().contains ("Xbox" )){
@@ -69,6 +70,7 @@ public static boolean isControllerConnected(){
69
70
70
71
@ Override
71
72
public void connected (Controller controller ) {
73
+ controllerActive = true ;
72
74
setControllerType (controller );
73
75
}
74
76
@@ -80,6 +82,7 @@ public void disconnected(Controller controller) {
80
82
@ Override
81
83
public boolean buttonDown (Controller controller , int buttonCode ) {
82
84
setControllerType (controller );
85
+ controllerActive = true ;
83
86
int keyCode = buttonToKey (controller , buttonCode );
84
87
if (keyCode != Input .Keys .UNKNOWN ){
85
88
KeyEvent .addKeyEvent (new KeyEvent (keyCode , true ));
@@ -91,6 +94,7 @@ public boolean buttonDown(Controller controller, int buttonCode) {
91
94
@ Override
92
95
public boolean buttonUp (Controller controller , int buttonCode ) {
93
96
setControllerType (controller );
97
+ controllerActive = true ;
94
98
int keyCode = buttonToKey (controller , buttonCode );
95
99
if (keyCode != Input .Keys .UNKNOWN ){
96
100
KeyEvent .addKeyEvent (new KeyEvent (keyCode , false ));
@@ -120,17 +124,21 @@ else if (axisCode == 4) {
120
124
121
125
if (L2Trigger < 0.5f && value >= 0.5f ){
122
126
KeyEvent .addKeyEvent (new KeyEvent (Input .Keys .BUTTON_L2 , true ));
127
+ controllerActive = true ;
123
128
} else if (L2Trigger >= 0.5f && value < 0.5f ){
124
129
KeyEvent .addKeyEvent (new KeyEvent (Input .Keys .BUTTON_L2 , false ));
130
+ controllerActive = true ;
125
131
}
126
132
L2Trigger = value ;
127
133
128
134
} else if (axisCode == 5 ){
129
135
130
136
if (R2Trigger < 0.5f && value >= 0.5f ){
131
137
KeyEvent .addKeyEvent (new KeyEvent (Input .Keys .BUTTON_R2 , true ));
138
+ controllerActive = true ;
132
139
} else if (R2Trigger >= 0.5f && value < 0.5f ){
133
140
KeyEvent .addKeyEvent (new KeyEvent (Input .Keys .BUTTON_R2 , false ));
141
+ controllerActive = true ;
134
142
}
135
143
R2Trigger = value ;
136
144
@@ -143,6 +151,7 @@ else if (axisCode == 4) {
143
151
private static PointF controllerPointerPos ;
144
152
145
153
public static void setControllerPointer ( boolean active ){
154
+ if (active ) controllerActive = true ;
146
155
if (controllerPointerActive == active ) return ;
147
156
controllerPointerActive = active ;
148
157
if (active ){
@@ -164,6 +173,7 @@ public static PointF getControllerPointerPos(){
164
173
public static void updateControllerPointer (PointF pos , boolean sendEvent ){
165
174
controllerPointerPos .set (pos );
166
175
if (sendEvent ) {
176
+ controllerActive = true ;
167
177
PointerEvent .addPointerEvent (new PointerEvent ((int ) controllerPointerPos .x , (int ) controllerPointerPos .y , 10_000 , PointerEvent .Type .HOVER , PointerEvent .NONE ));
168
178
}
169
179
}
@@ -211,9 +221,9 @@ public static boolean icControllerKey(int keyCode){
211
221
public static String customButtonName (int keyCode ){
212
222
if (lastUsedType == ControllerType .PLAYSTATION ){
213
223
if (keyCode == Input .Keys .BUTTON_A ){
214
- return "Circle Button" ;
215
- } else if (keyCode == Input .Keys .BUTTON_B ){
216
224
return "Cross Button" ;
225
+ } else if (keyCode == Input .Keys .BUTTON_B ){
226
+ return "Circle Button" ;
217
227
} else if (keyCode == Input .Keys .BUTTON_X ){
218
228
return "Square Button" ;
219
229
} else if (keyCode == Input .Keys .BUTTON_Y ){
0 commit comments