#include "TouchscreenButton.h"\r
\r
#include <QDebug>\r
+#include <TactonPlayer\Tacton.hpp>\r
+\r
\r
TouchscreenButton::TouchscreenButton(QWidget *parent, Qt::WFlags flags)\r
: QMainWindow(parent, flags)\r
{\r
setupUi(this);\r
-\r
+ \r
try\r
{\r
_touchscreen = new USBHIDImmersionTouchscreen();\r
- _wristband = new TactonPlayer("COM11");\r
}\r
catch(...)\r
{\r
- qDebug() << "Cannot find the touchscreen or the wristband";\r
+ qDebug() << "Cannot find the touchscreen";\r
+ _touchscreenoption->setChecked(false);\r
+ _touchscreenoption->setDisabled(true);\r
+ _touchscreen = NULL;\r
+ }\r
+\r
+ try\r
+ {\r
+ _wristband = new Wristband();\r
+ }\r
+ catch(...)\r
+ {\r
+ qDebug() << "Cannot find the wristband";\r
+ _wristbandoption->setChecked(false);\r
+ _wristbandoption->setDisabled(true);\r
+ _wristband = NULL;\r
}\r
\r
+ _play->setAttribute( Qt::WA_AcceptTouchEvents);\r
+\r
connect(_play, SIGNAL(pressed()), this, SLOT(play()));\r
+ connect(_play, SIGNAL(released()), this, SLOT(play()));\r
connect(_stop, SIGNAL(pressed()), this, SLOT(stop()));\r
+\r
+ connect(_pressoption, SIGNAL(stateChanged (int)), this, SLOT(pressFeedback(int)));\r
+ connect(_releaseoption, SIGNAL(stateChanged (int)), this, SLOT(releaseFeedback(int)));\r
+ \r
+// connect(_wristbandoption, SIGNAL(stateChanged(int)), this, SLOT(setWristbandState(int)));\r
+// connect(_touchscreenoption, SIGNAL(stateChanged(int)), this, SLOT(setTouchscreenState(int)));\r
}\r
\r
TouchscreenButton::~TouchscreenButton()\r
\r
void TouchscreenButton::play()\r
{\r
- _touchscreen->playEffect((unsigned char)(_effect->value()), (unsigned char)(_repeats->value()));\r
+ if (_touchscreenoption->checkState() == Qt::Checked)\r
+ _touchscreen->playEffect((unsigned char)(_effect->value()), (unsigned char)(_repeats->value()));\r
+ if (_wristbandoption->checkState() == Qt::Checked)\r
+ _wristband->playEffect((unsigned char)(_effect->value()), (unsigned char)(_repeats->value()));\r
}\r
\r
void TouchscreenButton::stop()\r
{\r
_touchscreen->playEffect(0, 1);\r
}\r
+\r
+void TouchscreenButton::pressFeedback(int state)\r
+{\r
+ if (state == Qt::Checked)\r
+ connect(_play, SIGNAL(pressed()), this, SLOT(play()));\r
+ else\r
+ disconnect(_play, SIGNAL(pressed()), this, SLOT(play()));\r
+}\r
+\r
+void TouchscreenButton::releaseFeedback(int state)\r
+{\r
+ if (state == Qt::Checked)\r
+ connect(_play, SIGNAL(released()), this, SLOT(play()));\r
+ else\r
+ disconnect(_play, SIGNAL(released()), this, SLOT(play()));\r
+}\r
\r
#include <ArduinoSerial\SerialWindows.hpp>\r
#include "USBHIDImmersionTouchscreen.h"\r
+#include "Wristband.h"\r
\r
class TouchscreenButton : public QMainWindow, public Ui::TouchscreenButtonClass\r
{\r
public slots:\r
void play();\r
void stop();\r
+ void pressFeedback(int);\r
+ void releaseFeedback(int);\r
\r
private:\r
USBHIDImmersionTouchscreen *_touchscreen;\r
- TactonPlayer *_wristband;\r
+ Wristband *_wristband;\r
};\r
\r
#endif // TOUCHSCREENBUTTON_H\r
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>\r
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
- <AdditionalDependencies>hidapid.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+ <AdditionalDependencies>tactonplayerd.lib;hidapid.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>\r
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r
<GenerateDebugInformation>false</GenerateDebugInformation>\r
- <AdditionalDependencies>hidapi.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+ <AdditionalDependencies>tactonplayer.lib;hidapi.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
</Link>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
<ClCompile Include="main.cpp" />\r
<ClCompile Include="TouchscreenButton.cpp" />\r
<ClCompile Include="USBHIDImmersionTouchscreen.cpp" />\r
+ <ClCompile Include="Wristband.cpp" />\r
</ItemGroup>\r
<ItemGroup>\r
<CustomBuild Include="TouchscreenButton.h">\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="GeneratedFiles\ui_touchscreenbutton.h" />\r
+ <ClInclude Include="Wristband.h" />\r
<CustomBuild Include="USBHIDImmersionTouchscreen.h">\r
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>\r
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
}\r
}\r
\r
-bool USBHIDImmersionTouchscreen::playEffect(unsigned char effect, unsigned char nbrepeat) const\r
+void USBHIDImmersionTouchscreen::playEffect(unsigned char effect, unsigned char nbrepeat) const\r
{\r
unsigned char buffer[35];\r
buffer[0] = PLAYEFFECTREPREAT_BYTE;\r
buffer[1] = effect;\r
buffer[2] = nbrepeat;\r
if (_devicehandle)\r
- return hid_write(_devicehandle, buffer, 35);\r
- else\r
- return -1;\r
+ hid_write(_devicehandle, buffer, 35);\r
}\r
\r
char * USBHIDImmersionTouchscreen::getStatus() const\r
See documentation for list of effects (0-46), 255 for no effect\r
nbrepeats: 255 for infinite until other effect or no effect\r
*/\r
- bool playEffect(unsigned char effect, unsigned char nbrepeat) const;\r
+ void playEffect(unsigned char effect, unsigned char nbrepeat) const;\r
char *getStatus() const;\r
//bool setNonVolatileEffects() const;\r
\r
#include "Wristband.h"\r
\r
#include <QDebug>\r
+#include <QThread>\r
\r
Wristband::Wristband()\r
{\r
try\r
{\r
- _tactonplayer = new TactonPlayer("COM11");\r
+ _tactonplayer = new TactonPlayer("COM8");\r
}\r
catch(...)\r
{\r
_tactonplayer = NULL;\r
}\r
\r
+ unsigned char desc[12];\r
+ //patterns\r
+ desc[0] = desc[6] = 0xff;\r
+ //duration\r
+ desc[1] = desc[7] = 0;\r
+ desc[2] = 10;\r
+ desc[8] = 90;\r
+ //frequency\r
+ desc[3] = desc[9] = 0;\r
+ desc[4] = desc[10] = 250;\r
+ //amplitude\r
+ desc[5] = 255;\r
+ desc[11] = 0;\r
+\r
+ //rel magnitude 10, durations 10; 90\r
+ _effects[0] = Tacton(2, desc);\r
+ //rel magnitude 8, durations 10; 45\r
+ desc[5] = 204;\r
+ desc[8] = 45;\r
+ _effects[1] = Tacton(2, desc);\r
+ //rel magnitude 8, durations 10; 90\r
+ desc[5] = 204;\r
+ desc[8] = 90;\r
+ _effects[2] = Tacton(2, desc);\r
+ //rel magnitude 8, durations 10; 180\r
+ desc[5] = 204;\r
+ desc[8] = 180;\r
+ _effects[3] = Tacton(2, desc);\r
+ //rel magnitude 6, durations 10; 90\r
+ desc[5] = 153;\r
+ desc[8] = 90;\r
+ _effects[4] = Tacton(2, desc);\r
+ //rel magnitude 5, durations 10; 90\r
+ desc[5] = 127;\r
+ _effects[5] = Tacton(2, desc);\r
+\r
+ //TODO: setup the other effects\r
}\r
\r
\r
delete _tactonplayer;\r
}\r
\r
-bool Wristband::playEffect(unsigned char effect, unsigned char nbrepeat) const\r
+void Wristband::playEffect(unsigned char effect, unsigned char nbrepeat) const\r
{\r
+ if (!_tactonplayer)\r
+ return;\r
+\r
for (int i = 0 ; i < nbrepeat ; i++)\r
{\r
_tactonplayer->play(_effects[effect]);\r
- ///TODO: add a pause\r
+ ///TODO: add a pause to prevent from overloading the arduino buffer\r
+ //messages are queues anyway, so it should not matters if nbrepeat is small\r
+ //QThread::msleep(_effects[effect].getDuration());\r
}\r
}\r
\r
char *Wristband::getStatus() const\r
{\r
+ return NULL;\r
}\r
Mimics Immersion touchscreen effects (0-46), 255 for no effect\r
nbrepeats: 255 for infinite until other effect or no effect\r
*/\r
- bool playEffect(unsigned char effect, unsigned char nbrepeat) const;\r
+ void playEffect(unsigned char effect, unsigned char nbrepeat) const;\r
char *getStatus() const;\r
\r
private:\r
<x>0</x>\r
<y>0</y>\r
<width>345</width>\r
- <height>191</height>\r
+ <height>321</height>\r
</rect>\r
</property>\r
<property name="windowTitle">\r
- <string>TouchscreenButton</string>\r
+ <string>Button</string>\r
</property>\r
<widget class="QWidget" name="centralWidget">\r
<layout class="QVBoxLayout" name="verticalLayout">\r
</property>\r
</widget>\r
</item>\r
+ <item row="3" column="1">\r
+ <widget class="QCheckBox" name="_pressoption">\r
+ <property name="text">\r
+ <string>Press</string>\r
+ </property>\r
+ <property name="checked">\r
+ <bool>true</bool>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item row="3" column="0">\r
+ <widget class="QCheckBox" name="_wristbandoption">\r
+ <property name="text">\r
+ <string>Wristband</string>\r
+ </property>\r
+ <property name="checked">\r
+ <bool>true</bool>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item row="4" column="0">\r
+ <widget class="QCheckBox" name="_touchscreenoption">\r
+ <property name="text">\r
+ <string>Touchscreen</string>\r
+ </property>\r
+ <property name="checked">\r
+ <bool>true</bool>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item row="4" column="1">\r
+ <widget class="QCheckBox" name="_releaseoption">\r
+ <property name="text">\r
+ <string>Release</string>\r
+ </property>\r
+ <property name="checked">\r
+ <bool>true</bool>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item row="2" column="0">\r
+ <widget class="QLabel" name="label_3">\r
+ <property name="font">\r
+ <font>\r
+ <weight>75</weight>\r
+ <bold>true</bold>\r
+ </font>\r
+ </property>\r
+ <property name="text">\r
+ <string>Feedback</string>\r
+ </property>\r
+ <property name="alignment">\r
+ <set>Qt::AlignCenter</set>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item row="2" column="1">\r
+ <widget class="QLabel" name="label_4">\r
+ <property name="font">\r
+ <font>\r
+ <weight>75</weight>\r
+ <bold>true</bold>\r
+ </font>\r
+ </property>\r
+ <property name="text">\r
+ <string>Events</string>\r
+ </property>\r
+ <property name="alignment">\r
+ <set>Qt::AlignCenter</set>\r
+ </property>\r
+ </widget>\r
+ </item>\r
</layout>\r
</item>\r
<item>\r
<widget class="QPushButton" name="_play">\r
<property name="font">\r
<font>\r
- <pointsize>20</pointsize>\r
+ <pointsize>50</pointsize>\r
</font>\r
</property>\r
<property name="text">\r
<widget class="QPushButton" name="_stop">\r
<property name="font">\r
<font>\r
- <pointsize>20</pointsize>\r
+ <pointsize>50</pointsize>\r
</font>\r
</property>\r
<property name="text">\r