Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add joy to keyboard button mapper #45

Merged
merged 4 commits into from
Oct 25, 2023
Merged

Add joy to keyboard button mapper #45

merged 4 commits into from
Oct 25, 2023

Conversation

tiopex
Copy link
Contributor

@tiopex tiopex commented Oct 10, 2023

Linux Joystick Mapper app for mapping joy/gamepad buttons to miyoo keyboard keys.

Configuration:
Provide configuration to your gamepad in file /mnt/joymap.map (as default there is configuration for xbox gamepad)
enter id or vendor and product from your gamepad (see /proc/bus/input/devices) and provide correct src numbers for buttons and axis

hint: use input_info /dev/input/event1 >>/mnt/input.log then ctrl+c to discover the correct src numbers for buttons and axis

Detailed configuration described in the attached config.pdf file

Usage:

  1. Run USB host script from gmenu2x
  2. Run joymap script from gmenu2x
  3. Connect gamepad

@Apaczer
Copy link
Member

Apaczer commented Oct 10, 2023

Not sure yet, but it does only register 2 axis on my generic gamepad and when pressed they stay in that state even after release. Couldn't map buttons - I have read src values from jstest --event /dev/input/js0. Took me some time to realize that /proc/bus/input/devices already has values in HEX of vendor and product

Here is my config:

button vendor=0x2563 product=0x0575 src=1 target=kbd button="leftalt"
button vendor=0x2563 product=0x0575 src=2 target=kbd button="leftctrl"
button vendor=0x2563 product=0x0575 src=3 target=kbd button=""
button vendor=0x2563 product=0x0575 src=4 target=kbd button="leftshift"
button vendor=0x2563 product=0x0575 src=5 target=kbd button="space"
button vendor=0x2563 product=0x0575 src=6 target=kbd button=""
button vendor=0x2563 product=0x0575 src=7 target=kbd button="tab"
button vendor=0x2563 product=0x0575 src=8 target=kbd button="backspace"
button vendor=0x2563 product=0x0575 src=9 target=kbd button="rightalt"
button vendor=0x2563 product=0x0575 src=10 target=kbd button="rightshift"
button vendor=0x2563 product=0x0575 src=11 target=kbd button="esc"


axis vendor=0x2563 product=0x0575 src=0 target=kbd plus="right" minus="left" flags=trinary
axis vendor=0x2563 product=0x0575 src=1 target=kbd plus="down" minus="up" flags=trinary

@Apaczer
Copy link
Member

Apaczer commented Oct 10, 2023

BTW u can run loadmap joymap.map from terminal to see list of available input devices to map

@tiopex
Copy link
Contributor Author

tiopex commented Oct 11, 2023

src values from jstest are incorrect. I've added input_info app (hint: input_info /dev/input/event1 >>/mnt/input.log then ctrl+c) to discover the correct src numbers for buttons and axis. Also added -d parameter to compute the calibration value so that events are reported in the range -32767 to 32767.

Can you check the values from axis in jstest after press and release?

@Apaczer
Copy link
Member

Apaczer commented Oct 11, 2023

Yes, the ranges are correct, but still the same issue on all axises. Buttons works correct after identyfing from input_info, so thanks for clarification.

I'll try the xdotool package with https://github.com/wizlab-it/joymap and see if I can get different outcome.

@tiopex
Copy link
Contributor Author

tiopex commented Oct 11, 2023

I was trying joymap with xdotool, not working at all.
You can try with different flags, binary trinary min max deadzone

@Apaczer
Copy link
Member

Apaczer commented Oct 11, 2023

Success! Had to wiggle a bit settings until I found one suitable for my joystick:

axis vendor=0x2563 product=0x0575 src=0 target=kbd minus="left" plus="right" min=0 max=255 deadzone=150 flags=trinary
axis vendor=0x2563 product=0x0575 src=1 target=kbd minus="up" plus="down" min=0 max=255 deadzone=150 flags=trinary

This will be great for frontend and other apps without complex input configuration! GJ 👍

I need to rework GMenu2X to simplify executing apps in bg, now it's a pain to do from there. Additionaly joymap.sh or linkapp should treat $1 as mapping to make enduser pick between suitable configuration.

@tiopex
Copy link
Contributor Author

tiopex commented Oct 11, 2023

I think one configuration for all will be fine, as it use product and vendor code. Like a base for all known gamepads. Can you share your config and the name of gamepad, so I will add it to the pr?

@tiopex
Copy link
Contributor Author

tiopex commented Oct 11, 2023

Also if you add param -8 to loadmap it should transform min-max from 0 255 to -32767 32767 and deadzone shouldn't be needed

…r to dynamically (during use) compute calibration value so that events are reported in the range -32767 to 32767
@Apaczer
Copy link
Member

Apaczer commented Oct 12, 2023

List of possible kbd button assigments, use name or number (if I only knew!):

esc			1
num1			2
num2			3
num3			4
num4			5
num5			6
num6			7
num7			8
num8			9
num9			10
num0			11
minus			12
equal			13
backspace		14
tab			15
q			16
w			17
e			18
r			19
t			20
y			21
u			22
i			23
o			24
p			25
[			26
]			27
enter			28
leftctrl		29
a			30
s			31
d			32
f			33
g			34
h			35
j			36
k			37
l			38
;			39
'			40
`			41
leftshift		42
\			43
z			44
x			45
c			46
v			47
b			48
n			49
m			50
,			51
.			52
/			53
rightshift		54
kpstar			55
leftalt			56
space			57
capslock		58
f1			59
f2			60
f3			61
f4			62
f5			63
f6			64
f7			65
f8			66
f9			67
f10			68
numlock			69
scrolllock		70
kp7			71
kp8			72
kp9			73
kpminus			74
kp4			75
kp5			76
kp6			77
kpplus			78
kp1			79
kp2			80
kp3			81
kp0			82
kpdot			83
f11			87
f12			88
kpenter			96
rightctrl		97
kpslash			98
sysrq			99
rightalt		100
home			102
up			103
pgup			104
left			105
right			106
end			107
down			108
pgdn			109
insert			110
delete			111
pause			119
leftmeta		125
rightmeta		126

@Apaczer
Copy link
Member

Apaczer commented Oct 12, 2023

maybe we could test if /dev/input/js0 exist, if not killall loadmap

@tiopex tiopex merged commit 1cdeb8b into MiyooCFW:master Oct 25, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants