I have a Raspberry Pi 3b+ setup that controls a robot. I am looking to control it using a small wireless bluetooth button.
After much research I was able to get this button connected https://www.amazon.com/HITSLAM-Bluetooth-Remote-Control/dp/B07L9V5FLL/
I use Pynput (https://pypi.org/project/pynput/) to listen for keypresses from it, using this code:
from pynput import keyboard
def on_press(key):
try:
print('alphanumeric key {0} pressed'.format(
key.char))
except AttributeError:
print('special key {0} pressed'.format(
key))
def on_release(key):
print('{0} released'.format(
key))
if key == keyboard.Key.esc:
# Stop listener
return False
# Collect events until released
with keyboard.Listener(
on_press=on_press,
on_release=on_release) as listener:
listener.join()
Currently when I press the Bluetooth button I get the following output:
alphanumeric key None pressed
Which I understand to mean the key isn't mapped to anything. I am able to use "None" to use the button to trigger events, so that is OK for my purposes.
Here's where I get lost. When I RELEASE the button I get:
<269025043> released
by comparison when I press a regular keyboard key like "a" I get:
alphanumberic key a pressed
au'a' released
The even more confusing thing is, when you HOLD the button down, it constantly sends the None signal (I didn't time it, but approx every 1/10th of a second) AND raises the VOLUME of the Raspberry Pi. I have no idea why or how to control that functionality.
So questions...
1) Is there any way to map the first key to something other than "None"?
2) What exactly does that 9 digit number code correspond to? It doesn't seem to be a keycode, a character or anything I can match but it is returned by key()
3) Can I stop it from autorepeating? I'm afraid I cannot if it's driver based.
4) Is there any way to figure out why the repeating signal is raising volume? I would think in order for it to have functionality like that it would need to send a signal other than None
Thanks so much for any help or insight into how to proceed next!