Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Joystick vibration  (Read 8233 times)

0 Members and 1 Guest are viewing this topic.

CastleDefender

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Joystick vibration
« on: April 18, 2013, 11:51:30 am »
Hello everyone,

I'm a recent user of SFML (2.0 RC), I started using it mainly for the sound module in order to add some music and sounds in my game (http://castledefenderdevdiary.blogspot.co.uk/). But the rest of sfml seems pretty good too, so I might switch all my code from glfw to SFML.

I'm interested in the sf::Joystick class, it doesn't seem to have any option for joystick vibration right now, but will this feature be one day part of SFML?

If it isn't planned, do you have any advice on how to implement joystick vibration/rumble in C++? I'm using Xbox360  Controllers on Linux.
And if I manage to get it working, then maybe we can talk about adding the functionality to the next version of sfml.

Regards,
Nick


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Joystick vibration
« Reply #1 on: April 18, 2013, 11:58:26 am »
I have no idea how this is done on Linux. On Windows I guess you have to use XInput.
Laurent Gomila - SFML developer

CastleDefender

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Joystick vibration
« Reply #2 on: April 18, 2013, 10:44:53 pm »
After reading an interesting post from this blog: http://blog.robothaus.org/2011/12/09/gamepad-vibration-zero-to-hero/, I managed  to make my X-Box 360 controller vibrate from the terminal!

Here's what I did for those who are interested:

1) I installed the "joystick" package on my Ubuntu 12.04
Quote
sudo apt-get install joystick

2)Find on which input is the joystick connected to:
Quote
dmesg | grep X-Box
[ 9191.142998] input: Microsoft X-Box 360 pad as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/input/input22

3)Run fftest on the corresponding event (22 in my case).
(Warning  you might need to use sudo for this, but I didn't)
Quote
fftest /dev/input/event22
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event22 opened
Axes query:
Effects: Periodic Rumble
Number of simultaneous effects: 16
Upload effects[1]: Invalid argument
Upload effects[2]: Invalid argument
Upload effects[3]: Invalid argument
Enter effect number, -1 to exit

4) Try some effects (up to 16 apparently)
In my case only effect 4 (strong rumble) and effect 5 (weak rumble) worked.

This is good news, even if I'm still far from having joystick vibration in the game, now I know it's possible! Now I need to see if I can make the joystick vibrate from C++ without doing system calls!

Nick


cepro

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Joystick vibration
« Reply #3 on: December 24, 2014, 10:48:44 am »
Has this been implemented?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Joystick vibration
« Reply #4 on: January 06, 2015, 11:01:02 pm »
No, it's not yet implemented. But haptic feedback should be a lot more realistic now, considering the mobile devices are capable of that as well. :)