Force feedback or vibration on gamepad - Naohiro2g/gamepad-tester GitHub Wiki

pygameは、SDLのgamepad/joystickサポートを利用している。SDL2で強化されるので、SDL2ベースに移行するpygame2に期待。 PS4-Dualshock4のバイブ、ランブルも使えるようになるはず。

「SDL2 Gets Better Support For Xbox / PS4 / Nintendo Switch Pro Controllers」 https://www.phoronix.com/scan.php?page=news_item&px=SDL2-HIDAPI-Joystick-Drivers SDL2.0.9 https://hg.libsdl.org/SDL/rev/399cc39583cc

「rumble sample」 https://lazyfoo.net/tutorials/SDL/20_force_feedback/index.php 「SDL2 wiki Force Feedback Support」 https://wiki.libsdl.org/CategoryForceFeedback

「Game Controller API in SDL2」 http://5pmcasual.com/post/sdl2-game-controllers/

「SDL2 Gamepad Tool」Macで動いた。 http://www.generalarcade.com/gamepadtool/ https://github.com/gabomdq/SDL_GameControllerDB

「The Linux Kernel Force feedback for Linux」

https://www.kernel.org/doc/html/latest/input/ff.html

ラズパイでチェック。 sudo apt-get install joystick 以下のパッケージが新たにインストールされます: inputattach joystick

fftestコマンドのチェック PS4のコントローラーで、#0, #4, #5のeffectが動いた。Switch ProConはダメだった。 0 Periodic sinusoidal ピカピカ、振動 4 Strong rumble, with heavy motor ピカx3、振動も? 5 Weak rumble, with light motor ピカx1

fftest /dev/input/event2
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event2 opened
Features:
  * Absolute axes: X, Y, Z, RX, RY, RZ, Hat 0 X, Hat 0 Y, 
    [3F 00 03 00 00 00 00 00 ]
  * Relative axes: 
    [00 00 ]
  * Force feedback effects types: Periodic, Rumble, Gain, 
    Force feedback periodic effects: Square, Triangle, Sine, 
    [00 00 00 00 00 00 00 00 00 00 03 07 01 00 00 00 ]
  * Number of simultaneous effects: 16

Setting master gain to 75% ... OK
Uploading effect #0 (Periodic sinusoidal) ... OK (id 0)
Uploading effect #1 (Constant) ... Error: Invalid argument
Uploading effect #2 (Spring) ... Error: Invalid argument
Uploading effect #3 (Damper) ... Error: Invalid argument
Uploading effect #4 (Strong rumble, with heavy motor) ... OK (id 1)
Uploading effect #5 (Weak rumble, with light motor) ... OK (id 2)
Enter effect number, -1 to exit