# Gamepad button as mod key for Sway?

**URL:** <https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581>\
**Category:** uConsole\
**Created:** [March 1, 2024, 7:42pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581 "2024-03-01T19:42:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![selfawaresoup](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/selfawaresoup/32/9065_2.png) [@selfawaresoup](https://forum.clockworkpi.com/u/selfawaresoup)\
**Post date:** [March 1, 2024, 7:42pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/1 "2024-03-01T19:42:42Z")

</div>

I would like to use the Sway window manager in my uConsole but it relies heavily on the “mod” key, which is the “Super” key by default so Fn + AltL on the uConsole. That’s too cumbersome to use effectively.

I was wondering if there is a way to use one of the gamepad buttons (A for example) for this since I’m not using those for anything right now. But I’m stuck trying to configure that since they aren’t really keyboard keys.

Any ideas?

---

<div class="post-metadata">

**Author:** ![dbeavers](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/dbeavers/32/8749_2.png) [@dbeavers](https://forum.clockworkpi.com/u/dbeavers)\
**Post date:** [March 1, 2024, 8:16pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/2 "2024-03-01T20:16:23Z")

</div>

User Funcron asked basically the same question 18 or so days ago.  
I would probably use the game keys for something besides gaming myself.

---

<div class="post-metadata">

**Author:** ![xpurple](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/xpurple/32/8911_2.png) [@xpurple](https://forum.clockworkpi.com/u/xpurple)\
**Post date:** [March 2, 2024, 7:23am UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/3 "2024-03-02T07:23:58Z")

</div>

I’d like to be able to map two of the buttons on the gamepad to page up and page down.

---

<div class="post-metadata">

**Author:** ![1337p337](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/1337p337/32/8689_2.png) [@1337p337](https://forum.clockworkpi.com/u/1337p337)\
**Post date:** [March 3, 2024, 1:52am UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/4 "2024-03-03T01:52:08Z")

</div>

> relies heavily on the “mod” key, which is the “Super” key by default so Fn + AltL on the uConsole

I do not know how easy it is to remap things under Wayland, but on the uConsole, I use the volume button for the window manager’s meta key. (`escape XF86AudioLowerVolume` in ratpoison. I use ratpoison on the DevTerm, too, but I use the Cmd key, which is Super\_R. I have the volume up/down buttons mapped to screen brightness, and Fn+\< and Fn+\> cycle through windows.) One thing you might try is remapping the right Ctrl/Alt keys, depending on whether you need both pairs.

> I was wondering if there is a way to use one of the gamepad buttons

There are some dip switches on the back of the keyboard that can be used to send normal keypresses instead of gamepad keypresses, but they’re mapped to letter keys. (I seem to recall the dip switches are actually on the board, but it’s a bit more involved to disassemble than the DevTerm is.)

You could try getting the Arduino devkit to work (if anyone knows a way to rebuild the firmware for the keyboard without going through Arduino’s IDE, please let me know) and that’d enable you to just tweak the appropriate bits in the firmware and reflash. Remapping a single key is not difficult. Have a look at [uConsole/Code/uconsole\_keyboard at master · clockworkpi/uConsole · GitHub](https://github.com/clockworkpi/uConsole/tree/master/Code/uconsole_keyboard) . The bit that handles the presses for the A button is here: [uConsole/Code/uconsole\_keyboard/keymaps.ino at master · clockworkpi/uConsole · GitHub](https://github.com/clockworkpi/uConsole/blob/master/Code/uconsole_keyboard/keymaps.ino#L367) . It looks like it’s mapped to “j” when the switch is toggled, so if you wanted it to send the same keycode as Cmd/Fn+Alt does, then, per line 670, it _looks_ like you want to use `_CMD_KEY`.

---

<div class="post-metadata">

**Author:** ![mikeschnier](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/mikeschnier/32/9697_2.png) [@mikeschnier](https://forum.clockworkpi.com/u/mikeschnier)\
**Post date:** [March 9, 2024, 5:50am UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/5 "2024-03-09T05:50:56Z")

</div>

Getting gamepad buttons to work as keyboard presses in Wayland is kind of a pain, so I just use Alt as the mod key.

I could probably swap Alt and Super to prevent conflicts but I haven’t had any issues so far.

---

<div class="post-metadata">

**Author:** ![xerxes42](https://avatars.discourse-cdn.com/v4/letter/x/d26b3c/32.png) [@xerxes42](https://forum.clockworkpi.com/u/xerxes42)\
**Post date:** [March 13, 2024, 4:27pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/6 "2024-03-13T16:27:02Z")

</div>

I relied on this post to get sway working with the uConsole mod keys

> [@Configuring Sway](https://forum.clockworkpi.com/t/configuring-sway/12470/10):
>
> Haven’t tried it yet, but if you haven’t rebuilt the wheel already I think this might work. [GitHub - sezanzeb/input-remapper: video_game keyboard An easy to use tool to change the behaviour of your input devices.](https://github.com/sezanzeb/input-remapper) Edit: Alright, I’ve tried it myself and it doesn’t work in PostmarketOS. BTW, if anyone’s trying to get shutdown commands to function in SwayWM under PostmarketOS (which doesn’t have systemd), loginctl poweroff works.

The ‘sticky’ mode in particular is necessary to avoid other Fn keys.  
Unfortunately, I’ve been unable to find any mapping for the gamepad buttons.  
`wev` doesn’t even register them.

---

<div class="post-metadata">

**Author:** ![OE4DNS](https://avatars.discourse-cdn.com/v4/letter/o/85f322/32.png) [@OE4DNS](https://forum.clockworkpi.com/u/OE4DNS)\
**Post date:** [December 4, 2024, 12:11am UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/7 "2024-12-04T00:11:38Z")

</div>

Only a few months later 😉

It seems that [AntiMicroX](https://github.com/AntiMicroX/antimicrox) is the way forward here. After compiling it myself (no ARM binaries provided) I was able to remap the Y and X buttons to PageUp and PageDown respectively. This makes scrolling in webpages much easier.

Unfortunately I was not yet able to remap the Sway modifier key (CMD, Fn+Alt) . There are some bugs in AntiMicroX still that might be related to this but I’m a bit at a dead end after two evenings of trying. Maybe someone else on this board can offer another insight.

---

<div class="post-metadata">

**Author:** ![xpurple](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/xpurple/32/8911_2.png) [@xpurple](https://forum.clockworkpi.com/u/xpurple)\
**Post date:** [December 4, 2024, 3:04am UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/8 "2024-12-04T03:04:32Z")

</div>

I’ve also had AntiMicroX just randomly crash on me after a few days of uptime. It solves my problem (page up/down), but is far from perfect.

---

<div class="post-metadata">

**Author:** ![Canto](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/canto/32/7236_2.png) [@Canto](https://forum.clockworkpi.com/u/Canto)\
**Post date:** [December 4, 2024, 6:47pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/9 "2024-12-04T18:47:41Z")

</div>

If you don’t mind dabbling in new keyboard firmware, [this works for me.](https://forum.clockworkpi.com/t/qmk-firmware-for-uconsole-keyboard/14410/18)

🙂

---

<div class="post-metadata">

**Author:** ![jessejallday](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/jessejallday/32/9104_2.png) [@jessejallday](https://forum.clockworkpi.com/u/jessejallday)\
**Post date:** [December 9, 2024, 1:30pm UTC](https://forum.clockworkpi.com/t/gamepad-button-as-mod-key-for-sway/12581/11 "2024-12-09T13:30:35Z")

</div>

AntimicroX is available on PiApps.
