Archive:Keyboard Internationalisation: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Webbanane
(Remvoed sketched solution. Discussion about solution is now in http://www.xboxmediacenter.com/forum/showthread.php?t=26796)
>Webbanane
(added link to forum)
Line 24: Line 24:


7. Actions and scripts: finally, the symbolic key names can be assigned (mapped) to actions or scripts within keymap.xml to customize, what should happen, when a physical key is pressed.
7. Actions and scripts: finally, the symbolic key names can be assigned (mapped) to actions or scripts within keymap.xml to customize, what should happen, when a physical key is pressed.
Current discussion now at: http://www.xboxmediacenter.com/forum/showthread.php?t=26796


[[category:Inner Workings]]
[[category:Inner Workings]]
[[category:Skin Development]]
[[category:Skin Development]]
[[category:Development]]
[[category:Development]]

Revision as of 18:47, 18 June 2007

Keyboard Internationalisation

Input Processing

Different input devices can be attached to the xbmc:

  • gamepad
  • remote
  • universal remote
  • keyboard

All these devices have several hardware buttons. A keyboard can have up to 256 keys (send 256 different scancodes). Real/usual keyboards do not really have 256 keys, they have about 100+ keys, thus not all scancodes are used and can occur. The scancodes have a number from 0 to 255 (decimal). From now on till the press of one button starts an action in xbmc several mappings take place.

1. Symbolic scancode names (DirectInputKeyboard.cpp): in the source code the scancodes also have symbolic names which are more readable and comprehensible. The position of the key with the symbolic name DIK_A on the keyboard is nearly always on the left side of the keyboard and is usually labeled with A. This is the first mapping (from scancodes to key labels of english keyboards). The most common PC keys are standardized. But producers of PC keyboards always have been creative inventing unconventional keyboards with unconventional keys (e.g. 24 function-keys from IBM?, windows keys from MS). Funnily enough today there is a trend for multimedia keyboards with multimedia keys. But those unconventional keys do not have a standardized mapping or symbolic name anymore. The only chance to process such keys is processing the raw scancode, that still is in the range from 0 to 255.

2. Real label mapping/keyboard layout (DirectInputKeyboard.cpp): allthough the symbolic name always refers to the usual label of a keyboard with english layout (QWERTY), the real label is not always the same as the symbolic name suggests. (Only the physical position of the key on the keyboard should always be the same!) Keyboards that do not have an english layout, e.g. german keyboards often/always use the same physical implementation of the keyboard, that always send the same scancodes if you press the same keys on the same physical position, but those keys maybe and often are labeled different, e.g. german keyboards always interchange the labels of Y and Z (QWERTZ) in contrast to english keyboards. And nearly all other keys besides a to z and 0 to 9 are labeled different, e.g. <>,;.:-_#'+*"§$%&/()=?{[]}\ and so on. If the software ignores this fact, like xbmc does till now, such a keyboard is nearly useless. So it is necessary to make a second mapping from scancodes or symbolic names to the real labels. At the moment xbmc does not map real labels! This mapping is necessary (for other keyboards than english ones or special/individual keyboards) but does not take place in xbmc till now.

3. Simultaneous key combination mapping (DirectInputKeyboard.cpp): if the user only presses the key labeled with "1" (with the symbolic name DIK_1), the number "1" should be processed. If the user additionally presses a second key labeled with "shift" at the same time, the character "!" should be processed. Thus, pressing several physical keys should be processed as if only one totally other key has been pressed (should be "mapped").

4. Character encoding: even, if you now know, that you want to process a character "!" how should this and all the other characters be encoded binary? Historically this is done with 7 bit and ascii encoding.Unfortunately this is not enough for encoding all the possible characters that are known and needed worldwide, e.g. for german umlauts. Till now, xbmc processes only ascii and is not able to process all/any special national characters like german umlauts from keyboard input. Conceptual the simplest solution today would be the use of unicode, e.g. UTF16 (or WCHAR in the programming language C++) but this will very probably need much rework of the xbmc code and the use of most of its libraries. Solving this problem is NOT part of the solution suggested at the end of this text. The additional complicaton of special national characters like german umlauts is negligible in comparison to the mentioned problem of real label mapping, at least for german keyboards. Nevertheless this is the next problem of (keyboard input) processing and character processing in general.

5. xbmc key codes (ButtonTranslator.cpp): as mentioned at the beginning of this text, keyboard input is not the only possibility of input for xbmc. All other devices have something similar like scancodes and such mappings. All those different inputs and buttons and ascii characters are finally mapped and "merged" into one internal xbmc key code that ranges from 0 to 65535 (2^16-1 or 2 Bytes).

6. Symbolic key mapping (ButtonTranslator.cpp): it is possible to customize, what should happen in xbmc, if these buttons/keys are pressed (keymap.xml). To be able to use comprehensible names of these buttons instead of knowing their xbmc internal key code/number, there is a mapping from comprehensible key names to the internal key codes.

7. Actions and scripts: finally, the symbolic key names can be assigned (mapped) to actions or scripts within keymap.xml to customize, what should happen, when a physical key is pressed.

Current discussion now at: http://www.xboxmediacenter.com/forum/showthread.php?t=26796