Simulating keyboard input on handhelds

Previous topic - Next topic

kaotiklabs

Hi,
I?m programming a small game for Wiz and I wonder how to fill the player?s name on the highscores.
(any keyboard input in general, using only the pads or the touchscreen)

This can be implemented in two ways, at least:
1- On screen keyboard ( I know there?s some post about it, but don?t know how to apply it here)
2- Using an array of letters and the pad for looping trough them (saw it in some examples but don?t remember where)

Has anyone implemented any of those exitously and would be kind enough to share an example?
I?m kinda lost in such a silly thing.
Any help will be apreciated.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Ian Price

#1
Here is a VERY simple 3 letter name entry function using cursors and space. It allows you to delete characters and enter the name. It should be easy to understand and adapt to your needs.

Code (glbasic) Select

// Name entry
FUNCTION name_entry:

LOCAL x=0

// Actual name
LOCAL nom$=""

// Characters required (Last two chars are BACKSPACE and ENTER)
LOCAL abc$="_ ABCDEFGHIJKLMNOPQRSTUVWXYZ<!"

LOCAL press, press2

// Loop until told to exit
WHILE exit=0

IF KEY(1) THEN exit=1

// Show alphabet characters
PRINT abc$,40,100

// Alphabet cursor
PRINT "_",x*8+40,103

// Move cursor left
IF KEY(203) AND x>0 AND press=0
  DEC x,1
  press=5
ENDIF

// Move cursor right
IF KEY(205) AND x<29 AND press=0
  INC x,1
  press=5
ENDIF

// Select letter with SPACE
IF KEY(57) AND press2=0

  // Enter a letter if character is less than BACKSPACE and ENTER
  IF x<28 THEN nom$=nom$+MID$(abc$,x,1)

  // BACKSPACE
  IF x=28 THEN nom$=MID$(nom$,0,LEN(nom$)-1)

  // ENTER
  IF x=29 THEN exit=1

  press2=10
ENDIF

// Cursor X number position
PRINT x,10,10

// Limit name to only 3 characters
IF LEN(nom$)>3 THEN nom$=MID$(nom$,0,LEN(nom$)-1)

// Show where name will appear
PRINT "___",150,123

// Show name
PRINT nom$,150,120

// Reduce key repeat speed
IF press>0 THEN DEC press,1
IF press2>0 THEN DEC press2,1

SHOWSCREEN

WEND

PRINT "NAME="+nom$,10,10

SHOWSCREEN

KEYWAIT

ENDFUNCTION
I came. I saw. I played.

kaotiklabs

Thanks Ian for the code, but will be difficult to use something similar due to the screen width limitations (320 px) and the fonts I?m using.
The abecedary string won't fit.
I?m thinking about use the up and down buttons for looping trough the abecedary, showing one letter at a time.
It should be enough for my needs, but I'm still thinking about on screen keyboard.
Will have to take a deeper reading to the related post.


Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Ian Price

I'm using bitmpapped chars (8x8) on a 320x240 screen for a Wiz game, using something akin to what's above (including several additional chars) and it displays just fine. In my version I use my own bitmap font routine rather than using print though, but otherwise it's pretty much the same.

How big are your characters?

Whilst I like on-screen keyboards, I hate having to use a stylus to enter a name, then put it away again to play the game. I can't stand games that use one control method for menus and a different one for the game itself. Making the user switch from one control method to another is a real pet-hate of mine. It should be a crime, punishable by death! :P
I came. I saw. I played.

kaotiklabs

#4
Hahaha, I agree with you Ian, mine is touch controled :P

So I should better go this way or I?ll be in danger hehe.

I?ve been reading carefully Yommi?s post about on screen keyboard but can?t locate the full source code.
Yommi seems to be out since near a year, could anyone post the full code or send it to me?

Eitherway I?ll try to do a quick and dirty one.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Kitty Hello

include DDGui, then DDGui_Input$()

amarliani

Or, if you want to build something on yourself:

http://www.glbasic.com/forum/index.php?topic=2676.0

But I wrote it for PC and VGA resolution and never made any smaller one, so the keyboard pics are far too big for you.

kaotiklabs

Thanks amarliani for sharing the code will be useful for my pc port :)

I have finally adopted the ddgui_input function solution but a bit customized.
Didn?t know it existed.

Thanks for the help mates.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!