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

View File

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