Jump to content
  • Advertisement
Sign in to follow this  
BMF

Using SDL with Irrlicht: Reading keyboard events

This topic is 4020 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

Hello people, I'm using Irrlicht to display graphics on my current project, but I want to use SDL for some other things too, such as reading keyboard events, since I didn't find a built-in method to find if a key is down in Irrlicht. My problem is that SDL doesn't seem to recognize key events when the window created using Irrlicht's createDevice method is focused. And that's what I need. It seems to work only when a window created using SDL_SetVideoMode is focused. From the SDL documentation: "Before we can read events SDL must be initialised with SDL_Init and a video mode must be set using SDL_SetVideoMode." I was wondering if there was a way for me to be able to mix these two great creations, Irrlicht and SDL, to be able to use things such as SDL's "Uint8 *keystates = SDL_GetKeyState( NULL );". Thanks in advance. BTW, if there is a way to check if a key is currently down using Irrlicht, I'd be glad to hear about it too. ;)

Share this post


Link to post
Share on other sites
Advertisement
IrrLicht is a much higher-level library than SDL, and rather than directly exposing an array of all key-states, it uses events. Just create an event listener, and then keep track of the keys you need.

Having access to all the keystates at any time is not terribly good from an architectural perspective, since it allows no way for other segments of your app to 'capture' keys which another segment usually watches.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!