ckb-next  beta-v0.2.8 at branch testing
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KbPerf Class Reference

#include <src/ckb/kbperf.h>

+ Inheritance diagram for KbPerf:
+ Collaboration diagram for KbPerf:

Public Types

enum  height {
  LOW = 1, LOWMED, MEDIUM, MEDHIGH,
  HIGH
}
 
enum  indicator {
  NUM, CAPS, SCROLL, HW_IMAX = SCROLL,
  MODE, MACRO, LIGHT, LOCK,
  MUTE
}
 
enum  i_hw { NONE = -1, NORMAL, ON, OFF }
 

Signals

void didLoad ()
 
void settingsUpdated ()
 

Public Member Functions

 KbPerf (KbMode *parent)
 
 KbPerf (KbMode *parent, const KbPerf &other)
 
const KbPerfoperator= (const KbPerf &rhs)
 
void load (CkbSettings &settings)
 
void save (CkbSettings &settings)
 
bool needsSave () const
 
height liftHeight () const
 
void liftHeight (height newHeight)
 
bool angleSnap () const
 
void angleSnap (bool newAngleSnap)
 
QPoint dpi (int index) const
 
void dpi (int index, const QPoint &newValue)
 
QPoint sniperDpi () const
 
void sniperDpi (const QPoint &newValue)
 
void dpi (int index, int newValue)
 
void sniperDpi (int newValue)
 
QPoint curDpi () const
 
void curDpi (const QPoint &newDpi)
 
void curDpi (int newDpi)
 
int curDpiIdx () const
 
void curDpiIdx (int newIdx)
 
void dpiUp ()
 
void dpiDown ()
 
bool dpiEnabled (int index) const
 
void dpiEnabled (int index, bool newEnabled)
 
quint64 pushDpi (const QPoint &newDpi)
 
quint64 pushDpi (int newDpi)
 
quint64 pushSniper ()
 
void popDpi (quint64 pushIdx)
 
float iOpacity () const
 
void iOpacity (float newIOpacity)
 
bool dpiIndicator () const
 
void dpiIndicator (bool newDpiIndicator)
 
QColor dpiColor (int index) const
 
void dpiColor (int index, const QColor &newColor)
 
void getIndicator (indicator index, QColor &color1, QColor &color2, QColor &color3, bool &software_enable, i_hw &hardware_enable)
 
void setIndicator (indicator index, const QColor &color1, const QColor &color2, const QColor &color3=QColor(), bool software_enable=true, i_hw hardware_enable=NORMAL)
 
void update (QFile &cmd, int notifyNumber, bool force=false, bool saveCustomDpi=true)
 
void setNeedsUpdate ()
 
void applyIndicators (int modeIndex, const bool indicatorState[HW_I_COUNT])
 

Static Public Attributes

static const int DPI_COUNT = 6
 
static const int SNIPER = 0
 
static const int DPI_MIN = 100
 
static const int DPI_MAX = 12000
 
static const int OTHER = DPI_COUNT
 
static const int I_COUNT = (int)MUTE + 1
 
static const int HW_I_COUNT = (int)HW_IMAX + 1
 

Private Member Functions

KbModemodeParent () const
 
KbBindbind () const
 
KbLightlight () const
 
void lightIndicator (const char *name, QRgb rgba)
 
void _curDpi (const QPoint &newDpi)
 

Private Attributes

int dpiX [DPI_COUNT]
 
int dpiY [DPI_COUNT]
 
int dpiCurX
 
int dpiCurY
 
int dpiCurIdx
 
QColor dpiClr [DPI_COUNT+1]
 
bool dpiOn [DPI_COUNT]
 
int dpiLastIdx
 
QMap< quint64, QPoint > pushedDpis
 
uint runningPushIdx
 
float _iOpacity
 
QColor iColor [I_COUNT][2]
 
QColor light100Color
 
QColor muteNAColor
 
bool iEnable [I_COUNT]
 
i_hw hwIType [HW_I_COUNT]
 
bool _dpiIndicator
 
height _liftHeight
 
bool _angleSnap
 
bool _needsUpdate
 
bool _needsSave
 

Detailed Description

Definition at line 15 of file kbperf.h.

Member Enumeration Documentation

Enumerator
LOW 
LOWMED 
MEDIUM 
MEDHIGH 
HIGH 

Definition at line 31 of file kbperf.h.

31  {
32  LOW = 1,
33  LOWMED,
34  MEDIUM,
35  MEDHIGH,
36  HIGH
37  };
Enumerator
NONE 
NORMAL 
ON 
OFF 

Definition at line 98 of file kbperf.h.

98  {
99  NONE = -1, // For non-hardware indicators
100  NORMAL,
101  ON,
102  OFF
103  };
Enumerator
NUM 
CAPS 
SCROLL 
HW_IMAX 
MODE 
MACRO 
LIGHT 
LOCK 
MUTE 

Definition at line 85 of file kbperf.h.

85  {
86  // Hardware
87  NUM,
88  CAPS,
90  // Software
91  MODE,
92  MACRO,
93  LIGHT,
94  LOCK,
95  MUTE
96  };

Constructor & Destructor Documentation

KbPerf::KbPerf ( KbMode parent)
explicit

Definition at line 13 of file kbperf.cpp.

References CAPS, DPI_COUNT, dpiClr, dpiCurIdx, dpiCurX, dpiCurY, dpiLastIdx, dpiOn, dpiX, dpiY, HW_I_COUNT, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, LOCK, MACRO, MODE, MUTE, muteNAColor, NORMAL, NUM, and SCROLL.

13  :
14  QObject(parent), runningPushIdx(1),
15  _iOpacity(1.f), _dpiIndicator(true), _liftHeight(MEDIUM), _angleSnap(false),
16  _needsUpdate(true), _needsSave(true) {
17  // Default DPI settings
18  dpiX[0] = dpiY[0] = 400;
19  dpiX[1] = dpiY[1] = 450;
20  dpiX[2] = dpiY[2] = 800;
21  dpiX[3] = dpiY[3] = 1500;
22  dpiX[4] = dpiY[4] = 3000;
23  dpiX[5] = dpiY[5] = 6000;
24  dpiClr[0] = QColor(255, 0, 0);
25  dpiClr[1] = QColor(255, 192, 0);
26  dpiClr[2] = QColor(255, 255, 0);
27  dpiClr[3] = QColor(0, 255, 0);
28  dpiClr[4] = QColor(0, 255, 255);
29  dpiClr[5] = QColor(255, 255, 255);
30  dpiClr[6] = QColor(192, 192, 192);
31  for(int i = 0; i < DPI_COUNT; i++)
32  dpiOn[i] = true;
33  dpiLastIdx = dpiCurIdx = 3;
36  // Default indicators
37  iColor[NUM][0] = iColor[CAPS][0] = iColor[SCROLL][0] = QColor(0, 255, 0); // Lock lights: on = green, off = black
38  iColor[NUM][1] = iColor[CAPS][1] = iColor[SCROLL][1] = QColor(0, 0, 0);
39  iColor[MACRO][0] = QColor(255, 0, 0); // Macro: on = red, off = black
40  iColor[LOCK][0] = QColor(255, 255, 255); // Win lock: on = white, off = black
41  iColor[MODE][0] = iColor[MUTE][0] = QColor(255, 255, 255, 0); // Mode, mute: on = transparent, off = black
42  iColor[MODE][1] = iColor[MACRO][1] = iColor[LOCK][1] = iColor[MUTE][1] = muteNAColor = QColor(0, 0, 0);
43  iColor[LIGHT][0] = QColor(255, 0, 0); // Brightness: red, yellow, white
44  iColor[LIGHT][1] = QColor(255, 255, 0);
45  light100Color = QColor(255, 255, 255);
46  for(int i = 0; i < HW_I_COUNT; i++){
47  // Set all lock lights to HW mode
48  iEnable[i] = false;
49  hwIType[i] = NORMAL;
50  }
51  for(int i = HW_I_COUNT; i < I_COUNT; i++){
52  // Turn all other indicators on
53  iEnable[i] = true;
54  }
55 }
static const int HW_I_COUNT
Definition: kbperf.h:104
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
QColor light100Color
Definition: kbperf.h:151
uint runningPushIdx
Definition: kbperf.h:143
bool iEnable[I_COUNT]
Definition: kbperf.h:152
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
float _iOpacity
Definition: kbperf.h:149
height _liftHeight
Definition: kbperf.h:157
int dpiLastIdx
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:151
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
int dpiCurIdx
Definition: kbperf.h:134
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
bool _dpiIndicator
Definition: kbperf.h:154
static const int I_COUNT
Definition: kbperf.h:104
KbPerf::KbPerf ( KbMode parent,
const KbPerf other 
)

Definition at line 57 of file kbperf.cpp.

References curDpi(), DPI_COUNT, dpiClr, dpiOn, dpiX, dpiY, hwIType, I_COUNT, iColor, iEnable, and pushedDpis.

57  :
58  QObject(parent), dpiCurX(other.dpiCurX), dpiCurY(other.dpiCurY), dpiCurIdx(other.dpiCurIdx), dpiLastIdx(other.dpiLastIdx), runningPushIdx(1),
61  _needsUpdate(true), _needsSave(true) {
62  memcpy(dpiX, other.dpiX, sizeof(dpiX));
63  memcpy(dpiY, other.dpiY, sizeof(dpiY));
64  for(int i = 0; i < DPI_COUNT + 1; i++)
65  dpiClr[i] = other.dpiClr[i];
66  memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
67  for(int i = 0; i < I_COUNT; i++){
68  iColor[i][0] = other.iColor[i][0];
69  iColor[i][1] = other.iColor[i][1];
70  }
71  memcpy(iEnable, other.iEnable, sizeof(iEnable));
72  memcpy(hwIType, other.hwIType, sizeof(hwIType));
73  // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
74  if(!other.pushedDpis.isEmpty())
75  curDpi(other.pushedDpis[0]);
76 }
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
QColor light100Color
Definition: kbperf.h:151
uint runningPushIdx
Definition: kbperf.h:143
bool iEnable[I_COUNT]
Definition: kbperf.h:152
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
float _iOpacity
Definition: kbperf.h:149
height _liftHeight
Definition: kbperf.h:157
int dpiLastIdx
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:151
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
QPoint curDpi() const
Definition: kbperf.h:57
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
int dpiCurIdx
Definition: kbperf.h:134
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
bool _dpiIndicator
Definition: kbperf.h:154
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the call graph for this function:

Member Function Documentation

void KbPerf::_curDpi ( const QPoint &  newDpi)
private

Definition at line 262 of file kbperf.cpp.

References _needsSave, _needsUpdate, DPI_COUNT, dpiCurIdx, dpiCurX, dpiCurY, dpiLastIdx, dpiX, and dpiY.

Referenced by curDpi(), popDpi(), and pushDpi().

262  {
263  dpiCurX = newDpi.x();
264  dpiCurY = newDpi.y();
265  // Set current/last index
266  dpiCurIdx = -1;
267  for(int i = 0; i < DPI_COUNT; i++){
268  if(dpiCurX == dpiX[i] && dpiCurY == dpiY[i]){
269  dpiCurIdx = i;
270  if(i != 0)
271  dpiLastIdx = i;
272  break;
273  }
274  }
275  _needsUpdate = _needsSave = true;
276 }
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
int dpiLastIdx
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
int dpiCurIdx
Definition: kbperf.h:134
int dpiX[DPI_COUNT]
Definition: kbperf.h:132

+ Here is the caller graph for this function:

bool KbPerf::angleSnap ( ) const
inline

Definition at line 42 of file kbperf.h.

References _angleSnap.

Referenced by MPerfWidget::on_aSnapBox_clicked(), Kb::readNotify(), and MPerfWidget::setPerf().

42 { return _angleSnap; }
bool _angleSnap
Definition: kbperf.h:158

+ Here is the caller graph for this function:

void KbPerf::angleSnap ( bool  newAngleSnap)

Definition at line 368 of file kbperf.cpp.

References _angleSnap, _needsSave, and _needsUpdate.

368  {
369  _angleSnap = newAngleSnap;
370  _needsUpdate = _needsSave = true;
371 }
bool _needsUpdate
Definition: kbperf.h:160
bool _needsSave
Definition: kbperf.h:160
bool _angleSnap
Definition: kbperf.h:158
void KbPerf::applyIndicators ( int  modeIndex,
const bool  indicatorState[HW_I_COUNT] 
)

Definition at line 432 of file kbperf.cpp.

References _dpiIndicator, _iOpacity, bind(), CAPS, curDpiIdx(), dpiClr, getMuteState(), Kb::HWMODE_MAX, iColor, iEnable, LIGHT, light(), light100Color, lightIndicator(), LOCK, MACRO, MODE, MUTE, MUTED, muteNAColor, NUM, OTHER, KbLight::resetIndicators(), SCROLL, and UNMUTED.

Referenced by Kb::frameUpdate().

432  {
433  light()->resetIndicators();
434  if(_iOpacity <= 0.f)
435  return;
436  if(_dpiIndicator){
437  // Set DPI indicator according to index
438  int index = curDpiIdx();
439  if(index == -1 || index > OTHER)
440  index = OTHER;
441  lightIndicator("dpi", dpiClr[index].rgba());
442  }
443  // KB indicators
444  if(iEnable[MODE]){
445  for(int i = 0; i < Kb::HWMODE_MAX; i++){
446  char name[4];
447  snprintf(name, sizeof(name), "m%d", i + 1);
448  if(modeIndex == i)
449  lightIndicator(name, iColor[MODE][0].rgba());
450  else
451  lightIndicator(name, iColor[MODE][1].rgba());
452  }
453  }
454  if(iEnable[MACRO])
455  lightIndicator("mr", iColor[MUTE][1].rgba());
456  if(iEnable[LIGHT]){
457  switch(light()->dimming()){
458  case 0: // 100%
459  lightIndicator("light", light100Color.rgba());
460  break;
461  case 1: // 67%
462  lightIndicator("light", iColor[LIGHT][1].rgba());
463  break;
464  case 2: // 33%
465  case 3: // light off
466  lightIndicator("light", iColor[LIGHT][0].rgba());
467  break;
468  }
469  }
470  if(iEnable[LOCK]){
471  if(bind()->winLock())
472  lightIndicator("lock", iColor[LOCK][0].rgba());
473  else
474  lightIndicator("lock", iColor[LOCK][1].rgba());
475  }
476  if(iEnable[MUTE]){
477  switch(getMuteState()){
478  case MUTED:
479  lightIndicator("mute", iColor[MUTE][0].rgba());
480  break;
481  case UNMUTED:
482  lightIndicator("mute", iColor[MUTE][1].rgba());
483  break;
484  default:
485  lightIndicator("mute", muteNAColor.rgba());
486  break;
487  }
488  }
489  // Lock lights
490  if(iEnable[NUM])
491  lightIndicator("numlock", indicatorState[0] ? iColor[NUM][0].rgba() : iColor[NUM][1].rgba());
492  if(iEnable[CAPS])
493  lightIndicator("caps", indicatorState[1] ? iColor[CAPS][0].rgba() : iColor[CAPS][1].rgba());
494  if(iEnable[SCROLL])
495  lightIndicator("scroll", indicatorState[2] ? iColor[SCROLL][0].rgba() : iColor[SCROLL][1].rgba());
496 }
KbBind * bind() const
Definition: kbperf.cpp:100
QColor light100Color
Definition: kbperf.h:151
bool iEnable[I_COUNT]
Definition: kbperf.h:152
float _iOpacity
Definition: kbperf.h:149
void resetIndicators()
Definition: kblight.cpp:254
static const int HWMODE_MAX
Definition: kb.h:50
QColor muteNAColor
Definition: kbperf.h:151
muteState getMuteState()
Definition: media_linux.cpp:9
Definition: media.h:21
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
int curDpiIdx() const
Definition: kbperf.h:61
Definition: media.h:22
void lightIndicator(const char *name, QRgb rgba)
Definition: kbperf.cpp:425
KbLight * light() const
Definition: kbperf.cpp:104
static const int OTHER
Definition: kbperf.h:81
bool _dpiIndicator
Definition: kbperf.h:154

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KbBind * KbPerf::bind ( ) const
private

Definition at line 100 of file kbperf.cpp.

References KbMode::bind(), and modeParent().

Referenced by applyIndicators().

100  {
101  return modeParent()->bind();
102 }
KbBind * bind()
Definition: kbmode.h:61
KbMode * modeParent() const
Definition: kbperf.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QPoint KbPerf::curDpi ( ) const
inline

Definition at line 57 of file kbperf.h.

References dpiCurX, and dpiCurY.

Referenced by curDpiIdx(), KbPerf(), load(), operator=(), and pushDpi().

57 { return QPoint(dpiCurX, dpiCurY); }
int dpiCurY
Definition: kbperf.h:134
int dpiCurX
Definition: kbperf.h:134

+ Here is the caller graph for this function:

void KbPerf::curDpi ( const QPoint &  newDpi)

Definition at line 278 of file kbperf.cpp.

References _curDpi(), popDpi(), and pushedDpis.

278  {
279  while(pushedDpis.count() > 0)
280  popDpi(pushedDpis.keys().last());
281  _curDpi(newDpi);
282 }
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:262
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
void popDpi(quint64 pushIdx)
Definition: kbperf.cpp:296

+ Here is the call graph for this function:

void KbPerf::curDpi ( int  newDpi)
inline

Definition at line 59 of file kbperf.h.

References curDpi().

Referenced by curDpi().

59 { curDpi(QPoint(newDpi, newDpi)); }
QPoint curDpi() const
Definition: kbperf.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int KbPerf::curDpiIdx ( ) const
inline

Definition at line 61 of file kbperf.h.

References dpiCurIdx.

Referenced by applyIndicators(), dpiDown(), dpiUp(), and Kb::readNotify().

61 { return dpiCurIdx; }
int dpiCurIdx
Definition: kbperf.h:134

+ Here is the caller graph for this function:

void KbPerf::curDpiIdx ( int  newIdx)
inline

Definition at line 62 of file kbperf.h.

References curDpi(), and dpi().

62 { curDpi(dpi(newIdx)); }
QPoint dpi(int index) const
Definition: kbperf.h:48
QPoint curDpi() const
Definition: kbperf.h:57

+ Here is the call graph for this function:

void KbPerf::didLoad ( )
signal

Definition at line 134 of file moc_kbperf.cpp.

Referenced by load().

135 {
136  QMetaObject::activate(this, &staticMetaObject, 0, Q_NULLPTR);
137 }

+ Here is the caller graph for this function:

QPoint KbPerf::dpi ( int  index) const
inline

Definition at line 48 of file kbperf.h.

References DPI_COUNT, dpiX, and dpiY.

Referenced by MPerfWidget::boxXChanged(), MPerfWidget::boxYChanged(), curDpiIdx(), KeyAction::keyEvent(), Kb::readNotify(), RebindWidget::setBind(), MPerfWidget::setPerf(), MPerfWidget::sliderXMoved(), MPerfWidget::sliderYMoved(), and sniperDpi().

48 { if(index < 0 || index >= DPI_COUNT) return QPoint(); return QPoint(dpiX[index], dpiY[index]); }
static const int DPI_COUNT
Definition: kbperf.h:46
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiX[DPI_COUNT]
Definition: kbperf.h:132

+ Here is the caller graph for this function:

void KbPerf::dpi ( int  index,
const QPoint &  newValue 
)

Definition at line 249 of file kbperf.cpp.

References _needsSave, _needsUpdate, DPI_COUNT, dpiCurIdx, dpiCurX, dpiCurY, dpiX, and dpiY.

249  {
250  if(index < 0 || index >= DPI_COUNT)
251  return;
252  dpiX[index] = newValue.x();
253  dpiY[index] = newValue.y();
254  // Update current DPI if needed
255  if(dpiCurIdx == index){
256  dpiCurX = newValue.x();
257  dpiCurY = newValue.y();
258  }
259  _needsUpdate = _needsSave = true;
260 }
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
int dpiCurIdx
Definition: kbperf.h:134
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
void KbPerf::dpi ( int  index,
int  newValue 
)
inline

Definition at line 53 of file kbperf.h.

References dpi().

Referenced by dpi().

53 { dpi(index, QPoint(newValue, newValue)); }
QPoint dpi(int index) const
Definition: kbperf.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QColor KbPerf::dpiColor ( int  index) const
inline

Definition at line 82 of file kbperf.h.

References dpiClr.

Referenced by MPerfWidget::colorChanged(), Kb::readNotify(), MPerfWidget::setPerf(), and update().

82 { return dpiClr[index]; }
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135

+ Here is the caller graph for this function:

void KbPerf::dpiColor ( int  index,
const QColor &  newColor 
)
inline

Definition at line 83 of file kbperf.h.

References _needsSave, _needsUpdate, and dpiClr.

83 { dpiClr[index] = newColor; _needsUpdate = _needsSave = true; }
bool _needsUpdate
Definition: kbperf.h:160
bool _needsSave
Definition: kbperf.h:160
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
void KbPerf::dpiDown ( )

Definition at line 319 of file kbperf.cpp.

References curDpiIdx(), dpiOn, and SNIPER.

Referenced by KeyAction::keyEvent().

319  {
320  int idx = curDpiIdx();
321  do {
322  idx--;
323  if(idx <= SNIPER)
324  return;
325  } while(!dpiOn[idx]);
326  curDpiIdx(idx);
327 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
int curDpiIdx() const
Definition: kbperf.h:61
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool KbPerf::dpiEnabled ( int  index) const
inline

Definition at line 66 of file kbperf.h.

References dpiOn.

Referenced by MPerfWidget::enableChanged(), Kb::readNotify(), and MPerfWidget::setPerf().

66 { return dpiOn[index]; }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136

+ Here is the caller graph for this function:

void KbPerf::dpiEnabled ( int  index,
bool  newEnabled 
)
inline

Definition at line 67 of file kbperf.h.

References _needsSave, _needsUpdate, and dpiOn.

67 { if(index <= 0) return; dpiOn[index] = newEnabled; _needsUpdate = _needsSave = true; }
bool _needsUpdate
Definition: kbperf.h:160
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
bool _needsSave
Definition: kbperf.h:160
bool KbPerf::dpiIndicator ( ) const
inline

Definition at line 79 of file kbperf.h.

References _dpiIndicator.

Referenced by MPerfWidget::on_indicBox_clicked(), and MPerfWidget::setPerf().

79 { return _dpiIndicator; }
bool _dpiIndicator
Definition: kbperf.h:154

+ Here is the caller graph for this function:

void KbPerf::dpiIndicator ( bool  newDpiIndicator)
inline

Definition at line 80 of file kbperf.h.

References _dpiIndicator, and _needsSave.

80 { _dpiIndicator = newDpiIndicator; _needsSave = true; }
bool _needsSave
Definition: kbperf.h:160
bool _dpiIndicator
Definition: kbperf.h:154
void KbPerf::dpiUp ( )

Definition at line 308 of file kbperf.cpp.

References curDpiIdx(), DPI_COUNT, and dpiOn.

Referenced by KeyAction::keyEvent().

308  {
309  // Scroll past disabled DPIs and choose the next one up
310  int idx = curDpiIdx();
311  do {
312  idx++;
313  if(idx >= DPI_COUNT)
314  return;
315  } while(!dpiOn[idx]);
316  curDpiIdx(idx);
317 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
static const int DPI_COUNT
Definition: kbperf.h:46
int curDpiIdx() const
Definition: kbperf.h:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::getIndicator ( indicator  index,
QColor &  color1,
QColor &  color2,
QColor &  color3,
bool &  software_enable,
i_hw hardware_enable 
)

Definition at line 329 of file kbperf.cpp.

References HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, and NONE.

Referenced by KPerfWidget::setPerf().

329  {
330  if(index < 0 || index >= I_COUNT)
331  return;
332  color1 = iColor[index][0];
333  color2 = iColor[index][1];
334  if(index == LIGHT)
335  color3 = light100Color;
336  else if(index == MUTE)
337  color3 = muteNAColor;
338  else
339  color3 = QColor();
340  software_enable = iEnable[index];
341  hardware_enable = (index <= HW_IMAX ? hwIType[index] : NONE);
342 }
QColor light100Color
Definition: kbperf.h:151
bool iEnable[I_COUNT]
Definition: kbperf.h:152
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
QColor muteNAColor
Definition: kbperf.h:151
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the caller graph for this function:

float KbPerf::iOpacity ( ) const
inline

Definition at line 76 of file kbperf.h.

References _iOpacity.

Referenced by KPerfWidget::on_intensityBox_valueChanged(), MPerfWidget::on_spinBox_valueChanged(), KPerfWidget::setPerf(), and MPerfWidget::setPerf().

76 { return _iOpacity; }
float _iOpacity
Definition: kbperf.h:149

+ Here is the caller graph for this function:

void KbPerf::iOpacity ( float  newIOpacity)
inline

Definition at line 77 of file kbperf.h.

References _iOpacity, and _needsSave.

77 { _iOpacity = newIOpacity; _needsSave = true; }
float _iOpacity
Definition: kbperf.h:149
bool _needsSave
Definition: kbperf.h:160
height KbPerf::liftHeight ( ) const
inline

Definition at line 38 of file kbperf.h.

References _liftHeight.

Referenced by MPerfWidget::on_lHeightBox_activated(), Kb::readNotify(), and MPerfWidget::setPerf().

38 { return _liftHeight; }
height _liftHeight
Definition: kbperf.h:157

+ Here is the caller graph for this function:

void KbPerf::liftHeight ( height  newHeight)

Definition at line 361 of file kbperf.cpp.

References _liftHeight, _needsSave, _needsUpdate, and HIGH.

361  {
362  if(newHeight < LOW || newHeight > HIGH)
363  return;
364  _liftHeight = newHeight;
365  _needsUpdate = _needsSave = true;
366 }
bool _needsUpdate
Definition: kbperf.h:160
height _liftHeight
Definition: kbperf.h:157
bool _needsSave
Definition: kbperf.h:160
KbLight * KbPerf::light ( ) const
private

Definition at line 104 of file kbperf.cpp.

References KbMode::light(), and modeParent().

Referenced by applyIndicators(), and lightIndicator().

104  {
105  return modeParent()->light();
106 }
KbLight * light()
Definition: kbmode.h:60
KbMode * modeParent() const
Definition: kbperf.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::lightIndicator ( const char *  name,
QRgb  rgba 
)
private

Definition at line 425 of file kbperf.cpp.

References _iOpacity, light(), and KbLight::setIndicator().

Referenced by applyIndicators().

425  {
426  int a = round(qAlpha(rgba) * _iOpacity);
427  if(a <= 0)
428  return;
429  light()->setIndicator(name, qRgba(qRed(rgba), qGreen(rgba), qBlue(rgba), a));
430 }
float _iOpacity
Definition: kbperf.h:149
void setIndicator(const char *name, QRgb argb)
Definition: kblight.cpp:259
KbLight * light() const
Definition: kbperf.cpp:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::load ( CkbSettings settings)

Definition at line 108 of file kbperf.cpp.

References _angleSnap, _dpiIndicator, _iOpacity, _liftHeight, _needsSave, CkbSettings::contains(), CkbSettings::containsGroup(), curDpi(), didLoad(), DPI_COUNT, dpiClr, dpiLastIdx, dpiOn, dpiX, dpiY, HIGH, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, LOCK, MACRO, MEDIUM, MODE, MUTE, muteNAColor, NORMAL, OTHER, pushedDpis, runningPushIdx, and CkbSettings::value().

Referenced by KbMode::KbMode().

108  {
109  pushedDpis.clear();
110  runningPushIdx = 1;
111  _needsSave = false;
112  bool readIndicators = true;
113  if(!settings.containsGroup("Performance/Indicators")){
114  // Read old indicator settings from the lighting group, if present
115  // (ckb <= v0.2.0)
116  SGroup group(settings, "Lighting");
117  if(settings.contains("InactiveIndicators")){
118  bool inOk = false;
119  int inactive = settings.value("InactiveIndicators").toInt(&inOk);
120  if(!inOk || inactive > 2)
121  inactive = 2;
122  if(inactive == 1)
123  _iOpacity = 0.75f;
124  else if(inactive == 0)
125  _iOpacity = 0.5f;
126  else if(inactive < 0){
127  // Indicators disabled
128  iEnable[MODE] = iEnable[MACRO] = iEnable[LIGHT] = iEnable[LOCK] = iEnable[MUTE] = false;
129  }
130  bool showMute = (settings.value("ShowMute").toInt(&inOk) != 0);
131  if(inOk && !showMute)
132  iEnable[MUTE] = false;
133  readIndicators = false;
134  }
135  }
136  SGroup group(settings, "Performance");
137  // Read DPI settings
138  {
139  SGroup group(settings, "DPI");
140  for(int i = 0; i < DPI_COUNT; i++){
141  QString iStr = QString::number(i);
142  QPoint value = settings.value(iStr).toPoint();
143  if(value.isNull())
144  continue;
145  dpiX[i] = value.x(); dpiY[i] = value.y();
146  QColor color = settings.value(iStr + "RGB").toString();
147  if(color.isValid())
148  dpiClr[i] = color;
149  if(i != 0)
150  dpiOn[i] = !settings.value(iStr + "Disabled").toBool();
151  }
152  QColor color = settings.value("6RGB").toString();
153  if(color.isValid())
154  dpiClr[OTHER] = color;
155  if(settings.contains("LastIdx")){
156  dpiLastIdx = settings.value("LastIdx").toInt();
157  if(dpiLastIdx >= DPI_COUNT || dpiLastIdx < 0)
158  dpiLastIdx = 1;
159  }
160  QPoint value = settings.value("Current").toPoint();
161  if(!value.isNull())
162  curDpi(value);
163  }
164  // Read misc. mouse settings
165  _liftHeight = (height)settings.value("LiftHeight").toInt();
166  if(_liftHeight < LOW || _liftHeight > HIGH)
168  _angleSnap = settings.value("AngleSnap").toBool();
169  if(settings.contains("NoIndicator")){
170  // ckb <= v0.2.0
171  _dpiIndicator = !settings.value("NoIndicator").toBool();
172  } else {
173  _dpiIndicator = settings.value("Indicators/DPI", true).toBool();
174  }
175  // Read indicator settings
176  if(readIndicators){
177  SGroup group(settings, "Indicators");
178  _iOpacity = settings.value("Opacity", 100).toInt() / 100.f;
179  for(int i = 0; i < I_COUNT; i++){
180  SGroup group(settings, QString::number(i));
181  QColor color = settings.value("RGB0").toString();
182  if(color.isValid())
183  iColor[i][0] = color;
184  color = settings.value("RGB1").toString();
185  if(color.isValid())
186  iColor[i][1] = color;
187  if(i == LIGHT){
188  color = settings.value("RGB2").toString();
189  if(color.isValid())
190  light100Color = color;
191  } else if(i == MUTE){
192  color = settings.value("RGB2").toString();
193  if(color.isValid())
194  muteNAColor = color;
195  }
196  if(i <= HW_IMAX){
197  iEnable[i] = settings.value("Enable", false).toBool();
198  hwIType[i] = (i_hw)settings.value("Hardware", (int)NORMAL).toInt();
199  } else {
200  iEnable[i] = settings.value("Enable", true).toBool();
201  }
202  }
203  }
204  emit didLoad();
205 }
QColor light100Color
Definition: kbperf.h:151
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
uint runningPushIdx
Definition: kbperf.h:143
bool iEnable[I_COUNT]
Definition: kbperf.h:152
bool contains(const QString &key) const
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
float _iOpacity
Definition: kbperf.h:149
height _liftHeight
Definition: kbperf.h:157
int dpiLastIdx
Definition: kbperf.h:138
bool containsGroup(const QString &group)
height
Definition: kbperf.h:31
void didLoad()
Definition: moc_kbperf.cpp:134
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:151
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
QPoint curDpi() const
Definition: kbperf.h:57
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
i_hw
Definition: kbperf.h:98
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
static const int OTHER
Definition: kbperf.h:81
bool _dpiIndicator
Definition: kbperf.h:154
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KbMode* KbPerf::modeParent ( ) const
inlineprivate

Definition at line 124 of file kbperf.h.

Referenced by bind(), and light().

124 { return (KbMode*)parent(); }
Definition: kbmode.h:36

+ Here is the caller graph for this function:

bool KbPerf::needsSave ( ) const
inline

Definition at line 28 of file kbperf.h.

References _needsSave.

Referenced by KbMode::needsSave().

28 { return _needsSave; }
bool _needsSave
Definition: kbperf.h:160

+ Here is the caller graph for this function:

const KbPerf & KbPerf::operator= ( const KbPerf rhs)

Definition at line 78 of file kbperf.cpp.

References _angleSnap, _dpiIndicator, _iOpacity, _liftHeight, _needsSave, _needsUpdate, curDpi(), DPI_COUNT, dpiClr, dpiCurIdx, dpiCurX, dpiCurY, dpiLastIdx, dpiOn, dpiX, dpiY, hwIType, I_COUNT, iColor, iEnable, light100Color, muteNAColor, pushedDpis, and runningPushIdx.

78  {
79  dpiCurX = other.dpiCurX; dpiCurY = other.dpiCurY; dpiCurIdx = other.dpiCurIdx; dpiLastIdx = other.dpiLastIdx; runningPushIdx = 1;
80  _iOpacity = other._iOpacity; light100Color = other.light100Color; muteNAColor = other.muteNAColor; _dpiIndicator = other._dpiIndicator;
81  _liftHeight = other._liftHeight; _angleSnap = other._angleSnap;
82  _needsUpdate = true; _needsSave = true;
83  memcpy(dpiX, other.dpiX, sizeof(dpiX));
84  memcpy(dpiY, other.dpiY, sizeof(dpiY));
85  for(int i = 0; i < DPI_COUNT + 1; i++)
86  dpiClr[i] = other.dpiClr[i];
87  memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
88  for(int i = 0; i < I_COUNT; i++){
89  iColor[i][0] = other.iColor[i][0];
90  iColor[i][1] = other.iColor[i][1];
91  }
92  memcpy(iEnable, other.iEnable, sizeof(iEnable));
93  memcpy(hwIType, other.hwIType, sizeof(hwIType));
94  // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
95  if(!other.pushedDpis.isEmpty())
96  curDpi(other.pushedDpis[0]);
97  return other;
98 }
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
QColor light100Color
Definition: kbperf.h:151
uint runningPushIdx
Definition: kbperf.h:143
bool iEnable[I_COUNT]
Definition: kbperf.h:152
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
float _iOpacity
Definition: kbperf.h:149
height _liftHeight
Definition: kbperf.h:157
int dpiLastIdx
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:151
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
QPoint curDpi() const
Definition: kbperf.h:57
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
int dpiCurIdx
Definition: kbperf.h:134
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
bool _dpiIndicator
Definition: kbperf.h:154
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the call graph for this function:

void KbPerf::popDpi ( quint64  pushIdx)

Definition at line 296 of file kbperf.cpp.

References _curDpi(), _needsSave, _needsUpdate, map_last, and pushedDpis.

Referenced by curDpi(), and KeyAction::keyEvent().

296  {
297  if(pushIdx == 0 || !pushedDpis.contains(pushIdx))
298  return;
299  pushedDpis.remove(pushIdx);
300  // Set the DPI to the last-pushed value still on the stack
302  // If all values have been popped, remove the original DPI
303  if(pushedDpis.count() == 1)
304  pushedDpis.clear();
305  _needsUpdate = _needsSave = true;
306 }
bool _needsUpdate
Definition: kbperf.h:160
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:262
#define map_last(map)
Definition: kbperf.cpp:8
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
bool _needsSave
Definition: kbperf.h:160

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushDpi ( const QPoint &  newDpi)

Definition at line 284 of file kbperf.cpp.

References _curDpi(), curDpi(), pushedDpis, and runningPushIdx.

Referenced by KeyAction::keyEvent(), and pushSniper().

284  {
285  if(pushedDpis.isEmpty())
286  // Push original DPI
287  pushedDpis[0] = curDpi();
288  quint64 index = runningPushIdx++;
289  if(runningPushIdx == 0)
290  runningPushIdx = 1;
291  pushedDpis[index] = newDpi;
292  _curDpi(newDpi);
293  return index;
294 }
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:262
uint runningPushIdx
Definition: kbperf.h:143
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
QPoint curDpi() const
Definition: kbperf.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushDpi ( int  newDpi)
inline

Definition at line 71 of file kbperf.h.

References pushDpi().

Referenced by pushDpi().

71 { return pushDpi(QPoint(newDpi, newDpi)); }
quint64 pushDpi(const QPoint &newDpi)
Definition: kbperf.cpp:284

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushSniper ( )
inline

Definition at line 72 of file kbperf.h.

References pushDpi(), and sniperDpi().

Referenced by KeyAction::keyEvent().

72 { return pushDpi(sniperDpi()); }
QPoint sniperDpi() const
Definition: kbperf.h:50
quint64 pushDpi(const QPoint &newDpi)
Definition: kbperf.cpp:284

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::save ( CkbSettings settings)

Definition at line 207 of file kbperf.cpp.

References _angleSnap, _dpiIndicator, _liftHeight, _needsSave, DPI_COUNT, dpiClr, dpiCurX, dpiCurY, dpiLastIdx, dpiOn, dpiX, dpiY, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, OTHER, pushedDpis, and CkbSettings::setValue().

Referenced by KbMode::save().

207  {
208  _needsSave = false;
209  SGroup group(settings, "Performance");
210  {
211  SGroup group(settings, "DPI");
212  for(int i = 0; i < DPI_COUNT; i++){
213  QString iStr = QString::number(i);
214  settings.setValue(iStr, QPoint(dpiX[i], dpiY[i]));
215  settings.setValue(iStr + "RGB", dpiClr[i].name(QColor::HexArgb));
216  if(i != 0)
217  settings.setValue(iStr + "Disabled", !dpiOn[i]);
218  }
219  settings.setValue("6RGB", dpiClr[OTHER].name(QColor::HexArgb));
220  settings.setValue("LastIdx", dpiLastIdx);
221  int curX = dpiCurX, curY = dpiCurY;
222  // Ignore any pushed modes
223  if(pushedDpis.count() > 0){
224  curX = pushedDpis.value(0).x();
225  curY = pushedDpis.value(0).y();
226  }
227  settings.setValue("Current", QPoint(curX, curY));
228  }
229  settings.setValue("LiftHeight", _liftHeight);
230  settings.setValue("AngleSnap", _angleSnap);
231  {
232  SGroup group(settings, "Indicators");
233  settings.setValue("DPI", _dpiIndicator);
234  for(int i = 0; i < I_COUNT; i++){
235  SGroup group(settings, QString::number(i));
236  settings.setValue("RGB0", iColor[i][0].name(QColor::HexArgb));
237  settings.setValue("RGB1", iColor[i][1].name(QColor::HexArgb));
238  if(i == LIGHT)
239  settings.setValue("RGB2", light100Color.name(QColor::HexArgb));
240  else if(i == MUTE)
241  settings.setValue("RGB2", muteNAColor.name(QColor::HexArgb));
242  settings.setValue("Enable", iEnable[i]);
243  if(i <= HW_IMAX)
244  settings.setValue("Hardware", (int)hwIType[i]);
245  }
246  }
247 }
void setValue(const QString &key, const QVariant &value)
int dpiCurY
Definition: kbperf.h:134
QColor light100Color
Definition: kbperf.h:151
bool iEnable[I_COUNT]
Definition: kbperf.h:152
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:142
height _liftHeight
Definition: kbperf.h:157
int dpiLastIdx
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:160
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:151
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:135
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
int dpiX[DPI_COUNT]
Definition: kbperf.h:132
static const int OTHER
Definition: kbperf.h:81
bool _dpiIndicator
Definition: kbperf.h:154
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::setIndicator ( indicator  index,
const QColor &  color1,
const QColor &  color2,
const QColor &  color3 = QColor(),
bool  software_enable = true,
i_hw  hardware_enable = NORMAL 
)

Definition at line 344 of file kbperf.cpp.

References _needsSave, _needsUpdate, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, NONE, and NORMAL.

Referenced by KPerfWidget::uiUpdated().

344  {
345  if(index < 0 || index >= I_COUNT)
346  return;
347  iColor[index][0] = color1;
348  iColor[index][1] = color2;
349  if(index == LIGHT)
350  light100Color = color3;
351  else if(index == MUTE)
352  muteNAColor = color3;
353  iEnable[index] = software_enable;
354  if(hardware_enable == NONE)
355  hardware_enable = NORMAL;
356  if(index <= HW_IMAX)
357  hwIType[index] = hardware_enable;
358  _needsUpdate = _needsSave = true;
359 }
bool _needsUpdate
Definition: kbperf.h:160
QColor light100Color
Definition: kbperf.h:151
bool iEnable[I_COUNT]
Definition: kbperf.h:152
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
bool _needsSave
Definition: kbperf.h:160
QColor muteNAColor
Definition: kbperf.h:151
QColor iColor[I_COUNT][2]
Definition: kbperf.h:150
static const int I_COUNT
Definition: kbperf.h:104

+ Here is the caller graph for this function:

void KbPerf::setNeedsUpdate ( )
inline

Definition at line 113 of file kbperf.h.

References _needsUpdate.

Referenced by KbMode::setNeedsUpdate().

113 { _needsUpdate = true; }
bool _needsUpdate
Definition: kbperf.h:160

+ Here is the caller graph for this function:

void KbPerf::settingsUpdated ( )
signal

Definition at line 140 of file moc_kbperf.cpp.

Referenced by update().

141 {
142  QMetaObject::activate(this, &staticMetaObject, 1, Q_NULLPTR);
143 }

+ Here is the caller graph for this function:

QPoint KbPerf::sniperDpi ( ) const
inline

Definition at line 50 of file kbperf.h.

References dpi(), and SNIPER.

Referenced by pushSniper().

50 { return dpi(SNIPER); }
QPoint dpi(int index) const
Definition: kbperf.h:48
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::sniperDpi ( const QPoint &  newValue)
inline

Definition at line 51 of file kbperf.h.

References dpi(), and SNIPER.

51 { dpi(SNIPER, newValue); }
QPoint dpi(int index) const
Definition: kbperf.h:48
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

void KbPerf::sniperDpi ( int  newValue)
inline

Definition at line 54 of file kbperf.h.

References sniperDpi().

Referenced by sniperDpi().

54 { sniperDpi(QPoint(newValue, newValue)); }
QPoint sniperDpi() const
Definition: kbperf.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::update ( QFile &  cmd,
int  notifyNumber,
bool  force = false,
bool  saveCustomDpi = true 
)

Definition at line 373 of file kbperf.cpp.

References _angleSnap, _liftHeight, _needsUpdate, DPI_COUNT, dpiColor(), dpiCurIdx, dpiCurX, dpiCurY, dpiOn, dpiX, dpiY, HW_I_COUNT, hwIType, OFF, ON, and settingsUpdated().

Referenced by Kb::frameUpdate(), and Kb::hwSave().

373  {
374  if(!force && !_needsUpdate)
375  return;
376  emit settingsUpdated();
377  _needsUpdate = false;
378  // Save DPI stage 0 (sniper)
379  cmd.write(QString("dpi 0:%1,%2").arg(dpiX[0]).arg(dpiY[0]).toLatin1());
380  // If the mouse is set to a custom DPI, save it in stage 1
381  int stage = dpiCurIdx;
382  if(stage < 0 && saveCustomDpi){
383  stage = 1;
384  cmd.write(QString(" 1:%1,%2").arg(dpiCurX).arg(dpiCurY).toLatin1());
385  } else {
386  // Otherwise, save stage 1 normally
387  if(!dpiOn[1] && stage != 1)
388  cmd.write(" 1:off");
389  else
390  cmd.write(QString(" 1:%1,%2").arg(dpiX[1]).arg(dpiY[1]).toLatin1());
391  }
392  // Save stages 1 - 5
393  for(int i = 2; i < DPI_COUNT; i++){
394  if(!dpiOn[i] && stage != i)
395  cmd.write(QString(" %1:off").arg(i).toLatin1());
396  else
397  cmd.write(QString(" %1:%2,%3").arg(i).arg(dpiX[i]).arg(dpiY[i]).toLatin1());
398  }
399  // Save stage selection, lift height, and angle snap
400  cmd.write(QString(" dpisel %1 lift %2 snap %3").arg(stage).arg(_liftHeight).arg(_angleSnap ? "on" : "off").toLatin1());
401  // Save DPI colors
402  cmd.write(" rgb");
403  for(int i = 0; i < DPI_COUNT; i++){
404  QColor color = dpiColor(i);
405  cmd.write(" dpi");
406  char output[9];
407  snprintf(output, sizeof(output), "%1d:%02x%02x%02x", i, color.red(), color.green(), color.blue());
408  cmd.write(output);
409  }
410  // Enable indicator notifications
411  cmd.write(QString("\n@%1 inotify all").arg(notifyNumber).toLatin1());
412  // Set indicator state
413  const char* iNames[HW_I_COUNT] = { "num", "caps", "scroll" };
414  for(int i = 0; i < HW_I_COUNT; i++){
415  if(hwIType[i] == ON)
416  cmd.write(" ion ");
417  else if(hwIType[i] == OFF)
418  cmd.write(" ioff ");
419  else
420  cmd.write(" iauto ");
421  cmd.write(iNames[i]);
422  }
423 }
static const int HW_I_COUNT
Definition: kbperf.h:104
bool _needsUpdate
Definition: kbperf.h:160
int dpiCurY
Definition: kbperf.h:134
QColor dpiColor(int index) const
Definition: kbperf.h:82
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:136
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:153
height _liftHeight
Definition: kbperf.h:157
static const int DPI_COUNT
Definition: kbperf.h:46
bool _angleSnap
Definition: kbperf.h:158
int dpiY[DPI_COUNT]
Definition: kbperf.h:133
int dpiCurX
Definition: kbperf.h:134
int dpiCurIdx
Definition: kbperf.h:134
void settingsUpdated()
Definition: moc_kbperf.cpp:140
int dpiX[DPI_COUNT]
Definition: kbperf.h:132

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

bool KbPerf::_angleSnap
private

Definition at line 158 of file kbperf.h.

Referenced by angleSnap(), load(), operator=(), save(), and update().

bool KbPerf::_dpiIndicator
private

Definition at line 154 of file kbperf.h.

Referenced by applyIndicators(), dpiIndicator(), load(), operator=(), and save().

float KbPerf::_iOpacity
private

Definition at line 149 of file kbperf.h.

Referenced by applyIndicators(), iOpacity(), lightIndicator(), load(), and operator=().

height KbPerf::_liftHeight
private

Definition at line 157 of file kbperf.h.

Referenced by liftHeight(), load(), operator=(), save(), and update().

bool KbPerf::_needsSave
private
bool KbPerf::_needsUpdate
private
const int KbPerf::DPI_COUNT = 6
static
const int KbPerf::DPI_MAX = 12000
static

Definition at line 47 of file kbperf.h.

const int KbPerf::DPI_MIN = 100
static

Definition at line 47 of file kbperf.h.

Referenced by dpiExp(), and dpiLog().

QColor KbPerf::dpiClr[DPI_COUNT+1]
private

Definition at line 135 of file kbperf.h.

Referenced by applyIndicators(), dpiColor(), KbPerf(), load(), operator=(), and save().

int KbPerf::dpiCurIdx
private

Definition at line 134 of file kbperf.h.

Referenced by _curDpi(), curDpiIdx(), dpi(), KbPerf(), operator=(), and update().

int KbPerf::dpiCurX
private

Definition at line 134 of file kbperf.h.

Referenced by _curDpi(), curDpi(), dpi(), KbPerf(), operator=(), save(), and update().

int KbPerf::dpiCurY
private

Definition at line 134 of file kbperf.h.

Referenced by _curDpi(), curDpi(), dpi(), KbPerf(), operator=(), save(), and update().

int KbPerf::dpiLastIdx
private

Definition at line 138 of file kbperf.h.

Referenced by _curDpi(), KbPerf(), load(), operator=(), and save().

bool KbPerf::dpiOn[DPI_COUNT]
private

Definition at line 136 of file kbperf.h.

Referenced by dpiDown(), dpiEnabled(), dpiUp(), KbPerf(), load(), operator=(), save(), and update().

int KbPerf::dpiX[DPI_COUNT]
private

Definition at line 132 of file kbperf.h.

Referenced by _curDpi(), dpi(), KbPerf(), load(), operator=(), save(), and update().

int KbPerf::dpiY[DPI_COUNT]
private

Definition at line 133 of file kbperf.h.

Referenced by _curDpi(), dpi(), KbPerf(), load(), operator=(), save(), and update().

const int KbPerf::HW_I_COUNT = (int)HW_IMAX + 1
static

Definition at line 104 of file kbperf.h.

Referenced by KbPerf(), and update().

i_hw KbPerf::hwIType[HW_I_COUNT]
private

Definition at line 153 of file kbperf.h.

Referenced by getIndicator(), KbPerf(), load(), operator=(), save(), setIndicator(), and update().

const int KbPerf::I_COUNT = (int)MUTE + 1
static

Definition at line 104 of file kbperf.h.

Referenced by getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::iColor[I_COUNT][2]
private

Definition at line 150 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

bool KbPerf::iEnable[I_COUNT]
private

Definition at line 152 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::light100Color
private

Definition at line 151 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::muteNAColor
private

Definition at line 151 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

const int KbPerf::OTHER = DPI_COUNT
static

Definition at line 81 of file kbperf.h.

Referenced by applyIndicators(), MPerfWidget::colorChanged(), load(), save(), and MPerfWidget::setPerf().

QMap<quint64, QPoint> KbPerf::pushedDpis
private

Definition at line 142 of file kbperf.h.

Referenced by curDpi(), KbPerf(), load(), operator=(), popDpi(), pushDpi(), and save().

uint KbPerf::runningPushIdx
private

Definition at line 143 of file kbperf.h.

Referenced by load(), operator=(), and pushDpi().

const int KbPerf::SNIPER = 0
static

Definition at line 46 of file kbperf.h.

Referenced by dpiDown(), and sniperDpi().


The documentation for this class was generated from the following files: