From 0801930805cecd8d8ec92bdb2d8887f3fdfad331 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Sun, 9 Sep 2012 14:14:48 +0000 Subject: [PATCH] Latin1 fix, connect issues fix, screen resolution fix, add support for the keyboard git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@96 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- Expe-selection/dyna-expe2/Controler.cpp | 85 ++-- Expe-selection/dyna-expe2/Controler.h | 12 +- Expe-selection/dyna-expe2/HCISheet.cpp | 436 +++++++++++--------- Expe-selection/dyna-expe2/HCISheet.h | 17 +- Expe-selection/dyna-expe2/dyna-expe2.pro | 17 +- Expe-selection/dyna-expe2/expe/Expe.cpp | 2 +- Expe-selection/dyna-expe2/expe/ExpeData.cpp | 4 +- Expe-selection/dyna-expe2/main.cpp | 17 +- 8 files changed, 321 insertions(+), 269 deletions(-) diff --git a/Expe-selection/dyna-expe2/Controler.cpp b/Expe-selection/dyna-expe2/Controler.cpp index f4a92d2..626e625 100644 --- a/Expe-selection/dyna-expe2/Controler.cpp +++ b/Expe-selection/dyna-expe2/Controler.cpp @@ -5,11 +5,15 @@ #include #include -int secondScreenWidth = 1920; -int secondScreenHeight = 1200; +#include -void Controler::setFullScreen(){ - widgetParent->setWindowState(Qt::WindowFullScreen); +//int secondScreenWidth = 1920; +//int secondScreenHeight = 1200; + +void Controler::setFullScreen() +{ + widgetParent->showFullScreen(); + //widgetParent->setWindowState(Qt::WindowFullScreen); //widgetParent->resize(1280,1024); widgetParent->move(0,0); @@ -18,18 +22,18 @@ void Controler::setFullScreen(){ sheet->resize(this->widgetParent->width(), this->widgetParent->height()); } -Controler::Controler(MainWindow *_experimenterWindow) : Expe(),successSound(":ressources/success.wav"), errorSound("ressources/error.wav") +Controler::Controler(MainWindow *_experimenterWindow) +: Expe(), successSound(":ressources/success.wav"), errorSound("ressources/error.wav"), + experimenterWindow(_experimenterWindow), keyboardControler(NULL) { - - this->experimenterWindow = _experimenterWindow; //qDebug() << __PRETTY_FUNCTION__ ; setNbBlock(5); //TODO setNbTrials(28); //TODO - } //----------------------------- -QString Controler::CSVDirectoryOutput(){ +QString Controler::CSVDirectoryOutput() +{ QString res = Global::appPath()+"/../../dyna-expe2/log/"; qDebug()<< res; return res; @@ -66,10 +70,10 @@ void Controler::start(const QString& nameFile, QString user, const QString& , co QRect geometry = QApplication::desktop()->screenGeometry(); this->widgetParent->move(0, 0); //this->widgetParent->resize(1280,1024); - widgetParent->resize(1280,1024); - this->interBlockWidget->resize(1280,1024); - this->interTrialWidget->resize(1280,1024); - this->trialSheet->resize(1280,1024); + widgetParent->resize(1600, 900);//(1280,1024); + this->interBlockWidget->resize(1600, 900);//(1280,1024); + this->interTrialWidget->resize(1600, 900);//(1280,1024); + this->trialSheet->resize(1600, 900);//(1280,1024); //successSound.play(); @@ -84,9 +88,13 @@ void Controler::start(const QString& nameFile, QString user, const QString& , co } HCISheet* sheet = dynamic_cast(this->trialSheet); - connect(sheet, SIGNAL(hotkeyPressed(QString)), this, SLOT(hotkeyPressed(QString))); - connect(sheet, SIGNAL(hotkeyReleased(QString)), this, SLOT(hotkeyReleased(QString))); + connect(sheet, SIGNAL(hotkeyPressed(char)), this, SLOT(hotkeyPressed(char))); + connect(sheet, SIGNAL(hotkeyReleased(char)), this, SLOT(hotkeyReleased(char))); + //key sides + connect(sheet, SIGNAL(raisedKeyReleased(char, int)), this, SLOT(raisedKeyReleased(char, int))); + connect(sheet, SIGNAL(ctrlPressed()), this, SLOT(raiseKeys())); this->setFullScreen(); + keyboardControler = new QPushKeysKeyboardController("COM9", 115200, sheet); } //---------------------- @@ -121,19 +129,19 @@ void Controler::prepareTrialData(const QMap& prop) keyTarget = prop["target"]; keyTarget = keyTarget.replace("5",";"); keyTarget = keyTarget.replace("6","^"); - keyTarget = keyTarget.replace("0",QString::fromUtf8("à ")); - keyTarget = keyTarget.replace("9",QString::fromUtf8("ç")); + keyTarget = keyTarget.replace("0","à"); + keyTarget = keyTarget.replace("9","ç"); keyTarget = keyTarget.replace("4","'"); - QString key = keyTarget.left(1); - QString type = keyTarget.right(1); + char key = keyTarget[0].toLatin1(); + char type = keyTarget[1].toLatin1(); //this->keyId = key.toInt(); //QString target = this->getCharFromConfiguration(keyId, configuration); csvWriter.write("target", keyTarget); - csvWriter.write("key", key); - csvWriter.write("type", type); - bool raised = key=="d"|| key=="o"; + csvWriter.write("key", QString(key)); + csvWriter.write("type", QString(type)); + bool raised = key == 'd'|| key == 'o'; csvWriter.write("raised", QString::number(raised)); HCISheet * sheet = dynamic_cast(this->trialSheet); @@ -231,7 +239,7 @@ void Controler::onTrialExit() //this->trialSheet->releaseKeyboard(); //successSound.play(); } - +/* QString Controler::getCharFromConfiguration(int keyId, int configuration) { QString key="g"; @@ -266,34 +274,33 @@ QString Controler::getCharFromConfiguration(int keyId, int configuration) } return key; +}*/ + +void Controler::raiseKeys() +{ + keyboardControler->raiseKeys(0xffff); } //--------------------------- -void Controler::hotkeyPressed(QString c) +void Controler::hotkeyPressed(char /*c*/) { } //--------------------------- -void Controler::raisedKeyReleased(QString key, int side, int force){ - QString res=key; - if(side==1) key+="l"; - else if(side=2)key+="r"; - else if(side=3)key+="f"; - else if(side=4)key+="b"; - - if(force>0){ - if(false){//during trial - activateHotkey(res); - } - } - +void Controler::raisedKeyReleased(char key, int sides){ + QString res = QString(key); + if(sides & QSideKeyEvent::Left) res += "l"; + else if(sides & QSideKeyEvent::Right) res += "r"; + else if(sides & QSideKeyEvent::Front) res += "f"; + else if(sides & QSideKeyEvent::Back) res += "b"; } //--------------------------- -void Controler::hotkeyReleased(QString keyf) +void Controler::hotkeyReleased(char keyf) { - activateHotkey(keyf+"t"); + activateHotkey(QString(keyf)+"t"); + keyboardControler->lowerKeys(0xffff); } diff --git a/Expe-selection/dyna-expe2/Controler.h b/Expe-selection/dyna-expe2/Controler.h index bdfffd6..d608b31 100644 --- a/Expe-selection/dyna-expe2/Controler.h +++ b/Expe-selection/dyna-expe2/Controler.h @@ -7,6 +7,8 @@ #include "HCISheet.h" #include "MainWindow.h" +#include + class Controler : public Expe { Q_OBJECT @@ -26,13 +28,14 @@ signals: public slots: void setFullScreen(); - void hotkeyPressed(QString c); - void hotkeyReleased(QString c); + void hotkeyPressed(char c); + void hotkeyReleased(char c); //key will probably D or O. //side can be l(left), r(right) f(front) b(back) t(top) //force is the force - void raisedKeyReleased(QString key, int side, int force);//thomas, you can call this method + void raisedKeyReleased(char key, int sides);//thomas, you can call this method void activateHotkey(QString advHotkey); + void raiseKeys(); protected: @@ -51,7 +54,7 @@ protected: protected: - QString getCharFromConfiguration(int keyId, int configuration); + //QString getCharFromConfiguration(int keyId, int configuration); int execTime; //QString tech; //QString set; @@ -63,6 +66,7 @@ protected: //int configuration; bool succes; + DynamicKeyboardController *keyboardControler; }; #endif // CONTROLER_H diff --git a/Expe-selection/dyna-expe2/HCISheet.cpp b/Expe-selection/dyna-expe2/HCISheet.cpp index 88f47e3..58daf85 100644 --- a/Expe-selection/dyna-expe2/HCISheet.cpp +++ b/Expe-selection/dyna-expe2/HCISheet.cpp @@ -5,6 +5,7 @@ #include #include +#include HCISheet::HCISheet(QWidget *parent):TrialSheet(parent) { @@ -44,11 +45,11 @@ HCISheet::HCISheet(QWidget *parent):TrialSheet(parent) act_ctrlE->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E)); connect(act_ctrlE, SIGNAL(triggered()), this, SLOT(ctrlE())); this->addAction(act_ctrlE); - +/* QAction *act_ctrl4 = new QAction(this); act_ctrl4->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4)); connect(act_ctrl4, SIGNAL(triggered()), this, SLOT(ctrl4())); - this->addAction(act_ctrl4); + this->addAction(act_ctrl4);*/ QAction *act_ctrlX = new QAction(this); act_ctrlX->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); @@ -188,7 +189,7 @@ HCISheet::HCISheet(QWidget *parent):TrialSheet(parent) //-------------- QAction *act_ctrlChapeau = new QAction(this); - act_ctrlChapeau->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Dead_Circumflex)); + act_ctrlChapeau->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_AsciiCircum));//Qt::CTRL+Qt::Key_Dead_Circumflex)); connect(act_ctrlChapeau, SIGNAL(triggered()), this, SLOT(ctrlChapeau())); this->addAction(act_ctrlChapeau); @@ -277,9 +278,6 @@ HCISheet::HCISheet(QWidget *parent):TrialSheet(parent) act_ctrlMinus->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Minus)); connect(act_ctrlMinus, SIGNAL(triggered()), this, SLOT(ctrlMinus())); this->addAction(act_ctrlMinus); - - - } //--------------------------- @@ -303,7 +301,8 @@ void HCISheet::paintEvent(QPaintEvent *){ keyboard = keyboard.scaledToWidth(this->width() - 100); first = false; } - key = key.toUpper(); + if (key >= 'a' && key <= 'z') + key += 'A' - 'a'; QPainter p(this); p.fillRect(0,0,width(),height(),Qt::white); p.drawImage(width()/2 - keyboard.width()/2, height()/2- keyboard.height()/2, keyboard); @@ -313,15 +312,15 @@ void HCISheet::paintEvent(QPaintEvent *){ int w = 30; int h =30; // p.drawText(x+10, y+20, key); - this->paintRaisedKeys(p); - + paintRaisedKeys(p); QColor c1(Qt::darkCyan); c1.setAlpha(150); p.setBrush(c1); p.setPen(c1); - if(type == "t"){ + //top + if(type == 't'){ //p.drawRect(x-15+15, y-15+15, 30,30); p.setBrush(Qt::white); p.setPen(Qt::white); @@ -330,189 +329,189 @@ void HCISheet::paintEvent(QPaintEvent *){ p.setPen(c1); p.drawEllipse(posLetter[key].x()-w/2 + 5, posLetter[key].y()-h/2 -7, w, h); } - if(!type.compare("l")){ + if(type == 'l'){ //p.drawImage(x-15,y, left); p.setBrush(Qt::white); p.setPen(Qt::white); - if(key=="D"){ - p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 10, 46); + if(key=='D'){ + p.drawRect(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 29 - 2, 10, 58); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 10, 46); - //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); + p.drawRect(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 29 - 2, 10, 58); + //p.drawImage(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 23 - 2, left); }else { - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 10, 46); + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2, 10, 58); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 10, 46); - + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2, 10, 58); } - } - if(!type.compare("r")){ + if(type == 'r') + { //p.drawImage(x+15,100, right); - p.setBrush(Qt::white); - p.setPen(Qt::white); - if(key=="D"){ - - p.drawRect(posLetter["D"].x() - 23 + 12 + 46 - 10, posLetter["D"].y() - 23 - 2, 10, 46); - p.setBrush(c1); - p.setPen(c1); - p.drawRect(posLetter["D"].x() - 23 + 12 + 46 - 10, posLetter["D"].y() - 23 - 2, 10, 46); - //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); - - }else { - - p.drawRect(posLetter["O"].x() - 23 + 6 + 46 - 10, posLetter["O"].y() - 23- 2, 10, 46); - p.setBrush(c1); - p.setPen(c1); - p.drawRect(posLetter["O"].x() - 23 + 6 + 46 - 10, posLetter["O"].y() - 23- 2, 10, 46); - - } + p.setBrush(Qt::white); + p.setPen(Qt::white); + if(key=='D') + { + p.drawRect(posLetter['D'].x() - 27 + 12 + 58 - 10, posLetter['D'].y() - 29 - 2, 10, 58); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter['D'].x() - 27 + 12 + 58 - 10, posLetter['D'].y() - 29 - 2, 10, 58); + //p.drawImage(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 23 - 2, left); + } + else + { + p.drawRect(posLetter['O'].x() - 27 + 6 + 58 - 10, posLetter['O'].y() - 29 - 2, 10, 58); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter['O'].x() - 27 + 6 + 58 - 10, posLetter['O'].y() - 29 - 2, 10, 58); + } } - if(type =="f"){ + if(type == 'f') + { //p.drawImage(x,y+15, front); p.setBrush(Qt::white); p.setPen(Qt::white); - if(key=="D"){ - - p.drawRect(posLetter["D"].x() - 23 + 12 , posLetter["D"].y() - 23 - 2+46-10, 46, 10); + if(key=='D') + { + p.drawRect(posLetter['D'].x() - 27 + 12 , posLetter['D'].y() -29 - 2+58-10, 58, 10); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2+46-10, 46, 10); - //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); - - }else { - - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2+46-10, 46, 10); + p.drawRect(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 29 - 2+58-10, 58, 10); + //p.drawImage(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 23 - 2, left); + } + else + { + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2+58-10, 58, 10); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2+46-10, 46, 10); - + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2+58-10, 58, 10); } - } - if(type =="b"){ + if(type == 'b') + { //p.drawImage(x,y-15, back); p.setBrush(Qt::white); p.setPen(Qt::white); - if(key=="D"){ - - p.drawRect(posLetter["D"].x() - 23 + 12 , posLetter["D"].y() - 23 - 2, 46, 10); + if(key=='D') + { + p.drawRect(posLetter['D'].x() - 27 + 12 , posLetter['D'].y() - 29 - 2, 58, 10); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 46, 10); - //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); - - }else { - - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 10); + p.drawRect(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 29 - 2, 58, 10); + //p.drawImage(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 23 - 2, left); + } + else + { + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2, 58, 10); p.setBrush(c1); p.setPen(c1); - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 10); - + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2, 58, 10); } } - paintLetters(p); } -void HCISheet::paintRaisedKeys(QPainter &p){ +void HCISheet::paintRaisedKeys(QPainter &p) +{ QColor c(Qt::darkMagenta); c.setAlpha(50); p.setBrush(c); p.setPen(c); - p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 46); - p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 46, 46); + p.drawRect(posLetter['O'].x() - 27 + 6, posLetter['O'].y() - 29 - 2, 58, 58); + p.drawRect(posLetter['D'].x() - 27 + 12, posLetter['D'].y() - 29 - 2, 58, 58); } -void HCISheet::buildPosLetterMapping(){ - int x = 180; int y = 434; - float step = 48.5; - posLetter["A"] = QPoint(x,y); - posLetter["Z"] = QPoint(x+1*step,y); - posLetter["E"] = QPoint(x+2*step,y); - posLetter["R"] = QPoint(x+3*step,y); - posLetter["T"] = QPoint(x+4*step,y); - posLetter["Y"] = QPoint(x+5*step,y); - posLetter["U"] = QPoint(x+6*step,y); - posLetter["I"] = QPoint(x+7*step,y); - posLetter["O"] = QPoint(x+8*step,y); - posLetter["P"] = QPoint(x+9*step,y); - posLetter["^"] = QPoint(x+10*step,y); - posLetter["$"] = QPoint(x+11*step,y); - - x = 192; y = 482; - posLetter["Q"] = QPoint(x,y); - posLetter["S"] = QPoint(x+1*step,y); - posLetter["D"] = QPoint(x+2*step,y); - posLetter["F"] = QPoint(x+3*step,y); - posLetter["G"] = QPoint(x+4*step,y); - posLetter["H"] = QPoint(x+5*step,y); - posLetter["J"] = QPoint(x+6*step,y); - posLetter["K"] = QPoint(x+7*step,y); - posLetter["L"] = QPoint(x+8*step,y); - posLetter["M"] = QPoint(x+9*step,y); - posLetter[QString::fromUtf8("ù")] = QPoint(x+10*step,y); - posLetter["*"] = QPoint(x+11*step,y); - - x = 215; y = 530; - posLetter["<"] = QPoint(x - 1*step ,y); - posLetter["W"] = QPoint(x,y); - posLetter["X"] = QPoint(x+1*step,y); - posLetter["C"] = QPoint(x+2*step,y); - posLetter["V"] = QPoint(x+3*step,y); - posLetter["B"] = QPoint(x+4*step,y); - posLetter["N"] = QPoint(x+5*step,y); - posLetter[","] = QPoint(x+6*step,y); - posLetter[";"] = QPoint(x+7*step,y); - posLetter[":"] = QPoint(x+8*step,y); - //posLetter["="] = QPoint(x+9*step,y); - posLetter["!"] = QPoint(x+9*step,y); - - x = 107; y = 388; - //posLetter["`"] = QPoint(x,y); - posLetter["&"] = QPoint(x+1*step,y); - posLetter[QString::fromUtf8("é")] = QPoint(x+2*step,y); - posLetter["\""] = QPoint(x+3*step,y); - posLetter["'"] = QPoint(x+4*step,y); - posLetter["("] = QPoint(x+5*step,y); - posLetter["-"] = QPoint(x+6*step,y); - posLetter[QString::fromUtf8("è")] = QPoint(x+7*step,y); - posLetter["_"] = QPoint(x+8*step,y); - posLetter[QString::fromUtf8("ç").toUpper()] = QPoint(x+9*step,y); - posLetter[QString::fromUtf8("à ").toUpper()] = QPoint(x+10*step,y); - posLetter[")"] = QPoint(x+11*step,y); - posLetter["="] = QPoint(x+12*step,y); - - specialLetter["enter"] = QPoint(180 + 12*step, 434); - specialLetter["delete"] = QPoint(180 + 12*step, 384); - specialLetter["tab"] = QPoint(100, 434); - specialLetter["Caps lock"] = QPoint(100, 484); - specialLetter["shift l"] = QPoint(100, 534); - specialLetter["shift r"] = QPoint(760, 534); - specialLetter["ctrl l"] = QPoint(100, 584); - specialLetter["ctrl r"] = QPoint(760, 584); +void HCISheet::buildPosLetterMapping() +{ + int x = 218; int y = 480; + float step = 61; + posLetter['A'] = QPoint(x,y); + posLetter['Z'] = QPoint(x+1*step,y); + posLetter['E'] = QPoint(x+2*step,y); + posLetter['R'] = QPoint(x+3*step,y); + posLetter['T'] = QPoint(x+4*step,y); + posLetter['Y'] = QPoint(x+5*step,y); + posLetter['U'] = QPoint(x+6*step,y); + posLetter['I'] = QPoint(x+7*step,y); + posLetter['O'] = QPoint(x+8*step,y); + posLetter['P'] = QPoint(x+9*step,y); + posLetter['^'] = QPoint(x+10*step,y); + posLetter['$'] = QPoint(x+11*step,y); + + x = 232; y = 540; + posLetter['Q'] = QPoint(x,y); + posLetter['S'] = QPoint(x+1*step,y); + posLetter['D'] = QPoint(x+2*step,y); + posLetter['F'] = QPoint(x+3*step,y); + posLetter['G'] = QPoint(x+4*step,y); + posLetter['H'] = QPoint(x+5*step,y); + posLetter['J'] = QPoint(x+6*step,y); + posLetter['K'] = QPoint(x+7*step,y); + posLetter['L'] = QPoint(x+8*step,y); + posLetter['M'] = QPoint(x+9*step,y); + posLetter['ù'] = QPoint(x+10*step,y); //ù +// posLetter['\xf9'] = QPoint(x+10*step,y); //ù + posLetter['*'] = QPoint(x+11*step,y); + + x = 258; y = 600; + posLetter['<'] = QPoint(x - 1*step ,y); + posLetter['W'] = QPoint(x,y); + posLetter['X'] = QPoint(x+1*step,y); + posLetter['C'] = QPoint(x+2*step,y); + posLetter['V'] = QPoint(x+3*step,y); + posLetter['B'] = QPoint(x+4*step,y); + posLetter['N'] = QPoint(x+5*step,y); + posLetter[','] = QPoint(x+6*step,y); + posLetter[';'] = QPoint(x+7*step,y); + posLetter[':'] = QPoint(x+8*step,y); + //posLetter['='] = QPoint(x+9*step,y); + posLetter['!'] = QPoint(x+9*step,y); + + x = 123; y = 420; + //posLetter['`'] = QPoint(x,y); + posLetter['&'] = QPoint(x+1*step,y); + posLetter['é'] = QPoint(x+2*step,y); // é + posLetter['\"'] = QPoint(x+3*step,y); + posLetter['\''] = QPoint(x+4*step,y); + posLetter['('] = QPoint(x+5*step,y); + posLetter['-'] = QPoint(x+6*step,y); + posLetter['\è'] = QPoint(x+7*step,y); // è + posLetter['_'] = QPoint(x+8*step,y); + posLetter['ç'] = QPoint(x+9*step,y); // ç + posLetter['à'] = QPoint(x+10*step,y); //à + posLetter[')'] = QPoint(x+11*step,y); + posLetter['='] = QPoint(x+12*step,y); + + specialLetter["enter"] = QPoint(218 + 12*step, 480); + specialLetter["delete"] = QPoint(218 + 12*step, 420); + specialLetter["tab"] = QPoint(125, 480); + specialLetter["Caps lock"] = QPoint(125, 536); + specialLetter["shift l"] = QPoint(125, 600); + specialLetter["shift r"] = QPoint(908, 600); + specialLetter["ctrl l"] = QPoint(125, 657); + specialLetter["ctrl r"] = QPoint(960, 657); //specialLetter["win l"] = QPoint(170, 584); - specialLetter["alt l"] = QPoint(230, 584); - specialLetter["alt r"] = QPoint(580, 584); + specialLetter["alt l"] = QPoint(230, 657); + specialLetter["alt r"] = QPoint(720, 657); } -void HCISheet::paintLetters(QPainter& p){ - +void HCISheet::paintLetters(QPainter& p) +{ p.setPen(Qt::black); QFont f; f.setPixelSize(20); p.setFont(f); //float step = 48.5; //int x = 180; int y = 434; - QMap::const_iterator i = posLetter.constBegin(); - while (i != posLetter.constEnd()) { - p.drawText(i.value(), i.key()); + QMap::const_iterator i = posLetter.constBegin(); + while (i != posLetter.constEnd()) + { + p.drawText(i.value(), QString(QChar(i.key()))); ++i; } @@ -520,7 +519,8 @@ void HCISheet::paintLetters(QPainter& p){ p.setFont(f); QMap::const_iterator j = specialLetter.constBegin(); - while (j != specialLetter.constEnd()) { + while (j != specialLetter.constEnd()) + { p.drawText(j.value(), j.key()); ++j; } @@ -528,83 +528,38 @@ void HCISheet::paintLetters(QPainter& p){ f.setPixelSize(12); p.setFont(f); - - } //--------------------------- -void HCISheet::keyPressEvent(QKeyEvent *ke){ +void HCISheet::keyPressEvent(QKeyEvent *ke) +{ //qDebug()<<"keyPressEvent hci sheet "<text() <modifiers(); - if(ke->text() != "") +/* if(ke->text() != "") { emit hotkeyPressed(ke->text()); - } - if(ke->modifiers()==Qt::CTRL){ - this->ctrl_pressed = true; + }*/ + if((ke->modifiers() & Qt::CTRL) && !ctrl_pressed) + { + ctrl_pressed = true; + qDebug() << "ctrl pressed"; + emit(ctrlPressed()); + //TODO + //RaiseKey 1 2 } } -void HCISheet::ctrlF(){ qDebug()<<"ctrl F"; emit hotkeyReleased("f"); } -void HCISheet::ctrlA(){ qDebug()<<"ctrl A"; emit hotkeyReleased("a"); } -void HCISheet::ctrlS(){ qDebug()<<"ctrl S"; emit hotkeyReleased("s"); } -void HCISheet::ctrlD(){ qDebug()<<"ctrl D"; emit hotkeyReleased("d"); } -void HCISheet::ctrlG(){ qDebug()<<"ctrl G"; emit hotkeyReleased("g"); } -void HCISheet::ctrlE(){ qDebug()<<"ctrl E"; emit hotkeyReleased("e"); } -void HCISheet::ctrl4(){ qDebug()<<"ctrl F"; emit hotkeyReleased("4"); } -void HCISheet::ctrlX(){ qDebug()<<"ctrl X"; emit hotkeyReleased("x"); } -void HCISheet::ctrlC(){ qDebug()<<"ctrl C"; emit hotkeyReleased("c"); } -void HCISheet::ctrlH(){ qDebug()<<"ctrl H"; emit hotkeyReleased("h"); } - -void HCISheet::ctrlQ(){ qDebug()<<"ctrl Q"; emit hotkeyReleased("q"); } -void HCISheet::ctrlW(){ qDebug()<<"ctrl W"; emit hotkeyReleased("w"); } -void HCISheet::ctrlR(){ qDebug()<<"ctrl R"; emit hotkeyReleased("r"); } -void HCISheet::ctrlT(){ qDebug()<<"ctrl T"; emit hotkeyReleased("t"); } -void HCISheet::ctrlY(){ qDebug()<<"ctrl Y"; emit hotkeyReleased("y"); } -void HCISheet::ctrlU(){ qDebug()<<"ctrl U"; emit hotkeyReleased("u"); } -void HCISheet::ctrlI(){ qDebug()<<"ctrl I"; emit hotkeyReleased("i"); } -void HCISheet::ctrlO(){ qDebug()<<"ctrl O"; emit hotkeyReleased("o"); } -void HCISheet::ctrlP(){ qDebug()<<"ctrl P"; emit hotkeyReleased("p"); } -void HCISheet::ctrlBracketLeft(){ qDebug()<<"ctrl ["; emit hotkeyReleased("["); } -void HCISheet::ctrlBracketRight(){ qDebug()<<"ctrl ]"; emit hotkeyReleased("]"); } -void HCISheet::ctrlJ(){ qDebug()<<"ctrl J"; emit hotkeyReleased("j"); } -void HCISheet::ctrlK(){ qDebug()<<"ctrl K"; emit hotkeyReleased("k"); } -void HCISheet::ctrlL(){ qDebug()<<"ctrl L"; emit hotkeyReleased("l"); } -void HCISheet::ctrlPointVirgule(){ qDebug()<<"ctrl ;"; emit hotkeyReleased(";"); } -void HCISheet::ctrlApostrophe(){ qDebug()<<"ctrl '"; emit hotkeyReleased("'"); } -void HCISheet::ctrlZ(){ qDebug()<<"ctrl Z"; emit hotkeyReleased("z"); } -void HCISheet::ctrlV(){ qDebug()<<"ctrl V"; emit hotkeyReleased("v"); } -void HCISheet::ctrlB(){ qDebug()<<"ctrl B"; emit hotkeyReleased("b"); } -void HCISheet::ctrlN(){ qDebug()<<"ctrl N"; emit hotkeyReleased("n"); } -void HCISheet::ctrlM(){ qDebug()<<"ctrl M"; emit hotkeyReleased("m"); } -void HCISheet::ctrlVirgule(){ qDebug()<<"ctrl ,"; emit hotkeyReleased(","); } -void HCISheet::ctrlPoint(){ qDebug()<<"ctrl ."; emit hotkeyReleased("."); } -void HCISheet::ctrlSlash(){ qDebug()<<"ctrl /"; emit hotkeyReleased("/"); } - -void HCISheet::ctrlChapeau(){ qDebug()<<"ctrl ^"; emit hotkeyReleased("^"); } -void HCISheet::ctrlDollar(){ qDebug()<<"ctrl $"; emit hotkeyReleased("$"); } -void HCISheet::ctrlStar(){ qDebug()<<"ctrl *"; emit hotkeyReleased("*"); } -void HCISheet::ctrlAdvU(){ qDebug()<<("ctrl " + QString::fromUtf8("ù")); emit hotkeyReleased(QString::fromUtf8("ù")); } -void HCISheet::ctrlChevron(){ qDebug()<<"ctrl <"; emit hotkeyReleased("<"); } -void HCISheet::ctrlDoubleDot(){ qDebug()<<"ctrl :"; emit hotkeyReleased(":"); } -void HCISheet::ctrlExclamation(){ qDebug()<<"ctrl !"; emit hotkeyReleased("!"); } - -void HCISheet::ctrlEtCommercial(){ qDebug()<<"ctrl &"; emit hotkeyReleased("&"); } -void HCISheet::ctrlEAigu(){ qDebug()<<"ctrl "+QString::fromUtf8("é"); emit hotkeyReleased(QString::fromUtf8("é")); } -void HCISheet::ctrlEGrave(){ qDebug()<<"ctrl "+QString::fromUtf8("è"); emit hotkeyReleased(QString::fromUtf8("è")); } -void HCISheet::ctrlGuillement(){ qDebug()<<"ctrl \""; emit hotkeyReleased("\""); } -void HCISheet::ctrlParentheseO(){ qDebug()<<"ctrl ("; emit hotkeyReleased("("); } -void HCISheet::ctrlParentheseF(){ qDebug()<<"ctrl )"; emit hotkeyReleased(")"); } -void HCISheet::ctrl_(){ qDebug()<<"ctrl _"; emit hotkeyReleased("_"); } -void HCISheet::ctrlCedille(){ qDebug()<<"ctrl "+ QString::fromUtf8("ç"); emit hotkeyReleased(QString::fromUtf8("ç")); } -void HCISheet::ctrlAGrave(){ qDebug()<<"ctrl "+QString::fromUtf8("à "); emit hotkeyReleased(QString::fromUtf8("à ")); } -void HCISheet::ctrlEqual(){ qDebug()<<"ctrl ="; emit hotkeyReleased("="); } -void HCISheet::ctrlMinus(){ qDebug()<<"ctrl -"; emit hotkeyReleased("-"); } - //--------------------------- void HCISheet::keyReleaseEvent(QKeyEvent *ke){ + if(ctrl_pressed && !(ke->modifiers() & Qt::CTRL)) + { + this->ctrl_pressed = false; + qDebug() << "ctrl released"; + //TODO + //RaiseKey 1 2 + } - qDebug()<<"keyReleaseEvent hci sheet"<key() << " " << ke->text() << " " << ke->modifiers(); +// qDebug()<<"keyReleaseEvent hci sheet"<key() << " " << ke->text() << " " << ke->modifiers(); /* if(this->ctrl_pressed){ qDebug()<<"keyReleaseEvent hci sheet 2"<key() <modifiers(); @@ -623,3 +578,72 @@ void HCISheet::keyReleaseEvent(QKeyEvent *ke){ } */ } + +bool HCISheet::event(QEvent *event) +{ + if (event->type() == QSideKeyEvent::QSideKeyEventType) + { + QSideKeyEvent *evt = static_cast(event); + qDebug() << "Key " << evt->getKey() << "sides " << hex << evt->getSides(); + emit raisedKeyReleased(evt->getKey(), evt->getSides()); + return true; + } + + return QWidget::event(event); +} + +void HCISheet::ctrlF(){ qDebug()<<"ctrl F"; ctrl_pressed = false; emit hotkeyReleased('f'); } +void HCISheet::ctrlA(){ qDebug()<<"ctrl A"; ctrl_pressed = false; emit hotkeyReleased('a'); } +void HCISheet::ctrlS(){ qDebug()<<"ctrl S"; ctrl_pressed = false; emit hotkeyReleased('s'); } +void HCISheet::ctrlD(){ qDebug()<<"ctrl D"; ctrl_pressed = false; emit hotkeyReleased('D'); } +void HCISheet::ctrlG(){ qDebug()<<"ctrl G"; ctrl_pressed = false; emit hotkeyReleased('g'); } +void HCISheet::ctrlE(){ qDebug()<<"ctrl E"; ctrl_pressed = false; emit hotkeyReleased('e'); } +void HCISheet::ctrl4(){ qDebug()<<"ctrl F"; ctrl_pressed = false; emit hotkeyReleased('4'); } +void HCISheet::ctrlX(){ qDebug()<<"ctrl X"; ctrl_pressed = false; emit hotkeyReleased('x'); } +void HCISheet::ctrlC(){ qDebug()<<"ctrl C"; ctrl_pressed = false; emit hotkeyReleased('c'); } +void HCISheet::ctrlH(){ qDebug()<<"ctrl H"; ctrl_pressed = false; emit hotkeyReleased('h'); } + +void HCISheet::ctrlQ(){ qDebug()<<"ctrl Q"; ctrl_pressed = false; emit hotkeyReleased('q'); } +void HCISheet::ctrlW(){ qDebug()<<"ctrl W"; ctrl_pressed = false; emit hotkeyReleased('w'); } +void HCISheet::ctrlR(){ qDebug()<<"ctrl R"; ctrl_pressed = false; emit hotkeyReleased('r'); } +void HCISheet::ctrlT(){ qDebug()<<"ctrl T"; ctrl_pressed = false; emit hotkeyReleased('t'); } +void HCISheet::ctrlY(){ qDebug()<<"ctrl Y"; ctrl_pressed = false; emit hotkeyReleased('y'); } +void HCISheet::ctrlU(){ qDebug()<<"ctrl U"; ctrl_pressed = false; emit hotkeyReleased('u'); } +void HCISheet::ctrlI(){ qDebug()<<"ctrl I"; ctrl_pressed = false; emit hotkeyReleased('i'); } +void HCISheet::ctrlO(){ qDebug()<<"ctrl O"; ctrl_pressed = false; emit hotkeyReleased('O'); } +void HCISheet::ctrlP(){ qDebug()<<"ctrl P"; ctrl_pressed = false; emit hotkeyReleased('p'); } +void HCISheet::ctrlBracketLeft(){ qDebug()<<"ctrl ["; ctrl_pressed = false; emit hotkeyReleased('['); } +void HCISheet::ctrlBracketRight(){ qDebug()<<"ctrl ]"; ctrl_pressed = false; emit hotkeyReleased(']'); } +void HCISheet::ctrlJ(){ qDebug()<<"ctrl J"; ctrl_pressed = false; emit hotkeyReleased('j'); } +void HCISheet::ctrlK(){ qDebug()<<"ctrl K"; ctrl_pressed = false; emit hotkeyReleased('k'); } +void HCISheet::ctrlL(){ qDebug()<<"ctrl L"; ctrl_pressed = false; emit hotkeyReleased('l'); } +void HCISheet::ctrlPointVirgule(){ qDebug()<<"ctrl ;"; ctrl_pressed = false; emit hotkeyReleased(';'); } +void HCISheet::ctrlApostrophe(){ qDebug()<<"ctrl '"; ctrl_pressed = false; emit hotkeyReleased('\''); } +void HCISheet::ctrlZ(){ qDebug()<<"ctrl Z"; ctrl_pressed = false; emit hotkeyReleased('z'); } +void HCISheet::ctrlV(){ qDebug()<<"ctrl V"; ctrl_pressed = false; emit hotkeyReleased('v'); } +void HCISheet::ctrlB(){ qDebug()<<"ctrl B"; ctrl_pressed = false; emit hotkeyReleased('b'); } +void HCISheet::ctrlN(){ qDebug()<<"ctrl N"; ctrl_pressed = false; emit hotkeyReleased('n'); } +void HCISheet::ctrlM(){ qDebug()<<"ctrl M"; ctrl_pressed = false; emit hotkeyReleased('m'); } +void HCISheet::ctrlVirgule(){ qDebug()<<"ctrl ,"; ctrl_pressed = false; emit hotkeyReleased(','); } +void HCISheet::ctrlPoint(){ qDebug()<<"ctrl ."; ctrl_pressed = false; emit hotkeyReleased('.'); } +void HCISheet::ctrlSlash(){ qDebug()<<"ctrl /"; ctrl_pressed = false; emit hotkeyReleased('/'); } + +void HCISheet::ctrlChapeau(){ qDebug()<<"ctrl ^"; ctrl_pressed = false; emit hotkeyReleased('^'); } +void HCISheet::ctrlDollar(){ qDebug()<<"ctrl $"; ctrl_pressed = false; emit hotkeyReleased('$'); } +void HCISheet::ctrlStar(){ qDebug()<<"ctrl *"; ctrl_pressed = false; emit hotkeyReleased('*'); } +void HCISheet::ctrlAdvU(){ qDebug()<<("ctrl ù"); ctrl_pressed = false; emit hotkeyReleased('\xf9'); } +void HCISheet::ctrlChevron(){ qDebug()<<"ctrl <"; ctrl_pressed = false; emit hotkeyReleased('<'); } +void HCISheet::ctrlDoubleDot(){ qDebug()<<"ctrl :"; ctrl_pressed = false; emit hotkeyReleased(':'); } +void HCISheet::ctrlExclamation(){ qDebug()<<"ctrl !"; ctrl_pressed = false; emit hotkeyReleased('!'); } + +void HCISheet::ctrlEtCommercial(){ qDebug()<<"ctrl &"; ctrl_pressed = false; emit hotkeyReleased('&'); } +void HCISheet::ctrlEAigu(){ qDebug()<<"ctrl é"; ctrl_pressed = false; emit hotkeyReleased('\xe9'); } +void HCISheet::ctrlEGrave(){ qDebug()<<"ctrl è"; ctrl_pressed = false; emit hotkeyReleased('\xe8'); } +void HCISheet::ctrlGuillement(){ qDebug()<<"ctrl \""; ctrl_pressed = false; emit hotkeyReleased('\"'); } +void HCISheet::ctrlParentheseO(){ qDebug()<<"ctrl ("; ctrl_pressed = false; emit hotkeyReleased('('); } +void HCISheet::ctrlParentheseF(){ qDebug()<<"ctrl )"; ctrl_pressed = false; emit hotkeyReleased(')'); } +void HCISheet::ctrl_(){ qDebug()<<"ctrl _"; ctrl_pressed = false; emit hotkeyReleased('_'); } +void HCISheet::ctrlCedille(){ qDebug()<<"ctrl ç"; ctrl_pressed = false; emit hotkeyReleased('\xe7'); } +void HCISheet::ctrlAGrave(){ qDebug()<<"ctrl à"; ctrl_pressed = false; emit hotkeyReleased('\xe0'); } +void HCISheet::ctrlEqual(){ qDebug()<<"ctrl ="; ctrl_pressed = false; emit hotkeyReleased('='); } +void HCISheet::ctrlMinus(){ qDebug()<<"ctrl -"; ctrl_pressed = false; emit hotkeyReleased('-'); } diff --git a/Expe-selection/dyna-expe2/HCISheet.h b/Expe-selection/dyna-expe2/HCISheet.h index b3e7cd1..7bff87a 100644 --- a/Expe-selection/dyna-expe2/HCISheet.h +++ b/Expe-selection/dyna-expe2/HCISheet.h @@ -4,6 +4,8 @@ #include #include "expe/expeWidget/TrialSheet.h" +#include + class HCISheet : public TrialSheet { Q_OBJECT @@ -15,6 +17,7 @@ public: void paintEvent(QPaintEvent *); void keyPressEvent(QKeyEvent *); + bool event(QEvent *event); void keyReleaseEvent(QKeyEvent *); void paintLetters(QPainter& p); void paintRaisedKeys(QPainter& p); @@ -22,11 +25,13 @@ public: signals: - void hotkeyPressed(QString c); - void hotkeyReleased(QString c); + void ctrlPressed(); + void hotkeyPressed(char c); + void hotkeyReleased(char c); + void raisedKeyReleased(char key, int sides); public slots: - void setTargetKey(QString _key, QString _type){key = _key; type = _type; } + void setTargetKey(char _key, char _type){key = _key; type = _type; } void ctrlF(); void ctrlA(); void ctrlS(); @@ -83,10 +88,10 @@ public slots: void ctrlMinus(); protected: - QString key; - QString type; + char key; + char type; bool ctrl_pressed; - QMap posLetter; + QMap posLetter; QMap specialLetter; }; diff --git a/Expe-selection/dyna-expe2/dyna-expe2.pro b/Expe-selection/dyna-expe2/dyna-expe2.pro index 3165056..512fffe 100644 --- a/Expe-selection/dyna-expe2/dyna-expe2.pro +++ b/Expe-selection/dyna-expe2/dyna-expe2.pro @@ -1,7 +1,4 @@ -# ------------------------------------------------- -# Project created by QtCreator 2009-10-20T18:00:49 -# ------------------------------------------------- -TARGET = dyna-expe2 +TARGET = dyna-expe2 DESTDIR = ../tmp/exec/ TEMPLATE = app QT += xml @@ -13,8 +10,6 @@ INCLUDEPATH += expe RESOURCES += resources.qrc - - HEADERS += Controler.h \ HCISheet.h SOURCES += main.cpp Controler.cpp \ @@ -52,3 +47,13 @@ SOURCES += expe/csv/CSVWriter.cpp FORMS += expe/ExpeConfig.ui + +CONFIG(release): LIBS += -lDynamicKeyboardLibrary +#-L$$PWD/../../../../../../../../Program Files (x86)/Microsoft Visual Studio 10.0/VC/lib/ + +CONFIG(debug): LIBS += -lDynamicKeyboardLibraryd + +#-L$$PWD/../../../../../../../../Program Files (x86)/Microsoft Visual Studio 10.0/VC/lib/ + +#INCLUDEPATH += $$PWD/../../../../../../../../Program Files (x86)/Microsoft Visual Studio 10.0/VC/include +#DEPENDPATH += $$PWD/../../../../../../../../Program Files (x86)/Microsoft Visual Studio 10.0/VC/include diff --git a/Expe-selection/dyna-expe2/expe/Expe.cpp b/Expe-selection/dyna-expe2/expe/Expe.cpp index 9ee34ae..5a618dd 100644 --- a/Expe-selection/dyna-expe2/expe/Expe.cpp +++ b/Expe-selection/dyna-expe2/expe/Expe.cpp @@ -15,7 +15,7 @@ Expe::Expe() } //---------------- -void Expe::start(const QString& nameFile, QString user, const QString& option1, const QString& option2) +void Expe::start(const QString& nameFile, QString user, const QString& /*option1*/, const QString& /*option2*/) { this->designFileName = nameFile; widgetParent = createWidgetParent(); diff --git a/Expe-selection/dyna-expe2/expe/ExpeData.cpp b/Expe-selection/dyna-expe2/expe/ExpeData.cpp index 40902a6..995da87 100644 --- a/Expe-selection/dyna-expe2/expe/ExpeData.cpp +++ b/Expe-selection/dyna-expe2/expe/ExpeData.cpp @@ -44,14 +44,14 @@ QObject* ExpeDataFactory::newObject(const QString& className){ return 0; } -void ExpeDataFactory::setObjectParent(QObject* parent, QObject* child) +void ExpeDataFactory::setObjectParent(QObject* /*parent*/, QObject* /*child*/) { //ExpeDataList* _p = dynamic_cast(parent); //ExpeData* _c = dynamic_cast(child); //_p->addData(_c); } -void ExpeDataFactory::setMProperty(QObject* obj, QString metaName, QString name, QString value) +void ExpeDataFactory::setMProperty(QObject* /*obj*/, QString metaName, QString name, QString value) { qDebug()< #include + +#include + +/* void unitTest() { qDebug()<<"run keyboard experiment"; @@ -18,7 +22,7 @@ void unitTest() //qDebug()<<"sound is available: "<show(); + // MainWindow * mainWindow = new MainWindow(); + //mainWindow->show(); - Controler controler(mainWindow); + Controler controler(NULL);//mainWindow); return a.exec(); } -- 2.30.2