jflamy / owlcms4

Olympic Weightlifting Competition Management System
https://owlcms.github.io/owlcms4/#/index
Other
67 stars 22 forks source link

FLIC2: Problem with Announcer screen programmable shortcuts #667

Closed JDFS404 closed 3 months ago

JDFS404 commented 1 year ago

Is it possible to give the same shortcuts (unless . and , have different functions) to start or stop the clock? We run the clock from the Announcer screen 9/10 times and it would be great if we could program buttons for the Announcer as well to start or stop the clock without looking at the screen. Reason being is that sometimes we're short of referees and the Announcer is the third referee as well (I've been in that situation a couple of times).

jflamy commented 1 year ago

Actually the announcer normally never enters decimals, so that might work. Looking into it.

jflamy commented 1 year ago

Well guess what. The code was already there. , starts the clock, . stops it.

JDFS404 commented 1 year ago

Great! Would it also be in line of expectations to have something similar for the 1 and 2-minute buttons? Perhaps [ and ]? In that way, we could map them to a USB-controller as well :)

jflamy commented 1 year ago

Yes, https://www.w3.org/TR/uievents-code/#key-alphanumeric-writing-system indicates that the brackets can be used without ambiguity. Added to the announcer and timekeeper screen. Will show up in next release.

JDFS404 commented 1 year ago

Would it also be possible to map a keyboard shortcut as a toggle, so I can map one Flic button as a push device to basically toggle the clock? Perhaps \ or another button which is not in use?

JDFS404 commented 1 year ago

To add to that, unfortunately for Flic Buttons only certain characters can be mapped: ./*-+= - could you find it in your heart to add these shortcuts for the stop/start, 1 min and 2 min shortcuts? In anticipation of the actual USB devices I would like use Flic buttons for the Announcer / Timekeeper for now.

jflamy-dev commented 1 year ago

Urk. . is already used, so I would suggest /. I will see what I can do for toggling. Due to current behavior, the toggle would probably be yet another key, maybe = (assuming there is a simple way to implement, what should be simple sometimes isn't.

JDFS404 commented 1 year ago

Thanks a lot Monsieur Lamy, perhaps a moment to remap [ and ] to - and + as well so we can map it?

jflamy commented 1 year ago

Can't use - because it is actually used by the announcer to cancel a lift (-90 is no lift 90)

JDFS404 commented 1 year ago

Perhaps + for 2 minutes and * for 1 minute, and = for Toggle? It doesn't really matter to me which one is which, as long as I can map it 😄

jflamy commented 1 year ago

Flic is a pain. For the program, I need to use what's on the keycap (the bottom symbol) and then tell it the key modifier (if I need Shift for example). So so far I avoided modifiers, will test to see if they work appropriately.,

. for stop / and , for start - for 1 minute = for 2 minutes

* would be toggle

jflamy commented 1 year ago

As it turns out, * as sent by Flic is the numeric keypad *. I have added both SHIFT+DIGIT_8 and the numeric multiply as shortcuts for toggling.

JDFS404 commented 1 year ago

I'm SO looking forward to test this! 🥇

jflamy commented 1 year ago

Available in 38.5.3-rc00

jflamy commented 1 year ago

As it turns out - cannot be used. The only key left to use is + which the Flic sends as NumPad Add. So I added Shift= and numpad_add as shortcuts to reset to 1 min. Fixing the documentation and adding to the release notes.

JDFS404 commented 9 months ago

Hi @jflamy I recently purchases some new Flic buttons to have the announcer mapped as well.

Unfortunately, the shortcuts for ., , and = (start, stop and 2 min) don't seem to be working with Flic Universal Mode. Do you have any idea why? Because + is working (1 min), perhaps we should remap it or am I doing anything wrong?

jflamy commented 9 months ago

I'm certain this works -- I will need to dig up a Flic2 button and app to check, but nothing has changed for years in that area.

These are the start shortcuts defined, directly from the code. I believe I had to add / because , would not work on a Flic. Note that the key is where the character is located on a US keyboard.

addShortcutListener(() -> doStartTime(), Key.COMMA);
addShortcutListener(() -> doStartTime(), Key.SLASH);
addShortcutListener(() -> doToggleTime(), Key.NUMPAD_MULTIPLY);
addShortcutListener(() -> doToggleTime(), Key.DIGIT_8, KeyModifier.SHIFT);

There is only one stop shortcut

addShortcutListener(() -> doStopTime(), Key.PERIOD);

These are the ones for one minute

addShortcutListener(() -> do1Minute(), Key.NUMPAD_ADD);
addShortcutListener(() -> do1Minute(), Key.EQUAL, KeyModifier.SHIFT);

and for 2 minutes

addShortcutListener(() -> do2Minutes(), Key.EQUAL);
JDFS404 commented 9 months ago

I tried it - with my keyboard from my Windows machine I'm able to use the shortcuts, however not with the Flic button. Only for the 1 min clock via +

jflamy commented 9 months ago

I finally found a Flic2, managed to reset it, and managed to pair it with one of my laptops (my main laptop refuses to see it).

Well, never be certain of anything. It appears that the Flic2 sends the Numeric Keypad variations of the characters. On my North American laptop, Flic2 "." is seen as NUMERIC_DECIMAL (code 110) and Flic2 "/" is seen as NUMERIC_DIVIDE (code 111).

Please go to the site "https://toptal.com/developers/keycode" and confirm these values.

I will create a 46.0.0-beta06 in https://github.com/owlcms/owlcms4-prerelease/releases in a few minutes with the additional shortcuts. So you should use "." on the Flic2 to stop the clock and "/" to start it.

The updated list of shortcuts is as follows -- it appears you want the NUMPAD ones.

UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.COMMA);
UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.SLASH);
UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.NUMPAD_DIVIDE);

UI.getCurrent().addShortcutListener(() -> doStopTime(), Key.PERIOD);
UI.getCurrent().addShortcutListener(() -> doStopTime(), Key.NUMPAD_DECIMAL);

UI.getCurrent().addShortcutListener(() -> doToggleTime(), Key.DIGIT_8, KeyModifier.SHIFT);
UI.getCurrent().addShortcutListener(() -> doToggleTime(), Key.NUMPAD_MULTIPLY);

UI.getCurrent().addShortcutListener(() -> do1Minute(), Key.EQUAL, KeyModifier.SHIFT);
UI.getCurrent().addShortcutListener(() -> do1Minute(), Key.NUMPAD_ADD);

UI.getCurrent().addShortcutListener(() -> do2Minutes(), Key.EQUAL);
UI.getCurrent().addShortcutListener(() -> do2Minutes(), Key.NUMPAD_EQUAL);
JDFS404 commented 9 months ago

I finally found a Flic2, managed to reset it, and managed to pair it with one of my laptops (my main laptop refuses to see it).

Well, never be certain of anything. It appears that the Flic2 sends the Numeric Keypad variations of the characters. On my North American laptop, Flic2 "." is seen as NUMERIC_DECIMAL (code 110) and Flic2 "/" is seen as NUMERIC_DIVIDE (code 111).

Please go to the site "https://toptal.com/developers/keycode" and confirm these values.

I will create a 46.0.0-beta06 in https://github.com/owlcms/owlcms4-prerelease/releases in a few minutes with the additional shortcuts. So you should use "." on the Flic2 to stop the clock and "/" to start it.

The updated list of shortcuts is as follows -- it appears you want the NUMPAD ones.

UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.COMMA);
UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.SLASH);
UI.getCurrent().addShortcutListener(() -> doStartTime(), Key.NUMPAD_DIVIDE);

UI.getCurrent().addShortcutListener(() -> doStopTime(), Key.PERIOD);
UI.getCurrent().addShortcutListener(() -> doStopTime(), Key.NUMPAD_DECIMAL);

UI.getCurrent().addShortcutListener(() -> doToggleTime(), Key.DIGIT_8, KeyModifier.SHIFT);
UI.getCurrent().addShortcutListener(() -> doToggleTime(), Key.NUMPAD_MULTIPLY);

UI.getCurrent().addShortcutListener(() -> do1Minute(), Key.EQUAL, KeyModifier.SHIFT);
UI.getCurrent().addShortcutListener(() -> do1Minute(), Key.NUMPAD_ADD);

UI.getCurrent().addShortcutListener(() -> do2Minutes(), Key.EQUAL);
UI.getCurrent().addShortcutListener(() -> do2Minutes(), Key.NUMPAD_EQUAL);

I just tested the beta - it works for start stop! It's not yet working for = aka 2 min clock. On JS this gives me 187 (but with or without modifier it's the same). perhaps we can also do another shortcut for the 2 min clock? This will complete our announcer buttons as well: image

JDFS404 commented 8 months ago

Hi @jflamy any luck for the 2 min clock?

jflamy commented 8 months ago

There is a shortcut for = and it does work with a regular keyboard. However Firefox and the other browsers don't send the same code. My battery in my Flic2 is dead -- I have others in a box somewhere that I need to find and investigate.

JDFS404 commented 8 months ago

Woops, I have my Flic tomorrow and will confirm the key code for = in the browser!

jflamy commented 8 months ago

Got new batteries. The Flic2 sends the code for NUMPAD_EQUALS when the = shortcut is used. Also added ; as a shortcut. Please test 47.0.0-alpha03 (you can ignore the dire warnings at the top -- there are no crazy changes in this release)

Updated the documentation

Shortcuts

For shortcuts, the keys given are the key locations for a US keyboard. You will need to press the key at the location shown on this diagram, no matter what is actually printed on your keyboard.

The clock can be started by using the , (comma) or / keys on the keyboard. The / key on the numeric keypad also works. On the Flic2 buttons, this is the / shortcut.

The clock can be stopped by using the . (period) key on the keyboard. The decimal fraction character on the numeric keypad should also work (in many countries, the numeric keypad shows a , instead of a . to match the local usage for decimal fraction). For the Flic2 buttons, this is the . shortcut.

The clock can be reset to 1:00 by using the + key on the keyboard (more precisely, the key combination that corresponds to + on a US keyboard, that is, Shift=). Using the + key on the numeric keypad will also work. On the Flic2 buttons, this is the = shortcut.

The clock can be reset to 2:00 by using the = or ;key on the keyboard ). Using the + key on the numeric keypad will also work. On the Flic2 buttons, this is the = or ; shortcut.

JDFS404 commented 8 months ago

Just tested - it works perfectly :) Thank you for doing this for us, now we have a full announcer setup as well next to the referee buttons. This makes the comp for the announcer also easier to focus; no need to have to look at the screen every time to pause the clock! I think it's perfect to migrate to the production version!

jflamy commented 8 months ago

I will add it to 46 that is on the doorstep. No plan to move it back to 45.