Skip to content

Instantly share code, notes, and snippets.

@bodnaristvan
Last active October 21, 2022 09:52
Show Gist options
  • Save bodnaristvan/15cbdd2ecb9665483e7c570ff5fce2af to your computer and use it in GitHub Desktop.
Save bodnaristvan/15cbdd2ecb9665483e7c570ff5fce2af to your computer and use it in GitHub Desktop.
Using a Samsung AH59-02532A remote with Linux

Preface

Fuck this whole thing. Why does it have to be so outdated and complicated?!

Main things

  • ir-keytable and triggerhappy are the MVPs
  • no need for lirc at all, which just installs 100meg of unused GTK & Gnome stuff
  • this samsung remote uses keycodes from two different protocols (necx + samsung)

Setting up infrared receiver

(This is Raspberry Pi specific). In /boot/config.txt make sure you have infra enabled:

dtoverlay=gpio-ir,gpio_pin=17

(change GPIO as needed)

Setting up ir-keytable

Install using apt install ir-keytable. Copy the attached samsung.toml and samsung-other.toml files to /etc/rc_keymaps/ Load the newly created when ir-keytables runs, by adding these lines to /etc/rc_maps.cfg:

# driver   table   file
*          *       samsung.toml
*          *       samsung-other.toml

They'll load two different protocols: necx and samsung36 from /usr/lib/udev/rc_keymaps/protocols, and config basic key codes.

Configure triggerhappy

See the example config attached, otherwise just go to https://github.com/wertarbyte/triggerhappy and see your options

Useful links:

Keycodes: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/input-event-codes.h#n64

LibreELEC infra setup guide: https://wiki.libreelec.tv/configuration/ir-remotes

MusicLounge Triggerhappy install guiude: https://linuxaudiofoundation.org/category/triggerhappy/

[[protocols]]
name = "samsung-other"
protocol = "samsung36"
[protocols.scancodes]
0xcf00ee11 = "KEY_VOLUMEUP"
0xcf001ee1 = "KEY_VOLUMEDOWN"
0xcf0051ae = "KEY_PLAYPAUSE"
0xcf00b14e = "KEY_STOP"
0xcf008e71 = "KEY_MUTE"
0xcf00c13e = "KEY_LEFT"
0xcf0041be = "KEY_RIGHT"
0xcf0031ce = "KEY_NEXT"
0xcf00d12e = "KEY_PREVIOUS"
0xcf000ef1 = "KEY_POWER"
0xcf00619e = "KEY_SCREEN"
[[protocols]]
name = "samsung"
protocol = "nec"
[protocols.scancodes]
0x70707 = "KEY_VOLUMEUP"
0x7070b = "KEY_VOLUMEDOWN"
0x70712 = "KEY_CHANNELUP"
0x70710 = "KEY_CHANNELDOWN"
0x70702 = "KEY_POWER2"
0x7070f = "KEY_MUTE"
KEY_VOLUMEUP 1 amixer set "Khadas Tone Control " 2dB+
KEY_VOLUMEUP 2 amixer set "Khadas Tone Control " 2dB+
KEY_VOLUMEDOWN 1 amixer set "Khadas Tone Control " 2dB-
KEY_VOLUMEDOWN 2 amixer set "Khadas Tone Control " 2dB-
KEY_PLAYPAUSE 1 mpc toggle > /dev/null
KEY_STOP 1 mpc stop > /dev/null
KEY_NEXT 1 mpc next > /dev/null
KEY_PREVIOUS 1 mpc prev > /dev/null
KEY_RIGHT 1 mpc seek +10 > /dev/null
KEY_RIGHT 2 mpc seek +10 > /dev/null
KEY_LEFT 1 mpc seek -10 > /dev/null
KEY_LEFT 2 mpc seek -10 > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment