void EPlaybackWing::parseData(const QByteArray& data) { /* Check if page buttons were pressed and act accordingly */ applyExtraButtons(data); /* Check that we can get all buttons from the packet */ int size = EWING_PLAYBACK_BYTE_BUTTON + EWING_PLAYBACK_BUTTON_SIZE; if (data.size() < size) { qWarning() << Q_FUNC_INFO << "Expected at least" << size << "bytes for buttons but got only" << data.size(); return; } /* Read the state of each button */ for (int byte = size - 1; byte >= EWING_PLAYBACK_BYTE_BUTTON; byte--) { /* Each byte has 8 button values as binary bits */ for (int bit = 7; bit >= 0; bit--) { char value; /* Calculate the key number, which is 10-49, since sliders are mapped to 0-9. */ int key = (size - byte - 1) * 8; key += bit; /* 0 = button down, 1 = button up */ if ((data[byte] & (1 << bit)) == 0) value = UCHAR_MAX; else value = 0; /* Get the correct channel number for each key. */ setCacheValue(m_channelMap[key], value); } } /* Check that we can get all sliders from the packet */ size = EWING_PLAYBACK_BYTE_SLIDER + EWING_PLAYBACK_SLIDER_SIZE; Q_ASSERT(data.size() >= size); /* Read the state of each slider. Each value takes all 8 bits. */ for (int slider = 0; slider < EWING_PLAYBACK_SLIDER_SIZE; slider++) { char value = data[EWING_PLAYBACK_BYTE_SLIDER + slider]; /* Slider channels start from zero */ setCacheValue(slider, value); } }
const QVariant &Settings::localValue(const QString &key, const QVariant &def) { QString normKey = normalizedKey(group, key); if(!isCached(normKey)) { create_qsettings; setCacheValue(normKey, s.value(normKey, def)); } return cacheValue(normKey); }
void Settings::setLocalValue(const QString &key, const QVariant &data) { QString normKey = normalizedKey(group, key); create_qsettings; s.setValue(normKey, data); setCacheValue(normKey, data); if(hasNotifier(normKey)) { emit notifier(normKey)->valueChanged(data); } }
QVariant Settings::localValue(const QString& key, const QVariant& def) const { QString normKey = normalizedKey(_group, key); if (!isCached(normKey)) { create_qsettings; // Since we're loading from settings anyways, cache whether or not the key exists on disk setCacheKeyPersisted(normKey, s.contains(normKey)); // Cache key value setCacheValue(normKey, s.value(normKey, def)); } if (cacheKeyPersisted(normKey)) { return cacheValue(normKey); } // Don't return possibly wrong cached values // A key gets cached with the first default value requested and never changes afterwards return def; }
void ShortcutWing::parseData(const QByteArray& data) { /* Check if page buttons were pressed and act accordingly */ applyPageButtons(data); /* Check that we can get all channels from the packet */ int size = WING_SHORTCUT_BYTE_BUTTON + WING_SHORTCUT_BUTTON_SIZE; if (data.size() < size) { qWarning() << Q_FUNC_INFO << "Expected at least" << size << "bytes for buttons but got only" << data.size(); return; } /* Read the state of each button */ for (int byte = size - 1; byte >= WING_SHORTCUT_BYTE_BUTTON; byte--) { /* Each byte has 8 button values as binary bits */ for (int bit = 7; bit >= 0; bit--) { int key; uchar value; key = (size - byte - 1) * 8; key += (7 - bit); /* There's only 60 channels in a Shortcut Wing, but the data packet contains 64 values. So don't read the extra 4 bits. */ if (key > 59) break; /* 0 = button down, 1 = button up */ if ((data[byte] & (1 << bit)) == 0) value = UCHAR_MAX; else value = 0; setCacheValue(key, value); } } }
void EShortcutWing::parseData(const QByteArray& data) { char value; int size; /* Check that we can get all channels from the packet */ size = EWING_SHORTCUT_BYTE_BUTTON + EWING_SHORTCUT_BUTTON_SIZE; Q_ASSERT(data.size() >= size); /* Read the state of each button */ for (int byte = size - 1; byte >= EWING_SHORTCUT_BYTE_BUTTON; byte--) { /* Each byte has 8 button values as binary bits */ for (int bit = 7; bit >= 0; bit--) { int key; key = (size - byte - 1) * 8; key += (7 - bit); /* There's only 60 channels in a Shortcut Wing, but the data packet contains 64 values. So don't read the extra 4 bits. */ if (key > 59) break; /* 0 = button down, 1 = button up */ if ((data[byte] & (1 << bit)) == 0) value = 255; else value = 0; setCacheValue(key, value); } } }