mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
ANDROID: Add an on-screen menu button
This commit is contained in:
parent
3ddce1cf3a
commit
c1702a0953
@ -77,7 +77,8 @@ enum {
|
||||
JE_BMB_UP = 19,
|
||||
JE_FMB_DOWN = 20,
|
||||
JE_FMB_UP = 21,
|
||||
JE_QUIT = 0x1000
|
||||
JE_QUIT = 0x1000,
|
||||
JE_MENU = 0x1001
|
||||
};
|
||||
|
||||
// meta modifier
|
||||
@ -1221,6 +1222,13 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
||||
|
||||
return;
|
||||
|
||||
case JE_MENU:
|
||||
e.type = Common::EVENT_MAINMENU;
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
LOGE("unknown jevent type: %d", type);
|
||||
|
||||
|
@ -38,6 +38,7 @@ import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -115,6 +116,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
|
||||
private EditableSurfaceView _main_surface = null;
|
||||
private ImageView _toggleKeyboardBtnIcon = null;
|
||||
private ImageView _openMenuBtnIcon = null;
|
||||
|
||||
public View _screenKeyboard = null;
|
||||
static boolean keyboardWithoutTextInputShown = false;
|
||||
@ -570,6 +572,18 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
};
|
||||
|
||||
|
||||
public final View.OnClickListener menuBtnOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
_scummvm.pushEvent(ScummVMEventsBase.JE_MENU, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private class MyScummVM extends ScummVM {
|
||||
|
||||
public MyScummVM(SurfaceHolder holder, final MyScummVMDestroyedCallback destroyedCallback) {
|
||||
@ -879,14 +893,24 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
|
||||
_videoLayout.addView(_main_surface, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
|
||||
LinearLayout buttonLayout = new LinearLayout(this);
|
||||
buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
FrameLayout.LayoutParams buttonLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.END);
|
||||
buttonLayoutParams.setMarginEnd(5);
|
||||
buttonLayoutParams.topMargin = 5;
|
||||
buttonLayoutParams.rightMargin = 5;
|
||||
_videoLayout.addView(buttonLayout, buttonLayoutParams);
|
||||
_videoLayout.bringChildToFront(buttonLayout);
|
||||
|
||||
_toggleKeyboardBtnIcon = new ImageView(this);
|
||||
_toggleKeyboardBtnIcon.setImageResource(R.drawable.ic_action_keyboard);
|
||||
FrameLayout.LayoutParams keybrdBtnlayout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.END);
|
||||
keybrdBtnlayout.setMarginEnd(15);
|
||||
keybrdBtnlayout.topMargin = 15;
|
||||
keybrdBtnlayout.rightMargin = 15;
|
||||
_videoLayout.addView(_toggleKeyboardBtnIcon, keybrdBtnlayout);
|
||||
_videoLayout.bringChildToFront(_toggleKeyboardBtnIcon);
|
||||
buttonLayout.addView(_toggleKeyboardBtnIcon, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
||||
buttonLayout.bringChildToFront(_toggleKeyboardBtnIcon);
|
||||
|
||||
_openMenuBtnIcon = new ImageView(this);
|
||||
_openMenuBtnIcon.setImageResource(R.drawable.ic_action_menu);
|
||||
buttonLayout.addView(_openMenuBtnIcon, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
||||
buttonLayout.bringChildToFront(_openMenuBtnIcon);
|
||||
|
||||
_main_surface.setFocusable(true);
|
||||
_main_surface.setFocusableInTouchMode(true);
|
||||
@ -976,6 +1000,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
// On screen button listener
|
||||
//findViewById(R.id.show_keyboard).setOnClickListener(keyboardBtnOnClickListener);
|
||||
_toggleKeyboardBtnIcon.setOnClickListener(keyboardBtnOnClickListener);
|
||||
_openMenuBtnIcon.setOnClickListener(menuBtnOnClickListener);
|
||||
|
||||
// Keyboard visibility listener - mainly to hide system UI if keyboard is shown and we return from Suspend to the Activity
|
||||
setKeyboardVisibilityListener(this);
|
||||
@ -1223,7 +1248,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
// }
|
||||
// }
|
||||
|
||||
// Show or hide the semi-transparent keyboard btn (which is used to explicitly bring up the android keyboard).
|
||||
// Show or hide the semi-transparent onscreen controls
|
||||
// Called by the override of showKeyboardControl()
|
||||
private void showToggleKeyboardBtnIcon(boolean show) {
|
||||
//ImageView keyboardBtn = findViewById(R.id.show_keyboard);
|
||||
@ -1234,6 +1259,14 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||
_toggleKeyboardBtnIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (_openMenuBtnIcon != null ) {
|
||||
if (show) {
|
||||
_openMenuBtnIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
_openMenuBtnIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Listener to check for keyboard visibility changes
|
||||
|
@ -48,6 +48,7 @@ public class ScummVMEventsBase implements
|
||||
public static final int JE_FMB_DOWN = 20;
|
||||
public static final int JE_FMB_UP = 21;
|
||||
public static final int JE_QUIT = 0x1000;
|
||||
public static final int JE_MENU = 0x1001;
|
||||
|
||||
final protected Context _context;
|
||||
final protected ScummVM _scummvm;
|
||||
|
@ -1,5 +0,0 @@
|
||||
<vector android:alpha="0.5" android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2zM11,8h2v2h-2L11,8zM11,11h2v2h-2v-2zM8,8h2v2L8,10L8,8zM8,11h2v2L8,13v-2zM7,13L5,13v-2h2v2zM7,10L5,10L5,8h2v2zM16,17L8,17v-2h8v2zM16,13h-2v-2h2v2zM16,10h-2L14,8h2v2zM19,13h-2v-2h2v2zM19,10h-2L17,8h2v2z"/>
|
||||
</vector>
|
Binary file not shown.
Before Width: | Height: | Size: 309 B |
Binary file not shown.
Before Width: | Height: | Size: 265 B |
Binary file not shown.
Before Width: | Height: | Size: 354 B |
Binary file not shown.
Before Width: | Height: | Size: 326 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
14
dists/android/res/drawable/ic_action_keyboard.xml
Normal file
14
dists/android/res/drawable/ic_action_keyboard.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48"
|
||||
android:alpha="0.5">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 40 10 L 8 10 C 5.79 10 4.02 11.79 4.02 14 L 4 34 C 4 36.21 5.79 38 8 38 L 40 38 C 42.21 38 44 36.21 44 34 L 44 14 C 44 11.79 42.21 10 40 10 Z M 22 16 L 26 16 L 26 20 L 22 20 L 22 16 Z M 22 22 L 26 22 L 26 26 L 22 26 L 22 22 Z M 16 16 L 20 16 L 20 20 L 16 20 L 16 16 Z M 16 22 L 20 22 L 20 26 L 16 26 L 16 22 Z M 14 26 L 10 26 L 10 22 L 14 22 L 14 26 Z M 14 20 L 10 20 L 10 16 L 14 16 L 14 20 Z M 32 34 L 16 34 L 16 30 L 32 30 L 32 34 Z M 32 26 L 28 26 L 28 22 L 32 22 L 32 26 Z M 32 20 L 28 20 L 28 16 L 32 16 L 32 20 Z M 38 26 L 34 26 L 34 22 L 38 22 L 38 26 Z M 38 20 L 34 20 L 34 16 L 38 16 L 38 20 Z"
|
||||
android:fillColor="#ffffff"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
14
dists/android/res/drawable/ic_action_menu.xml
Normal file
14
dists/android/res/drawable/ic_action_menu.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48"
|
||||
android:alpha="0.5">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 6 36 L 42 36 L 42 32 L 6 32 L 6 36 Z M 6 26 L 42 26 L 42 22 L 6 22 L 6 26 Z M 6 12 L 6 16 L 42 16 L 42 12 L 6 12 Z"
|
||||
android:fillColor="#ffffff"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
Loading…
x
Reference in New Issue
Block a user