Hei all

We were doing a very simple prototype for a cross platform python game (same
code on s60, 770 and desktop) , and at least in the pygame(python + sdl) it
was so simple to make the bitmap solution (even with cap and simbols) take
less then a couple of hours to prototype (not clean coding etc)

Of course I cannot assure that we supported languages like hungarian, or
even our brasilian portuguese, but for the game input was ok and made in
just one day.

So I agree with jacub, if you  really need, go and make a simple thing for
you the fits your need. It's not a problem at all.

I had a lot more problems with the DOOM, that needed more visual controls
then a keyboard : / but at least was playable in the end and showed
something :
maybe you don't need a full keyboard =)

http://www.marceloeduardo.com/blog/wp-content/uploads/2007/01/picture-8.png


Together goes the keyboard for the demo in python (you can bring it easily
to C)

Obs : this was a fast prototype of a non-python developer =) so do not look
at with demanding eyes =)

BR

Marcelo Oliveira
INdT - Recife
www.marceloeduardo.com

---------
( http://www.marceloeduardo.com/blog/wp-content/uploads/2007/01/2.png )
class KeyBoard:

   # Constructor
   def __init__(self, people):
       self.show = 0
       self.shift = 0
       self.msg = ""
       self.whisper = ""
       self.text = 0
       self.people = people
       self.lower_keys = pygame.image.load("pixmaps/keyboard-lower.png")
       self.upper_keys = pygame.image.load("pixmaps/keyboard-upper.png")
       self.keymap1 = (("q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
"[", "]", "1", "2", "3"),
                       ("a", "s", "d", "f", "g", "h", "j", "k", "l", ";",
"`", "'", "4", "5", "6"),
                       ("z", "x", "c", "v", "b", "n", "m", ",", ".", "?",
"!", "+", "7", "8", "9"),
                       (" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", "-", "0", "="))
       self.keymap2 = (("Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
"{", "}", "!", "@", "#"),
                       ("A", "S", "D", "F", "G", "H", "J", "K", "L", ":",
"\"", "/", "$", "%", "^"),
                       ("Z", "X", "C", "V", "B", "N", "M", "<", ">", "?",
"~", "\\", "&", "*", "("),
                       (" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", "_", ")", "+"))

   # Create text
   def create_text(self):
       if self.msg != "":
           self.text = font.render(self.msg, 1, (255, 255, 255))
           if self.text.get_width() > 484:
               self.text = self.text.subsurface(self.text.get_width() -
484, 0, 484, self.text.get_height())
       else:
           self.text = 0

   def set_whisper(self, name):
       self.show = 1
       self.whisper = name

   # Update keyboard state
   def update(self, event):
       if event.type == KEYDOWN and event.key == K_RETURN:
           self.whisper = ""
           self.show = not self.show
       elif self.show and event.type == MOUSEBUTTONDOWN:
           x, y = pygame.mouse.get_pos()
           if x >= 7 and x < 472 and y >= 347 and y < 471:
               x = (x - 7) / 31
               y = (y - 347) / 31
               if x == 0 and y == 3:
                   self.shift = not self.shift
               else:
                   if self.shift:
                       self.msg += self.keymap2[y][x]
                   else:
                       self.msg += self.keymap1[y][x]
                   self.create_text()
           elif x >= 472 and x < 505 and y >= 347 and y < 378:
               self.msg = self.msg[:-1]
               self.create_text()
           elif x >= 472 and x < 505 and y >= 378 and y < 441 and
self.msg.strip() != "":
               self.people.msg_me(self.msg, self.whisper)
               self.show = 0
               self.text = 0
               self.msg = ""
               self.whisper = ""
           elif x >= 472 and x < 505 and y >= 441 and y < 471:
               self.whisper = ""
               self.show = not self.show

   # Draw keyboard
   def draw(self):
       if self.show:
           if self.shift:
               map.blit(self.upper_keys, (0, 302))
           else:
               map.blit(self.lower_keys, (0, 302))
           if self.text:
               map.blit(self.text, (14, 315))






On Jan 26, 2007, at 6:09 PM, Kees Jongenburger wrote:

On 1/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Kees Jongenburger wrote:
I have been asking
around but did not find a simple pluggable virtual keyboard for sdl.

This is IMHO a very simple problem. Just a quick guess: You have to draw a
nice keyboard,
export it to BMP and load it with SDL_LoadBMP(). Then you display (blit) it
with
SDL_BlitSurface(). Don't forget to update the screen with SDL_UpdateRects().
Then you can
SDL_WaitEvent() to wait for SDL_MOUSEBUTTONDOWN events. You just need a
table
which contains the x and y coords of our virtual keyboard to decode coords
to the key
pressed. Of course you should handle shift, delete and something else. The
decoded char
can now be displayed, you probably need some kind of "displaying a
text"-function (sfont.c)
for it. And so on. This all can be packed in a function like "char
*SDL_EnterText()".

An other problem would be to incoperate such a virtual SDL keyboard to the
large number of
different SDL-GUI toolkits.

For the most number of action games, you don't need to enter text during
game play. Its
enough if you do this on startup, and therefor you can use a Maemo startup
window.
This sounds good and easy to me.The bmp can even have alpha! and
perhaps the code is already there?

http://www.mulliner.org/nokia770/feed/fotos/n770_xkbdbthid_02.png
greetings

keesj
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


On 1/26/07, Kees Jongenburger <[EMAIL PROTECTED]> wrote:

On 1/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Kees Jongenburger wrote:
> > I have been asking
> > around but did not find a simple pluggable virtual keyboard for sdl.
>
> This is IMHO a very simple problem. Just a quick guess: You have to draw
a nice keyboard,
> export it to BMP and load it with SDL_LoadBMP(). Then you display (blit)
it with
> SDL_BlitSurface(). Don't forget to update the screen with
SDL_UpdateRects(). Then you can
> SDL_WaitEvent() to wait for SDL_MOUSEBUTTONDOWN events. You just need a
table
> which contains the x and y coords of our virtual keyboard to decode
coords to the key
> pressed. Of course you should handle shift, delete and something else.
The decoded char
> can now be displayed, you probably need some kind of "displaying a
text"-function (sfont.c)
> for it. And so on. This all can be packed in a function like "char
*SDL_EnterText()".
>
> An other problem would be to incoperate such a virtual SDL keyboard to
the large number of
> different SDL-GUI toolkits.
>
> For the most number of action games, you don't need to enter text
during  game play. Its
> enough if you do this on startup, and therefor you can use a Maemo
startup window.
This sounds good and easy to me.The bmp can even have alpha! and
perhaps the code is already there?

http://www.mulliner.org/nokia770/feed/fotos/n770_xkbdbthid_02.png
greetings

keesj
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers




--
Marcelo Eduardo Moraes de Oliveira
-----------------------------------------------------
Just  Handful of nothing
http://www.marceloeduardo.com
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers

Reply via email to