The pointer now appears only when needed.

This commit is contained in:
SerpentSpirale 2021-05-27 20:01:12 +02:00 committed by SerpentSpirale
parent 1b605d0548
commit 087eadb1e5
2 changed files with 9 additions and 1 deletions

View File

@ -47,7 +47,7 @@ public class Gamepad {
private final GamepadMapping menuMap = new GamepadMapping();
private GamepadMapping currentMap = menuMap;
private boolean isGrabbing = false;
private boolean isGrabbing = true;
private Thread mouseThread;
@ -125,6 +125,7 @@ public class Gamepad {
//TODO hide the cursor
currentMap = gameMap;
menuMap.resetPressedState();
setPointerViewVisible(false);
}else{
//TODO place the cursor at the center
currentMap = menuMap;
@ -135,6 +136,7 @@ public class Gamepad {
gameActivity.mouse_y = CallbackBridge.windowHeight/2;
CallbackBridge.sendCursorPos(gameActivity.mouse_x, gameActivity.mouse_y);
placePointerView(CallbackBridge.physicalWidth/2, CallbackBridge.physicalHeight/2);
setPointerViewVisible(true);
}
}
@ -294,6 +296,11 @@ public class Gamepad {
pointerView.setTranslationY(y-32);
}
private void setPointerViewVisible(boolean state){
new Handler(Looper.getMainLooper()).post(() -> pointerView.setVisibility( state ? View.VISIBLE : View.INVISIBLE));
}
private void sendButton(KeyEvent event){
int keycode = event.getKeyCode();
switch (keycode){

View File

@ -41,6 +41,7 @@
<ImageView
android:id="@+id/console_pointer"
android:visibility="invisible"
android:layout_width="64px"
android:layout_height="64px"
app:srcCompat="@drawable/pointer" />