mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add input device debug info to touchscreen test screen
(yeah maybe there's a better place but it's fine). Also make a slight tweak to the detection order which I don't think matters much.
This commit is contained in:
1 parent
bccb854f9c
commit
e6857388c7
8 files changed
+142
-17
No files matched your search
@@ -62,7 +62,6 @@ PFN_vkBindImageMemory vkBindImageMemory;
|
||||
PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
|
||||
PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
||||
PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
|
||||
PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
|
||||
PFN_vkQueueBindSparse vkQueueBindSparse;
|
||||
PFN_vkCreateFence vkCreateFence;
|
||||
PFN_vkDestroyFence vkDestroyFence;
|
||||
@@ -586,7 +585,6 @@ void VulkanLoadDeviceFunctions(VkDevice device, const VulkanExtensions &enabledE
|
||||
LOAD_DEVICE_FUNC(device, vkGetBufferMemoryRequirements);
|
||||
LOAD_DEVICE_FUNC(device, vkGetImageMemoryRequirements);
|
||||
LOAD_DEVICE_FUNC(device, vkGetImageSparseMemoryRequirements);
|
||||
LOAD_DEVICE_FUNC(device, vkGetPhysicalDeviceSparseImageFormatProperties);
|
||||
LOAD_DEVICE_FUNC(device, vkQueueBindSparse);
|
||||
LOAD_DEVICE_FUNC(device, vkCreateFence);
|
||||
LOAD_DEVICE_FUNC(device, vkDestroyFence);
|
||||
|
||||
@@ -68,7 +68,6 @@ extern PFN_vkBindImageMemory vkBindImageMemory;
|
||||
extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
|
||||
extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
||||
extern PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
|
||||
extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
|
||||
extern PFN_vkQueueBindSparse vkQueueBindSparse;
|
||||
extern PFN_vkCreateFence vkCreateFence;
|
||||
extern PFN_vkDestroyFence vkDestroyFence;
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
#include "UI/ControlMappingScreen.h"
|
||||
#include "UI/GameSettingsScreen.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
#include "android/jni/app-android.h"
|
||||
#endif
|
||||
|
||||
class SingleControlMapper : public UI::LinearLayout {
|
||||
public:
|
||||
SingleControlMapper(int pspKey, std::string keyName, ScreenManager *scrm, UI::LinearLayoutParams *layoutParams = nullptr);
|
||||
@@ -805,7 +809,7 @@ void TouchTestScreen::render() {
|
||||
|
||||
ui_context->Begin();
|
||||
|
||||
char buffer[1024];
|
||||
char buffer[2048];
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id != -1) {
|
||||
ui_context->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0);
|
||||
@@ -814,15 +818,19 @@ void TouchTestScreen::render() {
|
||||
}
|
||||
}
|
||||
|
||||
char extra_debug[2048]{};
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
truncate_cpy(extra_debug, Android_GetInputDeviceDebugString().c_str());
|
||||
#endif
|
||||
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
"display_res: %dx%d\n"
|
||||
#endif
|
||||
"dp_res: %dx%d\n"
|
||||
"pixel_res: %dx%d\n"
|
||||
"g_dpi: %f\n"
|
||||
"g_dpi_scale: %0.3fx%0.3f\n"
|
||||
"g_dpi_scale_real: %0.3fx%0.3f\n",
|
||||
"dp_res: %dx%d pixel_res: %dx%d\n"
|
||||
"g_dpi: %0.3f g_dpi_scale: %0.3fx%0.3f\n"
|
||||
"g_dpi_scale_real: %0.3fx%0.3f\n%s",
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
display_xres, display_yres,
|
||||
#endif
|
||||
@@ -830,7 +838,10 @@ void TouchTestScreen::render() {
|
||||
pixel_xres, pixel_yres,
|
||||
g_dpi,
|
||||
g_dpi_scale_x, g_dpi_scale_y,
|
||||
g_dpi_scale_real_x, g_dpi_scale_real_y);
|
||||
g_dpi_scale_real_x, g_dpi_scale_real_y, extra_debug);
|
||||
|
||||
// On Android, also add joystick debug data.
|
||||
|
||||
|
||||
ui_context->DrawTextShadow(buffer, bounds.centerX(), bounds.y + 20.0f, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
|
||||
ui_context->Flush();
|
||||
|
||||
@@ -170,6 +170,7 @@ static float g_safeInsetTop = 0.0;
|
||||
static float g_safeInsetBottom = 0.0;
|
||||
|
||||
static jmethodID postCommand;
|
||||
static jmethodID getDebugString;
|
||||
|
||||
static jobject nativeActivity;
|
||||
static volatile bool exitRenderLoop;
|
||||
@@ -489,6 +490,24 @@ bool System_GetPropertyBool(SystemProperty prop) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Android_GetInputDeviceDebugString() {
|
||||
if (!nativeActivity) {
|
||||
return "(N/A)";
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring param = env->NewStringUTF("InputDevice");
|
||||
|
||||
jstring str = (jstring)env->CallObjectMethod(nativeActivity, getDebugString, param);
|
||||
if (!str) {
|
||||
return "(N/A)";
|
||||
}
|
||||
|
||||
const char *charArray = env->GetStringUTFChars(str, 0);
|
||||
std::string retVal = charArray;
|
||||
env->DeleteLocalRef(str);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string GetJavaString(JNIEnv *env, jstring jstr) {
|
||||
if (!jstr)
|
||||
return "";
|
||||
@@ -501,7 +520,9 @@ std::string GetJavaString(JNIEnv *env, jstring jstr) {
|
||||
extern "C" void Java_org_ppsspp_ppsspp_NativeActivity_registerCallbacks(JNIEnv *env, jobject obj) {
|
||||
nativeActivity = env->NewGlobalRef(obj);
|
||||
postCommand = env->GetMethodID(env->GetObjectClass(obj), "postCommand", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
getDebugString = env->GetMethodID(env->GetObjectClass(obj), "getDebugString", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
_dbg_assert_(postCommand);
|
||||
_dbg_assert_(getDebugString);
|
||||
|
||||
Android_RegisterStorageCallbacks(env, obj);
|
||||
Android_StorageSetNativeActivity(nativeActivity);
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/File/AndroidStorage.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID) && !defined(__LIBRETRO__)
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
|
||||
std::string Android_GetInputDeviceDebugString();
|
||||
|
||||
#if !defined(__LIBRETRO__)
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
@@ -22,5 +26,6 @@ class AndroidLogger : public LogListener {
|
||||
public:
|
||||
void Log(const LogMessage &message) override;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,8 @@ import android.view.InputDevice.MotionRange;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||
public class InputDeviceState {
|
||||
private static final String TAG = "InputDeviceState";
|
||||
@@ -17,29 +19,95 @@ public class InputDeviceState {
|
||||
private InputDevice mDevice;
|
||||
private int[] mAxes;
|
||||
|
||||
private int sources;
|
||||
|
||||
InputDevice getDevice() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
void logAdvanced(InputDevice device) {
|
||||
Log.i(TAG, "Vendor ID:" + device.getVendorId() + " productId: " + device.getProductId());
|
||||
static void logAdvanced(InputDevice device) {
|
||||
Log.i(TAG, "Vendor ID:" + device.getVendorId() + " productId: " + device.getProductId() + " sources: " + String.format("%08x", device.getSources()));
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
public String getDebugString() {
|
||||
String str = mDevice.getName() + " sources: " + String.format("%08x", sources) + "\n classes: ";
|
||||
|
||||
String[] classes = { "BUTTON ", "POINTER ", "TRACKBALL ", "POSITION ", "JOYSTICK " };
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if ((sources & (1 << i)) != 0) {
|
||||
str += classes[i];
|
||||
}
|
||||
}
|
||||
str += "\n ";
|
||||
|
||||
// Check the full identifications.
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
|
||||
str += "GAMEPAD ";
|
||||
}
|
||||
|
||||
if ((sources & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) {
|
||||
str += "KEYBOARD";
|
||||
if (mDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
|
||||
str += "(alpha) ";
|
||||
} else {
|
||||
str += " ";
|
||||
}
|
||||
}
|
||||
|
||||
if ((sources & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) {
|
||||
str += "JOYSTICK ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
|
||||
str += "DPAD ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_HDMI) == InputDevice.SOURCE_HDMI) {
|
||||
// what?
|
||||
str += "HDMI ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
|
||||
str += "MOUSE ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE) {
|
||||
str += "MOUSE_RELATIVE ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_ROTARY_ENCODER) == InputDevice.SOURCE_ROTARY_ENCODER) {
|
||||
str += "ROTARY_ENCODER ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) {
|
||||
str += "STYLUS ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD) {
|
||||
str += "TOUCHPAD ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
|
||||
str += "TOUCHSCREEN ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_TOUCH_NAVIGATION) == InputDevice.SOURCE_TOUCH_NAVIGATION) {
|
||||
str += "TOUCH_NAVIGATION ";
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_BLUETOOTH_STYLUS) == InputDevice.SOURCE_BLUETOOTH_STYLUS) {
|
||||
str += "BLUETOOTH_STYLUS ";
|
||||
}
|
||||
str += "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
public InputDeviceState(InputDevice device) {
|
||||
int sources = device.getSources();
|
||||
sources = device.getSources();
|
||||
// First, anything that's a gamepad is a gamepad, even if it has a keyboard or pointer.
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
|
||||
this.deviceId = NativeApp.DEVICE_ID_PAD_0;
|
||||
} else if ((sources & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD && device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
|
||||
this.deviceId = NativeApp.DEVICE_ID_KEYBOARD;
|
||||
} else if ((sources & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
|
||||
this.deviceId = NativeApp.DEVICE_ID_MOUSE;
|
||||
} else if ((sources & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK ||
|
||||
(sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
|
||||
this.deviceId = NativeApp.DEVICE_ID_PAD_0;
|
||||
} else if ((sources & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
|
||||
this.deviceId = NativeApp.DEVICE_ID_MOUSE;
|
||||
} else {
|
||||
// Built-in buttons like Back etc.
|
||||
// Built-in device buttons like Back etc.
|
||||
this.deviceId = NativeApp.DEVICE_ID_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@@ -930,6 +930,21 @@ public abstract class NativeActivity extends Activity {
|
||||
return state;
|
||||
}
|
||||
|
||||
protected String getInputDeviceDebugString() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
String buffer = "";
|
||||
for (InputDeviceState input : inputPlayers) {
|
||||
buffer += input.getDebugString();
|
||||
}
|
||||
if (buffer.length() == 0) {
|
||||
buffer = "(no devices)";
|
||||
}
|
||||
return buffer;
|
||||
} else {
|
||||
return "(input device debug not available before Android Kitkat)";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsXperiaPlay() {
|
||||
return android.os.Build.MODEL.equals("R800a") || android.os.Build.MODEL.equals("R800i") || android.os.Build.MODEL.equals("R800x") || android.os.Build.MODEL.equals("R800at") || android.os.Build.MODEL.equals("SO-01D") || android.os.Build.MODEL.equals("zeus");
|
||||
}
|
||||
|
||||
@@ -135,6 +135,14 @@ public class PpssppActivity extends NativeActivity {
|
||||
});
|
||||
}
|
||||
|
||||
public String getDebugString(String str) {
|
||||
if (str.equals("InputDevice")) {
|
||||
return getInputDeviceDebugString();
|
||||
} else {
|
||||
return "bad debug string: " + str;
|
||||
}
|
||||
}
|
||||
|
||||
public int openContentUri(String uriString, String mode) {
|
||||
try {
|
||||
Uri uri = Uri.parse(uriString);
|
||||
|
||||
Reference in new issue
Block a user