16 { 0x1b1c, 0x1b17,
"corsair k65 rgb" },
17 { 0x1b1c, 0x1b13,
"corsair k70 rgb" },
18 { 0x1b1c, 0x1b11,
"corsair k95 rgb" },
19 { 0x1b1c, 0x1b15,
"corsair strafe monochrome" },
20 { 0x1b1c, 0x1b20,
"corsair strafe rgb" },
22 { 0x1b1c, 0x1b12,
"corsair m65 rgb" },
23 { 0x1b1c, 0x1b1e,
"corsair scimitar rgb" },
25 { 0x1b1c, 0x1b32,
"corsair sabre optical rgb" }
34 blob(fwBlob), kb(device), evLoop(0), exitSuccess(true)
38 ui->
newLabel->setText(QString::number(newV,
'f', 2));
41 connect(device, SIGNAL(destroyed()),
this, SLOT(
removeDev()));
60 QDir tmp = QDir::temp();
61 qint64 pid = QCoreApplication::applicationPid();
62 QString path = tmp.absoluteFilePath(QString(
"ckb-%1-fwblob.bin").arg(pid));
64 if(!output.open(QIODevice::WriteOnly)){
67 if(!output.write(
blob)){
85 static float verifyFw(
const QByteArray& blob,
const QString& features){
86 if(blob.length() < 0x0108)
88 const char* bData = blob.data();
91 for(uint i = 0; i <
sizeof(
ids)/
sizeof(
KbId); i++){
92 if(!memcmp(&ids[i].vendor, bData + 0x102, 2) && !memcmp(&ids[i].product, bData + 0x104, 2)
93 && features.startsWith(ids[i].feature, Qt::CaseInsensitive)){
102 memcpy(&version, bData + 0x106, 2);
104 return QString::number(version, 16).toFloat() / 100.f;
113 QMessageBox::warning(parentWidget(),
"Error",
"<center>Not a valid firmware for this device.</center>");
114 return QDialog::Rejected;
116 ui->
newLabel->setText(QString::number(newV,
'f', 2));
129 QMessageBox::warning(parentWidget(),
"Error",
"<center>There was a problem with the downloaded file.<br />Please try again later.</center>");
130 return QDialog::Rejected;
136 QMessageBox::warning(parentWidget(),
"Error",
"<center>Unable to save temporary file.</center>");
137 return QDialog::Rejected;
143 ui->
statusLabel->setText(
"Ready to install new firmware.<br /><br /><b>Disclaimer:</b> ckb is not endorsed by Corsair. This is <i>unlikely</i> to brick your device, but I accept no responsibility if it does. If you're paranoid, update from Windows.");
149 evLoop =
new QEventLoop(
this);
153 return exitSuccess ? QDialog::Accepted : QDialog::Rejected;
164 if(current > 0 && total > 0){
182 QTimer::singleShot(10000,
evLoop, SLOT(quit()));
void fwUpdateFinished(bool succeeded)
QPushButton * cancelButton
static QByteArray dataForBoard(const QString &features)
void on_cancelButton_clicked()
static const int DIALOG_HEIGHT_MAX(240)
QPushButton * actionButton
void closeEvent(QCloseEvent *event)
void fwUpdate(const QString &path)
const QString & saveBlob()
void on_actionButton_clicked()
QProgressBar * progressBar
void fwUpdateProgress(int current, int total)
static const int DIALOG_WIDTH
static float verifyFw(const QByteArray &blob, const QString &features)
static const int DIALOG_HEIGHT_MIN
void setupUi(QDialog *FwUpgradeDialog)
FwUpgradeDialog(QWidget *parent, float newV, const QByteArray &fwBlob, Kb *device)