parent
9181ab19c7
commit
e48e45db76
|
@ -764,17 +764,70 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
|
|
||||||
Frontend::GetTouchCoords(x, y);
|
if (Frontend::GetTouchCoords(x, y))
|
||||||
|
|
||||||
// clamp to screen range
|
|
||||||
if (x < 0) x = 0;
|
|
||||||
else if (x > 255) x = 255;
|
|
||||||
if (y < 0) y = 0;
|
|
||||||
else if (y > 191) y = 191;
|
|
||||||
|
|
||||||
NDS::TouchScreen(x, y);
|
NDS::TouchScreen(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenHandler::screenHandleTablet(QTabletEvent* event)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
|
||||||
|
switch(event->type())
|
||||||
|
{
|
||||||
|
case QEvent::TabletPress:
|
||||||
|
case QEvent::TabletMove:
|
||||||
|
{
|
||||||
|
int x = event->x();
|
||||||
|
int y = event->y();
|
||||||
|
|
||||||
|
if (Frontend::GetTouchCoords(x, y))
|
||||||
|
{
|
||||||
|
touching = true;
|
||||||
|
NDS::TouchScreen(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::TabletRelease:
|
||||||
|
if (touching)
|
||||||
|
{
|
||||||
|
NDS::ReleaseScreen();
|
||||||
|
touching = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenHandler::screenHandleTouch(QTouchEvent* event)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
|
||||||
|
switch(event->type())
|
||||||
|
{
|
||||||
|
case QEvent::TouchBegin:
|
||||||
|
case QEvent::TouchUpdate:
|
||||||
|
if (event->touchPoints().length() > 0)
|
||||||
|
{
|
||||||
|
QPointF lastPosition = event->touchPoints().first().lastPos();
|
||||||
|
int x = (int)lastPosition.x();
|
||||||
|
int y = (int)lastPosition.y();
|
||||||
|
|
||||||
|
if (Frontend::GetTouchCoords(x, y))
|
||||||
|
{
|
||||||
|
touching = true;
|
||||||
|
NDS::TouchScreen(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::TouchEnd:
|
||||||
|
if (touching)
|
||||||
|
{
|
||||||
|
NDS::ReleaseScreen();
|
||||||
|
touching = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenHandler::showCursor()
|
void ScreenHandler::showCursor()
|
||||||
{
|
{
|
||||||
mainWindow->panel->setCursor(Qt::ArrowCursor);
|
mainWindow->panel->setCursor(Qt::ArrowCursor);
|
||||||
|
@ -801,6 +854,8 @@ ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent)
|
||||||
|
|
||||||
touching = false;
|
touching = false;
|
||||||
|
|
||||||
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
|
|
||||||
OSD::Init(nullptr);
|
OSD::Init(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,6 +934,23 @@ void ScreenPanelNative::mouseMoveEvent(QMouseEvent* event)
|
||||||
screenOnMouseMove(event);
|
screenOnMouseMove(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenPanelNative::tabletEvent(QTabletEvent* event)
|
||||||
|
{
|
||||||
|
screenHandleTablet(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenPanelNative::event(QEvent* event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::TouchBegin
|
||||||
|
|| event->type() == QEvent::TouchEnd
|
||||||
|
|| event->type() == QEvent::TouchUpdate)
|
||||||
|
{
|
||||||
|
screenHandleTouch((QTouchEvent*)event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return QWidget::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenPanelNative::onScreenLayoutChanged()
|
void ScreenPanelNative::onScreenLayoutChanged()
|
||||||
{
|
{
|
||||||
setMinimumSize(screenGetMinSize());
|
setMinimumSize(screenGetMinSize());
|
||||||
|
@ -890,6 +962,7 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent)
|
||||||
{
|
{
|
||||||
touching = false;
|
touching = false;
|
||||||
|
|
||||||
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenPanelGL::~ScreenPanelGL()
|
ScreenPanelGL::~ScreenPanelGL()
|
||||||
|
@ -1090,6 +1163,23 @@ void ScreenPanelGL::mouseMoveEvent(QMouseEvent* event)
|
||||||
screenOnMouseMove(event);
|
screenOnMouseMove(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenPanelGL::tabletEvent(QTabletEvent* event)
|
||||||
|
{
|
||||||
|
screenHandleTablet(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenPanelGL::event(QEvent* event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::TouchBegin
|
||||||
|
|| event->type() == QEvent::TouchEnd
|
||||||
|
|| event->type() == QEvent::TouchUpdate)
|
||||||
|
{
|
||||||
|
screenHandleTouch((QTouchEvent*)event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return QWidget::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenPanelGL::onScreenLayoutChanged()
|
void ScreenPanelGL::onScreenLayoutChanged()
|
||||||
{
|
{
|
||||||
setMinimumSize(screenGetMinSize());
|
setMinimumSize(screenGetMinSize());
|
||||||
|
|
|
@ -110,6 +110,9 @@ protected:
|
||||||
void screenOnMouseRelease(QMouseEvent* event);
|
void screenOnMouseRelease(QMouseEvent* event);
|
||||||
void screenOnMouseMove(QMouseEvent* event);
|
void screenOnMouseMove(QMouseEvent* event);
|
||||||
|
|
||||||
|
void screenHandleTablet(QTabletEvent* event);
|
||||||
|
void screenHandleTouch(QTouchEvent* event);
|
||||||
|
|
||||||
float screenMatrix[Frontend::MaxScreenTransforms][6];
|
float screenMatrix[Frontend::MaxScreenTransforms][6];
|
||||||
int screenKind[Frontend::MaxScreenTransforms];
|
int screenKind[Frontend::MaxScreenTransforms];
|
||||||
int numScreens;
|
int numScreens;
|
||||||
|
@ -137,6 +140,8 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
|
void tabletEvent(QTabletEvent* event) override;
|
||||||
|
bool event(QEvent* event) override;
|
||||||
private slots:
|
private slots:
|
||||||
void onScreenLayoutChanged();
|
void onScreenLayoutChanged();
|
||||||
|
|
||||||
|
@ -168,6 +173,8 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
|
void tabletEvent(QTabletEvent* event) override;
|
||||||
|
bool event(QEvent* event) override;
|
||||||
private slots:
|
private slots:
|
||||||
void onScreenLayoutChanged();
|
void onScreenLayoutChanged();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue