jgeumlek / MoltenGamepad

Flexible Linux input device translator, geared for gamepads
MIT License
280 stars 42 forks source link

Pretty complicated to get this to work #115

Open TaiTair opened 2 years ago

TaiTair commented 2 years ago

I spent upwards of 8 hours today trying to configure moltengamepad. I followed all the documentation and reached a stalemate before opening this issue. To make my gendev I used this: https://github.com/jgeumlek/MoltenGamepad/blob/master/documentation/gendev.md To make my profile I used this: https://github.com/jgeumlek/MoltenGamepad/blob/master/documentation/profiles.md

To reach my intended goal I inspired myself from this post: https://github.com/jgeumlek/MoltenGamepad/issues/53

I'm trying to map keyboard keys to gamepad buttons and mouse movement to the joystick. Yes I am aware now that moltengamepad doesn't support mouse to joystick so I abandonned that.

I painstakingly mapped most of the events of my keyboard so that I could still use my keyboard alongside emulating a gamepad.

Here's my gendev:

# Asus built-in keyboard
[vendor=0xb05 product=0x1869]
# logitech mouse
[vendor=0x46d product=0x400a]

# Options

name = "ttrkeyboard"
devname = "kb_"
exclusive = "true"
change_permissions = "true"
flatten = "true"
rumble = "false"

# Event mappings

key_esc = "KEY_ESC", "Escape"
key_1 = "KEY_1", "Number 1"
key_2 = "KEY_2", "Number 2"
key_3 = "KEY_3", "Number 3"
key_4 = "KEY_4", "Number 4"
key_5 = "KEY_5", "Number 5"
key_6 = "KEY_6", "Number 6"
key_7 = "KEY_7", "Number 7"
key_8 = "KEY_8", "Number 8"
key_9 = "KEY_9", "Number 9"
key_0 = "KEY_0", "Number 0"
key_minus = "KEY_MINUS", "Minus"
key_equal = "KEY_EQUAL", "Equal"
key_backspace = "KEY_BACKSPACE", "Backspace"
key_tab = "KEY_TAB", "Tab"
key_q = "KEY_Q", "Q"
key_w = "KEY_W", "W"
key_e = "KEY_E", "E"
key_r = "KEY_R", "R"
key_t = "KEY_T", "T"
key_y = "KEY_Y", "Y"
key_u = "KEY_U", "U"
key_i = "KEY_I", "I"
key_o = "KEY_O", "O"
key_p = "KEY_P", "P"
key_leftbrace = "KEY_LEFTBRACE", "["
key_rightbrace = "KEY_RIGHTBRACE", "]"
key_enter = "KEY_ENTER", "Enter"
key_leftctrl = "KEY_LEFTCTRL", "LCTRL"
key_a = "KEY_A", "A"
key_s = "KEY_S", "S"
key_d = "KEY_D", "D"
key_f = "KEY_F", "F"
key_g = "KEY_G", "G"
key_h = "KEY_H", "H"
key_j = "KEY_J", "J"
key_k = "KEY_K", "K"
key_l = "KEY_L", "L"
key_semicolon = "KEY_SEMICOLON", ";"
key_apostrophe = "KEY_APOSTROPHE", "'"
key_grave = "KEY_GRAVE", "`"
key_leftshift = "KEY_LEFTSHIFT", "LSHIFT"
key_backslash = "KEY_BACKSLASH", "Backslash"
key_z = "KEY_Z", "Z"
key_x = "KEY_X", "X"
key_c = "KEY_C", "C"
key_v = "KEY_V", "V"
key_b = "KEY_B", "B"
key_n = "KEY_N", "N"
key_m = "KEY_M", "M"
key_comma = "KEY_COMMA", ","
key_dot = "KEY_DOT", "."
key_slash = "KEY_SLASH", "/"
key_rightshift = "KEY_RIGHTSHIFT", "RSHIFT"
key_kpasterisk = "KEY_KPASTERISK", "Numpad *"
key_leftalt = "KEY_LEFTALT", "LALT"
key_space = "KEY_SPACE", "Space"
key_capslock = "KEY_CAPSLOCK", "Capslock"
key_f1 = "KEY_F1", "F1"
key_f2 = "KEY_F2", "F2"
key_f3 = "KEY_F3", "F3"
key_f4 = "KEY_F4", "F4"
key_f5 = "KEY_F5", "F5"
key_f6 = "KEY_F6", "F6"
key_f7 = "KEY_F7", "F7"
key_f8 = "KEY_F8", "F8"
key_f9 = "KEY_F9", "F9"
key_f10 = "KEY_F10", "F10"
key_numlock = "KEY_NUMLOCK", "Numlock"
key_scrolllock = "KEY_SCROLLLOCK", "Scrolllock"
key_kp7 = "KEY_KP7", "Numpad 7"
key_kp8 = "KEY_KP8", "Numpad 8"
key_kp9 = "KEY_KP9", "Numpad 9"
key_kpminus = "KEY_KPMINUS", "Numpad -"
key_kp4 = "KEY_KP4", "Numpad 4"
key_kp5 = "KEY_KP5", "Numpad 5"
key_kp6 = "KEY_KP6", "Numpad 6"
key_kpplus = "KEY_KPPLUS", "Numpad +"
key_kp1 = "KEY_KP1", "Numpad 1"
key_kp2 = "KEY_KP2", "Numpad 2"
key_kp3 = "KEY_KP3", "Numpad 3"
key_kp0 = "KEY_KP0", "Numpad 0"
key_kpdot = "KEY_KPDOT", "Numpad ."
key_zenkakuhankaku = "KEY_ZENKAKUHANKAKU", "Zenkakuhankaku"
key_102nd = "KEY_102ND", "102ND"
key_f11 = "KEY_F11", "F11"
key_f12 = "KEY_F12", "F12"
key_ro = "KEY_RO", "RO"
key_katakana = "KEY_KATAKANA", "KATAKANA"
key_hiragana = "KEY_HIRAGANA", "HIRAGANA"
key_henkan = "KEY_HENKAN", "HENKAN"
key_katakanahiragana = "KEY_KATAKANAHIRAGANA", "KATAKANAHIRAGANA"
key_muhenkan = "KEY_MUHENKAN", "MUHENKAN"
key_kpjpcomma = "KEY_KPJPCOMMA", "Numpad JPCOMMA"
key_kpenter = "KEY_KPENTER", "Numpad Enter"
key_rightctrl = "KEY_RIGHTCTRL", "RCTRL"
key_kpslash = "KEY_KPSLASH", "Numpad /"
key_sysrq = "KEY_SYSRQ", "SYSRQ"
key_rightalt = "KEY_RIGHTALT", "RALT"
key_home = "KEY_HOME", "Home"
key_up = "KEY_UP", "Up Arrow"
key_pageup = "KEY_PAGEUP", "Page Up"
key_left = "KEY_LEFT", "Left Arrow"
key_right = "KEY_RIGHT", "Right Arrow"
key_end = "KEY_END", "End"
key_down = "KEY_DOWN", "Down Arrow"
key_pagedown = "KEY_PAGEDOWN", "Page Down"
key_insert = "KEY_INSERT", "Insert"
key_delete = "KEY_DELETE", "Delete"
key_mute = "KEY_MUTE", "Mute"
key_volumedown = "KEY_VOLUMEDOWN", "Volume Down"
key_volumeup = "KEY_VOLUMEUP", "Volume Up"
key_power = "KEY_POWER", "Power"
key_kpequal = "KEY_KPEQUAL", "Numpad ="
key_pause = "KEY_PAUSE", "Pause"
key_kpcomma = "KEY_KPCOMMA", "Numpad ,"
key_hanguel = "KEY_HANGUEL", "HANGUEL"
key_hanja = "KEY_HANJA", "HANJA"
key_yen = "KEY_YEN", "YEN"
key_leftmeta = "KEY_LEFTMETA", "Left SuperKey"
key_rightmeta = "KEY_RIGHTMETA", "Right SuperKey"
key_compose = "KEY_COMPOSE", "Compose key"
key_calc = "KEY_CALC", "Calculator"
key_sleep = "KEY_SLEEP", "Sleep"
key_nextsong = "KEY_NEXTSONG", "Next Song"
key_playpause = "KEY_PLAYPAUSE", "Play/Pause"
key_previoussong = "KEY_PREVIOUSSONG", "Previous Song"
key_scrollup = "KEY_SCROLLUP", "Scroll Up"
key_scrolldown = "KEY_SCROLLDOWN", "Scroll Down"
key_kpleftparen = "KEY_KPLEFTPAREN", "Numpad Left Parenthesis"
key_kprightparen = "KEY_KPRIGHTPAREN", "Numpad Right Parenthesis"
key_play = "KEY_PLAY", "Play"
key_brightnessdown = "KEY_BRIGHTNESSDOWN", "Brightness Up"
key_brightnessup = "KEY_BRIGHTNESSUP", "Brightness Down"
key_rfkill = "KEY_RFKILL", "RFKILL"
key_micmute = "KEY_MICMUTE", "Mute Microphone"
btn_left = "BTN_LEFT", "Mouse left"
btn_right = "BTN_RIGHT", "Mouse right"
btn_middle = "BTN_MIDDLE", "Middle mouse"
btn_forward = "BTN_FORWARD", "Mouse forward"
btn_back = "BTN_BACK", "Mouse back"
#rel_x = "REL_X", "Mouse X"
#rel_y = "REL_Y", "Mouse Y"

My profile is just a test profile with a few useful things like press A (on the gamepad), press Enter, press CTRL and press C.

[ttrkeyboard]
KEY_SLASH = first
KEY_ENTER = key(key_enter)
KEY_LEFTCTRL = key(key_leftctrl)
KEY_C = key(key_c)

When I launch moltengamepad it complains about not being able to change permissions and then it starts spamming Enter. What happens is that 1. I can't see any output from moltengamepad in the console because it spams Enter. 2. I have to reboot my computer because that effectively locks up my keyboard. Edit: This seems to have been caused by my own negligence, I was running moltengamepad in the background as a service and also trying to run it from the command-line at the same time.

Here's my udev rules to expose both mouse and keyboard:

#Allow keyboard and mouse to be accessed from non-root user
ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="1869", MODE="0666", TAG+="uaccess"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="400a", MODE="0666", TAG+="uaccess"

Interestingly enough the keyboard was exposed for my normal user this way but not the mouse, even though the hex codes are correct. (Double and triple checked)

TaiTair commented 2 years ago

Ok so I figured what my problem was. I failed to realize that in system-wide mode I need to create my gendev and profiles under /etc/xdg/moltengamepad. I also failed to realize that I needed to load my profile, either through a command or through moltengamepad.cfg.

The problem I'm having now is that parsec does not process the events correctly. If I go on gamepad-tester.com from my linux laptop I can see my keyboard acting correctly as an xbox360 gamepad. If I go on that website through parsec on my windows computer, then the events are not being processed correctly:

  1. It does not hold the stick - it sends a stick at max position signal and then dies right after.
  2. Parsec does not get the right signal, it stays stuck on positive or negative, e.g. If I press w (which is on left_y-) then I will see -max in the value, then if I press s (which is on left_y+) I will still see -max in the value being processed. Parsec is not happy with the way events are being sent. I'm going to see if there's any driver parameters that can help with that. This seems like a parsec issue and now my next stop is the parsec discord.

Here's my updated gendev:

# Asus built-in keyboard
[vendor=0xb05 product=0x1869]
# logitech mouse
# [vendor=0x46d product=0x400a]
# [ "Dummy" ]
# Options

name = "ttrkeyboard"
devname = "kb_"
exclusive = "true"
change_permissions = "false"
flatten = "false"
rumble = "false"

# Event mappings

key_esc = "escape", "Escape"
key_1 = "1", "Number 1"
key_2 = "2", "Number 2"
key_3 = "3", "Number 3"
key_4 = "4", "Number 4"
key_5 = "5", "Number 5"
key_6 = "6", "Number 6"
key_7 = "7", "Number 7"
key_8 = "8", "Number 8"
key_9 = "9", "Number 9"
key_0 = "0", "Number 0"
key_minus = "minus", "Minus"
key_equal = "equal", "Equal"
key_backspace = "backspace", "Backspace"
key_tab = "tab", "Tab"
key_q = "q", "Q"
key_w = "w", "W"
key_e = "e", "E"
key_r = "r", "R"
key_t = "t", "T"
key_y = "y", "Y"
key_u = "u", "U"
key_i = "i", "I"
key_o = "o", "O"
key_p = "p", "P"
key_leftbrace = "leftbrace", "["
key_rightbrace = "rightbrace", "]"
key_enter = "enter", "Enter"
key_leftctrl = "leftctrl", "LCTRL"
key_a = "a", "A"
key_s = "s", "S"
key_d = "d", "D"
key_f = "f", "F"
key_g = "g", "G"
key_h = "h", "H"
key_j = "j", "J"
key_k = "k", "K"
key_l = "l", "L"
key_semicolon = "semicolon", ";"
key_apostrophe = "apostrophe", "'"
key_grave = "grave", "`"
key_leftshift = "leftshift", "LSHIFT"
key_backslash = "backslash", "Backslash"
key_z = "z", "Z"
key_x = "x", "X"
key_c = "c", "C"
key_v = "v", "V"
key_b = "b", "B"
key_n = "n", "N"
key_m = "m", "M"
key_comma = "comma", ","
key_dot = "dot", "."
key_slash = "slash", "Slash"
key_rightshift = "rightshift", "RSHIFT"
key_kpasterisk = "kpasterisk", "Numpad *"
key_leftalt = "leftalt", "LALT"
key_space = "space", "Space"
key_capslock = "capslock", "Capslock"
key_f1 = "f1", "F1"
key_f2 = "f2", "F2"
key_f3 = "f3", "F3"
key_f4 = "f4", "F4"
key_f5 = "f5", "F5"
key_f6 = "f6", "F6"
key_f7 = "f7", "F7"
key_f8 = "f8", "F8"
key_f9 = "f9", "F9"
key_f10 = "f10", "F10"
key_numlock = "numlock", "Numlock"
key_scrolllock = "scrolllock", "Scrolllock"
key_kp7 = "kp7", "Numpad 7"
key_kp8 = "kp8", "Numpad 8"
key_kp9 = "kp9", "Numpad 9"
key_kpminus = "kpminus", "Numpad -"
key_kp4 = "kp4", "Numpad 4"
key_kp5 = "kp5", "Numpad 5"
key_kp6 = "kp6", "Numpad 6"
key_kpplus = "kpplus", "Numpad +"
key_kp1 = "kp1", "Numpad 1"
key_kp2 = "kp2", "Numpad 2"
key_kp3 = "kp3", "Numpad 3"
key_kp0 = "kp0", "Numpad 0"
key_kpdot = "kpdot", "Numpad ."
key_102nd = "KEY_102ND", "102ND"
key_f11 = "f11", "F11"
key_f12 = "f12", "F12"
key_kpenter = "kpenter", "Numpad Enter"
key_rightctrl = "rightctrl", "RCTRL"
key_kpslash = "kpslash", "Numpad /"
key_sysrq = "sysrq", "SYSRQ"
key_rightalt = "rightalt", "RALT"
key_home = "home", "Home"
key_up = "up", "Up Arrow"
key_pageup = "pageup", "Page Up"
key_left = "left", "Left Arrow"
key_right = "right", "Right Arrow"
key_end = "end", "End"
key_down = "down", "Down Arrow"
key_pagedown = "pagedown", "Page Down"
key_insert = "insert", "Insert"
key_delete = "delete", "Delete"
key_mute = "mute", "Mute"
key_volumedown = "volumedown", "Volume Down"
key_volumeup = "volumeup", "Volume Up"
key_power = "power", "Power"
key_kpequal = "kpequal", "Numpad ="
key_pause = "pause", "Pause"
key_kpcomma = "kpcomma", "Numpad ,"
key_leftmeta = "leftmeta", "Left SuperKey"
key_rightmeta = "rightmeta", "Right SuperKey"
key_compose = "compose", "Compose key"
key_calc = "calc", "Calculator"
key_sleep = "sleep", "Sleep"
key_nextsong = "nextsong", "Next Song"
key_playpause = "playpause", "Play/Pause"
key_previoussong = "previoussong", "Previous Song"
key_scrollup = "scrollup", "Scroll Up"
key_scrolldown = "scrolldown", "Scroll Down"
key_kpleftparen = "kpleftparen", "Numpad Left Parenthesis"
key_kprightparen = "kprightparen", "Numpad Right Parenthesis"
key_play = "play", "Play"
key_brightnessdown = "brightnessdown", "Brightness Down"
key_brightnessup = "brightnessup", "Brightness Up"
key_rfkill = "rfkill", "RFKILL"
key_micmute = "micmute", "Mute Microphone"
#btn_left = "btnleft", "Mouse left"
#btn_right = "btnright", "Mouse right"
#btn_middle = "btnmiddle", "Middle mouse"
#btn_forward = "btnforward", "Mouse forward"
#btn_back = "btnback", "Mouse back"
#rel_x = "REL_X", "Mouse X"
#rel_y = "REL_Y", "Mouse Y"

Here's my updated profile:

[ttrkeyboard]
escape = key(key_esc)
1 = key(key_1)
2 = key(key_2)
3 = key(key_3)
4 = key(key_4)
5 = key(key_5)
6 = key(key_6)
7 = key(key_7)
8 = key(key_8)
9 = key(key_9)
0 = key(key_0)
minus = key(key_minus)
equal = key(key_equal)
backspace = key(key_backspace)
tab = key(key_tab)
q = key(key_q)
w = left_y-
e = key(key_e)
r = key(key_r)
t = key(key_t)
y = key(key_y)
u = key(key_u)
i = key(key_i)
o = key(key_o)
p = key(key_p)
leftbrace = key(key_leftbrace)
rightbrace = key(key_rightbrace)
enter = key(key_enter)
leftctrl = key(key_leftctrl)
a = left_x-
s = left_y+
d = left_x+
f = key(key_f)
g = key(key_g)
h = key(key_h)
j = key(key_j)
k = key(key_k)
l = key(key_l)
semicolon = key(key_semicolon)
apostrophe = key(key_apostrophe)
grave = key(key_grave)
leftshift = key(key_leftshift)
backslash = key(key_backslash)
z = key(key_z)
x = key(key_x)
c = key(key_c)
v = key(key_v)
b = key(key_b)
n = key(key_n)
m = key(key_m)
comma = key(key_comma)
dot = key(key_dot)
slash = primary
rightshift = key(key_rightshift)
kpasterisk = key(key_kpasterisk)
leftalt = key(key_leftalt)
space = key(key_space)
capslock = key(key_capslock)
f1 = key(key_f1)
f2 = key(key_f2)
f3 = key(key_f3)
f4 = key(key_f4)
f5 = key(key_f5)
f6 = key(key_f6)
f7 = key(key_f7)
f8 = key(key_f8)
f9 = key(key_f9)
f10 = key(key_f10)
numlock = key(key_numlock)
scrolllock = key(key_scrolllock)
kp7 = key(key_kp7)
kp8 = key(key_kp8)
kp9 = key(key_kp9)
kpminus = key(key_kpminus)
kp4 = key(key_kp4)
kp5 = key(key_kp5)
kp6 = key(key_kp6)
kpplus = key(key_kpplus)
kp1 = key(key_kp1)
kp2 = key(key_kp2)
kp3 = key(key_kp3)
kp0 = key(key_kp0)
kpdot = key(key_kpdot)
KEY_102ND = key(key_102nd)
f11 = key(key_f11)
f12 = key(key_f12)
kpenter = key(key_kpenter)
rightctrl = key(key_rightctrl)
kpslash = key(key_kpslash)
sysrq = key(key_sysrq)
rightalt = key(key_rightalt)
home = key(key_home)
up = key(key_up)
pageup = key(key_pageup)
left = key(key_left)
right = key(key_right)
end = key(key_end)
down = key(key_down)
pagedown = key(key_pagedown)
insert = key(key_insert)
delete = key(key_delete)
mute = key(key_mute)
volumedown = key(key_volumedown)
volumeup = key(key_volumeup)
power = key(key_power)
kpequal = key(key_kpequal)
pause = key(key_pause)
kpcomma = key(key_kpcomma)
leftmeta = key(key_leftmeta)
rightmeta = key(key_rightmeta)
compose = key(key_compose)
calc = key(key_calc)
sleep = key(key_sleep)
nextsong = key(key_nextsong)
playpause = key(key_playpause)
previoussong = key(key_previoussong)
scrollup = key(key_scrollup)
scrolldown = key(key_scrolldown)
kpleftparen = key(key_kpleftparen)
kprightparen = key(key_kprightparen)
play = key(key_play)
brightnessdown = key(key_brightnessdown)
brightnessup = key(key_brightnessup)
rfkill = key(key_rfkill)
micmute = key(key_micmute)

Thanks for the hard work and sorry if I was being a bit harsh. Spending hours upon hours of settings things up for it to not work can be a bit frustrating.