mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 16:19:44 +00:00
Remove legacy pointer tracking outside Windows.
This commit is contained in:
parent
1ca40488f2
commit
255c726c1e
@ -548,7 +548,6 @@ namespace MainWindow
|
|||||||
mouseButtonDown = true;
|
mouseButtonDown = true;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
std::lock_guard<std::mutex> guard(input_state.lock);
|
||||||
input_state.mouse_valid = true;
|
|
||||||
input_state.pointer_down[0] = true;
|
input_state.pointer_down[0] = true;
|
||||||
|
|
||||||
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;
|
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||||
|
@ -736,23 +736,8 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch
|
|||||||
touch.x = scaledX;
|
touch.x = scaledX;
|
||||||
touch.y = scaledY;
|
touch.y = scaledY;
|
||||||
touch.flags = code;
|
touch.flags = code;
|
||||||
if (code & 2) {
|
|
||||||
input_state.pointer_down[pointerId] = true;
|
|
||||||
} else if (code & 4) {
|
|
||||||
input_state.pointer_down[pointerId] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool retval = NativeTouch(touch);
|
bool retval = NativeTouch(touch);
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
|
||||||
if (pointerId >= MAX_POINTERS) {
|
|
||||||
ELOG("Too many pointers: %i", pointerId);
|
|
||||||
return false; // We ignore 8+ pointers entirely.
|
|
||||||
}
|
|
||||||
input_state.pointer_x[pointerId] = scaledX;
|
|
||||||
input_state.pointer_y[pointerId] = scaledY;
|
|
||||||
input_state.mouse_valid = true;
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,9 +653,9 @@ int main(int argc, char *argv[]) {
|
|||||||
int framecount = 0;
|
int framecount = 0;
|
||||||
float t = 0;
|
float t = 0;
|
||||||
float lastT = 0;
|
float lastT = 0;
|
||||||
while (true) {
|
bool mouseDown = false;
|
||||||
input_state.mouse_valid = true;
|
|
||||||
|
|
||||||
|
while (true) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
float mx = event.motion.x * g_dpi_scale;
|
float mx = event.motion.x * g_dpi_scale;
|
||||||
@ -742,10 +742,7 @@ int main(int argc, char *argv[]) {
|
|||||||
switch (event.button.button) {
|
switch (event.button.button) {
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT:
|
||||||
{
|
{
|
||||||
input_state.pointer_x[0] = mx;
|
mouseDown = true;
|
||||||
input_state.pointer_y[0] = my;
|
|
||||||
input_state.pointer_down[0] = true;
|
|
||||||
input_state.mouse_valid = true;
|
|
||||||
TouchInput input;
|
TouchInput input;
|
||||||
input.x = mx;
|
input.x = mx;
|
||||||
input.y = my;
|
input.y = my;
|
||||||
@ -783,10 +780,7 @@ int main(int argc, char *argv[]) {
|
|||||||
NativeKey(key);
|
NativeKey(key);
|
||||||
}
|
}
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
if (input_state.pointer_down[0]) {
|
if (mouseDown) {
|
||||||
input_state.pointer_x[0] = mx;
|
|
||||||
input_state.pointer_y[0] = my;
|
|
||||||
input_state.mouse_valid = true;
|
|
||||||
TouchInput input;
|
TouchInput input;
|
||||||
input.x = mx;
|
input.x = mx;
|
||||||
input.y = my;
|
input.y = my;
|
||||||
@ -799,11 +793,7 @@ int main(int argc, char *argv[]) {
|
|||||||
switch (event.button.button) {
|
switch (event.button.button) {
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT:
|
||||||
{
|
{
|
||||||
input_state.pointer_x[0] = mx;
|
mouseDown = false;
|
||||||
input_state.pointer_y[0] = my;
|
|
||||||
input_state.pointer_down[0] = false;
|
|
||||||
input_state.mouse_valid = true;
|
|
||||||
//input_state.mouse_buttons_up = 1;
|
|
||||||
TouchInput input;
|
TouchInput input;
|
||||||
input.x = mx;
|
input.x = mx;
|
||||||
input.y = my;
|
input.y = my;
|
||||||
|
@ -249,10 +249,6 @@ bool MainUI::event(QEvent *e)
|
|||||||
break;
|
break;
|
||||||
case Qt::TouchPointPressed:
|
case Qt::TouchPointPressed:
|
||||||
case Qt::TouchPointReleased:
|
case Qt::TouchPointReleased:
|
||||||
input_state.pointer_down[touchPoint.id()] = (touchPoint.state() == Qt::TouchPointPressed);
|
|
||||||
input_state.pointer_x[touchPoint.id()] = touchPoint.pos().x() * g_dpi_scale * xscale;
|
|
||||||
input_state.pointer_y[touchPoint.id()] = touchPoint.pos().y() * g_dpi_scale * yscale;
|
|
||||||
|
|
||||||
input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
|
input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
|
||||||
input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
|
input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
|
||||||
input.flags = (touchPoint.state() == Qt::TouchPointPressed) ? TOUCH_DOWN : TOUCH_UP;
|
input.flags = (touchPoint.state() == Qt::TouchPointPressed) ? TOUCH_DOWN : TOUCH_UP;
|
||||||
@ -260,9 +256,6 @@ bool MainUI::event(QEvent *e)
|
|||||||
NativeTouch(input);
|
NativeTouch(input);
|
||||||
break;
|
break;
|
||||||
case Qt::TouchPointMoved:
|
case Qt::TouchPointMoved:
|
||||||
input_state.pointer_x[touchPoint.id()] = touchPoint.pos().x() * g_dpi_scale * xscale;
|
|
||||||
input_state.pointer_y[touchPoint.id()] = touchPoint.pos().y() * g_dpi_scale * yscale;
|
|
||||||
|
|
||||||
input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
|
input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
|
||||||
input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
|
input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
|
||||||
input.flags = TOUCH_MOVE;
|
input.flags = TOUCH_MOVE;
|
||||||
@ -280,10 +273,6 @@ bool MainUI::event(QEvent *e)
|
|||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
input_state.pointer_down[0] = (e->type() == QEvent::MouseButtonPress);
|
|
||||||
input_state.pointer_x[0] = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
|
||||||
input_state.pointer_y[0] = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
|
||||||
|
|
||||||
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
||||||
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
||||||
input.flags = (e->type() == QEvent::MouseButtonPress) ? TOUCH_DOWN : TOUCH_UP;
|
input.flags = (e->type() == QEvent::MouseButtonPress) ? TOUCH_DOWN : TOUCH_UP;
|
||||||
@ -291,9 +280,6 @@ bool MainUI::event(QEvent *e)
|
|||||||
NativeTouch(input);
|
NativeTouch(input);
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
input_state.pointer_x[0] = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
|
||||||
input_state.pointer_y[0] = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
|
||||||
|
|
||||||
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
|
||||||
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
|
||||||
input.flags = TOUCH_MOVE;
|
input.flags = TOUCH_MOVE;
|
||||||
|
@ -110,15 +110,10 @@ public:
|
|||||||
struct InputState {
|
struct InputState {
|
||||||
// Lock this whenever you access the data in this struct.
|
// Lock this whenever you access the data in this struct.
|
||||||
mutable std::mutex lock;
|
mutable std::mutex lock;
|
||||||
InputState()
|
InputState() {
|
||||||
: mouse_valid(false) {
|
|
||||||
memset(pointer_down, 0, sizeof(pointer_down));
|
memset(pointer_down, 0, sizeof(pointer_down));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mouse/touch style input
|
|
||||||
// There are up to 8 mice / fingers.
|
|
||||||
volatile bool mouse_valid;
|
|
||||||
|
|
||||||
int pointer_x[MAX_POINTERS];
|
int pointer_x[MAX_POINTERS];
|
||||||
int pointer_y[MAX_POINTERS];
|
int pointer_y[MAX_POINTERS];
|
||||||
bool pointer_down[MAX_POINTERS];
|
bool pointer_down[MAX_POINTERS];
|
||||||
|
@ -264,8 +264,6 @@ static GraphicsContext *graphicsContext;
|
|||||||
|
|
||||||
- (void)touchX:(float)x y:(float)y code:(int)code pointerId:(int)pointerId
|
- (void)touchX:(float)x y:(float)y code:(int)code pointerId:(int)pointerId
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
|
||||||
|
|
||||||
float scale = [UIScreen mainScreen].scale;
|
float scale = [UIScreen mainScreen].scale;
|
||||||
|
|
||||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)]) {
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)]) {
|
||||||
@ -276,19 +274,14 @@ static GraphicsContext *graphicsContext;
|
|||||||
float scaledY = (int)(y * dp_yscale) * scale;
|
float scaledY = (int)(y * dp_yscale) * scale;
|
||||||
|
|
||||||
TouchInput input;
|
TouchInput input;
|
||||||
|
|
||||||
input_state.pointer_x[pointerId] = scaledX;
|
|
||||||
input_state.pointer_y[pointerId] = scaledY;
|
|
||||||
input.x = scaledX;
|
input.x = scaledX;
|
||||||
input.y = scaledY;
|
input.y = scaledY;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 1 :
|
case 1 :
|
||||||
input_state.pointer_down[pointerId] = true;
|
|
||||||
input.flags = TOUCH_DOWN;
|
input.flags = TOUCH_DOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
input_state.pointer_down[pointerId] = false;
|
|
||||||
input.flags = TOUCH_UP;
|
input.flags = TOUCH_UP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -296,7 +289,6 @@ static GraphicsContext *graphicsContext;
|
|||||||
input.flags = TOUCH_MOVE;
|
input.flags = TOUCH_MOVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
input_state.mouse_valid = true;
|
|
||||||
input.id = pointerId;
|
input.id = pointerId;
|
||||||
NativeTouch(input);
|
NativeTouch(input);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user