houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
295 stars 25 forks source link

Volume control keys not working with scan code #140

Closed RiccardoBarbieri closed 5 months ago

RiccardoBarbieri commented 5 months ago

I created the following mappings:

volumeMuteCmd = $(/home/riccardoob/scripts/audio-polybar/pulseaudio-control togmute) ^    
volumeDownCmd = $(/home/riccardoob/scripts/audio-polybar/pulseaudio-control --volume-max 130 down) ^
volumeUpCmd = $(/home/riccardoob/scripts/audio-polybar/pulseaudio-control --volume-max 130 up) ^

173 >> volumeMuteCmd
174 >> volumeDownCmd    
175 >> volumeUpCmd

to launch the scripts when I press the volume controls but it doesn't seem to work. I tested with other mappings such as 173 >> Backspace to understand if the problem was with the command definitions but it still does not work. I tried using the event names and it works.

How can I get it to work with the scan codes? In the documentation it is not specified how to actually use them.

ristomatti commented 5 months ago

I define them as aliases and then use like any other key like below, but they do work with just the number if you prefer to do that. Are you sure the scan codes are correct?

# AVRCP media keys (hex values are just a comment for my self)
MediaPlay       = 200    # 0x00C8
MediaPause      = 201    # 0x00C9

MediaPlay >> some_action
RiccardoBarbieri commented 5 months ago

@ristomatti yes, I used the web tool suggested in the documentation to get the codes, same for the names that I ended up using since with those it works.

houmain commented 5 months ago

The scan codes on windows are: AudioVolumeMute = 0xE020 AudioVolumeDown = 0xE02E AudioVolumeUp = 0xE030

You can find them here or in the source. But there should be no need for the scan codes when the keys have names (which you can get here).

ristomatti commented 5 months ago

@RiccardoBarbieri Just to clarify, the key codes shown on https://www.toptal.com/developers/keycode aren't the same as scan codes, I got confused by this initially also. The site is only useful for finding the key names used by Keymapper.

To find out the scan codes you'll need some other tool. I'm not on Windows so I don't know which one to recommend. Based on a quick search you'll find one easily in case you run across a key that's not recognized by Toptal.