Gamepad vibration in raspberry pi with Python don't work - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Gamepad vibration in raspberry pi with Python don't work (/thread-16632.html) |
Gamepad vibration in raspberry pi with Python don't work - sleepwalk - Mar-07-2019 Before starting the post, thanks in advance for your time! 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 . 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: 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 Any help will be appreciated even any encouragement :P Thanks! |