Support us on Patreon to keep GamingOnLinux alive. This ensures all of our main content remains free for everyone. Just good, fresh content! Alternatively, you can donate through PayPal. You can also buy games using our partner links for GOG and Humble Store.
using keyboard as xbox controller manjaro
c00kie55 Jun 20, 2023
i have a arcade case with a ultimate i-PAC Arcade controller that i would like to use with steam but it works as a keyboard so i was thinking of some sort of controller emulator, i have looked at MoltenGamepad but dont know how to install it, fails on make and i am new to manjaro :/ sorry.

is this possible? and what is the best solution a gui would be nice.
the i-pac is before 2015 so dont think i can install the new firmware, i also like it to work with default mame layout.

thanks.
Cyril Jun 20, 2023
I don't know that ultimate i-PAC controller nor MoltenGamepad.
What do you actually want to do? It's not recognized properly in games?
I was thinking about AntiMicroX but I'm not sure if it fits for your issue.

For MoltenGamepad it's available in the AUR (so available on Manjaro), did you tried to install it that way?
c00kie55 Jun 20, 2023
i have already installed AntiMicroX but i think it works the other way around, typing keys with a controller.

Thanks for the AUR info is it possible to only install selected things from AUR, i have some mixed experince with ubuntu and bleeding edge ppa's
whizse Jun 20, 2023
I'm not sure if you're into programming, but the UInput system and evdev bindings for Oython makes it very easy to create your own keyboard to gamepad wrapper.

Very (very!) basic example below:

 
#!/usr/bin/python3

# Very simple keyboard (WASD) to 4-button gamepad example,
# Requires the python-evdev package.
# Run as root!
#
# Use evtest as root to find keyboard path

from evdev import InputDevice, UInput, ecodes as e

dev = InputDevice('/dev/input/event3') # <- Needs to be changed to your keyboard!

wasd_keys = [e.KEY_W, e.KEY_A, e.KEY_S, e.KEY_D]
controller_keys = [e.BTN_X, e.BTN_Y, e.BTN_B, e.BTN_A]
cap = {
    e.EV_KEY : controller_keys,
}

ui = UInput(cap, name='Totally an Xbox controller', version=0x3)

for event in dev.read_loop():
    if event.type == e.EV_KEY:
        if event.code in wasd_keys:
            index = wasd_keys.index(event.code)
            ui.write(e.EV_KEY, controller_keys[index], event.value)
            ui.syn()
c00kie55 Jun 20, 2023
i do some basic programing / scripting and i think that one looks like something i can figure out
is it possible to start this when i launch a steam game and kill it when the game quits.

i could be cool if i could control gnome dash 2 dock whit controller stick and a emulated mouse left click button and when i launch a steam game the script takes over the controller and when i launch the qmc2 frontend (M.A.M.E) it uses default keyboard settings, if steam windows is in focus (xdotool) use xbox script
Grogan Jun 21, 2023
Quoting: c00kie55Thanks for the AUR info is it possible to only install selected things from AUR, i have some mixed experince with ubuntu and bleeding edge ppa's

As long as the package you are building from AUR compiles, links and works with existing dependencies on your system, yes.

For this one here:
https://aur.archlinux.org/packages/moltengamepad

You're going to need some additional dependencies not provided by the distro, but installing these will not affect anything else if you don't have them. (They are libraries for interfacing with the Steam Controller)


scraw (scraw-git)
scrawpp (scrawpp-git)

When you see it given like that, it means you can use either scraw or scraw-git (from AUR in this case)

This doc building tool is available in the distro, but it's also a dependency for the build (only)

go-md2man (make)

Last edited by Grogan on 21 June 2023 at 12:39 am UTC
c00kie55 Jun 21, 2023
both MoltenGamepad and MoltenGamepad-git fails to build tried yay and the packetmanager.
i also tried a git clone and adding the memory fix but this also fails

this is a little over my compile skills
 
/usr/include/c++/13.1.1/bits/hashtable_policy.h:1304:23: fejl: static assertion failed: hash function must be invocable with an argument of key type
 1304 |         static_assert(__is_invocable<const _Hash&, const _Key&>{}


Quoting: whizseVery (very!) basic example below:
not shure i understand, i replaced keys from evtest
 
!/usr/bin/python3

# Very simple keyboard (WASD) to 4-button gamepad example,
# Requires the python-evdev package.
# Run as root!
#
# Use evtest as root to find keyboard path

from evdev import InputDevice, UInput, ecodes as e

dev = InputDevice('/dev/input/event13') # <- Needs to be changed to your keyboard!

wasd_keys = [e.KEY_UP, e.KEY_LEFT, e.KEY_DOWN, e.KEY_RIGHT]
controller_keys = [e.KEY_LEFTALT, e.KEY_1, e.KEY_SPACE, e.KEY_LEFTCTRL]
cap = {
    e.EV_KEY : controller_keys,
}

ui = UInput(cap, name='I-Pac controller 01', version=0x3)

for event in dev.read_loop():
    if event.type == e.EV_KEY:
        if event.code in wasd_keys:
            index = wasd_keys.index(event.code)
            ui.write(e.EV_KEY, controller_keys[index], event.value)
            ui.syn()

it does nothing and when i Ctrl+c it print this
 
./xbox-controller01                                                                   INT ✘  5s   c00kie55@c0-gamebox 
^CTraceback (most recent call last):
  File "/home/C00kie55/./xbox-controller01", line 21, in <module>
    for event in dev.read_loop():
  File "/usr/lib/python3.11/site-packages/evdev/eventio.py", line 45, in read_loop
    r, w, x = select.select([self.fd], [], [])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

can you point me to some documentation :)

Last edited by c00kie55 on 21 June 2023 at 4:14 pm UTC
Grogan Jun 21, 2023
Yeah, I'm not familiar with the project and its code base but it figures:

Last Updated: 2022-02-18 17:57 (UTC)

It's likely that the last time the PKGBUILD maintainer built this was with gcc 11.2 and its libstdc++

Even the moltengamepad-git build is using code that is 3 to 7 years old. (last commit on Oct 22, 2020)

It looks like a dead project. I don't know if coding around this one error would be the only land mine in the build, stuff like this can really get me chasing my tail (especially since my programming knowledge consists of needing examples to fix things if it's not obvious)

Last edited by Grogan on 21 June 2023 at 5:55 pm UTC
whizse Jun 21, 2023
Quoting: c00kie55wasd_keys = [e.KEY_UP, e.KEY_LEFT, e.KEY_DOWN, e.KEY_RIGHT]
controller_keys = [e.KEY_LEFTALT, e.KEY_1, e.KEY_SPACE, e.KEY_LEFTCTRL]

So, the wasd_keys variable are the keyboard keys on your physical controller. The controller_keys variable are the button presses to be emitted on the virtual controller.

Apologies for the confusion!

You need to switch them around and find suitable gamepad events to emit. I used the XYAB button events in my example, but there's a long list of event codes here:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

There's good documentation and a quite thorough tutorial for python-evdev here:
https://python-evdev.readthedocs.io/en/latest/tutorial.html
c00kie55 Jun 23, 2023
Quoting: GroganIt looks like a dead project.
anyway i learned how to enable AUR

Quoting: whizseApologies for the confusion!
this looks good i will just have to dig into the documentation.
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register


Or login with...
Sign in with Steam Sign in with Google
Social logins require cookies to stay logged in.

Buy Games
Buy games with our affiliate / partner links: