| 229 | } |
| 230 | |
| 231 | void KeyAction::keyEvent(KbBind* bind, bool down){ |
| 232 | // No need to respond to standard actions |
| 233 | if(!isSpecial()) |
| 234 | return; |
| 235 | QStringList parts = _value.split(":"); |
| 236 | if(parts.length() < 2) |
| 237 | return; |
| 238 | QString prefix = parts[0]; |
| 239 | int suffix = parts[1].toInt(); |
| 240 | if(prefix == "$mode"){ |
| 241 | if(!down) |
| 242 | return; |
| 243 | // Change mode |
| 244 | Kb* device = bind->devParent(); |
| 245 | KbProfile* currentProfile = device->currentProfile(); |
| 246 | int mode = currentProfile->indexOf(currentProfile->currentMode()); |
| 247 | int modeCount = currentProfile->modeCount(); |
| 248 | switch(suffix){ |
| 249 | case MODE_PREV_WRAP: |
| 250 | mode--; |
| 251 | if(mode < 0) |
| 252 | mode = modeCount - 1; |
| 253 | break; |
| 254 | case MODE_NEXT_WRAP: |
| 255 | mode++; |
| 256 | if(mode >= modeCount) |
| 257 | mode = 0; |
| 258 | break; |
| 259 | case MODE_PREV: |
| 260 | mode--; |
| 261 | break; |
| 262 | case MODE_NEXT: |
| 263 | mode++; |
| 264 | break; |
| 265 | default: |
| 266 | // Absolute |
| 267 | mode = suffix; |
| 268 | break; |
| 269 | } |
| 270 | if(mode < 0 || mode >= modeCount) |
| 271 | return; |
| 272 | device->setCurrentMode(currentProfile->modes()[mode]); |
| 273 | } else if(prefix == "$dpi"){ |
| 274 | KbPerf* perf = bind->perf(); |
| 275 | int level = parts[1].split("+")[0].toInt(); |
| 276 | switch(level){ |
| 277 | case DPI_UP: |
| 278 | if(!down) |
| 279 | return; |
| 280 | perf->dpiUp(); |
| 281 | break; |
| 282 | case DPI_DOWN: |
| 283 | if(!down) |
| 284 | return; |
| 285 | perf->dpiDown(); |
| 286 | break; |
| 287 | case DPI_SNIPER: |
| 288 | if(down) |
nothing calls this directly
no test coverage detected