Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Gamepad vibration in raspberry pi with Python don't work
#1
Before starting the post, thanks in advance for your time! Smile

I'm new with Python although I have some experience with C++, php, arduino...
And I'm trying to start a project with raspberry pi and Python, and I got stuck before the start Tongue .

I want to manage a gamepad through Python, I'm using an original PS3 USB gamepad and a third party Xbox360 gamepad, I only use one at time but I test both in order to avoid any compatibility problem.
The fact is I don't have any problem to read any button or axis using EVDEV or INPUTS modules in Python BUT, I can't make the vibration work.
I tried the examples that EVDEV and INPUTS modules have in their documentation, and the EVDEV vibration example doesn't give me any error or feedback (simple doesn't work) and INPUTS with this example:

"""Simple example showing how to get the gamepad to vibrate."""

from __future__ import print_function
import time

import inputs


def main(gamepad=None):
    """Vibrate the gamepad."""
    if not gamepad:
        gamepad = inputs.devices.gamepads[0]

    # Vibrate left
    gamepad.set_vibration(1, 0, 1000)

    time.sleep(2)

    # Vibrate right
    gamepad.set_vibration(0, 1, 1000)
    time.sleep(2)

    # Vibrate Both
    gamepad.set_vibration(1, 1, 2000)
    time.sleep(2)


if __name__ == "__main__":
    main()
Give me this error:
Error:
pi@raspberrypi:~/Desktop $ python3 vibrate_example.py Traceback (most recent call last): File "vibrate_example.py", line 29, in <module> main() File "vibrate_example.py", line 15, in main gamepad.set_vibration(1, 0, 1000) File "/usr/local/lib/python3.5/dist-packages/inputs.py", line 2983, in set_vibration self._set_vibration_nix(left_motor, right_motor, duration) File "/usr/local/lib/python3.5/dist-packages/inputs.py", line 2969, in _set_vibration_nix code = self.__get_vibration_code(left_motor, right_motor, duration) File "/usr/local/lib/python3.5/dist-packages/inputs.py", line 2963, in __get_vibration_code buf_conts = ioctl(self._write_device, 1076905344, inner_event) OSError: [Errno 14] Bad address pi@raspberrypi:~/Desktop $


I'm under Raspbian 9.8 (Release date: 2018-11-13 Kernel version: 4.14) up to date, and Python 3.5.3.
Raspberry pi 2B+.
Under Raspbian I can read buttons with "jstest-gtk" software and make the gamepads vibration work with command "fftest". So I suppose that drivers can manage the feature.

I tried Python 3.7.2 and 2.7 with the same result.
I tried Ubuntu Mate and Python 3.6? and 2.7 with the same result.

But under my PC with Windows 7 it works, same example, same lines (Python 3.7), and also with Ubuntu 18.04 (Python 3.6).

I can't find any information about this problem on the web and I really want to use raspberry pi hardware, so I'm stuck and I can't see what's the problem that don't allow Python to access to gamepads vibration sectors in raspberry.
I suppose that maybe is a hardware/drivers change respect other architectures... or maybe I'm a really big noob and I'm missing something obvious Tongue

Any help will be appreciated even any encouragement :P Thanks!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  A question about python in Raspberry Psycopast 3 122 Aug-14-2019, 06:36 PM
Last Post: buran
  Raspberry - Python 3.7 - Installation trouble madjo1983 2 293 Jul-07-2019, 02:06 AM
Last Post: DeaD_EyE
  Install Python on Raspberry Pi 3 B+ loren41 4 695 May-03-2019, 03:13 PM
Last Post: loren41
  Python Beacon positioning and animation with Raspberry pi matplotlib joefreedy 1 431 Feb-14-2019, 08:47 PM
Last Post: joefreedy
  Python version 3 that seems to be ignored by the system on a Raspberry Pi Discret68 3 503 Dec-28-2018, 06:42 PM
Last Post: Gribouillis
  Python Idea Assist.: BerryIMU & Raspberry Pi 3 Audio Mapping StephLeber 0 581 Dec-09-2018, 10:43 AM
Last Post: StephLeber
  No route to host error when using requests.post in python on raspberry pi mariummalik22 0 1,426 Jan-06-2018, 08:34 PM
Last Post: mariummalik22

Forum Jump:


Users browsing this thread: 1 Guest(s)