Merge branch 'emulator' of github.com:t-moe/discoverpixy into emulator

This commit is contained in:
id101010
2015-04-27 18:43:08 +02:00
29 changed files with 413 additions and 113 deletions

View File

@@ -25,7 +25,7 @@ QT_LIB=$(QT_DIR)/libemulatorqt.a
CPPFLAGS= -march=x86-64 -mtune=generic -fPIC $(INCLUDES)
CFLAGS= -O0 -g
CFLAGS= -O0 -g -std=c99
LIBS= pixy usb-1.0 boost_system boost_timer boost_chrono

View File

@@ -111,6 +111,7 @@ usblink_open__close_and_exit:
usblink_open__exit:
log("pixydebug: USBLink::open() returned %d\n", return_value);
usleep(100* 1000); //let pixy init pass
return return_value;
}

View File

@@ -14,12 +14,14 @@ SOURCES += \
mainwindow.cpp \
main.cpp \
ll_tft.cpp \
ll_system.cpp
ll_system.cpp \
ll_touch.cpp
HEADERS += \
mainwindow.h \
INCLUDEPATH+= ../../common/lowlevel/
INCLUDEPATH+= ../../common/lowlevel/ \
../../common/touch/
FORMS += \

View File

@@ -1,4 +1,6 @@
#include <QThread>
#include <QApplication>
extern "C" {
#include "ll_system.h"
}
@@ -11,3 +13,10 @@ void ll_system_delay(uint32_t msec) {
QThread::msleep(msec);
}
void ll_system_process() {
QApplication::processEvents();
}
void ll_system_toggle_led() {
}

8
emulator/qt/ll_touch.cpp Normal file
View File

@@ -0,0 +1,8 @@
extern "C" {
#include "ll_touch.h"
}
bool ll_touch_init() {
return true;
}

View File

@@ -10,7 +10,6 @@ extern "C" {
void app_loop() {
while(!QApplication::closingDown()) {
app_process();
QApplication::processEvents();
}
}

View File

@@ -3,6 +3,11 @@
#include <QDebug>
#include <QPainter>
#include <math.h>
#include <QMouseEvent>
extern "C" {
#include "touch.h"
}
#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 240
@@ -116,9 +121,38 @@ void MainWindow::paintEvent(QPaintEvent *)
//render_mutex.unlock();
}
void MainWindow::mousePressEvent(QMouseEvent *evt)
{
//qDebug() << "down" << evt->pos();
checkAndSendEvent(evt->pos(),true);
}
void MainWindow::mouseReleaseEvent(QMouseEvent *evt)
{
//qDebug() << "up" << evt->pos();
checkAndSendEvent(evt->pos(),false);
}
void MainWindow::mouseMoveEvent(QMouseEvent *evt)
{
//qDebug() << "move" << evt->pos();
checkAndSendEvent(evt->pos(),true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::checkAndSendEvent(QPoint pos, bool down)
{
QPoint p = pos - QPoint(DISPLAY_X,DISPLAY_Y);
if(p.x()<0 || p.y()<0 || p.x() >= DISPLAY_WIDTH || p.y() >= DISPLAY_HEIGHT) return;
//qDebug() << down << p;
touch_add_raw_event(p.x(),p.y(),down?TOUCH_DOWN:TOUCH_UP);
}

View File

@@ -26,11 +26,15 @@ public:
protected:
void paintEvent(QPaintEvent * evt);
void mousePressEvent(QMouseEvent* evt);
void mouseReleaseEvent(QMouseEvent* evt);
void mouseMoveEvent(QMouseEvent* evt);
~MainWindow();
private:
//QMutex render_mutex;
QImage image;
void checkAndSendEvent(QPoint pos, bool down);
Ui::MainWindow *ui;