?
Round 2
Ok, the following is what I think we have decided and some open
questions.
Text Input Event
This event returns the fully modified text generated by a sequence of
characters. This is how you get the input from an IME or get control x
from the keyboard.
SDLKey
SDLKey is an unsigned 32 bit integer. Its values come from two distinct
sets. It can either hold a Unicode code point or a value from the
SDLPhysicalKey enumeration. Values in the enumeration are distinguished
from Unicode code points by a single “magic”.
The name and location of the magic bit have not been determined, but I
would suggest SDL_KEY_BIT and I would suggest putting it in bit 30. Bit
30 is better than bit 31 because of sign extension in left shifts and
the possibility of making the value negative even though it is an
unsigned value.
When returned by an SDL function the Unicode code point is always the
unmodified character on the key. That means the effect of num lock,
shift lock, shift, ctrl, alt, super, and any other modifier keys are
ignored.
Key Press/Release Event
Within the limits of what is possible and practical this event returns
the SDLPhysicalKey value that is closest to the actual location of the
key on the keyboard (as defined by USB HID usage tables, version 1.12
http://www.usb.org/developers/devclass_docs/Hut1_12.pdf, section “10
Keyboard/Keypad Page (0x07)”. This information is meant to provide
positional information, not the key name on any particular keyboard.
The only open question is what to do with the Unicode field of the
event. Should we return the Unicode code point when it is available? If
so, these would be unmodified values that are compatible with the
definition of SDLKey given above.
SDL_GetLayoutKey()
Given an SDLKey value from a key press/release event this function
converts it to either an unmodified Unicode code point representing the
label of the key or it returns a member of the SDLPhysicalKey
enumeration that matches the function of the key.
SDL_GetKeyName()
What this function returns seems to have become an open question. I’m
going along with Sam and suggesting that it should return a pointer to
the string for the name of the key in the SDLPhysicalKey enumeration
minus the leading “SDL_”. That means that when given the values:
SDL_KP_1 == "KP_1"
SDL_F6 == “F6”
and so on…
If passed a Unicode code point this function would simply return it.
Classification Functions.
This is a very open question. There was some discussion about the need
to be able to classify SDLKey values so you could quickly find out if a
key is a modifier, a command key, a key pad key, and so on. It looks
like this could be handled with a table and an enumeration of the key
class bits. Does any one feel the need for this feature?
Bob Pendleton--
±-------------------------------------+
- Bob Pendleton: writer and programmer +
- email: Bob at Pendleton.com +
- web: www.GameProgrammer.com +
- www.Wise2Food.com +
- nutrient info on 7,000+ common foods +
±-------------------------------------+