extern uint32_t qt5_window_height;
extern int qt5_window_angle;
+/* multitouch data */
+extern float *qt5_mt_points;
+extern int qt5_mt_count;
+extern const void *qt5_mt_pixels;
+extern int qt5_mt_width;
+extern int qt5_mt_height;
+
struct vigs_gl_surface;
struct vigs_winsys_gl_surface
GLfloat rotated_ortho[16];
GLfloat *ortho;
float brightness = (float)(255 - brightness_tbl[brightness_level]) / 255.0f;
+ int i, mt_count = qt5_mt_count;
if (display_off) {
brightness = 0.0f;
vigs_gl_draw_dpy_tex_prog(gl_backend, 6);
}
+ if (!gl_backend->mt_tex) {
+ GLuint mt_tex = 0;
+
+ if (!qt5_mt_pixels || qt5_mt_width == 0 || qt5_mt_height == 0) {
+ /* multitouch not initialized */
+ goto out;
+ }
+
+ gl_backend->GenTextures(1, &mt_tex);
+
+ if (!mt_tex) {
+ VIGS_LOG_WARN("MT: GenTextures failed");
+ goto out;
+ }
+
+ gl_backend->BindTexture(GL_TEXTURE_2D, mt_tex);
+
+ gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ gl_backend->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
+ qt5_mt_width, qt5_mt_height, 0,
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ qt5_mt_pixels);
+
+ gl_backend->mt_tex = mt_tex;
+ gl_backend->mt_tex_width = qt5_mt_width;
+ gl_backend->mt_tex_height = qt5_mt_height;
+ } else {
+ gl_backend->BindTexture(GL_TEXTURE_2D, gl_backend->mt_tex);
+ }
+
+ vigs_vector_resize(&gl_backend->dpy_v1, 0);
+ vigs_vector_resize(&gl_backend->dpy_v2, 0);
+
+ for (i = 0; i < mt_count; i++) {
+ GLfloat w = (GLfloat)gl_backend->mt_tex_width *
+ ((GLfloat)gl_backend->dpy_tex_width / (GLfloat)qt5_window_width);
+ GLfloat h = (GLfloat)gl_backend->mt_tex_height *
+ ((GLfloat)gl_backend->dpy_tex_height / (GLfloat)qt5_window_height);
+ GLfloat x = qt5_mt_points[2 * i + 0] - w / 2;
+ GLfloat y = gl_backend->dpy_tex_height - qt5_mt_points[2 * i + 1] - h / 2;
+
+ vert_coords = vigs_vector_append(&gl_backend->dpy_v1,
+ (12 * sizeof(GLfloat)));
+ tex_coords = vigs_vector_append(&gl_backend->dpy_v2,
+ (12 * sizeof(GLfloat)));
+
+ vert_coords[6] = vert_coords[0] = x;
+ vert_coords[7] = vert_coords[1] = y;
+ vert_coords[2] = x + w;
+ vert_coords[3] = y;
+ vert_coords[8] = vert_coords[4] = x + w;
+ vert_coords[9] = vert_coords[5] = y + h;
+ vert_coords[10] = x;
+ vert_coords[11] = y + h;
+
+ tex_coords[6] = tex_coords[0] = 0;
+ tex_coords[7] = tex_coords[1] = 1;
+ tex_coords[2] = 1;
+ tex_coords[3] = 1;
+ tex_coords[8] = tex_coords[4] = 1;
+ tex_coords[9] = tex_coords[5] = 0;
+ tex_coords[10] = 0;
+ tex_coords[11] = 0;
+ }
+
+ if (mt_count) {
+ gl_backend->Enable(GL_BLEND);
+ gl_backend->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ if (scale) {
+ vigs_gl_draw_dpy_scale_prog(gl_backend, mt_count * 6);
+ } else {
+ vigs_gl_draw_dpy_tex_prog(gl_backend, mt_count * 6);
+ }
+
+ gl_backend->Disable(GL_BLEND);
+ }
+
+out:
gl_backend->Finish();
return true;
void vigs_gl_backend_cleanup(struct vigs_gl_backend *gl_backend)
{
if (gl_backend->make_current(gl_backend, true)) {
+ if (gl_backend->mt_tex) {
+ gl_backend->DeleteTextures(1, &gl_backend->mt_tex);
+ }
if (gl_backend->dpy_tex) {
gl_backend->DeleteTextures(1, &gl_backend->dpy_tex);
}
*/
#include <QWidget>
+#include <QPainter>
+#include <QImage>
#include <QDebug>
#include "multitouchtracker.h"
#include "displaybase.h"
+float *qt5_mt_points = 0;
+int qt5_mt_count = 0;
+const void *qt5_mt_pixels = 0;
+int qt5_mt_width = 0;
+int qt5_mt_height = 0;
+
extern "C" {
void virtio_touchscreen_event(int x, int y, int z, int buttons_state);
}
{
this->hostPos = hostPos;
this->guestPos = guestPos;
+
+ qt5_mt_points[2 * (this->id - 1) + 0] = guestPos.x();
+ qt5_mt_points[2 * (this->id - 1) + 1] = guestPos.y();
+ qt5_graphic_hw_invalidate();
}
MultiTouchTracker::MultiTouchTracker(
- TouchScreenHelper* parent, int maxTouchPoint)
+ TouchScreenHelper* parent, int maxTouchPoint):
+ touchPointImage(32, 32, QImage::Format_ARGB32)
{
this->parent = parent;
this->maxTouchPoint = maxTouchPoint;
mtProcessingFunc[MT_SEPA] = &MultiTouchTracker::processingSepa;
mtProcessingFunc[MT_PARA] = &MultiTouchTracker::processingPara;
mtProcessingFunc[MT_SYMM] = &MultiTouchTracker::processingSymm;
+
+ touchPointImage.fill(Qt::transparent);
+
+ QPainter p(&touchPointImage);
+ p.setPen(QColor(255, 255, 255, 255));
+ p.setBrush(QBrush(QColor(128, 128, 128, 128)));
+ p.drawEllipse(0, 0, 31, 31);
+
+ qt5_mt_points = new float[2 * maxTouchPoint]();
+ qt5_mt_count = 0;
+ qt5_mt_pixels = touchPointImage.constBits();
+ qt5_mt_width = qt5_mt_height = 32;
}
int MultiTouchTracker::getMaxTouchPoint()
TouchPoint *point = new TouchPoint(touchCnt + 1, hostPos, guestPos);
touchPointList.append(point);
- qDebug() << "ID" << point->getID() << "point touching";
+ qDebug() << "ID" << point->getID() << "point touching" << hostPos << guestPos;
+
+ qt5_mt_points[2 * qt5_mt_count + 0] = guestPos.x();
+ qt5_mt_points[2 * qt5_mt_count + 1] = guestPos.y();
+ qt5_mt_count++;
+ qt5_graphic_hw_invalidate();
return touchPointList.count();
}
const int beforeCnt = touchPointList.count();
TouchPoint *point = NULL;
+ int diff;
while (touchPointList.count() > remainCnt) {
point = touchPointList.last();
}
touchPointList.removeLast();
+
+ qt5_mt_count--;
+ }
+
+ diff = beforeCnt - touchPointList.count();
+
+ if (diff) {
+ qt5_graphic_hw_invalidate();
}
- return beforeCnt - touchPointList.count();
+ return diff;
}
void MultiTouchTracker::mtProcessing(int mode, QPoint hostPos, QPoint guestPos)
}
}
touchPointList.clear();
+
+ qt5_mt_count = 0;
+ qt5_graphic_hw_invalidate();
}
MultiTouchTracker::~MultiTouchTracker()
qDebug("destroy multi-touch tracker");
finishTracking();
+
+ delete[] qt5_mt_points;
+ qt5_mt_points = 0;
+ qt5_mt_count = 0;
+ qt5_mt_pixels = 0;
+ qt5_mt_width = qt5_mt_height = 0;
}