WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Bluetooth connecting to game pad (Umido)  (Read 1336 times)

Offline uutzinger

  • Newbie
  • *
  • Posts: 4
Bluetooth connecting to game pad (Umido)
« on: April 15, 2023, 11:10:51 PM »
I would like to use bluetooth gamepad Umido ESoul DH2 to control a motor project.

On raspian I can connect to to the gamepad using the desktop bluetooth manager. It creates a mouse device and I can move the mouse cursor with the gamepad.

On piCore I can pair, trust and obtain information from the gamepad but a connection attempt fails. It appears the rules to create a bluetooth mouse and keyboard are missing.

Do I simply need to copy the udev rules from the Raspian system to the piCore system?


I followed this thread to create the bluetooth connection on piCore.
http://forum.tinycorelinux.net/index.php/topic,26117.msg167671.html#msg167671

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14553
Re: Bluetooth connecting to game pad (Umido)
« Reply #1 on: April 16, 2023, 12:35:34 AM »
You could try using the blueman extension to pair once you have started bluez.

Offline CNK

  • Full Member
  • ***
  • Posts: 239
Re: Bluetooth connecting to game pad (Umido)
« Reply #2 on: April 16, 2023, 02:36:57 AM »
I followed this thread to create the bluetooth connection on piCore.
http://forum.tinycorelinux.net/index.php/topic,26117.msg167671.html#msg167671

I have had a Playstation 4 controller connected, it needs the joydev module loaded with "sudo modprobe joydev". I haven't had it working as a mouse though, that might require an extra step.

Here's my connection script for a bluetooth controller (run after bluetooth is initialised with the script I posted at the link), although I'm not sure how well I've tested it:

Code: [Select]
#!/bin/ash
# Connect to bluetooth device with mac or ID listed in file
# Run as root.

if [ -s "/home/tc/btdev_controller.txt" ]
then
modprobe joydev
echo Searching for bluetooth controllers...
dev=
while [ -z "$dev" ]
do
  sleep 1
  dev="`bluetoothctl devices | grep -f /mnt/mmcblk0p1/btdev_controller.txt`"
done
mac=`expr "$dev" : 'Device \(..:..:..:..:..:..\) '`
bluetoothctl pair $mac
bluetoothctl connect $mac
fi

Offline CNK

  • Full Member
  • ***
  • Posts: 239
Re: Bluetooth connecting to game pad (Umido)
« Reply #3 on: April 16, 2023, 06:08:48 PM »
Oops, I left in the wrong path to btdev_controller.txt in the grep command.

Code: [Select]
if [ -s "/home/tc/btdev_controller.txt" ]
then
modprobe joydev
echo Searching for bluetooth controllers...
dev=
while [ -z "$dev" ]
do
  sleep 1
  dev="`bluetoothctl devices | grep -f /home/tc/btdev_controller.txt`"
done
mac=`expr "$dev" : 'Device \(..:..:..:..:..:..\) '`
bluetoothctl pair $mac
bluetoothctl connect $mac
fi

Also it looks like I probably added the joydev module out of:
http://tinycorelinux.net/13.x/armv6/releases/RPi/src/kernel/5.10.77-piCore_modules.tar.xz
So you'll have to do that first (you can copy the joydev.ko file over and then add it to /opt/.filetool.lst). Copy from the _modules.tar.xz file that matches the PiCore build that you're using (armv6, PiCore 13.1, in that case).
« Last Edit: April 16, 2023, 06:23:39 PM by CNK »

Offline uutzinger

  • Newbie
  • *
  • Posts: 4
Re: Bluetooth connecting to game pad (Umido)
« Reply #4 on: April 17, 2023, 08:09:23 AM »
I tired with bluetooth desktop manager.

With bluetoothctl I get

Code: [Select]
info 00:00:00:33:9B:58
Device 00:00:00:33:9B:58 (public)
        Name: Umido ESoul DH2
        Alias: Umido ESoul DH2
        Class: 0x00000508
        Icon: input-gaming
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: no
        LegacyPairing: yes
        UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v0201p0009d0001
        RSSI: -41

and with connect 00:00:00:33:9B:58

Code: [Select]
Device 00:00:00:33:9B:58 Connected: yes
Device 00:00:00:33:9B:58 ServicesResolved: yes
Failed to connect: org.bluez.Error.NotAvailable
Device 00:00:00:33:9B:58 ServicesResolved: no
Device 00:00:00:33:9B:58 Connected: no

It appears either support for Human Interface Device or PnP is not available
 
More when I tried joydev approach ...

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1081
Re: Bluetooth connecting to game pad (Umido)
« Reply #5 on: April 17, 2023, 09:43:54 AM »
You likely need the uinput kernel module loaded.   But there may be others you need.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11227
Re: Bluetooth connecting to game pad (Umido)
« Reply #6 on: April 17, 2023, 10:58:16 AM »
Hi uutzinger
The  org.bluez.Error.NotAvailable  message shows up in this thread:
https://forum.tinycorelinux.net/index.php/topic,25245.msg161269.html#msg161269

That thread deals with a bluetooth keyboard, but it might contain some ideas
that apply to your situation too.

Offline CNK

  • Full Member
  • ***
  • Posts: 239
Re: Bluetooth connecting to game pad (Umido)
« Reply #7 on: April 17, 2023, 02:49:57 PM »
Code: [Select]
Device 00:00:00:33:9B:58 Connected: yes
Device 00:00:00:33:9B:58 ServicesResolved: yes
Failed to connect: org.bluez.Error.NotAvailable
Device 00:00:00:33:9B:58 ServicesResolved: no
Device 00:00:00:33:9B:58 Connected: no

That is what I remember happening before I added and loaded the joydev module. Although mine didn't automatically become a mouse after connecting, I was only looking to use it as a joystick device.

Offline uutzinger

  • Newbie
  • *
  • Posts: 4
Re: Bluetooth connecting to game pad (Umido)
« Reply #8 on: April 18, 2023, 07:30:46 AM »
Quote
The  org.bluez.Error.NotAvailable  message shows up in this thread:
https://forum.tinycorelinux.net/index.php/topic,25245.msg161269.html#msg161269

That thread deals with a bluetooth keyboard, but it might contain some ideas
that apply to your situation too.

This was helpful (and embarrassing as I read that thread before but I did not realize there was second page).
I tested it with a bluetooth keyboard and it worked, except for Ctrl-key.

Then I was able to extract joydev.ko and copied it to system. I also added a line to modules.dep so that modprobe could find it.

After modprobe uhid, uinput and joydev the game pad connected. Yeah.
After startx, the joytstick worked like a mouse and the main button as mouse-click. Great!

Thanks very much.

Next step is to figure out pybluez and pyserial, but that is for an other post....