Sign in to follow this  
Neith

SDL keyboard input

Recommended Posts

Greetings all! I am attempting to write a text-based adventure game with my SDL engine. Problem is, I need a good way to get the keyboard input. I've played around with ways of polling the keys and adding the SDL_GetKeyName() char to a vector. I'm wondering if anyone knows a better way? I'm unsure of how to handle key modifiers, backspaces, spaces, etc. All of the tuts I've found only deal with the usual game input (left, right movement, etc.); none deal with actually getting a string of text input. All replies are appreciated, ~Neith

Share this post


Link to post
Share on other sites
Great, that works. Thanks!

There's a slight typo in that tutorial: the comment for the line

else if( ( event.key.keysym.unicode >= (Uint16)'a' ) && ( event.key.keysym.unicode <= (Uint16)'z' ) )

...reads "//If the key is a space"

I like the other tuts by the way...can't wait to see more :o)


One more thing...how would I go about allowing appostrophies, underscores, periods, etc.?


~Neith

[Edited by - Neith on October 1, 2006 1:44:35 PM]

Share this post


Link to post
Share on other sites
while I'm at it...

I'm also trying to create the output buffer with SDL_TTF. Problem is, it only works with one line of text; I'm not sure on how to create new lines.


~Neith

Share this post


Link to post
Share on other sites
Quote:
Original post by Neith
while I'm at it...

I'm also trying to create the output buffer with SDL_TTF. Problem is, it only works with one line of text; I'm not sure on how to create new lines.


~Neith


Unfortunately you're going to have to cut up the string into sub strings, render surfaces each of those substrings then blit the rendered surfaces one after the other.

Or you can do it the way my bitmap font does it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this