Skip to content

Commit

Permalink
[player] Handle tablet hover
Browse files Browse the repository at this point in the history
  • Loading branch information
hgy29 committed Feb 16, 2023
1 parent 0195a88 commit d19d93d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions player/Headers/glcanvas.h
Expand Up @@ -43,6 +43,7 @@ class GLCanvas : public QOpenGLWidget{
static QString appPackage;
static bool EnableVSYNC;
static bool TabletActive;
static bool TabletPress;

private slots:
void onTimer();
Expand Down
14 changes: 10 additions & 4 deletions player/Sources/glcanvas.cpp
Expand Up @@ -211,6 +211,7 @@ static Server* g_server = NULL;
QString GLCanvas::appPackage;
bool GLCanvas::EnableVSYNC=false;
bool GLCanvas::TabletActive=false;
bool GLCanvas::TabletPress=false;

static void printToServer(const char* str, int len, void* data) {
G_UNUSED(data);
Expand Down Expand Up @@ -257,6 +258,7 @@ GLCanvas::GLCanvas(QWidget *parent) :
for( int i=1; i<=4; ++i )
mouseButtonPressed_[i] = false;
setMouseTracking(true);
setTabletTracking(true);
//setFocusPolicy(Qt::WheelFocus);

/*
Expand Down Expand Up @@ -1267,13 +1269,17 @@ void GLCanvas::tabletEvent(QTabletEvent* event) {


if(event->type() == QEvent::TabletPress){
ginputp_touchesBegin(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->button());
TabletPress=true;
ginputp_touchesBegin(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->buttons());

}else if(event->type() == QEvent::TabletMove){
ginputp_touchesMove(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->buttons());

if (TabletPress)
ginputp_touchesMove(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->buttons());
else
ginputp_mouseHover(xs[0], ys[0],0, m);
}else if(event->type() == QEvent::TabletRelease){
ginputp_touchesEnd(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->button());
ginputp_touchesEnd(xs[0], ys[0], ids[0], pressures[0], touchTypes[0], 1, xs, ys, ids, pressures, touchTypes,m,event->buttons());
if (event->buttons()==0) TabletPress=false;
}
event->accept();
}
Expand Down

0 comments on commit d19d93d

Please sign in to comment.