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

[pygame] Keyboard inputs



For my current project(which is not a game but a game
maker or "GCS" program...made entirely with Python), I
have implemented a virtualized input system; game
inputs use the virtual inputs rather than SDL-provided
ones, so as I develop it I can map "virtual joysticks"
to any device and all the code will work with it
immediately.

Now I'm getting around to implementing the virtual
keyboard, which will return an arbitrary string -
which, for devices lacking keyboards like consoles or
portables, means that an alternative means of string
input can be provided.

I had a problem, which was that it doesn't seem like
there's an "easy way" to handle the keyboard in
Pygame. Mapping all keydown events < 128 to chr()
works in a basic way, but doesn't account for shift or
ctrl. Then I found out that I could use event.unicode
to get those values and translate them to ASCII as
needed. Whew.

(I thought there was no way to do it without making my
own mapping dict, started writing this, then figured
it out. Might as well post about it.)

I should mention while I'm writing this, that I think
it would be cool if there were some virtual-input
standard so that the user could set their devices up
once and reuse them in all games, just like a console.
From both the player and developer standpoints the
main deficiency of computer games compared with
consoles is the setup process....so I really like this
idea. (cost used to be a major reason, but the gap is
pretty narrow now for entry-level computer gaming)

But it seems unlikely to gain traction outside of a
closed system like my GCS since you get issues like
"how many buttons are enough" or "what's the best way
to seperate the controls of different players" that
are hard to come to a perfect consensus on - for my
project I specify six buttons (AB/XY/Start/System) and
one joystick mapped to eight-way(four-value) digital
mappings per player. I figure that if you need more
you can allocate a second player to the same
device....but while the basics are there, I haven't
done anything to implement analog sticks, and my
design hasn't even considered things like throttles or
mice or coin-mechs yet. 

Has anyone else given thought to a universal control setup?

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com