Re: [pygame] Multiple keyboard

2011-11-19 Thread pierrelafran...@sympatico.ca

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 0x461,
 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, pierrelafran...@sympatico.ca
mailto:pierrelafran...@sympatico.ca pierrelafran...@sympatico.ca
mailto:pierrelafran...@sympatico.ca 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, pierrelafran...@sympatico.ca
mailto:pierrelafran...@sympatico.ca
mailto:PierreLafrance1@__sympatico.ca
mailto:pierrelafran...@sympatico.ca
pierrelafran...@sympatico.ca mailto:pierrelafran...@sympatico.ca

mailto:PierreLafrance1@__sympatico.ca
mailto:pierrelafran...@sympatico.ca 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 0x521,
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 0x521,
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 0x521,
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 0x521,
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 0x521,
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 0x521,
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 0x521,
root 0x10b, subw 0x0, time 443295313, 

Re: [pygame] more basic python lists question

2011-11-19 Thread Russell Jones
I don't know if it was intentional, but that's a masterful play on words if
so :)

On 19 November 2011 03:41, Jake b ninmonk...@gmail.com wrote:

 That's called 'list comprehension':
 http://docs.python.org/tutorial/datastructures.html#list-comprehensions

 On Thu, Nov 17, 2011 at 8:14 PM, Lee Buckingham 
 lee.bucking...@gmail.comwrote:




 filenames = [f for f in filenames if f.endswith(.png)]



 Slick!  I learn so much listening to you guys and your questions.




 --
 Jake



Re: [pygame] Multiple keyboard

2011-11-19 Thread Miriam English
It looks like the serial value changes each time you use a different 
keyboard. I tried pressing 1 then 2 on one keyboard and found the 
serial number doesn't change. Interesting.


Unfortunately when you input from another keyboard the serial number 
just seems to increment. With just 2 keyboards I guess this should be a 
matter of _even_ serial numbers being from one keyboard, and _odd_ 
serial numbers being from the other keyboard.


I'm not sure how you detect the serial numbers from python though. 
Perhaps someone else here knows more about this stuff.


Best wishes,

- Miriam

pierrelafran...@sympatico.ca wrote:


KeyPress event, serial 38, synthetic NO, window 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 root 0x10b, subw 0x0, time 443297553, (833,223), root:(839,249),

Re: [pygame] Multiple keyboard

2011-11-19 Thread Alec Bennett
Have you tried the pyHooks module? It can hook the keyboard at what might
be a lower level than pygame. I know, for example, that it works whether or
not the application has focus.

There's a demo script that prints all the info about a given keystroke,
maybe there's something in it that differentiates multiple keyboards.

Apologies if this was already mentioned.




On Sat, Nov 19, 2011 at 2:15 PM, Miriam English m...@miriam-english.orgwrote:

 It looks like the serial value changes each time you use a different
 keyboard. I tried pressing 1 then 2 on one keyboard and found the
 serial number doesn't change. Interesting.

 Unfortunately when you input from another keyboard the serial number just
 seems to increment. With just 2 keyboards I guess this should be a matter
 of _even_ serial numbers being from one keyboard, and _odd_ serial numbers
 being from the other keyboard.

 I'm not sure how you detect the serial numbers from python though. Perhaps
 someone else here knows more about this stuff.

 Best wishes,

- Miriam


 pierrelafran...@sympatico.ca wrote:


 KeyPress event, serial 38, synthetic NO, window 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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 0x521,
 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