git-developer / batocera-extra

Additional features for batocera
GNU General Public License v3.0
14 stars 0 forks source link

No motion using a DS4 controller in Cemu #4

Closed git-developer closed 10 months ago

git-developer commented 10 months ago

User fablog via discord:

Thanks for Batocera_extra. I just installed it today. I had to use MOTION_EVDEV for my DS4... with MOTION_SONY my DS4 was unresponsive. I'm not sure it works with MOTION_EVDEV...the controller is working but the aiming control with BOTW doesn't. How could I confirm the motion control is working?

git-developer commented 10 months ago

Thanks for trying batocera-extra.

Motion should work for a DS4 controller in Cemu in Batocera 38.

Please open a terminal in Batocera (via SSH or File Manager) and try the following commands to find out what's wrong:

  1. Check that extra_patches and motion_evdev are enabled:

    # batocera-services list
    extra_patches *
    motion_evdev *
    motion_nintendo -
    motion_remote -
    motion_sony -
    motion_steam_controller -
    motion_steam_deck -
    motion_wiimote -
    remote_touchpad *
    ledspicer  -
    syncthing  -
  2. Check that extra_patches have been applied successfully:

    # cat ~/logs/extra_patches.log
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86_64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citraGenerator.py
    Citra Generator was patched for cemuhook.
    
    # ls -la /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.*
    -rw-r--r-- 1 root root 7346  9. Jan 17:42 /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.py
    -rw-r--r-- 1 root root 7723 23. Jun 2023  /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.py.backup-cemuhook
    -rw-r--r-- 1 root root 6685  9. Jan 17:42 /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuControllers.py.backup-cemuhook2
  3. Check that motion_evdev is running:

    # /userdata/extra/motion_evdev/service status
    motion_evdev            2980    evdevhook2              26766
    motion_evdev            2986    evdevhook2
  4. Check that cemuControllers.py creates a motion-enabled configuration (after starting Cemu):

    # cat ~/configs/cemu/controllerProfiles/controller0.xml
    <?xml version='1.0' encoding='UTF-8'?>
    <emulated_controller>
    <type>Wii U GamePad</type>
    <controller>
      <api>SDLController</api>
      <uuid>0_030000004c050000c405000011810000</uuid>
      <display_name>Sony Computer Entertainment Wireless Controller</display_name>
      <rumble>0</rumble>
      <axis>
         <deadzone>0.25</deadzone>
         <range>1</range>
      </axis>
      <rotation>
         <deadzone>0.25</deadzone>
         <range>1</range>
      </rotation>
      <trigger>
         <deadzone>0.25</deadzone>
         <range>1</range>
      </trigger>
      <mappings>
         <entry>
         <mapping>1</mapping>
         <button>1</button>
         </entry>
         ...
      </mappings>
    </controller>
    <controller>
      <api>DSUController</api>
      <uuid>0</uuid>
      <motion>true</motion>
      <ip>localhost</ip>
      <port>26766</port>
    </controller>

Please report if any of these commands give different results on your machine.

flelard commented 10 months ago

Thanks for your help :) Here at the logs. Step 3 isn't good!

  1. extra_patches *
    motion_evdev *
    motion_nintendo -
    motion_remote -
    motion_sony -
    motion_steam_controller -
    motion_steam_deck -
    motion_wiimote -
    remote_touchpad -
    ledspicer  *
    syncthing  -
  2. Installing archlinux package patch in revision 2023-08-03
    Downloading package from https://archive.archlinux.org/repos/2023/08/03/core/os/                                                                                                                                                             x86_64/patch-2.7.6-10-x86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    '/userdata/system/.xbmc' -> '/.xbmc'
    '/userdata/system/.cache/openbox' -> '/.cache/openbox'
    '/userdata/system/.local/state' -> '/.local/state'
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
    Installing archlinux package patch in revision 2023-08-03
    Using locally cached file /userdata/system/.cache/arch-packages/patch-2.7.6-10-x                                                                                                                                                             86_64.pkg.tar.zst
    Installing package from /userdata/system/.cache/arch-packages/patch-2.7.6-10-x86                                                                                                                                                             _64.pkg.tar.zst
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    patching file /usr/lib/python3.11/site-packages/configgen/generators/cemu/cemuCo                                                                                                                                                             ntrollers.py
    Cemu Generator was patched for cemuhook.
    patching file /usr/lib/python3.11/site-packages/configgen/generators/citra/citra                                                                                                                                                             Generator.py
    Citra Generator was patched for cemuhook.
  3. Nothing is showing

<?xml version='1.0' encoding='UTF-8'?>
<emulated_controller>
  <type>Wii U GamePad</type>
  <controller>
    <api>SDLController</api>
    <uuid>0_050000004c050000cc09000000810000</uuid>
    <display_name>Wireless Controller</display_name>
    <rumble>0</rumble>
    <axis>
      <deadzone>0.25</deadzone>
      <range>1</range>
    </axis>
    <rotation>
      <deadzone>0.25</deadzone>
      <range>1</range>
    </rotation>
    <trigger>
      <deadzone>0.25</deadzone>
      <range>1</range>
    </trigger>
    <mappings>
      <entry>
        <mapping>1</mapping>
        <button>1</button>
      </entry>
      <entry>
        <mapping>2</mapping>
        <button>0</button>
      </entry>
      <entry>
        <mapping>3</mapping>
        <button>3</button>
      </entry>
      <entry>
        <mapping>4</mapping>
        <button>2</button>
      </entry>
      <entry>
        <mapping>5</mapping>
        <button>9</button>
      </entry>
      <entry>
        <mapping>6</mapping>
        <button>10</button>
      </entry>
      <entry>
        <mapping>7</mapping>
        <button>42</button>
      </entry>
      <entry>
        <mapping>8</mapping>
        <button>43</button>
      </entry>
      <entry>
        <mapping>9</mapping>
        <button>6</button>
      </entry>
      <entry>
        <mapping>10</mapping>
        <button>4</button>
      </entry>
      <entry>
        <mapping>11</mapping>
        <button>11</button>
      </entry>
      <entry>
        <mapping>12</mapping>
        <button>12</button>
      </entry>
      <entry>
        <mapping>13</mapping>
        <button>13</button>
      </entry>
      <entry>
        <mapping>14</mapping>
        <button>14</button>
      </entry>
      <entry>
        <mapping>15</mapping>
        <button>7</button>
      </entry>
      <entry>
        <mapping>16</mapping>
        <button>8</button>
      </entry>
      <entry>
        <mapping>17</mapping>
        <button>45</button>
      </entry>
      <entry>
        <mapping>18</mapping>
        <button>39</button>
      </entry>
      <entry>
        <mapping>19</mapping>
        <button>44</button>
      </entry>
      <entry>
        <mapping>20</mapping>
        <button>38</button>
      </entry>
      <entry>
        <mapping>21</mapping>
        <button>47</button>
      </entry>
      <entry>
        <mapping>22</mapping>
        <button>41</button>
      </entry>
      <entry>
        <mapping>23</mapping>
        <button>46</button>
      </entry>
      <entry>
        <mapping>24</mapping>
        <button>40</button>
      </entry>
      <entry>
        <mapping>25</mapping>
        <button>7</button>
      </entry>
    </mappings>
  </controller>
  <controller>
    <api>DSUController</api>
    <uuid>0</uuid>
    <motion>true</motion>
    <ip>localhost</ip>
    <port>26762</port>
  </controller>
git-developer commented 10 months ago

Looks like Cemu is configured for motion_sony instead of motion_evdev, because the cemu config contains the wrong port 26762 (it should be 26766). To be sure:

  1. Check the port in your batocera configuration (probably gives port 26762 on your machine):
    # grep cemuhook ~/batocera.conf
    3ds.citra_motion_device=engine:cemuhookudp
    wiiu.cemuhook_server_ip=localhost
    wiiu.cemuhook_server_port=26766
  2. Check if motion_sony is running (probably gives some output on your machine):
    # /userdata/extra/motion_sony/service status

To fix it:

  1. Disable MOTION_EVDEV, either from the Batocera menu (you have to leave the menu to see an effect) or by running # batocera-services stop motion_evdev && batocera-services disable motion_evdev
  2. After that, enable MOTION_EVDEV, either from the Batocera menu or by running # batocera-services enable motion_evdev && batocera-services start motion_evdev

To verify the fix, check that batocera.conf contains the port for motion_evdev:

# grep cemuhook ~/batocera.conf
3ds.citra_motion_device=engine:cemuhookudp
wiiu.cemuhook_server_ip=localhost
wiiu.cemuhook_server_port=26766
git-developer commented 10 months ago

There's one more thing that you can check. The following command should output motion_evdev only and not motion_sony:

# /userdata/extra/bin/extra-services status
Service                 PID     Name                    Port    Comment
motion_evdev            2801    evdevhook2              26766
motion_evdev            2807    evdevhook2

If motion_sony is listed, disable it either from the Batocera menu or by running

# batocera-services stop motion_sony && batocera-services disable motion_sony
flelard commented 10 months ago

After the fix here what I get:

  1. [root@BATOCERA /userdata/system]# grep cemuhook ~/batocera.conf
    3ds.citra_motion_device=engine:cemuhookudp
    wiiu.cemuhook_server_ip=localhost
    wiiu.cemuhook_server_port=26762
  2. [root@BATOCERA /userdata/system]# /userdata/extra/motion_sony/service status
    [root@BATOCERA /userdata/system]#
  3. [root@BATOCERA /userdata/system]# /userdata/extra/bin/extra-services status
    Service                 PID     Name                    Port    Comment
    [root@BATOCERA /userdata/system]#
git-developer commented 10 months ago

Hm... looks like motion_evdev is not running.

Does the output of the following command show any errors?

# cat ~/logs/motion_evdev.log
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1-x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Using locally cached file /userdata/system/.cache/arch-packages/upower-1.90.2-1-x86_64.pkg.tar.zst
Installing package from /userdata/system/.cache/arch-packages/upower-1.90.2-1-x86_64.pkg.tar.zst
Installing archlinux package libimobiledevice in revision 2023-08-03 from repo extra
Using locally cached file /userdata/system/.cache/arch-packages/libimobiledevice-1.3.0-9-x86_64.pkg.tar.zst
Installing package from /userdata/system/.cache/arch-packages/libimobiledevice-1.3.0-9-x86_64.pkg.tar.zst
Installing archlinux package libplist in revision 2023-08-03 from repo extra
Using locally cached file /userdata/system/.cache/arch-packages/libplist-2.3.0-2-x86_64.pkg.tar.zst
Installing package from /userdata/system/.cache/arch-packages/libplist-2.3.0-2-x86_64.pkg.tar.zst
Installing archlinux package openssl in revision 2023-08-03
Using locally cached file /userdata/system/.cache/arch-packages/openssl-3.1.2-1-x86_64.pkg.tar.zst
Installing package from /userdata/system/.cache/arch-packages/openssl-3.1.2-1-x86_64.pkg.tar.zst
Installing archlinux package libusbmuxd in revision 2023-08-03 from repo extra
Using locally cached file /userdata/system/.cache/arch-packages/libusbmuxd-2.0.2-3-x86_64.pkg.tar.zst
Installing package from /userdata/system/.cache/arch-packages/libusbmuxd-2.0.2-3-x86_64.pkg.tar.zst
Marked dbus-python==1.2.18 as installed.
Found device Sony Computer Entertainment Wireless Controller Motion Sensors (unique identifier '84:17:66:61:8e:e3') - connecting... done!

Is your controller connected via bluetooth or USB? Debugging is simpler with USB.

flelard commented 10 months ago

I connected via USB now. Here the log:

[root@BATOCERA /userdata/system]# cat ~/logs/motion_evdev.log
Installing archlinux package upower in revision 2023-08-03 from repo extra
curl: (18) Error
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1                                                        -x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1                                                        -x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1                                                        -x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1                                                        -x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.1                                                        -x86_64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03                                                        ' and arch 'x86_64'
git-developer commented 10 months ago

Thanks. I can reproduce the problem. I need some time to find out what's going on.

Workaround:

  1. Unzip 2023-08-03.extra.packages.zip in the directory /userdata/system/.cache/arch-packages/, so that it looks like this:
    # ls -la /userdata/system/.cache/arch-packages/2023-08-03.extra.packages
    -rw-r--r-- 1 root root 550958 22. Okt 05:37 /userdata/system/.cache/arch-packages/2023-08-03.extra.packages
  2. Either dis- and enable motion_evdev once more, or simply reboot.

/userdata/extra/bin/extra-services status should list motion_evdev after that.

flelard commented 10 months ago

Yeah!! It works now, thank you :) I had to dis- and enable motion_evdev because reboot didn't work.

git-developer commented 10 months ago

Nice to hear that!

git-developer commented 10 months ago

I analyzed the problem and committed a fix.

motion_evdev requires a few dependencies that are not part of batocera. These libraries are downloaded from the Arch linux repository. The version numbers of these libraries is not hardcoded in batocera-extra but will be determined based on a date that corresponds to the batocera version. For example, Batocera 38 requires Arch libraries from 2023-08-03.

Problem: when the version numbers were requested from the Arch server via HTTP, the response failed because the server closed the connection before the response has been received completely by the client. Unfortunately, there's no fix for this behavior on client side. To workaround this behavior, batocera-extra now contains an offline cache of these version numbers so that no HTTP request is required. This cache has to be updated for each Batocera release (by the maintainer of batocera-extra). When the cache is missing, version numbers are requested via HTTP.

A better long term fix could be to integrate the dependencies into Batocera so that they don't need to be downloaded at all.

vickscripts commented 6 months ago

Sorry to reopen this but I'm having a similar issue but in aarch64 and v39. Haven't figured out how to fix it yet on my own batocera-bcm2711-bcm2711-39-20240228.img

Using up-to-date local file /userdata/system/.cache/evdevhook2/evdevhook2-v1.0.2-aarch64.AppImage
Installing archlinux package upower in revision 2023-08-03 from repo extra
Error: No URL found in repo 'extra' for package 'upower' in revision '2023-08-03' and arch 'aarch64'