[crossfire] [RFC 0/3] Work on keys.c and the keybinding system

Arvid Brodin arvidb at kth.se
Mon Oct 28 18:09:39 CDT 2013


Hi,

This patch series is meant to make keybinding usage a lot more obvious - to new
users especially, but hopefully also for the more experienced ones. Hopefully it
also makes the keys.c file a bit more maintainable.

In detail:

* Coding style fixes (so that it is at least consistent in the keys.c file).

* Show all keybindings (incl default ones) in both 'unbind' and the keybindings
dialog. (Should reduce confusion for new users.)

* Add "Any" key modifier type; New "Any" button in keybindings dialog. This lets
the user choose between having a key work regardless of modifier (Ctrl, Alt, etc)
key states, or to use the same key with different modifiers for different 
bindings. How this worked before ("All"/"Normal") was pretty unclear, even in the
code comments. (New feature/bug fix.)

* Consistent use of hash helper functions (keybind_insert(), keybind_remove(), 
etc). This should make the code more maintainable and reduce the risk of bugs.

* Removed possibility to rebind Ctrl, Shift, Alt, Meta modifiers. This feature
is very unusual and breaks the normal design pattern of using the designated 
keys as keyboard modifiers.

* Better usage texts (among other things they used '[' which was interpreted as 
a style tag, making parts of the usage text go missing). (Bug fix.)

* Bind only lowercase keys - we handle Shift state separately. (Bug fix.)

* Rehash keybind entry on key dialog update (fixes bug where keybinding with 
modified keyval would become unusable until restart). (Bug fix.)

* Removed -afmnr flags from 'bind' - instead use only "press the key combo you 
want" when you bind the key. This is to simplify the keybind without removing 
any real functionality.

* Per-character keys files.


I'm thinking that perhaps I should also change the flags in the keys file so
that they conform with the modifier keys? Originally they were:

[A]ll, [N]ormal, [F]ire, [R]un, A[L]t, [M]eta, [E]dit.

Now I'm writing:

[A]ny, [N]one, [F] Shift, [R] Ctrl, A[L]t, [M]eta, [E]dit.

Perhaps

[A]ny, [N]one, [S]hift, [C]trl, A[L]t, [M]eta, [E]dit.

would be a better idea? It doesn't clash with the old characters, so it's easy 
to keep the capability of reading both old and new formats. This also fits
nicely with patch #3 (character-specific keys file) in that we won't overwrite 
the old keys file, but just write new per-character ones in the new format.


Maybe also change the -d flag of 'bind' to '-i' (ignore)? Or '-a' (but -a meant 
Alt before). 


Looking forward, I would like to remove the fire_on and run_on "hacks" and
instead use a generic way to handle repeating keys. Then one would bind e.g.

KP_6: walk east
Ctrl + KP_6: attack east
Shift + KP_6: fire east



This all needs testing, so if you like it, please test it! It should apply to 
current Subversion trunk (rev 19081).

-- 
Arvid


More information about the crossfire mailing list