Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private var lastOnUpdate = null;
- private var lastOnShow = null;
- private var lastLapAlert = null;
- private var hotkeyReps = 0;
- private var haveHotkey = 0;
- private var cfgHotkey; // 0=disabled, 1=once, 2=twice
- private const hotkeyThreshold = 2000; // ms
- function onTimerLap() {
- lastLapAlert = System.getTimer();
- //...
- }
- function onUpdate(dc) {
- var now = System.getTimer();
- lastOnUpdate = now;
- //...
- }
- function onShow() {
- var now = System.getTimer();
- // ignore first onShow() within 8 seconds after lap alert
- if (lastLapAlert != null && lastOnShow != null && lastLapAlert > lastOnShow && now - lastLapAlert < 8000) {
- lastLapAlert = null;
- } else if (lastOnUpdate != null && cfgHotkey) {
- if (now - lastOnUpdate <= hotkeyThreshold * cfgHotkey) {
- hotkeyReps++;
- if (hotkeyReps >= cfgHotkey) {
- hotkeyReps = 0;
- haveHotkey = true;
- // trigger hotkey action
- // ...
- }
- }
- }
- lastOnShow = now;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment