Remove legacy pointer tracking outside Windows.

This commit is contained in:
Unknown W. Brackets 2017-03-14 21:09:43 -07:00
parent 1ca40488f2
commit 255c726c1e
6 changed files with 6 additions and 59 deletions

View File

@ -548,7 +548,6 @@ namespace MainWindow
mouseButtonDown = true;
{
std::lock_guard<std::mutex> guard(input_state.lock);
input_state.mouse_valid = true;
input_state.pointer_down[0] = true;
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;

View File

@ -736,23 +736,8 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch
touch.x = scaledX;
touch.y = scaledY;
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);
{
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;
}

View File

@ -653,9 +653,9 @@ int main(int argc, char *argv[]) {
int framecount = 0;
float t = 0;
float lastT = 0;
while (true) {
input_state.mouse_valid = true;
bool mouseDown = false;
while (true) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
float mx = event.motion.x * g_dpi_scale;
@ -742,10 +742,7 @@ int main(int argc, char *argv[]) {
switch (event.button.button) {
case SDL_BUTTON_LEFT:
{
input_state.pointer_x[0] = mx;
input_state.pointer_y[0] = my;
input_state.pointer_down[0] = true;
input_state.mouse_valid = true;
mouseDown = true;
TouchInput input;
input.x = mx;
input.y = my;
@ -783,10 +780,7 @@ int main(int argc, char *argv[]) {
NativeKey(key);
}
case SDL_MOUSEMOTION:
if (input_state.pointer_down[0]) {
input_state.pointer_x[0] = mx;
input_state.pointer_y[0] = my;
input_state.mouse_valid = true;
if (mouseDown) {
TouchInput input;
input.x = mx;
input.y = my;
@ -799,11 +793,7 @@ int main(int argc, char *argv[]) {
switch (event.button.button) {
case SDL_BUTTON_LEFT:
{
input_state.pointer_x[0] = mx;
input_state.pointer_y[0] = my;
input_state.pointer_down[0] = false;
input_state.mouse_valid = true;
//input_state.mouse_buttons_up = 1;
mouseDown = false;
TouchInput input;
input.x = mx;
input.y = my;

View File

@ -249,10 +249,6 @@ bool MainUI::event(QEvent *e)
break;
case Qt::TouchPointPressed:
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.y = touchPoint.pos().y() * g_dpi_scale * yscale;
input.flags = (touchPoint.state() == Qt::TouchPointPressed) ? TOUCH_DOWN : TOUCH_UP;
@ -260,9 +256,6 @@ bool MainUI::event(QEvent *e)
NativeTouch(input);
break;
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.y = touchPoint.pos().y() * g_dpi_scale * yscale;
input.flags = TOUCH_MOVE;
@ -280,10 +273,6 @@ bool MainUI::event(QEvent *e)
break;
case QEvent::MouseButtonPress:
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.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
input.flags = (e->type() == QEvent::MouseButtonPress) ? TOUCH_DOWN : TOUCH_UP;
@ -291,9 +280,6 @@ bool MainUI::event(QEvent *e)
NativeTouch(input);
break;
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.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
input.flags = TOUCH_MOVE;

View File

@ -110,15 +110,10 @@ public:
struct InputState {
// Lock this whenever you access the data in this struct.
mutable std::mutex lock;
InputState()
: mouse_valid(false) {
InputState() {
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_y[MAX_POINTERS];
bool pointer_down[MAX_POINTERS];

View File

@ -264,8 +264,6 @@ static GraphicsContext *graphicsContext;
- (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;
if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)]) {
@ -276,19 +274,14 @@ static GraphicsContext *graphicsContext;
float scaledY = (int)(y * dp_yscale) * scale;
TouchInput input;
input_state.pointer_x[pointerId] = scaledX;
input_state.pointer_y[pointerId] = scaledY;
input.x = scaledX;
input.y = scaledY;
switch (code) {
case 1 :
input_state.pointer_down[pointerId] = true;
input.flags = TOUCH_DOWN;
break;
case 2 :
input_state.pointer_down[pointerId] = false;
input.flags = TOUCH_UP;
break;
@ -296,7 +289,6 @@ static GraphicsContext *graphicsContext;
input.flags = TOUCH_MOVE;
break;
}
input_state.mouse_valid = true;
input.id = pointerId;
NativeTouch(input);
}