ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fwupgradedialog.cpp File Reference
#include <QDir>
#include <QMessageBox>
#include "fwupgradedialog.h"
#include "kbfirmware.h"
#include "ui_fwupgradedialog.h"
+ Include dependency graph for fwupgradedialog.cpp:

Go to the source code of this file.

Data Structures

struct  KbId
 

Functions

static const int DIALOG_HEIGHT_MAX (240)
 
static float verifyFw (const QByteArray &blob, const QString &features)
 

Variables

static KbId ids []
 
static const int DIALOG_WIDTH = 420
 
static const int DIALOG_HEIGHT_MIN = 200
 

Data Structure Documentation

struct KbId

Definition at line 8 of file fwupgradedialog.cpp.

+ Collaboration diagram for KbId:
Data Fields
const char * feature
short product
short vendor

Function Documentation

static const int DIALOG_HEIGHT_MAX ( 240  )
static

Referenced by FwUpgradeDialog::exec().

+ Here is the caller graph for this function:

static float verifyFw ( const QByteArray &  blob,
const QString &  features 
)
static

Definition at line 86 of file fwupgradedialog.cpp.

References ids.

Referenced by FwUpgradeDialog::exec().

86  {
87  if(blob.length() < 0x0108)
88  return 0.f;
89  const char* bData = blob.data();
90  // Make sure it matches this device based on the vendor and product IDs embedded in the blob
91  bool match = false;
92  for(uint i = 0; i < sizeof(ids)/sizeof(KbId); i++){
93  if(!memcmp(&ids[i].vendor, bData + 0x102, 2) && !memcmp(&ids[i].product, bData + 0x104, 2)
94  && features.startsWith(ids[i].feature, Qt::CaseInsensitive)){
95  match = true;
96  break;
97  }
98  }
99  if(!match)
100  return 0.f;
101  // Copy the version from the blob
102  short version;
103  memcpy(&version, bData + 0x106, 2);
104  // Un-hexify it
105  return QString::number(version, 16).toFloat() / 100.f;
106 }
static KbId ids[]

+ Here is the caller graph for this function:

Variable Documentation

const int DIALOG_HEIGHT_MIN = 200
static
const int DIALOG_WIDTH = 420
static
KbId ids[]
static
Initial value:
= {
{ 0x1b1c, 0x1b17, "corsair k65 rgb" },
{ 0x1b1c, 0x1b3f, "corsair k68" },
{ 0x1b1c, 0x1b13, "corsair k70 rgb" },
{ 0x1b1c, 0x1b11, "corsair k95 rgb" },
{ 0x1b1c, 0x1b15, "corsair strafe monochrome" },
{ 0x1b1c, 0x1b20, "corsair strafe rgb" },
{ 0x1b1c, 0x1b12, "corsair m65 rgb" },
{ 0x1b1c, 0x1b1e, "corsair scimitar rgb" },
{ 0x1b1c, 0x1b32, "corsair sabre optical rgb" }
}

Definition at line 14 of file fwupgradedialog.cpp.

Referenced by verifyFw().