Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Because SDL 1.3 is still a long way coming I implemented native force feedback (rumble) support for Aquaria:

However, I could not find a way to find the according event device (force feedback device) for any given joystick (gamepad) device. I looked in the SDL 1.3 source and I thought this might be how it is done:

std::ostringstream os;
os << "/dev/input/js" << sdl_index;
std::string jsdevice(os.str());
char evdevice[128];
evdevice[0] = 0;

int fd = open(jsdevice.c_str(), O_RDONLY, 0);
if (fd <= 0) {
    std::cerr << "Could not open joystick [" << jsdevice << "]: " << strerror(errno) << std::endl;

if (ioctl(fd, EVIOCGNAME(sizeof(evdevice)), evdevice) == -1) {
    std::cerr << "Could not get event device for joystick [" << jsdevice << "]: " << strerror(errno) << std::endl;


// ...

But it always just prints this:

Could not get event device for joystick [/dev/input/js0]: Invalid argument

Currently I use an environment variable to indicate the force feedback device that should be used. Does anyone know how to automatically find the correct device? What I've got is the input device as an index (e.g. the 0 in /dev/input/js0) and therefore the path.

share|improve this question

The joystick devices (/dev/input/js*) can be queried via the ioctl function code defined in "joystick.h" (codes starting with JSIOC). The general input devices (/dev/input/event*) can be queried with the codes defined in "input.h" (codes starting with EVIOC).

Of course each joystick device has an associated event input device. I do'not know if this is for true for all distributions, but on my OpenSuse system, there are mappings like


Google for libjoyrumble.c to find some example code to detect the matching event device.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.