SDL_Keycode, mouse ? C++ |
AntTheAlchemist
|
Technically it works, but it's purely by chance that it does work.
This is very coding bad practice, specifically because SDL_BUTTON_LEFT could have the same value as SDLK_F2 and result in your else ifs not working. SDL_BUTTON_X1 and SDL_SCANCODE_A both have the value of 4. So, using your code logic, if you were to press one of the extra mouse buttons, your code would think it was the A key on the keyboard. These are the kind of bugs that are a headache to locate. |
|||||||||||
|
macrofeet
|
Thanks for the reply AntTheAlchemist, I expected this would be the case any thing like SDL_Keycode for both ?
|
|||||||||||
|
AntTheAlchemist
|
No, they can't be mixed. Store and process the inputs separately is the only way to do it.
Are you wanting to be clean or efficient by merging the checks into one GetUserInput variable? It's a bad idea, trust me. Keep them separate. Just in case you didn't already know, look at using the switch / case statements instead of stacking if / else. The compiler builds up an efficient jump table for long case lists. |
|||||||||||
|
macrofeet
|
Yea above was exactly what I was trying to accomplish, decided to ditch the mouse as it was only duplicating key presses, started of with a working case statement, currently combining keys for Game menu & get keys for main game, case statement gave me brain ache working out logic.
|
|||||||||||||||
|