commit f647ce82068cc87773a2207b42b8a3afaaac120d Author: SET Date: Wed Oct 12 09:03:25 2022 +0200 Initial commit. diff --git a/CMake/FindHidapi.cmake b/CMake/FindHidapi.cmake new file mode 100644 index 0000000..57b7737 --- /dev/null +++ b/CMake/FindHidapi.cmake @@ -0,0 +1,29 @@ +# + +# - Try to find Hidapi +# Once done this will define +# HIDAPI_FOUND - System has Hidapi +# HIDAPI_INCLUDE_DIRS - The Hidapi include directories +# HIDAPI_LIBRARIES - The libraries needed to use Hidapi +# HIDAPI_DEFINITIONS - Compiler switches required for using Hidapi + +#find_package(PkgConfig) +#pkg_check_modules(PC_HIDAPI QUIET ) +#set(HIDAPI_DEFINITIONS ${PC_HIDAPI_CFLAGS_OTHER}) + +find_path(HIDAPI_INCLUDE_DIR hidapi/hidapi.h + HINTS ${PC_HIDAPI_INCLUDEDIR} ${PC_HIDAPI_INCLUDE_DIRS} + PATH_SUFFIXES hidapi ) + +find_library(HIDAPI_LIBRARY NAMES libhidapi-hidraw.so + HINTS ${PC_HIDAPI_LIBDIR} ${PC_HIDAPI_LIBRARY_DIRS} ) + +set(HIDAPI_LIBRARIES ${HIDAPI_LIBRARY} ) +set(HIDAPI_INCLUDE_DIRS ${HIDAPI_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set HIDAPI_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Hidapi DEFAULT_MSG + HIDAPI_LIBRARY HIDAPI_INCLUDE_DIR) +mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY ) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..dce9283 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.0) + +project(T7) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") + +find_package(wxWidgets + CONFIG + REQUIRED + ) + +find_package(Hidapi REQUIRED) + +add_executable(T7 + PedalManager.h PedalManager.cpp + KeyboardSimulation.h KeyboardSimulation.cpp + XT7Main.h XT7Main.cpp + UI/t7app.h UI/t7app.cpp + UI/t7main.h UI/t7main.cpp + ) + +install(TARGETS T7 RUNTIME DESTINATION bin) + +target_link_libraries(T7 ${wxWidgets_LIBRARIES} + ${HIDAPI_LIBRARIES} + ) diff --git a/KeyboardSimulation.cpp b/KeyboardSimulation.cpp new file mode 100644 index 0000000..56c12f9 --- /dev/null +++ b/KeyboardSimulation.cpp @@ -0,0 +1,65 @@ +/* + * File: KeyboardSimulation.cpp + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2022 + * + * Created on October 8, 2022, 3:43 PM + */ + +#include "KeyboardSimulation.h" + +KeyboardSimulation::KeyboardSimulation(PedalEVH * evh) { + m_pedalEVH = evh; + if (!m_pedalEVH) + return; + m_pedalEVH->m_owner->Bind(wxEVT_CHAR_HOOK, &KeyboardSimulation::OnKeyDown, this); +} + +KeyboardSimulation::~KeyboardSimulation() { +} + +void KeyboardSimulation::OnKeyDown(wxKeyEvent& evt) { + const int keycode = evt.GetKeyCode(); + if (keycode != WXK_ESCAPE && keycode != WXK_F5 + && keycode != WXK_F6 && keycode != WXK_F7) + return; + // Stop current. + if (m_currentLeftStatus == PedalEvent::PRESSED) { + m_currentLeftStatus = PedalEvent::RELEASED; + m_pedalEVH->Left(m_currentLeftStatus); + } + if (m_currentMiddleStatus == PedalEvent::PRESSED) { + m_currentMiddleStatus = PedalEvent::RELEASED; + m_pedalEVH->Middle(m_currentMiddleStatus); + } + if (m_currentRightStatus == PedalEvent::PRESSED) { + m_currentRightStatus = PedalEvent::RELEASED; + m_pedalEVH->Right(m_currentRightStatus); + } + // Start new or stop all.. + switch (keycode) { + case WXK_F5: + m_currentLeftStatus = PedalEvent::PRESSED; + m_pedalEVH->Left(m_currentLeftStatus); + break; + case WXK_F6: + m_currentMiddleStatus = PedalEvent::PRESSED; + m_pedalEVH->Middle(m_currentMiddleStatus); + break; + case WXK_F7: + m_currentRightStatus = PedalEvent::PRESSED; + m_pedalEVH->Right(m_currentRightStatus); + break; + case WXK_ESCAPE: + m_currentLeftStatus = PedalEvent::RELEASED; + m_pedalEVH->Left(m_currentLeftStatus); + m_currentMiddleStatus = PedalEvent::RELEASED; + m_pedalEVH->Middle(m_currentMiddleStatus); + m_currentRightStatus = PedalEvent::RELEASED; + m_pedalEVH->Right(m_currentRightStatus); + break; + default: + break; + } +} diff --git a/KeyboardSimulation.h b/KeyboardSimulation.h new file mode 100644 index 0000000..30d7f83 --- /dev/null +++ b/KeyboardSimulation.h @@ -0,0 +1,31 @@ +/* + * File: KeyboardSimulation.h + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2022 + * + * Created on October 8, 2022, 3:43 PM + */ + +#ifndef KEYBOARDSIMULATION_H +#define KEYBOARDSIMULATION_H + +#include "XT7Main.h" + +class PedalEVH; + +class KeyboardSimulation { +public: + KeyboardSimulation(PedalEVH * evh); + virtual ~KeyboardSimulation(); +private: + PedalEvent::PedalStatus m_currentLeftStatus = PedalEvent::RELEASED; + PedalEvent::PedalStatus m_currentMiddleStatus = PedalEvent::RELEASED; + PedalEvent::PedalStatus m_currentRightStatus = PedalEvent::RELEASED; + + PedalEVH * m_pedalEVH; + void OnKeyDown(wxKeyEvent& evt); +}; + +#endif /* KEYBOARDSIMULATION_H */ + diff --git a/PedalManager.cpp b/PedalManager.cpp new file mode 100644 index 0000000..e71acdd --- /dev/null +++ b/PedalManager.cpp @@ -0,0 +1,408 @@ +/* + * File: PedalMonitor.cpp + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2014 + * + * Created on 18 février 2014, 20:52 + */ + +#include "PedalManager.h" +#include +using namespace std; + +IPedalMonitor::IPedalMonitor() {} +IPedalMonitor::~IPedalMonitor() {} +wxThread::ExitCode IPedalMonitor::Entry() {return (wxThread::ExitCode) 0;} + +PedalMonitor_OnOff::PedalMonitor_OnOff(const wxString& newDevice, PedalEvent * newPedalEVH, const unsigned short newLeftCode, const unsigned short newMiddleCode, const unsigned short newRightCode) { + CreateThread(wxTHREAD_DETACHED); + m_pedalEVH = newPedalEVH; + m_leftCode = newLeftCode; + m_middleCode = newMiddleCode; + m_rightCode = newRightCode; + m_device = newDevice; + m_current = PedalEvent::NONE; +} + +PedalMonitor_OnOff::~PedalMonitor_OnOff() { + hid_exit(); +} + +wxThread::ExitCode PedalMonitor_OnOff::Entry() { + /* Two pedal devices have been tested : + * The Infinity VEC IN-USB-2 + * The Olympus RS-28 + * Their individual pedals send different bytes : + * VEC + * LEFT : 1 + * MIDDLE : 2 + * RIGHT : 4 + * + * OLYMPUS RS-28 + * LEFT : 1 + * MIDDLE : 4 + * RIGHT : 2 + * + * This is obtained by mere exploration. + * The hardware documentation does not provide this information. + */ +/* + IF MORE THAN ONE PEDAL PRESSED, RELEASING ONE PEDAL FIRES + * THE EVENT OF THE PRESSED PEDALS + * + */ + if (!m_pedalEVH) { + return (wxThread::ExitCode) 1; + } + if (hid_init() != 0) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_device * dev = hid_open_path(m_device.c_str()); + if (!dev) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_set_nonblocking(dev, 0); + const unsigned short bsz = 256; + unsigned char b[bsz]; + unsigned short code = 0; + int nbRead = 0; + while(true) { + if (GetThread()->TestDestroy()) break; + nbRead = hid_read(dev, b, bsz); + if (GetThread()->TestDestroy()) break; + if (nbRead == -1) break; + /* + * There's only one significant byte of all the bytes read. + * All other bytes are zero. Ignore the order of the significant byte + * byte adding them all. + * This will break with a nasty device. + * A hypothetical device may work as follows : + * LEFT : 0 4 1 0 0 + * MIDDLE : 1 3 0 1 0 + * RIGHT : 0 1 1 1 2 + * Adding the bytes won't identify which pedal is pressed. + * But let's suppose hardware manufacturers are friendly. + * A (nailed) HID mouse can be used for testing. + */ + for (unsigned short i = 0; i < nbRead; i++) { + code += (unsigned short) b[i]; + } + // We stop everything when we catch anything. + if (m_current == PedalEvent::LEFT) m_pedalEVH->Left(PedalEvent::RELEASED); + if (m_current == PedalEvent::MIDDLE) m_pedalEVH->Middle(PedalEvent::RELEASED); + if (m_current == PedalEvent::RIGHT) m_pedalEVH->Right(PedalEvent::RELEASED); + // If more than one pedal is pressed, we start listening again. + if (code != 0 && code != m_leftCode && code != m_middleCode && code != m_rightCode) { + code = 0; + continue; + } + // Only one pedal is pressed + if (code == m_leftCode) { + m_current = PedalEvent::LEFT; + m_pedalEVH->Left(PedalEvent::PRESSED); + } + if (code == m_middleCode) { + m_current = PedalEvent::MIDDLE; + m_pedalEVH->Middle(PedalEvent::PRESSED); + } + if (code == m_rightCode) { + m_current = PedalEvent::RIGHT; + m_pedalEVH->Right(PedalEvent::PRESSED); + } + if (code == 0) m_current = PedalEvent::NONE; + code = 0; + } + + hid_close(dev); + hid_exit(); + m_pedalEVH->OnPedalMonitorExit(); + return (wxThread::ExitCode) 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// + +PedalMonitor_Override::PedalMonitor_Override(const wxString& newDevice, PedalEvent * newPedalEVH, const unsigned short newLeftCode, const unsigned short newMiddleCode, const unsigned short newRightCode) { + CreateThread(wxTHREAD_DETACHED); + m_pedalEVH = newPedalEVH; + m_leftCode = newLeftCode; + m_middleCode = newMiddleCode; + m_rightCode = newRightCode; + m_device = newDevice; + m_current = PedalEvent::NONE; + m_previous = PedalEvent::NONE; +} + +PedalMonitor_Override::~PedalMonitor_Override() { + hid_exit(); +} + +wxThread::ExitCode PedalMonitor_Override::Entry() { + if (!m_pedalEVH) { + return (wxThread::ExitCode) 1; + } + if (hid_init() != 0) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_device * dev = hid_open_path(m_device.c_str()); + if (!dev) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_set_nonblocking(dev, 0); + const unsigned short bsz = 256; + unsigned char b[bsz]; + unsigned short code = 0; + int nbRead = 0; + while(true) { + if (GetThread()->TestDestroy()) break; + nbRead = hid_read(dev, b, bsz); + if (GetThread()->TestDestroy()) break; + if (nbRead == -1) break; + for (unsigned short i = 0; i < nbRead; i++) { + code += (unsigned short) b[i]; + } + m_previous = m_current; + /* + * Two pedals are pressed. + * We proceed in a deterministic way, we ony have 3 pedals afterall. + */ + if (code == m_leftCode + m_middleCode) { + if (m_current == PedalEvent::LEFT) { + // Stop the current action + m_pedalEVH->Left(PedalEvent::RELEASED); + // Update the current action, the newly pressed pedal. + m_current = PedalEvent::MIDDLE; + code = code - m_leftCode; // OR code = middleCode; + } else { + m_pedalEVH->Middle(PedalEvent::RELEASED); + m_current = PedalEvent::LEFT; + code = code - m_middleCode; + } + } + if (code == m_leftCode + m_rightCode) { + if (m_current == PedalEvent::LEFT) { + m_pedalEVH->Left(PedalEvent::RELEASED); + m_current = PedalEvent::RIGHT; + code = code - m_leftCode; + } else { + m_pedalEVH->Right(PedalEvent::RELEASED); + m_current = PedalEvent::LEFT; + code = code - m_rightCode; + } + } + if (code == m_middleCode + m_rightCode) { + if (m_current == PedalEvent::MIDDLE) { + m_pedalEVH->Middle(PedalEvent::RELEASED); + m_current = PedalEvent::RIGHT; + code = code - m_middleCode; + } else { + m_pedalEVH->Right(PedalEvent::RELEASED); + m_current = PedalEvent::MIDDLE; + code = code - m_rightCode; + } + } + // If one or three pedals are pressed, we still need to stop everything. + if (m_previous == PedalEvent::LEFT) m_pedalEVH->Left(PedalEvent::RELEASED); + if (m_previous == PedalEvent::MIDDLE) m_pedalEVH->Middle(PedalEvent::RELEASED); + if (m_previous == PedalEvent::RIGHT) m_pedalEVH->Right(PedalEvent::RELEASED); + // If three pedals are pressed, we start listening again. + if (code == m_leftCode + m_middleCode + m_rightCode) { + code = 0; + continue; + } + // Proceed with the last pedal pressed. + if (code == m_leftCode) { + m_current = PedalEvent::LEFT; + m_pedalEVH->Left(PedalEvent::PRESSED); + } + if (code == m_middleCode) { + m_current = PedalEvent::MIDDLE; + m_pedalEVH->Middle(PedalEvent::PRESSED); + } + if (code == m_rightCode) { + m_current = PedalEvent::RIGHT; + m_pedalEVH->Right(PedalEvent::PRESSED); + } + if (code == 0) m_current = PedalEvent::NONE; + code = 0; + } + + hid_close(dev); + hid_exit(); + m_pedalEVH->OnPedalMonitorExit(); + return (wxThread::ExitCode) 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// + +PedalEvent::PedalEvent() {} +PedalEvent::~PedalEvent() {} + +void PedalEvent::Left(PedalEvent::PedalStatus status) {} +void PedalEvent::Middle(PedalEvent::PedalStatus PedalStatus) {} +void PedalEvent::Right(PedalEvent::PedalStatus PedalStatus) {} +void PedalEvent::OnPedalMonitorExit() {} +void PedalEvent::OnFastMoveExit(MediaFastMove * active) {} +void PedalEvent::OnCodeIdentifierExit(PedalCodeIdentifier* active) {} +void PedalEvent::OnPedalCaught(const unsigned short code) {} +void PedalEvent::OnMediaProgressExit(MediaProgress * active) {} +void PedalEvent::OnMediaProgressPosition() {} +void PedalEvent::OnMediaControlPosition(wxFileOffset position) {} +void PedalEvent::OnStreamError() {} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * We move 'm_step' interval, and wait 'm_sleepMs' milliseconds. + */ +MediaFastMove::MediaFastMove(wxMediaCtrl * newMedia, wxFileOffset newStep, unsigned long newSleepMs, PedalEvent * newCaller) { + CreateThread(wxTHREAD_DETACHED); + m_media = newMedia; + m_step = newStep; + m_sleepMs = newSleepMs; + m_pedalEVH = newCaller; +} +MediaFastMove::~MediaFastMove() { + +} +wxThread::ExitCode MediaFastMove::Entry() { + if (!m_pedalEVH) { + return (wxThread::ExitCode) 1; + } + // Fast forward + if (m_step > 0) { + wxFileOffset pos = m_media->Tell(); + wxFileOffset ln = pos; + wxFileOffset realStep = m_step; + m_media->Pause(); + while (pos <= ln) { + if (GetThread()->TestDestroy()) break; + ln = m_media->Length(); + realStep = ((ln - pos) < m_step) ? ln - pos : m_step; + //m_media->Seek(realStep, wxFromCurrent); + m_pedalEVH->OnMediaControlPosition(realStep); + wxMilliSleep(m_sleepMs); + pos = m_media->Tell(); + } + } + // Rewind, with a negative step + if (m_step < 0) { + //wxFileOffset ln = m_media->Length(); + wxFileOffset pos = m_media->Tell(); + wxFileOffset realStep = m_step; + m_media->Pause(); + while (pos > 0) { + if (GetThread()->TestDestroy()) break; + realStep = (pos < abs(m_step)) ? -pos : m_step; + //m_media->Seek(realStep, wxFromCurrent); + m_pedalEVH->OnMediaControlPosition(realStep); + wxMilliSleep(m_sleepMs); + pos = m_media->Tell(); + } + } + m_pedalEVH->OnFastMoveExit(this); + return (wxThread::ExitCode) 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Forward a pedal event to PedalEvent class. + * We want to identify the byte sent by pressing a pedal. + */ +PedalCodeIdentifier::PedalCodeIdentifier(const wxString& newDevice, PedalEvent* newPedalEvent) { + CreateThread(wxTHREAD_DETACHED); + m_pedalEVH = newPedalEvent; + m_device = newDevice; +} +PedalCodeIdentifier::~PedalCodeIdentifier() { + hid_exit(); +} +wxThread::ExitCode PedalCodeIdentifier::Entry() { + if (!m_pedalEVH) { + return (wxThread::ExitCode) 1; + } + if (hid_init() != 0) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_device * dev = hid_open_path(m_device.c_str()); + if (!dev) { + m_pedalEVH->OnStreamError(); + return (wxThread::ExitCode) 1; + } + hid_set_nonblocking(dev, 0); + const unsigned short bsz = 256; + unsigned char b[bsz]; + unsigned short code = 0; + int nbRead = 0; + while (true) { + if (GetThread()->TestDestroy()) break; + nbRead = hid_read(dev, b, bsz); + if (GetThread()->TestDestroy()) break; + if (nbRead == -1) break; + for (unsigned short i = 0; i < nbRead; i++) { + code += (unsigned short) b[i]; + } + m_pedalEVH->OnPedalCaught(code); + code = 0; + } + hid_close(dev); + hid_exit(); + m_pedalEVH->OnCodeIdentifierExit(this); + return (wxThread::ExitCode) 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Forward media position to PedalEvent class at a hard coded 250 ms interval. + */ +MediaProgress::MediaProgress(PedalEvent * newPedalEvent) { + CreateThread(wxTHREAD_DETACHED); + m_pedalEVH = newPedalEvent; +} +MediaProgress::~MediaProgress() { + +} +wxThread::ExitCode MediaProgress::Entry() { + if (!m_pedalEVH) { + return (wxThread::ExitCode) 1; + } + while (true) { + if (GetThread()->TestDestroy()) break; + m_pedalEVH->OnMediaProgressPosition(); + wxMilliSleep(250); + } + + m_pedalEVH->OnMediaProgressExit(this); + return (wxThread::ExitCode) 0; +} + +//////////////////////////////////////////////////////////////////////////////////// + +HIDTool::HIDTool() { +} + +HIDTool::~HIDTool() { +} + +void HIDTool::GetHIDDevices(wxComboBox * cmb, wxArrayString& paths) { + if (hid_init() == 0) { + hid_device_info * devices; + devices = hid_enumerate(0, 0); + AppendHIDDevice(devices, cmb, paths); + hid_free_enumeration(devices); + hid_exit(); + } +} +void HIDTool::AppendHIDDevice(hid_device_info* newDeviceInfo, wxComboBox * cmb, wxArrayString& paths) { + if (newDeviceInfo) { + wxString item(newDeviceInfo->manufacturer_string); + item += _T(" - ") + wxString(newDeviceInfo->product_string); + cmb->Append(item); + paths.Add(wxString(newDeviceInfo->path)); + if (newDeviceInfo->next) AppendHIDDevice(newDeviceInfo->next, cmb, paths); + } +} diff --git a/PedalManager.h b/PedalManager.h new file mode 100644 index 0000000..1fd6ebb --- /dev/null +++ b/PedalManager.h @@ -0,0 +1,158 @@ +/* + * File: PedalMonitor.h + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2014 + * + * Created on 18 février 2014, 20:52 + */ + +#ifndef PEDALMONITOR_H +#define PEDALMONITOR_H + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include +#include +#include + +class PedalEvent; +class PedalCodeIdentifier; +class PedalBytesPerClickFinder; +class MediaFastMove; +class MediaProgress; +class HIDTool; + +class IPedalMonitor: public wxThreadHelper { +public: + IPedalMonitor(); + virtual ~IPedalMonitor(); +protected: + virtual wxThread::ExitCode Entry() = 0; + +}; +/* + * In both modes below, pressing three pedals blocks everything. + * No pedal pressed means no action. + */ +/* + * In this mode, pressing a second pedal blocks everything. + * Releasing one pedal resumes the action of the pressed pedal. + */ +class PedalMonitor_OnOff : public IPedalMonitor { +public: + PedalMonitor_OnOff(const wxString& newDevice, PedalEvent * newPedalEVH, const unsigned short newLeftCode = 1, const unsigned short newMiddleCode = 2, const unsigned short newRightCode = 4); + virtual ~PedalMonitor_OnOff(); +protected: + virtual wxThread::ExitCode Entry(); +private: + PedalEvent * m_pedalEVH; + unsigned short m_leftCode, m_middleCode, m_rightCode; + unsigned short m_current; + wxString m_device; +}; +/* + *In this mode, pressing a second pedal overrides the first pedal. + * The action of the last pedal pressed takes precedence. + * Releasing one pedal resumes the action of the pressed pedal. + */ +class PedalMonitor_Override : public IPedalMonitor { +public: + PedalMonitor_Override(const wxString& newDevice, PedalEvent * newPedalEVH, const unsigned short newLeftCode = 1, const unsigned short newMiddleCode = 2, const unsigned short newRightCode = 4); + virtual ~PedalMonitor_Override(); +protected: + virtual wxThread::ExitCode Entry(); +private: + PedalEvent * m_pedalEVH; + unsigned short m_leftCode, m_middleCode, m_rightCode; + unsigned short m_current, m_previous; + wxString m_device; +}; +/* + * A single class to manage events form many classes. + * Function names are explicit. + * Not using custom wxWidgets events facility because it's abstract to me, sorry. + */ +class PedalEvent { +public: + enum PedalStatus{RELEASED = 0, PRESSED}; + enum PedalPressed{NONE = 0, LEFT, MIDDLE, RIGHT}; + PedalEvent(); + virtual ~PedalEvent(); + + virtual void Left(PedalEvent::PedalStatus status); + virtual void Middle(PedalEvent::PedalStatus PedalStatus); + virtual void Right(PedalEvent::PedalStatus PedalStatus); + virtual void OnPedalMonitorExit(); + virtual void OnFastMoveExit(MediaFastMove * active); + virtual void OnCodeIdentifierExit(PedalCodeIdentifier * active); + virtual void OnPedalCaught(const unsigned short code); + virtual void OnMediaProgressExit(MediaProgress * active); + virtual void OnMediaProgressPosition(); + virtual void OnMediaControlPosition(wxFileOffset position); + virtual void OnStreamError(); +private: + +}; +/* + * For fast forward and rewind + */ +class MediaFastMove : public wxThreadHelper { +public: + MediaFastMove (wxMediaCtrl * newMedia, wxFileOffset newStep, unsigned long newSleepMs, PedalEvent * newCaller); + virtual ~MediaFastMove(); + +protected: + virtual wxThread::ExitCode Entry(); + +private: + wxMediaCtrl * m_media; + wxFileOffset m_step; + unsigned long m_sleepMs; + PedalEvent * m_pedalEVH; +}; +/* + * Identify the bytes sent by each pedal. + */ +class PedalCodeIdentifier : public wxThreadHelper { +public: + PedalCodeIdentifier(const wxString& newDevice, PedalEvent * newPedalEvent); + ~PedalCodeIdentifier(); +protected: + virtual wxThread::ExitCode Entry(); +private: + PedalEvent * m_pedalEVH; + wxString m_device; +}; +/* + * Update media position in UI. + */ +class MediaProgress : public wxThreadHelper { +public: + MediaProgress(PedalEvent * newPedalEvent); + ~MediaProgress(); +protected: + virtual wxThread::ExitCode Entry(); +private: + PedalEvent * m_pedalEVH; +}; + +class HIDTool { +public: + HIDTool(); + virtual ~HIDTool(); + + static void GetHIDDevices(wxComboBox * cmb, wxArrayString& paths); +private: + static void AppendHIDDevice(hid_device_info * newDeviceInfo, wxComboBox * cmb, wxArrayString& paths); +}; + +#endif /* PEDALMONITOR_H */ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..313eb23 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +#T7 + +HID foot pedal controlled transcription application. + +## Build + +$ cd T7 + +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release ../ + +$ make -j4 + +## Usage + +Udev's facilities are used here. A group with read/write access to the +device must be created, with users added to that group. + +$ groupadd transcript +$ usermod -a -G transcript user + +Create /etc/udev/rules.d/99-mypedal.rules with (one single line) : +KERNEL=="hidraw[0-9]*", ATTRS{idVendor}=="abcd", ATTRS{idProduct}=="efgh", +MODE="0660", GROUP="transcript" + +Get 'abcd' and 'efgh' with 'lsusb' command or 'dmesg |tail' commands +after plugging the foot pedal. + +Remove the pedal device and plug it again. On next login, users in group +'transcript' should have read access to the device. + +##### T7 configuration: + +Open the two nested collapsible panes at the bottom of the main window. + +Select the foot pedal device. + +Identify each of the three pedals in turn. + +Restart the application. + +Declare pedal roles. + +Choose an automatic rewind duration on pause. + +Select a root media directory. + +Refresh the list. + +Double click on an item. + +Use the pedals. + +## Disclaimer + +Programming is just my hobby, use at your own risks. + +T7 does not claim to be fit for any purpose. + +## Limitations + +Not designed for devices with less or more than three pedals. +Developed on Linux, other operating systems are not a target. + diff --git a/UI/T7.pjd b/UI/T7.pjd new file mode 100644 index 0000000..db17fea --- /dev/null +++ b/UI/T7.pjd @@ -0,0 +1,2214 @@ + + +
+ 0 + "" + "" + "" + "" + "" + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + "Saleem EDAH-TALLY" + "Copyright Saleem EDAH-TALLY." + "" + 0 + 0 + 0 + 0 + "<All platforms>" + "2.9.2" + "Standard" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "" + "// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + " /// %BODY% +" + " +/* + * %BODY% + */ + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "utf-8" + "utf-8" + "utf-8" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + 4286447616 + "" + "Debug" + "Unicode" + "Static" + "Modular" + "GUI" + "wxGTK+2" + "Default" + "Dynamic" + "Yes" + "No" + "Yes" + "No" + "No" + "Yes" + "Yes" + "Yes" + "Yes" + "Yes" + "builtin" + "Yes" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%WXVERSION%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + 0 + 1 + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 1 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "T7App" + "dialog-document" + "" + "app" + 0 + 1 + 0 + 0 + "wbAppProxy" + 10000 + 0 + "" + 0 + "" + "Standard" + 0 + 0 + "T7App" + "wxApp" + "t7app.cpp" + "t7app.h" + "" + "" + "" + + + "T7" + "dialog-document" + "" + "frame" + 0 + 1 + 0 + 0 + "wbFrameProxy" + 10000 + 0 + "" + 0 + "" + "Standard" + 0 + 0 + "ID_T7MAIN" + 10000 + "T7Main" + "wxFrame" + "t7main.cpp" + "t7main.h" + "" + "T7" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + 0 + 0 + -1 + -1 + 500 + 400 + 0 + "" + + "wxScrolledWindow: ID_SCROLLEDWINDOW" + "dialog-control-document" + "" + "scrolledwindow" + 0 + 1 + 0 + 0 + "wbScrolledWindowProxy" + "ID_SCROLLEDWINDOW" + 10001 + "" + "wxScrolledWindow" + "wxScrolledWindow" + 1 + 0 + "" + "" + "scrlMain" + 1 + 1 + 0 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + "" + 0 + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "szMain" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxPanel: ID_PANEL1" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "wbPanelProxy" + "ID_PANEL1" + 10049 + "" + "wxPanel" + "wxPanel" + 1 + 0 + "" + "" + "panPedals" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "Tiled" + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 1 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + "" + 0 + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "szMediaMain" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "szMediaTop" + "Expand" + "Centre" + 1 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxMediaCtrl: ID_MEDIACTRL" + "dialog-control-document" + "" + "window" + 0 + 1 + 0 + 0 + "wbMediaCtrlProxy" + "ID_MEDIACTRL" + 10068 + "" + "wxMediaCtrl" + "wxMediaCtrl" + 1 + 0 + "" + "" + "medMain" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + "" + + + "wxSlider: ID_SLIDER" + "dialog-control-document" + "" + "slider" + 0 + 1 + 0 + 0 + "wbSliderProxy" + "ID_SLIDER" + 10069 + "" + "wxSlider" + "wxSlider" + 1 + 0 + "" + "" + "sldMediaPosition" + 0 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "szMediaInfo" + "Right" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "lblMediaCurrent" + "Position" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "lblMediaLength" + "Total" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "wbSpacerProxy" + 10 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_BUTTON1" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbButtonProxy" + "ID_BUTTON1" + 10079 + "" + "wxButton" + "wxButton" + 1 + 0 + "" + "" + "btnMediaRootRefresh" + "Rafraîchir" + 0 + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxDirPickerCtrl: ID_DIRPICKERCTRL1" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbDirPickerCtrlProxy" + "ID_DIRPICKERCTRL1" + 10078 + "" + "wxDirPickerCtrl" + "wxDirPickerCtrl" + 1 + 0 + "" + "" + "dpkMediaRoot" + "" + "" + "" + "Dossier racine des médias." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 1 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + + + "wxCollapsiblePane: ID_COLLAPSIBLEPANE6" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "wbCollapsiblePaneProxy" + "ID_COLLAPSIBLEPANE6" + 10070 + "" + "wxCollapsiblePane" + "wxCollapsiblePane" + 1 + 0 + "" + "" + "panePedalIDs" + "Configuration du pédalier" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "szPedalMain" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxCollapsiblePane: ID_COLLAPSIBLEPANE7" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "wbCollapsiblePaneProxy" + "ID_COLLAPSIBLEPANE7" + 10077 + "" + "wxCollapsiblePane" + "wxCollapsiblePane" + 1 + 0 + "" + "" + "panePedalHardware" + "Matériel" + 1 + "" + "Vous ne devez pas jouer avec ces valeurs une fois paramétrées." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "szPedalHardware" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "" + "1. Périphérique" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxComboBox: ID_COMBOBOX_HW" + "dialog-control-document" + "" + "combobox" + 0 + 1 + 0 + 0 + "wbComboBoxProxy" + "ID_COMBOBOX_HW" + 10003 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "cmbHIDDevices" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "" + "2. Appuyez sur la pédale" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxComboBox: ID_XCOMBOBOX6" + "dialog-control-document" + "" + "combobox" + 0 + 1 + 0 + 0 + "wbComboBoxProxy" + "ID_XCOMBOBOX6" + 10072 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "cmbPedals" + "" + "" + "" + "Vous ne devriez pas jouer avec cette valeur une fois bien paramétrée." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "%PARENT%, %IDENTIFIER%, %Initial value%, %POSITION%, %SIZE%, %Strings%, %STYLE%" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "lblPedalCode" + "" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 1 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_BUTTON" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbButtonProxy" + "ID_BUTTON" + 10002 + "" + "wxButton" + "wxButton" + 1 + 0 + "" + "" + "btnAbout" + "A propos" + 0 + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "" + "Actions" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxComboBox: ID_XCOMBOBOX9" + "dialog-control-document" + "" + "combobox" + 0 + 1 + 0 + 0 + "wbComboBoxProxy" + "ID_XCOMBOBOX9" + 10075 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "cmbPedalActionLeft" + "" + "" + "" + "Pédale de gauche" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "%PARENT%, %IDENTIFIER%, %Initial value%, %POSITION%, %SIZE%, %Strings%, %STYLE%" + "" + + + "wxComboBox: ID_XCOMBOBOX7" + "dialog-control-document" + "" + "combobox" + 0 + 1 + 0 + 0 + "wbComboBoxProxy" + "ID_XCOMBOBOX7" + 10073 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "cmbPedalActionMiddle" + "" + "" + "" + "Pédale du milieu." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "%PARENT%, %IDENTIFIER%, %Initial value%, %POSITION%, %SIZE%, %Strings%, %STYLE%" + "" + + + "wxComboBox: ID_XCOMBOBOX8" + "dialog-control-document" + "" + "combobox" + 0 + 1 + 0 + 0 + "wbComboBoxProxy" + "ID_XCOMBOBOX8" + 10074 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "cmbPedalActionRight" + "" + "" + "" + "Pédale de droite." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "%PARENT%, %IDENTIFIER%, %Initial value%, %POSITION%, %SIZE%, %Strings%, %STYLE%" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "" + "wxStaticText" + "wxStaticText" + 1 + 0 + "" + "" + "" + "Revenir en arrière à la fin de la lecture" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxTextCtrl: ID_XTEXTCTRL7" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "wbTextCtrlProxy" + "ID_XTEXTCTRL7" + 10071 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "txtMediaAutoRewind" + "1000" + 6 + "" + "En millisecondes. Appuyez sur ENTRÉE pour enregistrer après modification." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "%PARENT%, %IDENTIFIER%, %Initial value%, %POSITION%, %SIZE%, %STYLE%" + "" + + + + + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "T7.rc" + "source-editor-document" + "T7.rc" + "source-editor" + 0 + 0 + 1 + 0 + "1/3/2014" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/UI/T7.rc b/UI/T7.rc new file mode 100644 index 0000000..b86c4e2 --- /dev/null +++ b/UI/T7.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/UI/t7app.cpp b/UI/t7app.cpp new file mode 100644 index 0000000..31d8d8c --- /dev/null +++ b/UI/t7app.cpp @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: t7app.cpp +// Purpose: +// Author: SET +// Modified by: +// Created: sam. 01 mars 2014 14:17:48 CET +// RCS-ID: +// Copyright: Copyright SET (nmset@yandex.com) - © 2014. +// Licence: LGPL 2.1 +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "t7app.h" +#include "../XT7Main.h" + +////@begin XPM images +////@end XPM images + + +/* + * Application instance implementation + */ + +////@begin implement app +IMPLEMENT_APP( T7App ) +////@end implement app + + +/* + * T7App type definition + */ + +IMPLEMENT_CLASS( T7App, wxApp ) + + +/* + * T7App event table definition + */ + +BEGIN_EVENT_TABLE( T7App, wxApp ) + +////@begin T7App event table entries +////@end T7App event table entries + +END_EVENT_TABLE() + + +/* + * Constructor for T7App + */ + +T7App::T7App() +{ + Init(); +} + + +/* + * Member initialisation + */ + +void T7App::Init() +{ +////@begin T7App member initialisation +////@end T7App member initialisation +} + +/* + * Initialisation for T7App + */ + +bool T7App::OnInit() +{ +////@begin T7App initialisation + // Remove the comment markers above and below this block + // to make permanent changes to the code. + +#if wxUSE_XPM + wxImage::AddHandler(new wxXPMHandler); +#endif +#if wxUSE_LIBPNG + wxImage::AddHandler(new wxPNGHandler); +#endif +#if wxUSE_LIBJPEG + wxImage::AddHandler(new wxJPEGHandler); +#endif +#if wxUSE_GIF + wxImage::AddHandler(new wxGIFHandler); +#endif +////@end T7App initialisation + + wxSetlocale(LC_ALL, wxLocale::GetLanguageCanonicalName(wxLocale::GetSystemLanguage()) + _T(".") + wxLocale::GetSystemEncodingName()); + SetAppName(_APPNAME_T7_); + SetExitOnFrameDelete(true); + XT7Main * main = new XT7Main( NULL); + SetTopWindow(main); + main->Show(); + + return true; +} + + +/* + * Cleanup for T7App + */ + +int T7App::OnExit() +{ +////@begin T7App cleanup + return wxApp::OnExit(); +////@end T7App cleanup +} diff --git a/UI/t7app.h b/UI/t7app.h new file mode 100644 index 0000000..09db341 --- /dev/null +++ b/UI/t7app.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: t7app.h +// Purpose: +// Author: SET +// Modified by: +// Created: sam. 01 mars 2014 14:17:48 CET +// RCS-ID: +// Copyright: Copyright SET (nmset@yandex.com) - © 2014. +// Licence: LGPL 2.1 +///////////////////////////////////////////////////////////////////////////// + +#ifndef _T7APP_H_ +#define _T7APP_H_ + +/*! + * Includes + */ + + +////@begin includes +#include "wx/image.h" +////@end includes +#include + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +////@end control identifiers + +/*! + * T7App class declaration + */ + +class T7App: public wxApp +{ + DECLARE_CLASS( T7App ) + DECLARE_EVENT_TABLE() + +public: + /// Constructor + T7App(); + + void Init(); + + /// Initialises the application + virtual bool OnInit(); + + /// Called on exit + virtual int OnExit(); + +////@begin T7App event handler declarations + +////@end T7App event handler declarations + +////@begin T7App member function declarations + +////@end T7App member function declarations + +////@begin T7App member variables +////@end T7App member variables +}; + +/*! + * Application instance declaration + */ + +////@begin declare app +DECLARE_APP(T7App) +////@end declare app + +#endif + // _T7APP_H_ diff --git a/UI/t7main.cpp b/UI/t7main.cpp new file mode 100644 index 0000000..f5b715c --- /dev/null +++ b/UI/t7main.cpp @@ -0,0 +1,287 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: t7main.cpp +// Purpose: +// Author: SET +// Modified by: +// Created: sam. 01 mars 2014 14:23:16 CET +// RCS-ID: +// Copyright: Copyright SET (nmset@yandex.com) - © 2014. +// Licence: LGPL 2.1 +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "t7main.h" + +////@begin XPM images +////@end XPM images + + +/* + * T7Main type definition + */ + +IMPLEMENT_CLASS( T7Main, wxFrame ) + + +/* + * T7Main event table definition + */ + +BEGIN_EVENT_TABLE( T7Main, wxFrame ) + +////@begin T7Main event table entries +////@end T7Main event table entries + +END_EVENT_TABLE() + + +/* + * T7Main constructors + */ + +T7Main::T7Main() +{ + Init(); +} + +T7Main::T7Main( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Init(); + Create( parent, id, caption, pos, size, style ); +} + + +/* + * T7Main creator + */ + +bool T7Main::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin T7Main creation + wxFrame::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + Centre(); +////@end T7Main creation + return true; +} + + +/* + * T7Main destructor + */ + +T7Main::~T7Main() +{ +////@begin T7Main destruction +////@end T7Main destruction +} + + +/* + * Member initialisation + */ + +void T7Main::Init() +{ +////@begin T7Main member initialisation + scrlMain = NULL; + szMain = NULL; + panPedals = NULL; + szMediaMain = NULL; + szMediaTop = NULL; + medMain = NULL; + sldMediaPosition = NULL; + szMediaInfo = NULL; + lblMediaCurrent = NULL; + lblMediaLength = NULL; + btnMediaRootRefresh = NULL; + dpkMediaRoot = NULL; + panePedalIDs = NULL; + szPedalMain = NULL; + panePedalHardware = NULL; + szPedalHardware = NULL; + cmbHIDDevices = NULL; + cmbPedals = NULL; + lblPedalCode = NULL; + btnAbout = NULL; + cmbPedalActionLeft = NULL; + cmbPedalActionMiddle = NULL; + cmbPedalActionRight = NULL; + txtMediaAutoRewind = NULL; +////@end T7Main member initialisation +} + + +/* + * Control creation for T7Main + */ + +void T7Main::CreateControls() +{ +////@begin T7Main content construction + T7Main* itemFrame1 = this; + + scrlMain = new wxScrolledWindow( itemFrame1, ID_SCROLLEDWINDOW, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); + scrlMain->SetScrollbars(1, 1, 0, 0); + szMain = new wxBoxSizer(wxVERTICAL); + scrlMain->SetSizer(szMain); + + panPedals = new wxPanel( scrlMain, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + szMain->Add(panPedals, 1, wxGROW|wxALL, 5); + szMediaMain = new wxBoxSizer(wxVERTICAL); + panPedals->SetSizer(szMediaMain); + + szMediaTop = new wxBoxSizer(wxVERTICAL); + szMediaMain->Add(szMediaTop, 1, wxGROW|wxALL, 5); + medMain = new wxMediaCtrl( panPedals, ID_MEDIACTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxNO_BORDER ); + szMediaTop->Add(medMain, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + sldMediaPosition = new wxSlider( panPedals, ID_SLIDER, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL ); + szMediaTop->Add(sldMediaPosition, 0, wxGROW|wxALL, 5); + + szMediaInfo = new wxBoxSizer(wxHORIZONTAL); + szMediaTop->Add(szMediaInfo, 0, wxALIGN_RIGHT|wxALL, 5); + lblMediaCurrent = new wxStaticText( panPedals, wxID_STATIC, _("Position"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); + szMediaInfo->Add(lblMediaCurrent, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + lblMediaLength = new wxStaticText( panPedals, wxID_STATIC, _("Total"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); + szMediaInfo->Add(lblMediaLength, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + szMediaInfo->Add(10, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); + szMediaTop->Add(itemBoxSizer13, 0, wxGROW|wxALL, 5); + btnMediaRootRefresh = new wxButton( panPedals, ID_BUTTON1, wxGetTranslation(wxString(wxT("Rafra")) + (wxChar) 0x00EE + wxT("chir")), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(btnMediaRootRefresh, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + dpkMediaRoot = new wxDirPickerCtrl( panPedals, ID_DIRPICKERCTRL1, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE|wxDIRP_USE_TEXTCTRL|wxDIRP_DIR_MUST_EXIST|wxDIRP_CHANGE_DIR ); + if (T7Main::ShowToolTips()) + dpkMediaRoot->SetToolTip(wxGetTranslation(wxString(wxT("Dossier racine des m")) + (wxChar) 0x00E9 + wxT("dias."))); + itemBoxSizer13->Add(dpkMediaRoot, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + panePedalIDs = new wxCollapsiblePane( panPedals, ID_COLLAPSIBLEPANE6, wxGetTranslation(wxString(wxT("Configuration du p")) + (wxChar) 0x00E9 + wxT("dalier")), wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE ); + szMediaMain->Add(panePedalIDs, 0, wxGROW|wxALL, 5); + szPedalMain = new wxBoxSizer(wxVERTICAL); + panePedalIDs->GetPane()->SetSizer(szPedalMain); + + panePedalHardware = new wxCollapsiblePane( panePedalIDs->GetPane(), ID_COLLAPSIBLEPANE7, wxGetTranslation(wxString(wxT("Mat")) + (wxChar) 0x00E9 + wxT("riel")), wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE ); + if (T7Main::ShowToolTips()) + panePedalHardware->SetToolTip(wxGetTranslation(wxString(wxT("Vous ne devez pas jouer avec ces valeurs une fois param")) + (wxChar) 0x00E9 + wxT("tr") + (wxChar) 0x00E9 + wxT("es."))); + szPedalMain->Add(panePedalHardware, 0, wxGROW|wxALL, 5); + szPedalHardware = new wxBoxSizer(wxVERTICAL); + panePedalHardware->GetPane()->SetSizer(szPedalHardware); + + wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); + szPedalHardware->Add(itemBoxSizer20, 0, wxGROW|wxALL, 5); + wxStaticText* itemStaticText21 = new wxStaticText( panePedalHardware->GetPane(), wxID_STATIC, wxGetTranslation(wxString(wxT("1. P")) + (wxChar) 0x00E9 + wxT("riph") + (wxChar) 0x00E9 + wxT("rique")), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxArrayString cmbHIDDevicesStrings; + cmbHIDDevices = new wxComboBox( panePedalHardware->GetPane(), ID_COMBOBOX_HW, wxEmptyString, wxDefaultPosition, wxDefaultSize, cmbHIDDevicesStrings, wxCB_READONLY ); + itemBoxSizer20->Add(cmbHIDDevices, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL); + szPedalHardware->Add(itemBoxSizer23, 0, wxGROW|wxALL, 5); + wxStaticText* itemStaticText24 = new wxStaticText( panePedalHardware->GetPane(), wxID_STATIC, wxGetTranslation(wxString(wxT("2. Appuyez sur la p")) + (wxChar) 0x00E9 + wxT("dale")), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer23->Add(itemStaticText24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxArrayString cmbPedalsStrings; + cmbPedals = new wxComboBox( panePedalHardware->GetPane(), ID_XCOMBOBOX6, wxEmptyString, wxDefaultPosition, wxDefaultSize, cmbPedalsStrings, wxCB_READONLY ); + if (T7Main::ShowToolTips()) + cmbPedals->SetToolTip(wxGetTranslation(wxString(wxT("Vous ne devriez pas jouer avec cette valeur une fois bien param")) + (wxChar) 0x00E9 + wxT("tr") + (wxChar) 0x00E9 + wxT("e."))); + itemBoxSizer23->Add(cmbPedals, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + lblPedalCode = new wxStaticText( panePedalHardware->GetPane(), wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer23->Add(lblPedalCode, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + btnAbout = new wxButton( panePedalHardware->GetPane(), ID_BUTTON, _("A propos"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer23->Add(btnAbout, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxHORIZONTAL); + szPedalMain->Add(itemBoxSizer28, 0, wxGROW|wxALL, 5); + wxStaticText* itemStaticText29 = new wxStaticText( panePedalIDs->GetPane(), wxID_STATIC, _("Actions"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer28->Add(itemStaticText29, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxArrayString cmbPedalActionLeftStrings; + cmbPedalActionLeft = new wxComboBox( panePedalIDs->GetPane(), ID_XCOMBOBOX9, wxEmptyString, wxDefaultPosition, wxDefaultSize, cmbPedalActionLeftStrings, wxCB_READONLY ); + if (T7Main::ShowToolTips()) + cmbPedalActionLeft->SetToolTip(wxGetTranslation(wxString(wxT("P")) + (wxChar) 0x00E9 + wxT("dale de gauche"))); + itemBoxSizer28->Add(cmbPedalActionLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxArrayString cmbPedalActionMiddleStrings; + cmbPedalActionMiddle = new wxComboBox( panePedalIDs->GetPane(), ID_XCOMBOBOX7, wxEmptyString, wxDefaultPosition, wxDefaultSize, cmbPedalActionMiddleStrings, wxCB_READONLY ); + if (T7Main::ShowToolTips()) + cmbPedalActionMiddle->SetToolTip(wxGetTranslation(wxString(wxT("P")) + (wxChar) 0x00E9 + wxT("dale du milieu."))); + itemBoxSizer28->Add(cmbPedalActionMiddle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxArrayString cmbPedalActionRightStrings; + cmbPedalActionRight = new wxComboBox( panePedalIDs->GetPane(), ID_XCOMBOBOX8, wxEmptyString, wxDefaultPosition, wxDefaultSize, cmbPedalActionRightStrings, wxCB_READONLY ); + if (T7Main::ShowToolTips()) + cmbPedalActionRight->SetToolTip(wxGetTranslation(wxString(wxT("P")) + (wxChar) 0x00E9 + wxT("dale de droite."))); + itemBoxSizer28->Add(cmbPedalActionRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer33 = new wxBoxSizer(wxHORIZONTAL); + szPedalMain->Add(itemBoxSizer33, 0, wxGROW|wxALL, 5); + wxStaticText* itemStaticText34 = new wxStaticText( panePedalIDs->GetPane(), wxID_STATIC, wxGetTranslation(wxString(wxT("Revenir en arri")) + (wxChar) 0x00E8 + wxT("re ") + (wxChar) 0x00E0 + wxT(" la fin de la lecture")), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer33->Add(itemStaticText34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + txtMediaAutoRewind = new wxTextCtrl( panePedalIDs->GetPane(), ID_XTEXTCTRL7, _("1000"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT ); + txtMediaAutoRewind->SetMaxLength(6); + if (T7Main::ShowToolTips()) + txtMediaAutoRewind->SetToolTip(wxGetTranslation(wxString(wxT("En millisecondes. Appuyez sur ENTR")) + (wxChar) 0x00C9 + wxT("E pour enregistrer apr") + (wxChar) 0x00E8 + wxT("s modification."))); + itemBoxSizer33->Add(txtMediaAutoRewind, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + scrlMain->FitInside(); + +////@end T7Main content construction +} + + +/* + * Should we show tooltips? + */ + +bool T7Main::ShowToolTips() +{ + return true; +} + +/* + * Get bitmap resources + */ + +wxBitmap T7Main::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin T7Main bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end T7Main bitmap retrieval +} + +/* + * Get icon resources + */ + +wxIcon T7Main::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin T7Main icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end T7Main icon retrieval +} diff --git a/UI/t7main.h b/UI/t7main.h new file mode 100644 index 0000000..937450c --- /dev/null +++ b/UI/t7main.h @@ -0,0 +1,142 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: t7main.h +// Purpose: +// Author: SET +// Modified by: +// Created: sam. 01 mars 2014 14:23:16 CET +// RCS-ID: +// Copyright: Copyright SET (nmset@yandex.com) - © 2014. +// Licence: LGPL 2.1 +///////////////////////////////////////////////////////////////////////////// + +#ifndef _T7MAIN_H_ +#define _T7MAIN_H_ + +#define _APPNAME_T7_ wxString(_T("T7")) +#define _APPVERSION_T7_ wxString(_T("7")) + +/*! + * Includes + */ + +////@begin includes +#include "wx/frame.h" +#include "wx/mediactrl.h" +#include "wx/filepicker.h" +#include "wx/collpane.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +class wxMediaCtrl; +class wxDirPickerCtrl; +class wxCollapsiblePane; +////@end forward declarations +class wxPanel; +class wxStaticText; +class wxComboBox; +class wxSlider; +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_T7MAIN 10000 +#define ID_SCROLLEDWINDOW 10001 +#define ID_PANEL1 10049 +#define ID_MEDIACTRL 10068 +#define ID_SLIDER 10069 +#define ID_BUTTON1 10079 +#define ID_DIRPICKERCTRL1 10078 +#define ID_COLLAPSIBLEPANE6 10070 +#define ID_COLLAPSIBLEPANE7 10077 +#define ID_COMBOBOX_HW 10003 +#define ID_XCOMBOBOX6 10072 +#define ID_BUTTON 10002 +#define ID_XCOMBOBOX9 10075 +#define ID_XCOMBOBOX7 10073 +#define ID_XCOMBOBOX8 10074 +#define ID_XTEXTCTRL7 10071 +#define SYMBOL_T7MAIN_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_T7MAIN_TITLE _("T7") +#define SYMBOL_T7MAIN_IDNAME ID_T7MAIN +#define SYMBOL_T7MAIN_SIZE wxSize(500, 400) +#define SYMBOL_T7MAIN_POSITION wxDefaultPosition +////@end control identifiers + + +/*! + * T7Main class declaration + */ + +class T7Main: public wxFrame +{ + DECLARE_CLASS( T7Main ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + T7Main(); + T7Main( wxWindow* parent, wxWindowID id = SYMBOL_T7MAIN_IDNAME, const wxString& caption = SYMBOL_T7MAIN_TITLE, const wxPoint& pos = SYMBOL_T7MAIN_POSITION, const wxSize& size = SYMBOL_T7MAIN_SIZE, long style = SYMBOL_T7MAIN_STYLE ); + + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_T7MAIN_IDNAME, const wxString& caption = SYMBOL_T7MAIN_TITLE, const wxPoint& pos = SYMBOL_T7MAIN_POSITION, const wxSize& size = SYMBOL_T7MAIN_SIZE, long style = SYMBOL_T7MAIN_STYLE ); + + /// Destructor + ~T7Main(); + + /// Initialises member variables + void Init(); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin T7Main event handler declarations + +////@end T7Main event handler declarations + +////@begin T7Main member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end T7Main member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin T7Main member variables + wxScrolledWindow* scrlMain; + wxBoxSizer* szMain; + wxPanel* panPedals; + wxBoxSizer* szMediaMain; + wxBoxSizer* szMediaTop; + wxMediaCtrl* medMain; + wxSlider* sldMediaPosition; + wxBoxSizer* szMediaInfo; + wxStaticText* lblMediaCurrent; + wxStaticText* lblMediaLength; + wxButton* btnMediaRootRefresh; + wxDirPickerCtrl* dpkMediaRoot; + wxCollapsiblePane* panePedalIDs; + wxBoxSizer* szPedalMain; + wxCollapsiblePane* panePedalHardware; + wxBoxSizer* szPedalHardware; + wxComboBox* cmbHIDDevices; + wxComboBox* cmbPedals; + wxStaticText* lblPedalCode; + wxButton* btnAbout; + wxComboBox* cmbPedalActionLeft; + wxComboBox* cmbPedalActionMiddle; + wxComboBox* cmbPedalActionRight; + wxTextCtrl* txtMediaAutoRewind; +////@end T7Main member variables +}; + +#endif + // _T7MAIN_H_ diff --git a/XT7Main.cpp b/XT7Main.cpp new file mode 100644 index 0000000..42cb7ea --- /dev/null +++ b/XT7Main.cpp @@ -0,0 +1,660 @@ +/* + * File: XT7Main.cpp + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2014 + * + * Created on 1 mars 2014, 15:00 + */ + +#include "XT7Main.h" +#include +#include +#include +#include +using namespace std; + +int wxCALLBACK +CompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr WXUNUSED(sortData)) +{ + // Borrowed from wxListCtrl sample app, mostly verbatim. + if (item1 < item2) + return -1; + if (item1 > item2) + return 1; + + return 0; +} + +XT7Main::XT7Main() { +} + +XT7Main::XT7Main( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +: T7Main(parent, id, caption, pos, size, style ){ + wxConfigBase::DontCreateOnDemand(); + config = static_cast (wxConfigBase::Get(false)); + if (!config) { + config = new wxConfig(_APPNAME_T7_, _T("NMSET"), _APPNAME_T7_, wxEmptyString, wxCONFIG_USE_SUBDIR); + wxConfigBase::Set(config); + } + Init(); + configError = !ArePedalsFullyConfigured(); + if (!configError) { + ListenToPedal(); + Bind(wxEVT_IDLE, &XT7Main::OnIdle, this); + m_keyHandler = new KeyboardSimulation(pedalEVH); + } else { + MessageBox(_(L"Configuration du pédalier incomplète."), true); + } + UpdateTitle(); +} + +XT7Main::~XT7Main() { +#ifdef T7_EMBEDDED + // In case it's embedded in some other application + if (!streamError && !configError) { + if (pedMonitor && pedMonitor->GetThread()->IsRunning()) pedMonitor->GetThread()->Delete(); + if (mediaProgress && mediaProgress->GetThread()->IsRunning()) mediaProgress->GetThread()->Delete(); + if (pedCodeIdentifier && pedCodeIdentifier->GetThread()->IsRunning()) pedCodeIdentifier->GetThread()->Delete(); + } +#endif + delete m_keyHandler; +} + +void XT7Main::UpdateTitle() { + wxString title(_APPNAME_T7_ + _T(" - ")+ _APPVERSION_T7_); + if (lvMediaList->IsEmpty() || lvMediaList->GetFocusedItem() == -1) { + SetTitle(title); + return; + } + // Get the file name + wxListItem it; + it.SetId(lvMediaList->GetFocusedItem()); + it.SetColumn(2); + it.SetMask(wxLIST_MASK_TEXT); + if (lvMediaList->GetItem(it)) { + title += _T(" : ") + it.GetText(); + SetTitle(title); + } +} + +void XT7Main::MessageBox(const wxString& msg, const bool notify){ + if (!notify) { + wxMessageBox(msg, _APPNAME_T7_, wxOK, this); + } else { + wxNotificationMessage notifMsg(_APPNAME_T7_, msg, this); + notifMsg.Show(); + } +} +void XT7Main::CollapsiblePaneChanged(wxCollapsiblePaneEvent& evt) { + if (evt.GetEventObject() == panePedalIDs || evt.GetEventObject() == panePedalHardware) { + szPedalHardware->Layout(); + szPedalMain->Layout(); + szMediaInfo->Layout(); + panPedals->GetSizer()->Layout(); + } +} +void XT7Main::Init() { + pedMonitor = NULL; pedalEVH = NULL; pedCodeIdentifier = NULL; mediaProgress = NULL; + streamError = false; + if (!wxDir::Exists(wxStandardPaths::Get().GetUserDataDir())) + wxDir::Make(wxStandardPaths::Get().GetUserDataDir()); + // UI doesn't provide a direct way to insert a wxListView + lvMediaList = new wxListView(panPedals); + szMediaTop->Add(lvMediaList, 1, wxGROW|wxALL, 5); + medMain->Show(false); + // cmb = wxComboBox + HIDTool::GetHIDDevices(cmbHIDDevices, hidPaths); + wxString device = config->Read(_T("/PEDALES/Dispositif")); + cmbHIDDevices->SetSelection(cmbHIDDevices->FindString(device, true)); + cmbPedals->Append(_(L"de gauche")); + cmbPedals->Append(_(L"du milieu")); + cmbPedals->Append(_(L"de droite")); + cmbPedalActionLeft->Append(_(L"Retour rapide")); + cmbPedalActionLeft->Append(_(L"Avance rapide")); + cmbPedalActionLeft->Append(_(L"Lecture")); + cmbPedalActionMiddle->Append(_(L"Retour rapide")); + cmbPedalActionMiddle->Append(_(L"Avance rapide")); + cmbPedalActionMiddle->Append(_(L"Lecture")); + cmbPedalActionRight->Append(_(L"Retour rapide")); + cmbPedalActionRight->Append(_(L"Avance rapide")); + cmbPedalActionRight->Append(_(L"Lecture")); + // Automatic rewind on pause + // txt = wxTextCtrl + txtMediaAutoRewind->SetValidator(wxTextValidator(wxFILTER_DIGITS)); + long autoRw = 1500; + config->Read(_T("/PEDALES/DIVERS/RetourAuto"), &autoRw); + txtMediaAutoRewind->SetValue(wxVariant(autoRw).GetString()); + /* + * We provide default usual pedal actions : + * Left pedal : rewind + * Middle pedal : fast forward + * Right pedal : play + */ + long actionIndex = wxNOT_FOUND; + if (!config->Read(_T("/PEDALES/ACTIONS/Gauche"), &actionIndex) + && !config->Read(_T("/PEDALES/ACTIONS/Milieu"), &actionIndex) + && !config->Read(_T("/PEDALES/ACTIONS/Droit"), &actionIndex)) { + config->Write(_T("/PEDALES/ACTIONS/Gauche"), 0); + config->Write(_T("/PEDALES/ACTIONS/Milieu"), 1); + config->Write(_T("/PEDALES/ACTIONS/Droit"), 2); + config->Flush(); + } + actionIndex = wxNOT_FOUND; + config->Read(_T("/PEDALES/ACTIONS/Gauche"), &actionIndex); + cmbPedalActionLeft->SetSelection(actionIndex); + actionIndex = wxNOT_FOUND; + config->Read(_T("/PEDALES/ACTIONS/Milieu"), &actionIndex); + cmbPedalActionMiddle->SetSelection(actionIndex); + actionIndex = wxNOT_FOUND; + config->Read(_T("/PEDALES/ACTIONS/Droit"), &actionIndex); + cmbPedalActionRight->SetSelection(actionIndex); + // lbl = wxStaticText + lblMediaCurrent->SetLabel(wxEmptyString); + lblMediaLength->SetLabel(wxEmptyString); + // sld = wxSlider + sldMediaPosition->Bind(wxEVT_SLIDER, &XT7Main::SliderChanged, this); + lvMediaList->Bind(wxEVT_LIST_ITEM_ACTIVATED, &XT7Main::LoadMedia, this); + // dpk = wxDirPicker + dpkMediaRoot->GetTextCtrl()->SetEditable(false); + dpkMediaRoot->SetPath(config->Read(_T("/Medias/Racine"))); + dpkMediaRoot->Bind(wxEVT_DIRPICKER_CHANGED, &XT7Main::MediaRootChanged, this); + // btn = wxButton + btnMediaRootRefresh->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &XT7Main::ListMedia, this); + btnAbout->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &XT7Main::ShowAbout, this); + cmbHIDDevices->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &XT7Main::SavePedalDevice, this); + cmbPedalActionLeft->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &XT7Main::SavePedalAction, this); + cmbPedalActionMiddle->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &XT7Main::SavePedalAction, this); + cmbPedalActionRight->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &XT7Main::SavePedalAction, this); + cmbPedals->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &XT7Main::StartPedalCodeIdentification, this); + // pane = wxCollapsiblePane + panePedalIDs->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, &XT7Main::CollapsiblePaneChanged, this); + panePedalHardware->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, &XT7Main::CollapsiblePaneChanged, this); + txtMediaAutoRewind->Bind(wxEVT_COMMAND_TEXT_ENTER, &XT7Main::SavePedalAutoRewind, this); + // For display on Android handhelds where PPI may be set high for readable display + wxDouble scaleFactor = 1.0; + const wxDouble ppi = wxGetDisplayPPI().GetY(); + if (ppi > 96.0) scaleFactor = (ppi / 96.0); + SetSize((int) (600.0 * scaleFactor), (int) (450.0 * scaleFactor)); +} +bool XT7Main::ListenToPedal() { + // Create a pedal monitor and an event handler. + wxString device; + if (!config->Read(_T("/PEDALES/Dispositif"), &device)) return false; + if (!AreAllPedalsIdentified()) return false; + wxString devicePath = wxEmptyString; + if (cmbHIDDevices->GetSelection() != wxNOT_FOUND) + devicePath = hidPaths.Item(cmbHIDDevices->GetSelection()); + long leftCode, middleCode, rightCode; + config->Read(_T("/PEDALES/ID/Gauche"), &leftCode); + config->Read(_T("/PEDALES/ID/Milieu"), &middleCode); + config->Read(_T("/PEDALES/ID/Droit"), &rightCode); + long autoRewind = 1500; + config->Read(_T("/PEDALES/DIVERS/RetourAuto"), &autoRewind); + pedalEVH = new PedalEVH(this, (wxFileOffset) autoRewind); + pedMonitor = new PedalMonitor_OnOff(devicePath, pedalEVH, leftCode, middleCode, rightCode); + //pedMonitor = new PedalMonitor_Override(devicePath, pedalEVH, leftCode, middleCode, rightCode); + if (pedMonitor->GetThread()->Run() != wxTHREAD_NO_ERROR) { + delete pedalEVH; pedalEVH = NULL; + if (pedMonitor->GetThread()->IsRunning()) { + pedMonitor->GetThread()->Delete(); + pedMonitor = NULL; + } + return false; + } + return true; +} +void XT7Main::SavePedalDevice(wxCommandEvent& evt) { + if (config->Write(_T("/PEDALES/Dispositif"), cmbHIDDevices->GetValue())) { + MessageBox(_(L"Enregistré. Vous ne devriez pas jouer avec cette valeur une fois bien paramétrée."), true); + // Individual pedals must be identified again. + config->DeleteGroup(_T("/PEDALES/ID")); + config->Flush(); + //MessageBox(_T("Vous devez compléter l'identification de toutes les pédales."), true); + } else { + MessageBox(_(L"Echec de sauvegarde."), true); + } +} +void XT7Main::SavePedalAction(wxCommandEvent& evt) { + // What the user decides to do with each pedal + bool inconsistent = false; + wxComboBox * cmb = static_cast (evt.GetEventObject()); + const int actionIndex = cmb->GetSelection(); + if (cmb == cmbPedalActionLeft) { + inconsistent = (actionIndex == cmbPedalActionMiddle->GetSelection() || actionIndex == cmbPedalActionRight->GetSelection()); + } + if (cmb == cmbPedalActionMiddle) { + inconsistent = (actionIndex == cmbPedalActionLeft->GetSelection() || actionIndex == cmbPedalActionRight->GetSelection()); + } + if (cmb == cmbPedalActionRight) { + inconsistent = (actionIndex == cmbPedalActionLeft->GetSelection() || actionIndex == cmbPedalActionMiddle->GetSelection()); + } + if (inconsistent) { + MessageBox(_(L"Choix inconsistants."), true); + return; + } + config->Write(_T("/PEDALES/ACTIONS/Gauche"), cmbPedalActionLeft->GetSelection()); + config->Write(_T("/PEDALES/ACTIONS/Milieu"), cmbPedalActionMiddle->GetSelection()); + config->Write(_T("/PEDALES/ACTIONS/Droit"), cmbPedalActionRight->GetSelection()); + config->Flush(); +} +void XT7Main::SavePedalAutoRewind(wxCommandEvent& evt) { + config->Write(_T("/PEDALES/DIVERS/RetourAuto"), wxVariant(txtMediaAutoRewind->GetValue()).GetLong()); + config->Flush(); + long newAutoRewind; + config->Read(_T("/PEDALES/DIVERS/RetourAuto"), &newAutoRewind); + if (pedalEVH) pedalEVH->UpdateAutoRewind((wxFileOffset) newAutoRewind); +} +bool XT7Main::ArePedalActionsConsistent() { + // One pedal, one unique action. + const int left = cmbPedalActionLeft->GetSelection(); + const int middle = cmbPedalActionMiddle->GetSelection(); + const int right = cmbPedalActionRight->GetSelection(); + if ((left == wxNOT_FOUND) || (middle == wxNOT_FOUND) || (right == wxNOT_FOUND)) return false; + if ((left == middle) || (left == right)) return false; + if ((middle == right)) return false; + return true; +} +void XT7Main::StartPedalCodeIdentification(wxCommandEvent& evt) { + // Starts the thread that waits for a pedal to be pressed to catch the byte sent + if (streamError) return; + lblPedalCode->SetLabel(wxEmptyString); + if (!pedalEVH) pedalEVH = new PedalEVH(this); + if (!pedCodeIdentifier) { + wxString device = wxEmptyString; + config->Read(_T("/PEDALES/Dispositif"), &device); + if (device.IsEmpty()) { + MessageBox(_T("Périphérique non déclaré."), true); + return; + } + wxString devicePath = wxEmptyString; + devicePath = hidPaths.Item(cmbHIDDevices->GetSelection()); + pedCodeIdentifier = new PedalCodeIdentifier(devicePath, pedalEVH); + pedCodeIdentifier->GetThread()->Run(); + } +} +void XT7Main::UpdatePedalCode(const unsigned short code) { + /* + * Once started, process each pedal. + * We delete all known pedal codes and start all over. + * The user needs to do this only once + * or if she changes hardware + * Easier to code this way. + */ + static bool started = false; + if (!started) { + config->DeleteGroup(_T("/PEDALES/ID")); + config->Flush(); + started = true; + MessageBox(_T("Vous devez compléter l'identification de toutes les pédales."), true); + } + switch (cmbPedals->GetSelection()) { + case 0: + config->Write(_T("/PEDALES/ID/Gauche"), (long) code); + break; + case 1: + config->Write(_T("/PEDALES/ID/Milieu"), (long) code); + break; + case 2: + config->Write(_T("/PEDALES/ID/Droit"), (long) code); + break; + default: + return; + } + config->Flush(); + lblPedalCode->SetLabel(_(L"Enregistré. Vous pouvez identifier une autre pédale.")); + configError = !ArePedalsFullyConfigured(); + if (!configError) { + MessageBox(_T("Cette fenêtre va se fermer. Veuillez recommencer.")); + Close(); + } +} +bool XT7Main::AreAllPedalsIdentified() { + long left, middle, right; + return (config->Read(_T("/PEDALES/ID/Gauche"), &left) + && config->Read(_T("/PEDALES/ID/Milieu"), &middle) + && config->Read(_T("/PEDALES/ID/Droit"), &right)); +} +bool XT7Main::ArePedalsFullyConfigured() { + wxString device = wxEmptyString; + return (config->Read(_T("/PEDALES/Dispositif"), &device) && AreAllPedalsIdentified()); +} +void XT7Main::SliderChanged(wxCommandEvent& evt) { + // Manual media positioning + if (medMain) { + int pos = sldMediaPosition->GetValue(); + medMain->Seek((wxFileOffset) pos); + wxTimeSpan past(0, 0, 0, pos); + lblMediaCurrent->SetLabel(past.Format(_T("%H:%M:%S"))); + szMediaInfo->Layout(); + } +} +void XT7Main::UpdateMediaProgressPosition() { + // Called from MediaProgress::Entry() via PedalEVH using CallAfter. + if (medMain) { + sldMediaPosition->SetValue(medMain->Tell()); + wxTimeSpan past(0, 0, 0, medMain->Tell()); + lblMediaCurrent->SetLabel(past.Format(_T("%H:%M:%S"))); + } else { + // Should not happen !!! + sldMediaPosition->SetValue(0); + lblMediaCurrent->SetLabel(wxEmptyString); + lblMediaLength->SetLabel(wxEmptyString); + } + szMediaInfo->Layout(); +} +void XT7Main::UpdateMediaControlPosition(wxFileOffset position) { + // Called by PedalEVH from MediaFastMove using CallAfter. + if (medMain) { + medMain->Seek(position, wxFromCurrent); + } +} +void XT7Main::LoadMedia(wxListEvent& evt) { + /* + * N.B. : Length() is always 0 *here*, and in wxEVT_MEDIA_LOADED also. + * But may be real in OnIdle, media dependent. + * Length() may be 0 in OnIdle for some valid media. + * Media type does not seem to be a factor (mp3, mp4, avi ...). + */ + UpdateTitle(); // In case we return early. + if (lvMediaList->GetFocusedItem() == -1) return; // REALLY ? ON DOUBLE CLICK OR ENTER + // Get the file name + wxListItem it; + it.SetId(lvMediaList->GetFocusedItem()); + it.SetColumn(2); + it.SetMask(wxLIST_MASK_TEXT); + if (lvMediaList->GetItem(it)) { + wxString mediaRoot = config->Read(_T("/Medias/Racine")); + if (mediaRoot.IsEmpty()) return; + wxFileName media(mediaRoot + wxFileName::GetPathSeparator() + it.GetText()); + if (media.Exists()) { + if (pedalEVH) + pedalEVH->PauseFastMoveWorkers(); + // Manage media control + medMain->Stop(); + if (medMain->Load(media.GetFullPath())) { + UpdateTitle(); + loadedMediaPath = media.GetFullPath(); + medMain->Show(); + medMain->SetSize(medMain->GetBestSize()); + panPedals->GetSizer()->Layout(); + } else { + medMain->Hide(); + } + sldMediaPosition->SetValue(0); + wxTimeSpan zero(0); + lblMediaCurrent->SetLabel(zero.Format(_T("%H:%M:%S"))); + // Gives back positioning information + if (!mediaProgress) { + if (!configError) { + mediaProgress = new MediaProgress(pedalEVH); + mediaProgress->GetThread()->Run(); mediaProgress->GetThread()->Pause(); + } + } else { + // if LoadMedia called while an action is going on + if (mediaProgress->GetThread()->IsRunning()) + mediaProgress->GetThread()->Pause(); + } + } + } +} +void XT7Main::OnIdle(wxIdleEvent& evt) { + if (lvMediaList->GetFocusedItem() == -1) return; + + wxListItem itFileName; + itFileName.SetId(lvMediaList->GetFocusedItem()); + itFileName.SetColumn(2); + itFileName.SetMask(wxLIST_MASK_TEXT); + + if (lvMediaList->GetItem(itFileName)) { + wxString mediaRoot = config->Read(_T("/Medias/Racine")); + if (mediaRoot.IsEmpty()) return; + wxFileName media(mediaRoot + wxFileName::GetPathSeparator() + itFileName.GetText()); + if (media.GetFullPath() != loadedMediaPath) + return; + } + wxListItem itDuration; + itDuration.SetId(lvMediaList->GetFocusedItem()); + itDuration.SetColumn(1); + itDuration.SetMask(wxLIST_MASK_TEXT); + + // Manage positioning controls. Update if changed only. May avoid flickering. + if (sldMediaPosition->GetMax() != medMain->Length()) + sldMediaPosition->SetMax(medMain->Length()); + wxTimeSpan duration(0, 0, 0, medMain->Length()); + if (lblMediaLength->GetLabel() != duration.Format(_T("%H:%M:%S"))) + lblMediaLength->SetLabel(duration.Format(_T("%H:%M:%S"))); + if (lvMediaList->GetItem(itDuration)) { + if (itDuration.GetText() != lblMediaLength->GetLabel()) { + itDuration.SetText(lblMediaLength->GetLabel()); + lvMediaList->SetItem(itDuration); + } + } +} +void XT7Main::MediaRootChanged(wxFileDirPickerEvent& evt) { + // A directory where we look for media files. + config->Write(_T("/Medias/Racine"), dpkMediaRoot->GetPath()); + config->Flush(); + loadedMediaPath = wxString(); +} +void XT7Main::ListMedia(wxCommandEvent& evt) { + // We don't recurse in sub directories. + wxString mediaRoot = config->Read(_T("/Medias/Racine")); + if (mediaRoot.IsEmpty()) return; + lvMediaList->ClearAll(); + wxArrayString files; + wxDir::GetAllFiles(mediaRoot, &files, wxEmptyString, wxDIR_FILES); + lvMediaList->AppendColumn(_T("Date")); + lvMediaList->AppendColumn(_T("Durée")); + lvMediaList->AppendColumn(_T("Dictée")); + + for (int i = 0; i < files.GetCount(); i++) { + wxListItem it; + wxFileName filename(files.Item(i)); + it.SetId(i); + it.SetColumn(0); + it.SetText(filename.GetModificationTime().Format(_T("%a %d %b %Y %H:%M:%S"))); + long idx = lvMediaList->InsertItem(it); + lvMediaList->SetItemData(idx, (long) filename.GetModificationTime().GetTicks()); + + it.SetColumn(2); + it.SetText(filename.GetFullName()); + lvMediaList->SetItem(it); + } + lvMediaList->SetColumnWidth(0, wxLIST_AUTOSIZE); + lvMediaList->SetColumnWidth(2, wxLIST_AUTOSIZE); + lvMediaList->SortItems(CompareFunction, 0); + panPedals->GetSizer()->Layout(); + loadedMediaPath = wxString(); + UpdateTitle(); +} +void XT7Main::SetStreamError() { + streamError = true; + // We request application restart when stream is established again. + // We don't try to detect if the problem is resolved. Restart is cheap. + MessageBox(_(L"Erreur de communication avec le pédalier. Après avoir réglé le problème," + " veuillez redémarrer l'application." + "\n\n Au clavier : F5, F6, F7, ESC."), true); + medMain->Stop(); + UpdateMediaProgressPosition(); + if (mediaProgress && mediaProgress->GetThread()->IsRunning()) mediaProgress->GetThread()->Pause(); + if (pedalEVH) pedalEVH->ResetFastMoveWorkers(); +} +void XT7Main::ShowAbout(wxCommandEvent& evt) { + wxString msg = _APPNAME_T7_ + _T(" - ") + _APPVERSION_T7_ + _T("\n\n"); + msg += _(L"Auteur et copyright :") + _T("\n"); + msg += wxString(_T("SET, M.D.")) + _T("\n"); + msg += wxString(_T("nmset@yandex.com")) + _T("\n\n"); + msg += wxString(_(L"Sous license LGPL")); + MessageBox(msg); +} +//////////////////////////////////////////////////////////////////////////////////////// +/* + * Throughout, we want one background non-blocking worker through each + * pedal manager class. We do not want nor need concurrent multiple threads. + * MediaFastMove will have two non-concurrent threads. + * MediaFastMove threads are managed here. They never die. + * MediaProgress thread is managed by XT7Main. It never dies. + */ +PedalEVH::PedalEVH(XT7Main * parent, wxFileOffset newAutoRewindOnPause) { + m_owner = parent; + m_Rewind = NULL; + m_Forward = NULL; + m_autoRewind = newAutoRewindOnPause; +} +PedalEVH::~PedalEVH() { + ResetFastMoveWorkers(); +} +void PedalEVH::UpdateAutoRewind(wxFileOffset newAutoRewindOnPause) { + m_autoRewind = newAutoRewindOnPause; +} +void PedalEVH::ResetFastMoveWorkers() { + // They should be assigned NULL from OnFastMoveExit() + // If IsRunning() is false, Delete() crashes app. + if (m_Rewind && m_Rewind->GetThread()->IsRunning()) { + m_Rewind->GetThread()->Delete(); + } + if (m_Forward && m_Forward->GetThread()->IsRunning()) { + m_Forward->GetThread()->Delete(); + } +} +void PedalEVH::PauseFastMoveWorkers() { + if (m_Rewind && m_Rewind->GetThread()->IsRunning()) { + m_Rewind->GetThread()->Pause(); + } + if (m_Forward && m_Forward->GetThread()->IsRunning()) { + m_Forward->GetThread()->Pause(); + } +} +/* + * A given pedal fires an action as declared by the user. + */ +void PedalEVH::Left(PedalEvent::PedalStatus status) { + const int action = m_owner->cmbPedalActionLeft->GetSelection(); + switch (action) { + case 0: + Rewind(status); + break; + case 1: + FastForward(status); + break; + case 2: + Play(status); + break; + default : + m_owner->MessageBox(_(L"Action mal déclarée."), true); + } + +} +void PedalEVH::Middle(PedalEvent::PedalStatus status) { + const int action = m_owner->cmbPedalActionMiddle->GetSelection(); + switch (action) { + case 0: + Rewind(status); + break; + case 1: + FastForward(status); + break; + case 2: + Play(status); + break; + default : + m_owner->MessageBox(_(L"Action mal déclarée."), true); + } +} +void PedalEVH::Right(PedalEvent::PedalStatus status) { + const int action = m_owner->cmbPedalActionRight->GetSelection(); + switch (action) { + case 0: + Rewind(status); + break; + case 1: + FastForward(status); + break; + case 2: + Play(status); + break; + default : + m_owner->MessageBox(_(L"Action mal déclarée."), true); + } +} +void PedalEVH::Rewind(PedalEvent::PedalStatus status) { + if (status == PedalEvent::PRESSED) { + if (!m_Rewind) { + m_Rewind = new MediaFastMove(m_owner->medMain, -100, 10, this); + m_Rewind->GetThread()->Run(); + } + if (m_Rewind->GetThread()->IsPaused()) m_Rewind->GetThread()->Resume(); + // UI can update media position. + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsPaused()) m_owner->mediaProgress->GetThread()->Resume(); + } + if (status == PedalEvent::RELEASED) { + if (m_Rewind && m_Rewind->GetThread()->IsRunning()) m_Rewind->GetThread()->Pause(); + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsRunning()) m_owner->mediaProgress->GetThread()->Pause(); + } +} +void PedalEVH::FastForward(PedalEvent::PedalStatus status) { + if (status == PedalEvent::PRESSED) { + if (!m_Forward) { + m_Forward = new MediaFastMove(m_owner->medMain, 100, 10, this); + m_Forward->GetThread()->Run(); + } + if (m_Forward->GetThread()->IsPaused()) m_Forward->GetThread()->Resume(); + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsPaused()) m_owner->mediaProgress->GetThread()->Resume(); + } + if (status == PedalEvent::RELEASED) { + if (m_Forward && m_Forward->GetThread()->IsRunning()) m_Forward->GetThread()->Pause(); + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsRunning()) m_owner->mediaProgress->GetThread()->Pause(); + } +} +void PedalEVH::Play(PedalEvent::PedalStatus status) { + // Not done through a thread. + if (status == PedalEvent::PRESSED) { + m_owner->medMain->Play(); + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsPaused()) m_owner->mediaProgress->GetThread()->Resume(); + } + if (status == PedalEvent::RELEASED) { + m_owner->medMain->Pause(); + if (m_owner->mediaProgress && m_owner->mediaProgress->GetThread()->IsRunning()) m_owner->mediaProgress->GetThread()->Pause(); + wxFileOffset pos = m_owner->medMain->Tell(); + // Transcriptionists need that automatic rewind feature on pause. + if (pos > m_autoRewind) { + m_owner->medMain->Seek((m_autoRewind * -1), wxFromCurrent); + OnMediaProgressPosition(); + } + } +} +// From PedalCodeIdentifier +void PedalEVH::OnPedalCaught(const unsigned short code) { + if (!code) return; + XT7Main * xapp = static_cast (m_owner); + xapp->CallAfter(&XT7Main::UpdatePedalCode, code); +} +void PedalEVH::OnCodeIdentifierExit(PedalCodeIdentifier* active) { + m_owner->pedCodeIdentifier = NULL; +} +void PedalEVH::OnMediaProgressExit(MediaProgress* active) { + m_owner->mediaProgress = NULL; +} +void PedalEVH::OnMediaProgressPosition() { + XT7Main * xapp = static_cast (m_owner); + xapp->CallAfter(&XT7Main::UpdateMediaProgressPosition); +} +void PedalEVH::OnMediaControlPosition(wxFileOffset position) { + XT7Main * xapp = static_cast (m_owner); + xapp->CallAfter(&XT7Main::UpdateMediaControlPosition, position); +} +void PedalEVH::OnStreamError() { + m_owner->SetStreamError(); +} +void PedalEVH::OnPedalMonitorExit() { + m_owner->pedMonitor = NULL; +} +void PedalEVH::OnFastMoveExit(MediaFastMove * active) { + if (active == m_Forward) { + m_Forward = NULL; + } + if (active == m_Rewind) { + m_Rewind = NULL; + } +} diff --git a/XT7Main.h b/XT7Main.h new file mode 100644 index 0000000..e7a16d9 --- /dev/null +++ b/XT7Main.h @@ -0,0 +1,101 @@ +/* + * File: XT7Main.h + * Author: SET - nmset@yandex.com + * Licence : LGPL 2.1 + * Copyright SET, M.D. - © 2014 + * + * Created on 1 mars 2014, 15:00 + */ + +#ifndef XT7MAIN_H +#define XT7MAIN_H + +#include "UI/t7main.h" +#include "PedalManager.h" +#include "KeyboardSimulation.h" +#include +#include +#include + +class PedalEVH; +class KeyboardSimulation; + +class XT7Main : public T7Main { +public: + friend class PedalEVH; + XT7Main(); + XT7Main( wxWindow* parent, wxWindowID id = SYMBOL_T7MAIN_IDNAME, const wxString& caption = SYMBOL_T7MAIN_TITLE, const wxPoint& pos = SYMBOL_T7MAIN_POSITION, const wxSize& size = SYMBOL_T7MAIN_SIZE, long style = SYMBOL_T7MAIN_STYLE ); + virtual ~XT7Main(); +private: + wxConfig * config; + IPedalMonitor * pedMonitor; + PedalEVH * pedalEVH; + PedalCodeIdentifier * pedCodeIdentifier; + MediaProgress * mediaProgress; + wxListView * lvMediaList; + KeyboardSimulation * m_keyHandler; + bool streamError; + bool configError; + wxArrayString hidPaths; + wxString loadedMediaPath; + + void CollapsiblePaneChanged(wxCollapsiblePaneEvent& evt); + void UpdateTitle(); + void MessageBox(const wxString& msg, const bool notify = false); + bool ListenToPedal(); + void Init(); + void SavePedalDevice(wxCommandEvent& evt); + void SavePedalAction(wxCommandEvent& evt); + void SavePedalAutoRewind(wxCommandEvent& evt); + bool ArePedalActionsConsistent(); + void StartPedalCodeIdentification(wxCommandEvent& evt); + void UpdatePedalCode(const unsigned short code); + bool AreAllPedalsIdentified(); + bool ArePedalsFullyConfigured(); + void SliderChanged(wxCommandEvent& evt); // OTHER EVENTS ARE wxScrollEvent + void UpdateMediaProgressPosition(); + void UpdateMediaControlPosition(wxFileOffset position); + void LoadMedia(wxListEvent& evt); + void MediaRootChanged(wxFileDirPickerEvent& evt); + void ListMedia(wxCommandEvent& evt); + void SetStreamError(); + void ShowAbout(wxCommandEvent& evt); + void OnIdle(wxIdleEvent& evt); +}; + +/////////////////////////////////////////////////////////////////////////////////////// +/* + * Event handler of PedalEvent class. + */ +class PedalEVH : public PedalEvent { +public: + friend class KeyboardSimulation; + PedalEVH(XT7Main * parent, wxFileOffset newAutoRewindOnPause = 1000); + virtual ~PedalEVH(); + void UpdateAutoRewind(wxFileOffset newAutoRewindOnPause); + void ResetFastMoveWorkers(); + void PauseFastMoveWorkers(); +private: + XT7Main * m_owner; + MediaFastMove * m_Forward; + MediaFastMove * m_Rewind; + wxFileOffset m_autoRewind; + + void Left(PedalEvent::PedalStatus status); + void Middle(PedalEvent::PedalStatus status); + void Right(PedalEvent::PedalStatus status); + void OnPedalMonitorExit(); + void OnFastMoveExit(MediaFastMove * active); + void Rewind(PedalEvent::PedalStatus status); + void FastForward(PedalEvent::PedalStatus status); + void Play(PedalEvent::PedalStatus status); + void OnPedalCaught(const unsigned short code); + void OnCodeIdentifierExit(PedalCodeIdentifier * active); + void OnMediaProgressExit(MediaProgress * active); + void OnMediaProgressPosition(); + void OnMediaControlPosition(wxFileOffset position); + void OnStreamError(); +}; + +#endif /* XT7MAIN_H */ + diff --git a/gpl-2.0.txt b/gpl-2.0.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/gpl-2.0.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/lgpl-2.1.txt b/lgpl-2.1.txt new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/lgpl-2.1.txt @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it!