Thanks for your reply, xismn. I don't think this is exactly what I needed, but I'm not sure because some of this stuff is a little over my head. I didn't even realize that you could make an array of function pointers. It sounds like something that would be very useful, but I'm not sure if it would be helpful here, as I want to call the same function, regardless of which key is pressed, as long as it's a letter or number.
Anyway, I'm trying to do this in SDL 1.2, which I realize is outdated now, but I'm kind of invested in it. Also, I probably should have mentioned that I'm using OS X.
Hmmmm... okay, your code gave me an idea: I could create a Uint8 vector, and fill it with the SDL constants for all the keys whose states I want to check: SDLK_a, SDLK_b, SDLK_c, etc. Then I could just cycle through the vector...
1 2 3 4 5 6 7 8 9 10
|
bool keypress = false;
for (iter = keyVector.begin(); iter < keyVector.end(); iter++)
{
if (keystates[*iter])
keypress = true;
}
if (keypress)
{
myFunction();
}
|
I haven't tried it yet, but it seems like this would work, right? I'm afraid this might slow down my program, though. Well, I'm going to give it a shot; I'll probably be back with more questions later. Thanks again.