parent
9181ab19c7
commit
e48e45db76
|
@ -764,15 +764,68 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
|||
int x = event->pos().x();
|
||||
int y = event->pos().y();
|
||||
|
||||
Frontend::GetTouchCoords(x, y);
|
||||
if (Frontend::GetTouchCoords(x, y))
|
||||
NDS::TouchScreen(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;
|
||||
void ScreenHandler::screenHandleTablet(QTabletEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
|
||||
NDS::TouchScreen(x, y);
|
||||
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()
|
||||
|
@ -801,6 +854,8 @@ ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent)
|
|||
|
||||
touching = false;
|
||||
|
||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
|
||||
OSD::Init(nullptr);
|
||||
}
|
||||
|
||||
|
@ -879,6 +934,23 @@ void ScreenPanelNative::mouseMoveEvent(QMouseEvent* 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()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
|
@ -890,6 +962,7 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent)
|
|||
{
|
||||
touching = false;
|
||||
|
||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
}
|
||||
|
||||
ScreenPanelGL::~ScreenPanelGL()
|
||||
|
@ -1090,6 +1163,23 @@ void ScreenPanelGL::mouseMoveEvent(QMouseEvent* 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()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
|
|
|
@ -110,6 +110,9 @@ protected:
|
|||
void screenOnMouseRelease(QMouseEvent* event);
|
||||
void screenOnMouseMove(QMouseEvent* event);
|
||||
|
||||
void screenHandleTablet(QTabletEvent* event);
|
||||
void screenHandleTouch(QTouchEvent* event);
|
||||
|
||||
float screenMatrix[Frontend::MaxScreenTransforms][6];
|
||||
int screenKind[Frontend::MaxScreenTransforms];
|
||||
int numScreens;
|
||||
|
@ -137,6 +140,8 @@ protected:
|
|||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
void tabletEvent(QTabletEvent* event) override;
|
||||
bool event(QEvent* event) override;
|
||||
private slots:
|
||||
void onScreenLayoutChanged();
|
||||
|
||||
|
@ -168,6 +173,8 @@ protected:
|
|||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
void tabletEvent(QTabletEvent* event) override;
|
||||
bool event(QEvent* event) override;
|
||||
private slots:
|
||||
void onScreenLayoutChanged();
|
||||
|
||||
|
|
Loading…
Reference in New Issue