PDA

View Full Version : Use SDL to add keypress to keyboard buffer?



paul_nicholls
18-12-2006, 10:57 PM
Hi all,
I know I can get keyboard input using SDL, and even move the mouse using WarpMouse()...but is there a way of taking an SDL key symbol and simulating this key being pressed on the keyboard progmatically just like it was pressed by the user?

I would like to only use SDL to do this, or at least some cross-platform way...

I am wanting to make a virtual keyboard for the GP2X by clicking on virtual keys which add keys to the keyboard buffer. This could be handy for some programs.

cheers,
Paul.

jasonf
19-12-2006, 01:14 AM
Use an array.

Have a routine which captures SDL input codes and stores them in an array. Use this array as the core of your input system. Then when you want to programatically set keys... set the elements of the array. This system also gets around SDL's inabililty to handle key repeats ;)

paul_nicholls
19-12-2006, 05:41 AM
Use an array.

Have a routine which captures SDL input codes and stores them in an array. Use this array as the core of your input system. Then when you want to programatically set keys... set the elements of the array. This system also gets around SDL's inabililty to handle key repeats ;)

Sorry, but I don't think I was clear enough in my post :)
I want to send keypresses from my program into other running applications just like I had pressed the key(s) on the keyboard, but hopefully using SDL or another cross-platform way that is available on Windows and Linux and GP2X Linux-ARM (ultimately)...

Something similar to the keybd_event() method in Win32.
cheers,
Paul.

grudzio
19-12-2006, 11:41 AM
Create SDL_KeyboardEvent and use SDL_PushEvent function to add it to the events queue.