mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Cleanup, add right-click support to UI framework
This commit is contained in:
parent
caf27a5c0d
commit
19f4b22a56
@ -134,8 +134,9 @@ enum {
|
||||
TOUCH_UP = 1 << 2,
|
||||
TOUCH_CANCEL = 1 << 3, // Sent by scrollviews to their children when they detect a scroll
|
||||
TOUCH_WHEEL = 1 << 4, // Scrollwheel event. Usually only affects Y but can potentially affect X.
|
||||
TOUCH_MOUSE = 1 << 5, // Identifies that this touch event came from a mouse
|
||||
TOUCH_MOUSE = 1 << 5, // Identifies that this touch event came from a mouse. Id is now set to the mouse button for DOWN/UP commands.
|
||||
TOUCH_RELEASE_ALL = 1 << 6, // Useful for app focus switches when events may be lost.
|
||||
TOUCH_HOVER = 1 << 7,
|
||||
|
||||
// These are the Android getToolType() codes, shifted by 10.
|
||||
TOUCH_TOOL_MASK = 7 << 10,
|
||||
@ -153,6 +154,7 @@ struct TouchInput {
|
||||
float x;
|
||||
float y;
|
||||
int id; // Needs to be <= GestureDetector::MAX_PTRS (10.)
|
||||
int buttons; // bit mask
|
||||
int flags;
|
||||
double timestamp;
|
||||
};
|
||||
|
@ -249,6 +249,11 @@ bool Clickable::Touch(const TouchInput &input) {
|
||||
return contains;
|
||||
}
|
||||
|
||||
// Ignore buttons other than the left one.
|
||||
if ((input.flags & TOUCH_MOUSE) && input.id != 0) {
|
||||
return contains;
|
||||
}
|
||||
|
||||
if (input.flags & TOUCH_DOWN) {
|
||||
if (bounds_.Contains(input.x, input.y)) {
|
||||
if (IsFocusMovementEnabled())
|
||||
|
@ -954,15 +954,14 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) {
|
||||
// Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode).
|
||||
// We need to manually implement it here :/
|
||||
if (imguiVisible_ && imguiInited_ && (key.flags & KEY_DOWN)) {
|
||||
if (imguiVisible_ && imguiInited_) {
|
||||
InputMapping mapping(key.deviceId, key.keyCode);
|
||||
std::vector<int> pspButtons;
|
||||
bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons);
|
||||
if (mappingFound) {
|
||||
for (auto b : pspButtons) {
|
||||
if (b == VIRTKEY_TOGGLE_DEBUGGER) {
|
||||
imguiVisible_ = false;
|
||||
return true;
|
||||
if (b == VIRTKEY_TOGGLE_DEBUGGER || b == VIRTKEY_PAUSE) {
|
||||
return controlMapper_.Key(key, &pauseTrigger_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -632,9 +632,9 @@ namespace MainWindow
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_DOWN;
|
||||
TouchInput touch{};
|
||||
touch.flags = TOUCH_DOWN | TOUCH_MOUSE;
|
||||
touch.buttons = 1;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -680,10 +680,15 @@ namespace MainWindow
|
||||
float y = (float)cursorY * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
if (wParam & MK_LBUTTON) {
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_MOVE;
|
||||
if (wParam & (MK_LBUTTON | MK_RBUTTON)) {
|
||||
TouchInput touch{};
|
||||
touch.flags = TOUCH_MOVE | TOUCH_MOUSE;
|
||||
if (wParam & MK_LBUTTON) {
|
||||
touch.buttons |= 1;
|
||||
}
|
||||
if (wParam & MK_RBUTTON) {
|
||||
touch.buttons |= 2;
|
||||
}
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -702,9 +707,9 @@ namespace MainWindow
|
||||
float y = (float)GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_UP;
|
||||
TouchInput touch{};
|
||||
touch.buttons = 1;
|
||||
touch.flags = TOUCH_UP | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -716,6 +721,34 @@ namespace MainWindow
|
||||
touchHandler.handleTouchEvent(hWnd, message, wParam, lParam);
|
||||
return 0;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
float x = GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
|
||||
TouchInput touch{};
|
||||
touch.buttons = 2;
|
||||
touch.flags = TOUCH_DOWN | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
float x = GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
|
||||
TouchInput touch{};
|
||||
touch.buttons = 2;
|
||||
touch.flags = TOUCH_UP | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
@ -42,11 +42,17 @@ void ImGui_ImplPlatform_TouchEvent(const TouchInput &touch) {
|
||||
}
|
||||
if (touch.flags & TOUCH_DOWN) {
|
||||
io.AddMousePosEvent(x, y);
|
||||
io.AddMouseButtonEvent(0, true);
|
||||
if (touch.buttons & 1)
|
||||
io.AddMouseButtonEvent(0, true);
|
||||
if (touch.buttons & 2)
|
||||
io.AddMouseButtonEvent(1, true);
|
||||
}
|
||||
if (touch.flags & TOUCH_UP) {
|
||||
io.AddMousePosEvent(x, y);
|
||||
io.AddMouseButtonEvent(0, false);
|
||||
if (touch.buttons & 1)
|
||||
io.AddMouseButtonEvent(0, false);
|
||||
if (touch.buttons & 2)
|
||||
io.AddMouseButtonEvent(1, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user