Mapping ascii to keyboard syms

Noticing line 38 of SLD_keysysm.h, it says:
/* The keyboard syms have been cleverly chosen to map to ASCII */

I can’t seem to figure out how to take advantage of this. For example, how
would I map the SDL_RETURN key to “fire the BFG”. I’d like the proper key to
sit in a data file and then parse this data file in the code. Something like this:

///////////////////////
//data.dat
SDL_RETURN

EOF
///////////////////////

///////////////////////
// foobar.cpp
//

void Load()
{
ifstream fin(“data.dat”);
string strFire;
fin >> strFire;
// Now “SDL_RETURN” should be sitting in fire

// Need to get SDL_RETURN into kFire
SDLKey kFire = static_cast<SDLKey>(atoi(strFire.c_str()));

}

Is this the correct way?

P.

Parveen Kaler wrote:
[…]

void Load()
{
ifstream fin(“data.dat”);
string strFire;
fin >> strFire;
// Now “SDL_RETURN” should be sitting in fire

// Need to get SDL_RETURN into kFire
SDLKey kFire = static_cast<SDLKey>(atoi(strFire.c_str()));

}

Sorry, to reply to my own post. But to clarify my question, I guess I’m asking is:

atoi(“SDL_RETURN”) == SDL_RETURN

true for all SDLKeys?

P.

atoi(“SDL_RETURN”) == SDL_RETURN

true for all SDLKeys?

atoi(“random string”) is always zero.

atoi(“13”) is 13 and atoi(“15.2”) is 15.

Strings and numbers are not interchangable like that, and SDLK_RETURN
means nothing at runtime; when compiling it gets replaced with a number
(13, I think).

SDL is a bad place to start learning C.

–ryan.