#include <QDesktopWidget>
#include <QDebug>
-int secondScreenWidth = 1920;
-int secondScreenHeight = 1200;
+#include <DynamicKeyboard/QSideKeyEvent.h>
-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);
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;
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();
}
HCISheet* sheet = dynamic_cast<HCISheet*>(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);
}
//----------------------
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<HCISheet *>(this->trialSheet);
//this->trialSheet->releaseKeyboard();
//successSound.play();
}
-
+/*
QString Controler::getCharFromConfiguration(int keyId, int configuration)
{
QString key="g";
}
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);
}
#include <QAction>
#include <QFont>
+#include <DynamicKeyboard/QSideKeyEvent.h>
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));
//--------------
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);
act_ctrlMinus->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Minus));
connect(act_ctrlMinus, SIGNAL(triggered()), this, SLOT(ctrlMinus()));
this->addAction(act_ctrlMinus);
-
-
-
}
//---------------------------
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);
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);
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<QString, QPoint>::const_iterator i = posLetter.constBegin();
- while (i != posLetter.constEnd()) {
- p.drawText(i.value(), i.key());
+ QMap<char, QPoint>::const_iterator i = posLetter.constBegin();
+ while (i != posLetter.constEnd())
+ {
+ p.drawText(i.value(), QString(QChar(i.key())));
++i;
}
p.setFont(f);
QMap<QString, QPoint>::const_iterator j = specialLetter.constBegin();
- while (j != specialLetter.constEnd()) {
+ while (j != specialLetter.constEnd())
+ {
p.drawText(j.value(), j.key());
++j;
}
f.setPixelSize(12);
p.setFont(f);
-
-
}
//---------------------------
-void HCISheet::keyPressEvent(QKeyEvent *ke){
+void HCISheet::keyPressEvent(QKeyEvent *ke)
+{
//qDebug()<<"keyPressEvent hci sheet "<<ke->text() <<ke->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"<<ke->key() << " " << ke->text() << " " << ke->modifiers();
+// qDebug()<<"keyReleaseEvent hci sheet"<<ke->key() << " " << ke->text() << " " << ke->modifiers();
/*
if(this->ctrl_pressed){
qDebug()<<"keyReleaseEvent hci sheet 2"<<ke->key() <<ke->modifiers();
}
*/
}
+
+bool HCISheet::event(QEvent *event)
+{
+ if (event->type() == QSideKeyEvent::QSideKeyEventType)
+ {
+ QSideKeyEvent *evt = static_cast<QSideKeyEvent *>(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('-'); }