[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Multiple keyboard



On 11-11-07 06:38 AM, René Dudfield wrote:
Hi,

You're using X right?  I can't find a way with Xlib to find which
keyboard generated the event.  I also don't have an extra keyboard to
plugin at the moment.

Try running 'xev' in a terminal.  Then press a key on each keyboard, and
see if there are any differences in the output.

They should print something like this:
"""
KeyPress event, serial 36, synthetic NO, window 0x4600001,
     root 0xad, subw 0x0, time 223972330, (-345,178), root:(450,225),
     state 0x4, keycode 54 (keysym 0x63, c), same_screen YES,
     XLookupString gives 1 bytes: (03) ""
     XmbLookupString gives 1 bytes: (03) ""
     XFilterEvent returns: False
"""

Maybe copy them back to the email so we can all have a look.



cheers,

On Fri, Nov 4, 2011 at 9:33 PM, PierreLafrance1@xxxxxxxxxxxx
<mailto:PierreLafrance1@xxxxxxxxxxxx> <PierreLafrance1@xxxxxxxxxxxx
<mailto:PierreLafrance1@xxxxxxxxxxxx>> wrote:

    Debian on Atom-PC like computer / Python / Pygame
    Thanks


    --
    Pierre


    On 11-11-04 03:07 PM, René Dudfield wrote:

        Hi,

        It might be possible to get that information with a system message.
        What platform/s do you need to support?

        cheers,

        On Fri, Nov 4, 2011 at 7:37 PM, PierreLafrance1@xxxxxxxxxxxx
        <mailto:PierreLafrance1@xxxxxxxxxxxx>
        <mailto:PierreLafrance1@xxxxxxxxxxxxxx
        <mailto:PierreLafrance1@xxxxxxxxxxxx>>
        <PierreLafrance1@xxxxxxxxxxxx <mailto:PierreLafrance1@xxxxxxxxxxxx>

        <mailto:PierreLafrance1@xxxxxxxxxxxxxx
        <mailto:PierreLafrance1@xxxxxxxxxxxx>>> wrote:

            Hi
            We have an application using a Digital Keyboard like this one :
        http://www.targus.ca/ca/____product_details.asp?sku=____AKP10CA
        <http://www.targus.ca/ca/__product_details.asp?sku=__AKP10CA>

        <http://www.targus.ca/ca/__product_details.asp?sku=__AKP10CA
        <http://www.targus.ca/ca/product_details.asp?sku=AKP10CA>>

            Now our application need many of them, and our application must
            distinguish all key from all keyboard.  For example, when
        user press
            enter from keyboard 1, we must know the KP_ENTER is from
        keyboard 1,
            and same thing for keyboard 2...n

            Is this possible with Pygame (according to our web search
        this seams
            to not feasible with Pygame, but I'm hopping you prove me
        wrong and
            we will not have to do that at SDL level... (please...)

            Thanks,

            --
            Pierre,







Hi
Sorry for late response, being busy running a business.

This is the xev output on my Ubuntu system, with 2 identical Targus keyboads. I pressed 1 on keyboard 1 and 2 on keyboard 2, then 1 on keyboard 1 and 2 on keyboard 2, etc...

KeyPress event, serial 38, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443293042, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 39, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443293186, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

MappingNotify event, serial 39, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 39, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443294033, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XmbLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443294153, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

MappingNotify event, serial 40, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 40, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443294689, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 41, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443294817, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

MappingNotify event, serial 41, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 41, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443295313, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XmbLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443295441, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

MappingNotify event, serial 42, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 42, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443295937, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 43, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443296081, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

MappingNotify event, serial 43, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 43, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443296537, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XmbLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

KeyRelease event, serial 44, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443296641, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

MappingNotify event, serial 44, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 44, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443297553, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 45, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443297633, (833,223), root:(839,249),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

MappingNotify event, serial 45, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 45, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443298049, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XmbLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

KeyRelease event, serial 46, synthetic NO, window 0x5200001,
    root 0x10b, subw 0x0, time 443298153, (833,223), root:(839,249),
    state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False


So the question is : how can I differentiate the key stroke from wich keyboard it comes from ?

Is it possible with Pygame ? Or do we have to interface with SDL ?  Other ?

Thanks

--
Pierre