From 8c31f69223c17f7f8a86ab65e36881b6173d4f22 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Mon, 25 Mar 2013 14:40:07 +0000 Subject: [PATCH] Import new experiments git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@107 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- TactileMenus/TMenu.cpp | 32 ++ TactileMenus/TMenu.h | 21 ++ TactileMenus/TactileMenus.cpp | 63 ++++ TactileMenus/TactileMenus.h | 35 +++ TactileMenus/TactileMenus.vcxproj | 146 +++++++++ TactileMenus/main.cpp | 10 + TactileMenus/tactilemenus.qrc | 4 + TactileMenus/tactilemenus.ui | 56 ++++ Tactons Experiment.sln | 12 + Touchscreen Buttons Experiment/SetupGUI.cpp | 25 ++ Touchscreen Buttons Experiment/SetupGUI.h | 24 ++ .../Touchscreen Buttons Experiment.vcxproj | 194 ++++++++++++ .../TouchscreenButtonsExperiment.cpp | 179 +++++++++++ .../TouchscreenButtonsExperiment.h | 62 ++++ Touchscreen Buttons Experiment/main.cpp | 10 + Touchscreen Buttons Experiment/setupgui.ui | 78 +++++ Touchscreen Buttons Experiment/setupgui2.ui | 103 +++++++ .../touchscreenbuttonsexperiment.ui | 290 ++++++++++++++++++ 18 files changed, 1344 insertions(+) create mode 100644 TactileMenus/TMenu.cpp create mode 100644 TactileMenus/TMenu.h create mode 100644 TactileMenus/TactileMenus.cpp create mode 100644 TactileMenus/TactileMenus.h create mode 100644 TactileMenus/TactileMenus.vcxproj create mode 100644 TactileMenus/main.cpp create mode 100644 TactileMenus/tactilemenus.qrc create mode 100644 TactileMenus/tactilemenus.ui create mode 100644 Touchscreen Buttons Experiment/SetupGUI.cpp create mode 100644 Touchscreen Buttons Experiment/SetupGUI.h create mode 100644 Touchscreen Buttons Experiment/Touchscreen Buttons Experiment.vcxproj create mode 100644 Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.cpp create mode 100644 Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.h create mode 100644 Touchscreen Buttons Experiment/main.cpp create mode 100644 Touchscreen Buttons Experiment/setupgui.ui create mode 100644 Touchscreen Buttons Experiment/setupgui2.ui create mode 100644 Touchscreen Buttons Experiment/touchscreenbuttonsexperiment.ui diff --git a/TactileMenus/TMenu.cpp b/TactileMenus/TMenu.cpp new file mode 100644 index 0000000..c12c962 --- /dev/null +++ b/TactileMenus/TMenu.cpp @@ -0,0 +1,32 @@ +#include "TMenu.h" + + +TMenu::TMenu(TactonPlayer *tactonPlayer, QWidget *parent) +:QMenu(parent), _tactonPlayer(tactonPlayer) +{ + this->setStyleSheet(" QMenu {\ + background-color: #bbbbbb;\ + border: 1px solid black;\ + font-size: 30pt;\ + }\ + QMenu::item {\ + background-color: transparent;\ + padding: 10px 50px 10px 50px;\ + }\ + QMenu::item:selected {\ + background-color: #eeeeee;\ + }"); +} + + +TMenu::~TMenu(void) +{ +} + +void TMenu::mouseReleaseEvent(QMouseEvent * event) +{ + QAction *a; + if ((a = activeAction()) != NULL) + a->trigger(); + close(); +} \ No newline at end of file diff --git a/TactileMenus/TMenu.h b/TactileMenus/TMenu.h new file mode 100644 index 0000000..28d0e8c --- /dev/null +++ b/TactileMenus/TMenu.h @@ -0,0 +1,21 @@ +#ifndef __TMENU__ +#define __TMENU__ + +#include + +#include + + +class TMenu : public QMenu +{ + public: + TMenu(TactonPlayer *_tactonPlayer, QWidget *parent=NULL); + ~TMenu(); + + void mouseReleaseEvent(QMouseEvent * event); + + private: + TactonPlayer *_tactonPlayer; +}; + +#endif diff --git a/TactileMenus/TactileMenus.cpp b/TactileMenus/TactileMenus.cpp new file mode 100644 index 0000000..7310d17 --- /dev/null +++ b/TactileMenus/TactileMenus.cpp @@ -0,0 +1,63 @@ +#include "TactileMenus.h" + +#include +#include + +TactileMenus::TactileMenus(QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags), _menu(NULL) +{ + setupUi(this); + QWidget::showMaximized(); + + try + { + _tactonPlayer = new TactonPlayer("COM8"); + } + catch(...) + { + qDebug() << "Cannot find the touchscreen or the wristband"; + _tactonPlayer = NULL; + } + + _menu = new TMenu(_tactonPlayer, this); + + _signalMapper = new QSignalMapper(this); + + for (int i = 1 ; i < 8 ; i++) + { + QAction *a = new QAction(QString::number(i), this); + _menu->addAction(a); + connect(a, SIGNAL(triggered()), _signalMapper, SLOT(map())); + connect(a, SIGNAL(hovered()), this, SLOT(pouet())); + _signalMapper->setMapping(a, i); + } + + connect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(execute(int))); +} + + + +TactileMenus::~TactileMenus() +{ + if (_tactonPlayer) + delete _tactonPlayer; +} + +void TactileMenus::mousePressEvent(QMouseEvent *evt) +{ + //pouet(); + _menu->exec(evt->globalPos()); +} + +void TactileMenus::execute(int val) +{ + if (_tactonPlayer) + _tactonPlayer->play(Tacton(0x0f, 15, 250, 255)); + _text->setText(QString::number(val)); +} + +void TactileMenus::pouet() +{ + if (_tactonPlayer) + _tactonPlayer->play(Tacton(0x0f, 10, 100, 150)); +} \ No newline at end of file diff --git a/TactileMenus/TactileMenus.h b/TactileMenus/TactileMenus.h new file mode 100644 index 0000000..95935ad --- /dev/null +++ b/TactileMenus/TactileMenus.h @@ -0,0 +1,35 @@ +#ifndef TACTILEMENUS_H +#define TACTILEMENUS_H + +#include +#include "ui_tactilemenus.h" +#include "TMenu.h" +#include + +#include + +class TactileMenus : public QMainWindow, public Ui::TactileMenusClass +{ + Q_OBJECT + + public: + TactileMenus(QWidget *parent = 0, Qt::WFlags flags = 0); + ~TactileMenus(); + + void mousePressEvent(QMouseEvent * event); + //void mouseReleaseEvent(QMouseEvent * event); + + public slots: + void execute(int); + void pouet(); + + signals: + void selected(int); + + private: + TMenu *_menu; + QSignalMapper *_signalMapper; + TactonPlayer *_tactonPlayer; +}; + +#endif // TACTILEMENUS_H diff --git a/TactileMenus/TactileMenus.vcxproj b/TactileMenus/TactileMenus.vcxproj new file mode 100644 index 0000000..89d8b16 --- /dev/null +++ b/TactileMenus/TactileMenus.vcxproj @@ -0,0 +1,146 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {49223BDA-A1D1-4CAB-A637-3028D969EB2F} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + TactonPlayerd.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) + + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + TactonPlayer.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + true + + + + + + + + + true + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing TactileMenus.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing TactileMenus.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + + Document + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + + + + + + + \ No newline at end of file diff --git a/TactileMenus/main.cpp b/TactileMenus/main.cpp new file mode 100644 index 0000000..b82a5f6 --- /dev/null +++ b/TactileMenus/main.cpp @@ -0,0 +1,10 @@ +#include "TactileMenus.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + TactileMenus w; + w.show(); + return a.exec(); +} diff --git a/TactileMenus/tactilemenus.qrc b/TactileMenus/tactilemenus.qrc new file mode 100644 index 0000000..6ca33d8 --- /dev/null +++ b/TactileMenus/tactilemenus.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/TactileMenus/tactilemenus.ui b/TactileMenus/tactilemenus.ui new file mode 100644 index 0000000..e20d7fd --- /dev/null +++ b/TactileMenus/tactilemenus.ui @@ -0,0 +1,56 @@ + + + TactileMenusClass + + + + 0 + 0 + 600 + 400 + + + + TactileMenus + + + + + + + + 60 + 75 + true + + + + Press me + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + diff --git a/Tactons Experiment.sln b/Tactons Experiment.sln index 728a917..8c727a8 100644 --- a/Tactons Experiment.sln +++ b/Tactons Experiment.sln @@ -15,6 +15,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeltaTimeJND", "DeltaTimeJN EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AngularPosition", "AngularPosition\AngularPosition.vcxproj", "{002CBB10-B3C0-490E-BB15-02827293648A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Touchscreen Buttons Experiment", "Touchscreen Buttons Experiment\Touchscreen Buttons Experiment.vcxproj", "{9466E3E8-496E-4DDF-BCE6-20DD992504C1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TactileMenus", "TactileMenus\TactileMenus.vcxproj", "{49223BDA-A1D1-4CAB-A637-3028D969EB2F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -49,6 +53,14 @@ Global {002CBB10-B3C0-490E-BB15-02827293648A}.Debug|Win32.Build.0 = Debug|Win32 {002CBB10-B3C0-490E-BB15-02827293648A}.Release|Win32.ActiveCfg = Release|Win32 {002CBB10-B3C0-490E-BB15-02827293648A}.Release|Win32.Build.0 = Release|Win32 + {9466E3E8-496E-4DDF-BCE6-20DD992504C1}.Debug|Win32.ActiveCfg = Debug|Win32 + {9466E3E8-496E-4DDF-BCE6-20DD992504C1}.Debug|Win32.Build.0 = Debug|Win32 + {9466E3E8-496E-4DDF-BCE6-20DD992504C1}.Release|Win32.ActiveCfg = Release|Win32 + {9466E3E8-496E-4DDF-BCE6-20DD992504C1}.Release|Win32.Build.0 = Release|Win32 + {49223BDA-A1D1-4CAB-A637-3028D969EB2F}.Debug|Win32.ActiveCfg = Debug|Win32 + {49223BDA-A1D1-4CAB-A637-3028D969EB2F}.Debug|Win32.Build.0 = Debug|Win32 + {49223BDA-A1D1-4CAB-A637-3028D969EB2F}.Release|Win32.ActiveCfg = Release|Win32 + {49223BDA-A1D1-4CAB-A637-3028D969EB2F}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Touchscreen Buttons Experiment/SetupGUI.cpp b/Touchscreen Buttons Experiment/SetupGUI.cpp new file mode 100644 index 0000000..3080d11 --- /dev/null +++ b/Touchscreen Buttons Experiment/SetupGUI.cpp @@ -0,0 +1,25 @@ +#include "SetupGUI.h" + + +SetupGUI::SetupGUI(QWidget *parent, Qt::WFlags flags) +:QMainWindow(parent, flags), _expwindow(NULL) +{ + setupUi(this); + + connect(_start, SIGNAL(clicked()), this, SLOT(init())); +} + + +SetupGUI::~SetupGUI() +{ + if (_expwindow) + delete _expwindow; +} + +void SetupGUI::init() +{ + _expwindow = new TouchscreenButtonsExperiment(); + _expwindow->init(_user->text(), _effects->text(), _repetitions->value()); + _expwindow->show(); + this->hide(); +} diff --git a/Touchscreen Buttons Experiment/SetupGUI.h b/Touchscreen Buttons Experiment/SetupGUI.h new file mode 100644 index 0000000..070232a --- /dev/null +++ b/Touchscreen Buttons Experiment/SetupGUI.h @@ -0,0 +1,24 @@ +#ifndef __SETUPGUI__ +#define __SETUPGUI__ + +#include +#include "ui_setupgui.h" + +#include "TouchscreenButtonsExperiment.h" + +class SetupGUI : public QMainWindow, public Ui::SetupGUI +{ + Q_OBJECT + + public: + SetupGUI(QWidget *parent = 0, Qt::WFlags flags = 0); + ~SetupGUI(); + + public slots: + void init(); + + private: + TouchscreenButtonsExperiment *_expwindow; +}; + +#endif diff --git a/Touchscreen Buttons Experiment/Touchscreen Buttons Experiment.vcxproj b/Touchscreen Buttons Experiment/Touchscreen Buttons Experiment.vcxproj new file mode 100644 index 0000000..9fdd84a --- /dev/null +++ b/Touchscreen Buttons Experiment/Touchscreen Buttons Experiment.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {9466E3E8-496E-4DDF-BCE6-20DD992504C1} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + tactonplayerd.lib;hidapid.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) + + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + tactonplayer.lib;hidapi.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + + + true + + + true + + + + + + + + + true + + + true + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing TouchscreenButtonsExperiment.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing TouchscreenButtonsExperiment.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing SetupGUI.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing SetupGUI.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + + + + + Document + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + + + + \ No newline at end of file diff --git a/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.cpp b/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.cpp new file mode 100644 index 0000000..de61150 --- /dev/null +++ b/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.cpp @@ -0,0 +1,179 @@ +#include "TouchscreenButtonsExperiment.h" + +#include +#include + +TouchscreenButtonsExperiment::TouchscreenButtonsExperiment(QWidget *parent, Qt::WFlags flags) +: QMainWindow(parent, flags), _current(0) +{ + setupUi(this); + + try + { + _touchscreen = new USBHIDImmersionTouchscreen(); + } + catch(...) + { + qDebug() << "Cannot find the touchscreen"; + _touchscreen = NULL; + } + + try + { + _wristband = new Wristband(); + } + catch(...) + { + qDebug() << "Cannot find the wristband"; + _wristband = NULL; + } + + connect(_play, SIGNAL(pressed()), this, SLOT(pressWristband())); + connect(_play, SIGNAL(released()), this, SLOT(releaseWristband())); + connect(_play, SIGNAL(pressed()), this, SLOT(pressTouchscreen())); + + connect(_answer1, SIGNAL(actionTriggered(int)), this, SLOT(slider1Action(int))); + connect(_answer2, SIGNAL(actionTriggered(int)), this, SLOT(slider2Action(int))); + + + connect(_validate, SIGNAL(pressed()), this, SLOT(answer())); +} + +TouchscreenButtonsExperiment::~TouchscreenButtonsExperiment() +{ + if (_logfile) + fclose(_logfile); + if (_touchscreen) + delete _touchscreen; + if (_wristband) + delete _wristband; + hid_exit(); +} + +void TouchscreenButtonsExperiment::init(QString user, QString effects, int repetitions) +{ + _user = user; + QStringList effectlist = effects.split(";"); + _effects = new int[effectlist.length()]; + for (unsigned int i = 0 ; i < effectlist.length() ; i++) + _effects[i] = effectlist[i].toInt(); + _repetitions = repetitions; + + //create log file + QString date = QDate::currentDate().toString("yyyy-MM-dd") + "-" + QTime::currentTime().toString("HH-mm-ss"); + QString logfilename = user + "-" + QString::number(repetitions) + "-" + date + ".csv"; + _logfile = fopen(logfilename.toStdString().c_str(), "w"); + qDebug() << "log: " << logfilename; + if (_logfile) + fprintf(_logfile, "Time,User,Condition,Effect,NbPress,Answer1,Answer2\n"); + + //Prepare trials + for (int i = 0 ; i < _repetitions ; i++) + { + QList > temp; + //generate the block + for (int j = 0 ; j < NBCONDITIONS ; j++) + for (int k = 0 ; k < effectlist.length() ; k++) + temp.push_back(QPair(k, j)); + //shuffle + for (int j = 0; j < temp.count(); j++) + temp.swap(j, (rand() % (temp.count() - j)) + j); + //add the block to the trial + _trials.append(temp); + } + + //run trial + _timer.start(); + runTrial(); +} + +void TouchscreenButtonsExperiment::runTrial() +{ + if (_current >= _trials.count()) + { + _validate->setText("Terminé"); + _validate->setDisabled(true); + _play->setDisabled(true); + + disconnect(_play, SIGNAL(pressed()), this, SLOT(pressWristband())); + disconnect(_play, SIGNAL(released()), this, SLOT(releaseWristband())); + disconnect(_play, SIGNAL(pressed()), this, SLOT(pressTouchscreen())); + return; + } + + //reset stats + _presses = 0; + _validate->setDisabled(true); + _answer1->setValue((_answer1->minimum() + _answer1->maximum()) / 2); + _answer2->setValue((_answer2->minimum() + _answer2->maximum()) / 2); +} + + +void TouchscreenButtonsExperiment::answer() +{ + //write answer in the log file + log(); + + _current++; + + //run next trial + runTrial(); +} + +void TouchscreenButtonsExperiment::log() +{ + if (_logfile) + fprintf(_logfile, "%lld,%s,%d,%d,%d,%d,%d\n", + _timer.elapsed(), + _user.toStdString().c_str(), + _trials.at(_current).second, + _trials.at(_current).first, + _presses, + _answer1->value(), + _answer2->value()); +} + +void TouchscreenButtonsExperiment::pressWristband() +{ + switch (_trials.at(_current).second) + { + case WRISTBAND: + _wristband->playEffect(_trials.at(_current).first, 1); + break; + case WRISTBANDTIME: case BOTH: + _wristband->playEffect(_trials.at(_current).first, 2); + break; + default: + break; + } _validate->setEnabled(true); +} + +void TouchscreenButtonsExperiment::releaseWristband() +{ + if (_trials.at(_current).second == WRISTBAND) + _wristband->playEffect(_trials.at(_current).first, 1); + + _presses++; +} + +void TouchscreenButtonsExperiment::pressTouchscreen() +{ + if (_trials.at(_current).second == TOUCHSCREEN || _trials.at(_current).second == BOTH) + _touchscreen->playEffect(_trials.at(_current).first, 1); + + _validate->setEnabled(true); +} + +void TouchscreenButtonsExperiment::slider1Action(int action) +{ + // prevents the wlider from moving when pressing the sides of the handle + if (action != QAbstractSlider::SliderMove) + _answer1->setSliderPosition(_answer1->value()); +} + +void TouchscreenButtonsExperiment::slider2Action(int action) +{ + // prevents the wlider from moving when pressing the sides of the handle + if (action != QAbstractSlider::SliderMove) + _answer2->setSliderPosition(_answer2->value()); +} diff --git a/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.h b/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.h new file mode 100644 index 0000000..0f076b6 --- /dev/null +++ b/Touchscreen Buttons Experiment/TouchscreenButtonsExperiment.h @@ -0,0 +1,62 @@ +#ifndef TOUCHSCREENBUTTONSEXPERIMENT_H +#define TOUCHSCREENBUTTONSEXPERIMENT_H + +#include +#include +#include "ui_touchscreenbuttonsexperimenten.h" + +#include "..\..\dwell\TouchscreenButton\Wristband.h" +#include "..\..\dwell\TouchscreenButton\USBHIDImmersionTouchscreen.h" + +class TouchscreenButtonsExperiment : public QMainWindow, public Ui::TouchscreenButtonsExperimentClass +{ + Q_OBJECT + + public: + TouchscreenButtonsExperiment(QWidget *parent = 0, Qt::WFlags flags = 0); + ~TouchscreenButtonsExperiment(); + + void init(QString user, QString effects, int repetitions); + + void log(); + + + void runTrial(); + + public slots: + void answer(); + void pressWristband(); + void releaseWristband(); + void pressTouchscreen(); + + void slider1Action(int); + void slider2Action(int); + + private: + + enum Condition { + NOEFFECT, + WRISTBAND, + WRISTBANDTIME, + TOUCHSCREEN, + BOTH, + NBCONDITIONS + }; + + USBHIDImmersionTouchscreen *_touchscreen; + Wristband *_wristband; + + QString _user; + int *_effects; + int _repetitions; + int _presses; + + //each trial is a pair of + QList > _trials; + int _current; + QElapsedTimer _timer; + + FILE *_logfile; +}; + +#endif // TOUCHSCREENBUTTONSEXPERIMENT_H diff --git a/Touchscreen Buttons Experiment/main.cpp b/Touchscreen Buttons Experiment/main.cpp new file mode 100644 index 0000000..677f9ee --- /dev/null +++ b/Touchscreen Buttons Experiment/main.cpp @@ -0,0 +1,10 @@ +#include "SetupGUI.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + SetupGUI w; + w.show(); + return a.exec(); +} diff --git a/Touchscreen Buttons Experiment/setupgui.ui b/Touchscreen Buttons Experiment/setupgui.ui new file mode 100644 index 0000000..97a256b --- /dev/null +++ b/Touchscreen Buttons Experiment/setupgui.ui @@ -0,0 +1,78 @@ + + + SetupGUI + + + + 0 + 0 + 236 + 121 + + + + Touchscreen buttons experiment + + + 1.000000000000000 + + + + + + + + + User: + + + + + + + + + + Effects: + + + + + + + 3;8;12;13 + + + + + + + Repetitions: + + + + + + + 1 + + + 3 + + + + + + + + + Start + + + + + + + + + diff --git a/Touchscreen Buttons Experiment/setupgui2.ui b/Touchscreen Buttons Experiment/setupgui2.ui new file mode 100644 index 0000000..3399a5d --- /dev/null +++ b/Touchscreen Buttons Experiment/setupgui2.ui @@ -0,0 +1,103 @@ + + + SetupGUI + + + + 0 + 0 + 222 + 123 + + + + Dialog + + + + + + 6 + + + 0 + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + User: + + + + + + + + + + Effects: + + + + + + + 0;1;2 + + + + + + + Repetitions: + + + + + + + 10 + + + 3 + + + + + + + + + Start + + + + + + + + + + + _start + clicked() + SetupGUI + accept() + + + 278 + 253 + + + 96 + 254 + + + + + diff --git a/Touchscreen Buttons Experiment/touchscreenbuttonsexperiment.ui b/Touchscreen Buttons Experiment/touchscreenbuttonsexperiment.ui new file mode 100644 index 0000000..26f46e6 --- /dev/null +++ b/Touchscreen Buttons Experiment/touchscreenbuttonsexperiment.ui @@ -0,0 +1,290 @@ + + + TouchscreenButtonsExperimentClass + + + + 0 + 0 + 740 + 588 + + + + TouchscreenButtonsExperiment + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 50 + + + + QPushButton { + border: 2px solid #8f8f91; + border-radius: 6px; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #d6d7da, stop: 1 #babbbe); + min-width: 80px; + } + + QPushButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0#f6f7fa , stop: 1 #dadbde); + } + + QPushButton:hover:pressed { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #babbbe, stop: 1 #f6f7fa); + } + + QPushButton:flat { + border: none; /* no border for a flat push button */ + } + + QPushButton:default { + border-color: navy; /* make the default button prominent */ + } + + + Play + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 12 + + + + A quel point avez-vous l'impression de presser un bouton ? + + + + + + + + + + 12 + + + + Pas du tout + + + + + + + + 50 + 50 + + + + QSlider { height: 100px} + +QSlider::groove:horizontal { + border:2px solid #999999; + height:60px; + margin: 0 0 0 0; +} + +QSlider::handle:horizontal { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); + border: 1px solid #5c5c5c; + width:70px; + margin: -10px 0 -10px 0; + border-radius: 3px; +} + + + + 1 + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + + 12 + + + + Beaucoup + + + + + + + + + + 12 + + + + Est-ce que le ressenti du bouton est agréable ? + + + + + + + + + + 12 + + + + Pas du tout + + + + + + + + 0 + 50 + + + + QSlider { height: 100px} + +QSlider::groove:horizontal { + border:2px solid #999999; + height:60px; + margin: 0 0 0 0; +} + +QSlider::handle:horizontal { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); + border: 1px solid #5c5c5c; + width:70px; + margin: -10px 0 -10px 0; + border-radius: 3px; +} + + + + 1 + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + + 12 + + + + Beaucoup + + + + + + + + + + 50 + + + + QPushButton { + border: 2px solid #8f8f91; + border-radius: 6px; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #d6d7da, stop: 1 #babbbe); + min-width: 80px; + } + + QPushButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0#f6f7fa , stop: 1 #dadbde); + } + + QPushButton:hover:pressed { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #babbbe, stop: 1 #f6f7fa); + } + + QPushButton:flat { + border: none; /* no border for a flat push button */ + } + + QPushButton:default { + border-color: navy; /* make the default button prominent */ + } + + + Valider + + + + + + + + + + + + -- 2.30.2