| 352 | } |
| 353 | |
| 354 | void AnimScript::keypress(const QString& key, bool pressed, quint64 timestamp){ |
| 355 | if(!initialized) |
| 356 | return; |
| 357 | if(!process) |
| 358 | begin(timestamp); |
| 359 | int kpMode = _info.kpMode; |
| 360 | if(_paramValues.value("kpmode", 0).toInt() != 0) |
| 361 | // Disable KP mode according to user preferences |
| 362 | kpMode = KP_NONE; |
| 363 | switch(kpMode){ |
| 364 | case KP_NONE: |
| 365 | // If KPs aren't allowed, call retrigger/stop instead |
| 366 | if(pressed) |
| 367 | retrigger(timestamp); |
| 368 | else if(_paramValues.value("kprelease", false).toBool()) |
| 369 | stop(timestamp); |
| 370 | break; |
| 371 | case KP_NAME: |
| 372 | // Print keypress by name |
| 373 | advance(timestamp); |
| 374 | process->write(("key " + key + (pressed ? " down\n" : " up\n")).toLatin1()); |
| 375 | break; |
| 376 | case KP_POSITION: |
| 377 | // Print keypress by position |
| 378 | const Key& kp = _map.key(key); |
| 379 | if(!kp) |
| 380 | return; |
| 381 | advance(timestamp); |
| 382 | process->write(("key " + QString("%1,%2").arg(kp.x - minX).arg(kp.y - minY) + (pressed ? " down\n" : " up\n")).toLatin1()); |
| 383 | break; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | void AnimScript::end(){ |
| 388 | _colors.clear(); |