kokoye2007 / waitzar

Automatically exported from code.google.com/p/waitzar
Other
0 stars 1 forks source link

Unify keystroke code & fix VirtKey's alpha-vkeys. #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
#Code cleanup, needed at some point.

WaitZar uses a whole lot of different "key" identifiers: alphanumeric values, 
scancodes, hotkey identifiers, virtual key codes, and even keymagic-specific 
codes. The new VirtKey class does a LOT to reduce the complexities this 
introduces, but it doesn't go _quite_ far enough.

Here's what needs to be done:
  1) VirtKey stores the alphabet keys (a-z) with lowercase "virtual key" codes. This is flat-out wrong; VK_A - VK_Z are actually upper-case! We need to change this, and then change all places that work on this assumption. Fortunately, the "alphanum" parameter stores lowercase 'a'-'z', so we can rely on that when lowercase is appropriate.

  2) The keyboard highlighting code (and OnscreenKeyboard's whole nonsense) needs to be less reliant on hotkey values. (It also converts between way too many "internal formats").

  3) It would make sense to add a "scancode" parameter inside VirtKey, and then just add methods like getEnUSVKey() and getEnUSAlphanum() as helper functions. Since we save the scancode at the time of input, there'd be no worry about changing layouts in the middle of processing. Moreover, we could add getCurrLocaleVKey() and getCurrLocaleAlphanum() to round out the functionality, and modify getAsKeyMagicKey() to use getEnUSVKey(). At that point, we wouldn't have to worry so much about converting key codes at run-time. 

   4) All code locations that handle keystrokes should be identified, and all references to "old" style methods should be removed. The, we should heavily document VirtKey, and after that we will never have any problems ever again with confusing input.

I think the best time to do this is directly before/after we modify 
OnscreenKeyboard to handle arbitrary LetterBased input methods, since the 
majority of old code deals with that specifically.

Original issue reported on code.google.com by seth.h...@gmail.com on 21 Jun 2010 at 6:25