Skip to content

Commit

Permalink
Revert "Several Issues Using QZ with Rouvy and Zwift Play Controllers…
Browse files Browse the repository at this point in the history
… (Issue #2541)"

This reverts commit f6f9a95.
  • Loading branch information
cagnulein committed Dec 21, 2024
1 parent ca5fb75 commit fb390b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4187,7 +4187,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = "ADB_HOST=1";
Expand Down Expand Up @@ -4381,7 +4381,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -4611,7 +4611,7 @@
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -4707,7 +4707,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
Expand Down Expand Up @@ -4799,7 +4799,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -4913,7 +4913,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 977;
CURRENT_PROJECT_VERSION = 976;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
Expand Down
30 changes: 2 additions & 28 deletions src/zwift_play/abstractZapDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ class AbstractZapDevice: public QObject {
QByteArray REQUEST_START;
QByteArray RESPONSE_START;

AbstractZapDevice() : autoRepeatTimer(new QTimer(this)), watchdogTimer(new QTimer(this)) {
AbstractZapDevice() : autoRepeatTimer(new QTimer(this)) {
RIDE_ON = QByteArray::fromRawData("\x52\x69\x64\x65\x4F\x6E", 6); // "RideOn"
REQUEST_START = QByteArray::fromRawData("\x00\x09", 2); // {0, 9}
RESPONSE_START = QByteArray::fromRawData("\x01\x03", 2); // {1, 3}

// Setup auto-repeat
autoRepeatTimer->setInterval(500);
connect(autoRepeatTimer, &QTimer::timeout, this, &AbstractZapDevice::handleAutoRepeat);

// Setup watchdog timer
watchdogTimer->setInterval(400); // 400ms timeout, shorter than auto-repeat
connect(watchdogTimer, &QTimer::timeout, this, &AbstractZapDevice::handleWatchdogTimeout);
}

int processCharacteristic(const QString& characteristicName, const QByteArray& bytes, ZWIFT_PLAY_TYPE zapType) {
Expand Down Expand Up @@ -72,10 +68,6 @@ class AbstractZapDevice: public QObject {
#else
switch(bytes[0]) {
case 0x37:
if (autoRepeatTimer->isActive()) {
watchdogTimer->start();
}

if(bytes.length() == 5) {
if(bytes[2] == 0) {
if(DEBOUNCE) {
Expand Down Expand Up @@ -109,18 +101,12 @@ class AbstractZapDevice: public QObject {
risingEdge--;
if(risingEdge < 0)
risingEdge = 0;
if(risingEdge == 0) {
if(risingEdge == 0)
autoRepeatTimer->stop();
watchdogTimer->stop();
}
}
}
break;
case 0x07: // zwift play
if (autoRepeatTimer->isActive()) {
watchdogTimer->start();
}

if(bytes.length() > 5 && bytes[bytes.length() - 5] == 0x40 && (
(((uint8_t)bytes[bytes.length() - 4]) == 0xc7 && zapType == RIGHT) ||
(((uint8_t)bytes[bytes.length() - 4]) == 0xc8 && zapType == LEFT)
Expand Down Expand Up @@ -196,10 +182,6 @@ class AbstractZapDevice: public QObject {
qDebug() << "ignoring this frame";
return 1;
case 0x23: // zwift ride
if (autoRepeatTimer->isActive()) {
watchdogTimer->start();
}

if(bytes.length() > 12 &&
((((uint8_t)bytes[12]) == 0xc7 && zapType == RIGHT) ||
(((uint8_t)bytes[12]) == 0xc8 && zapType == LEFT))
Expand Down Expand Up @@ -337,7 +319,6 @@ class AbstractZapDevice: public QObject {
QByteArray devicePublicKeyBytes;
static volatile int8_t risingEdge;
QTimer* autoRepeatTimer; // Timer for auto-repeat
QTimer* watchdogTimer; // Watchdog timer to detect frame absence
bool lastButtonPlus = false; // Track which button was last pressed

private slots:
Expand All @@ -348,13 +329,6 @@ class AbstractZapDevice: public QObject {
emit minus();
}

void handleWatchdogTimeout() {
// No frames received for too long, stop auto-repeat
watchdogTimer->stop();
autoRepeatTimer->stop();
risingEdge = 0;
}

signals:
void plus();
void minus();
Expand Down

0 comments on commit fb390b3

Please sign in to comment.