Closed dlip closed 6 months ago
Curious, how are you using chords such that you're hitting the limit of 32 associated symbols? That's more than the alphabet keys on the keyboard.
If I remember correctly there shouldn't be a limit on number of actions within a group, only on participating symbols for the group.
@jtroo I'm working on this chord generator for common words, its easy to get into the triple digits when you have different combos for capitilized, past, continuing, plural forms etc. https://github.com/dlip/abbrgen
@jtroo maybe i misunderstood the error message, i thought it was total combos but maybe it is just symbols as you said. Let me test some more
@jtroo I tried again and the limit of 32 is indeed at the symbol level. My layout has 36 keys though so I'm unable to map all of them. Others probably have more keys, a full size keyboard has 101-104 keys.
You could try adjusting this to a u64
and see if that works as-is.
pub type ChordKeys = u32;
I also ran into this a month ago, I adjusted it to u128, not u64, and it worked fine. I can make a PR and push my changes if you want.
Not using u128, the biggest native/built-in Rust unsigned integer type is just an optimization right? I'd argue it is an unnecessary optimization since it does not make the program meaningfully or noticeably faster, because on each key press, it is just a hashmap lookup not a big compute task that needs optimization.
Curious, how are you using chords such that you're hitting the limit of 32 associated symbols? That's more than the alphabet keys on the keyboard.
a full sized keyboard has 104 keys. I've read that some keyboards even have the F12-F24 keys, so 12 extra keys, so a 116 key full sized keyboard. technically, the USB HID protocol standard supports all these distinct physical keys/scancodes.
this also means that using u128 should be about enough.
also in a defchords
group you don't just define the "symbols" which would be bound to physical keys, you also need to define in defchords
the chords that are a combination of these "symbols".
The lookup for running time (not parsing time) today is linear. Should probably change the code to sort the array and use binary search for lookup.
The lookup for running time (not parsing time) today is linear. Should probably change the code to sort the array and use binary search for lookup.
what do you mean? to be honest, I do not understand how or where it looksup the chords on each key press.
by array you mean the coords
array defined here?
and is the code for the lookup that should happen on each key press, in this part of the code:
Edit: has ChatGPT4 explained things right? https://chat.openai.com/share/ca96f711-5017-4864-ab11-93bd3403d0f0
No idea about chatgpt, I don't have an account.
But get_chord is right. Interestingly get_chord_unambiguous seems like it would be called more frequently. But I'm not sure how that could be optimized... Would be nice though to avoid iterating linearly over potentially thousands of elements.
https://github.com/jtroo/kanata/blob/main/keyberon/src/layout.rs#L543-L567
Taking another look, I think the best optimization that can be made for now is to check if the get_ calls need to be made in the first place. The checks are actually running on every tick right now, but that isn't necessary if the number of queued events hasn't changed since the last call. So probably need to store the number of queued events and do a fast-path tick-timeout-only check when the number hasn't changed.
No idea about chatgpt, I don't have an account.
Oh, sorry, just realized that they started asking for people to sign in to view shared conversations/threads. I exported the thread into markdown if you would like to view it.
expand spoiler to view thread (warning: long wall of text)
But get_chord is right. Interestingly get_chord_unambiguous seems like it would be called more frequently.
oh I thought that the relavent linear search happens on line 252: https://github.com/jtroo/kanata/blob/16c9da8df6295d294960901ecb998c8c3bdc4624/keyberon/src/action.rs#L250-L253
Would be nice though to avoid iterating linearly over potentially thousands of elements.
thousands of elements? the coords
Vec can have that many elements?
Anyways, I do not want to waste your time with unnecessary questions since I'm out of my depth here, I'm a newb in Rust, and I do not really understand how all of this chords related logic works, I only was capable of changing a type from u32
to u128
and it worked. so feel free to not answer the 2 questions above, since I see I'm not capable of contributing here, I included them just to show you my sense of understanding here.
@jtroo Thank you so much! It works as well as can be expected on my laptop keyboard. I've added it to the exporters in abbrgen https://github.com/dlip/abbrgen/tree/main?tab=readme-ov-file#kanata-chordedpy
Now I just need to get around to learning rust so I can fix #743 and start using it full time :sweat_smile:
Is your feature request related to a problem? Please describe.
I have many abbreviations for common words that I would like to write via a chord macro. Chord groups are currently limited to 32 max
Describe the solution you'd like.
I would like to be able to have a lot more possible combos, my abbreviation list currently has 5670 combos
Describe alternatives you've considered.
I have it working in qmk and zmk but it would be great to be able to use it when im stuck with my laptop
Additional context
No response