Jump to content
  • Advertisement
Sign in to follow this  
Neith

SDL keyboard input

This topic is 4280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!