Thread: Generate keypresses like the Robot class in java

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    3

    Generate keypresses like the Robot class in java

    Hi

    I'm the author of rejoystick (http://rejoystick.sourceforge.net/). I want to make it to work on more platforms than GNU/Linux. It's a C program that maps joystick events to keyboard key presses. So two things are needed

    1. Be able to read from the joystick (Right now I'm using SDL)
    2. Be able to generate a key press event (Right now I'm using the Xtest library in GNU/Linux but that only works with an X server)

    1 can easily be done with SDL but 2 is harder. I found the Robot class in java which does exactly that; http://java.sun.com/j2se/1.3/docs/api/j ... Robot.html but java doesn't have bindings for SDL (well they do but they aren't that good).

    So, do you know of any cross-platform library that does what the Xtest library or the Robot class does?

    Thanks in advance!

    Samuel

  2. #2
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    I don't know of anything cross-platform, but if you want to build a version for windows, you might want to look into SendInput().
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Thanks for the quick reply.

    It's good to know how I would go about to do it in windows in case I'll have to do it specfic for each OS.

    But I was hoping I could find a library so that I don't have to worry about a lot of things when libraries get updated. The xtest library got update recently and then an errornous function call I had produced a crash, so I want to minimize the maintaing.

    Any other suggestions?

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Okay, I said that the bindings for java were bad. That's not true. I was just lazy not to try enough. Embarrassing really.

    Anyway, if I followed the tutorial on http://sdljava.sourceforge.net/documentation.html to http://byteschreck.blogspot.com/2005...-tutorial.html
    and replaced the windows directories with my Linux directories everything worked perfectly.

    So, I have found that I can now use Java to read from the joystick using sdljava and use Java to generate keypress events using the Robot class.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Default class template problem
    By Elysia in forum C++ Programming
    Replies: 5
    Last Post: 07-11-2008, 08:44 AM
  3. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  4. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  5. Replies: 5
    Last Post: 09-08-2001, 09:18 AM