[Vm-dev] [Windows cog vm] [Keyboard events related] about keycode mapping

Guillermo Polito guillermopolito at gmail.com
Thu Jan 26 21:46:35 UTC 2012


On Thu, Jan 26, 2012 at 6:39 PM, Andreas Raab <andreas.raab at gmx.de> wrote:

>
>
> On 1/26/2012 22:29, Guillermo Polito wrote:
>
>
>
> Hi!
>
> On Thu, Jan 26, 2012 at 4:41 PM, Andreas Raab <andreas.raab at gmx.de> wrote:
>
>>
>>
>>
>> On 1/26/2012 15:43, Guillermo Polito wrote:
>>
>>
>>
>> The question is:
>>
>>  Should KeyDown, KeyUp and KeyChar events for the same key produce the
>> same keyCode?  I think yes.  Because the keyCode indicates the key pressed
>> in the keyboard. Doesn't it?
>>
>> It does. Which is precisely the reason why it *can't* produce different
>> values when you press the shift key with it.
>>
>>
>  The KEY you are pressing does not change depending on the modifier; your
>> OS decides that the combination of the Shift key and the P key produces an
>> uppercase P character. Similarly to the OS deciding that (when using dead
>> keys for example) pressing the accent key followed by the a key produces an
>> accented a. Would you expect the keyDown value for the accented a to change
>> as well? This way lies complete madness.
>>
>
> But you're talking about the keychar event and I've not modified at all
> it's behavior :/.  And yes, I agree I should not do any conversion on KeyUp
> and KeyDown :).
>
>
>>
>> Maybe you don't understand what these events are used for. Consider you
>> are writing a game and you're using shift and control key for primary and
>> secondary weapon action. Would you expect that the person writing the game
>> needs to handle all of the various control and shift key combos in order to
>> find out that the user pressed the a key to move forward?
>>
>
> Oh, yes I do understand.  Maybe I didn't explain me fine, sorry.
>
> The main problem is that I want keycodes to be the same through the three
> platforms (unix, mac and windows).  And for that, I have to do a mapping
> somewhere (this piece of code I wrote today was to play and see how it
> behaves, because the codes are to be defined :) ).
>
> So, I thought those conversions could be done through the *keymap* array.
> Maybe that's not the way to do the mapping, but *the* mapping should be
> done somewhere.
>
>
> The simplest place to do the mapping is inside the image.
>

But it's not about the simplest, it's about the better.  The Vm should
abstract the image from these things :/.  Tomorrow Dimitry adds support for
android specific keys, or I do it for Gtk and etc... and polluting the
image with all that seems unnecesary.



> Cheers,
>   - Andreas
>

Cheers,
Guille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120126/d3122b74/attachment.htm


More information about the Vm-dev mailing list