[Tips] IR Remote - Using Cheap USB PC Remote with Rune

Raspberry Pi related support

[Tips] IR Remote - Using Cheap USB PC Remote with Rune

Postby rern » 18 Aug 2016, 05:49

[Tips] IR Remote - Using Cheap USB PC Remote with Rune

With XBindkeys (already included with Rune)

For less than $4, this remote set was detected and can be used as a keyboard and a mouse.
    - Use as a mouse in RuneUI: edit use_cursor no to yes in /root/.xinitrc
    - Use as a keyboard to select an OS in NOOBS boot menu.
    - Use in Kodi without any settings. (no more CEC hassels)
Image

The following code assigns 6 keys:
    <left> = previous track
    <enter> = play / pause
    <right> = next track
    <up> = forward (@10s)
    <down> = reverse (@10s)
    <backspace> = stop
Switch or add more as you like.
    - Not includes keys that not working.
      <red>
      <skipback>
      <skipnext>
      <play/pause>
      <mute>
      <vol->
      <vol+>
      <switchwindow>
      <windows>
    - Read carefully for <'color'>s and <numlock> buttons.

If you want a customizable remote, you need this: [edited to mean not this remote]
JP1 Remote - The ultimate solution of a remote
It's like Raspberry Pi of ir remote world.

Code: Select all
# /root/.xbindkeysrc

# for USB PC Remote (ID 1d57:ad02 Xenta SE340D PC Remote Control)
####################################################################

# buttons from left to right

# <email>
#"command"
#   m:0x0 + c:163

#<www>
#"command"
#   m:0x0 + c:180

#<close>
#"command"
#   m:0x8 + c:64 + m:0x0 + c:70

# <green> *** works once > locks all buttons | press <amber> to unlock
#"command"
#   m:0xc + c:38

# <amber>
#"command"
#   m:0xc + c:56

# <blue> *** works once > locks all buttons | press <amber> to unlock
#"command"
#   m:0xc + c:54

# <yellow> *** works once > locks all buttons | press <amber> to unlock
#"command"
#   m:0xc + c:40

# <rewind>
#"command"
#   m:0x0 + c:248

# <forward>
#"command"
#   m:0x0 + c:248

# <stop>
#"command"
#   m:0x0 + c:174

# <fullscreen>
#"command"
#   m:0x4 + c:37 + m:0x0 + c:12

# <tab>
#"command"
#   m:0x0 + c:23

### Forward <up>
"mpc seek +00:00:10"
   m:0x0 + c:111

### Stop <backspace>
"mpc stop"
   m:0x0 + c:22

### Previous <left>
"mpc prev"
   m:0x0 + c:113

### Play / Pause <enter>
"mpc toggle"
   m:0x0 + c:36

### Next <right>
"mpc next"
   m:0x0 + c:114

# <pageup>
#"command"
#   m:0x0 + c:112

# <folder>
#"command"
#   m:0x4 + c:37 + m:0x0 + c:32

### Rewind <down>
"mpc seek -00:00:10"
   m:0x0 + c:116

# <esc>
#"command"
#   m:0x0 + c:9

# <pagedown>
#"command"
#   m:0x0 + c:117

# <numlock>
# !!! avoid pressing / using !!!
# toggles between <navigate> / <alpha-numeric> buttons (gray background)
# (navigate -> alpha-numeric -> uppercase -> alpha-numeric -> navigate)

# <mypc>
#"command"
#   m:0x40 + c:133 + m:0x0 + c:26

# <desktop>
#"command"
#   m:0x40 + c:133 + m:0x0 + c:40
Last edited by rern on 24 Mar 2018, 14:27, edited 7 times in total.
Raspberry Pi 3 > SMSL M8 DAC
GitHub
rern
 
Posts: 361
Joined: 14 Jul 2016, 08:15

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby den_hr » 19 Aug 2016, 14:21

THX for useful info... :)
I've used that same USB remote in one of my earlier builds, and also on PC-based "thin client" MPD servers (Puppy Linux)....

Also, are you saying that that particular ebay USB remote can be *modified" using JP1 Remote software (i.e. key functions changed/modified on the remote itself)?
That would be a great help, since I still have several of those, and don't use them because of the pesky "NumLock" key, which changes the remote behavior, and is easy to accidentally press (and suddenly the remote doesn't work any more....).
den_hr
 
Posts: 52
Joined: 06 Feb 2015, 17:10
Location: Croatia

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby rern » 22 Aug 2016, 04:44

With JP1 remote, not this PC Remote, you can:
    Keymap virtually any button to:
      - any function from the same device or across devices (even a device that not even in 'the code list')
      - any sequence of functions from the same device or across devices
      - discrete function like on, off, hdmi1, hdmi2 ... instead of toggle
      and much more!
    Leave ALL of your remotes, even the fancy programmable ones, in a deep dark shoebox for good. (Even my Harmony has been there ever since.)
(@den_hr - Sorry for misleading. I've edited to a correct meaning.)
Last edited by rern on 30 Aug 2016, 14:04, edited 2 times in total.
Raspberry Pi 3 > SMSL M8 DAC
GitHub
rern
 
Posts: 361
Joined: 14 Jul 2016, 08:15

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby MarmiteSandwich » 29 Aug 2016, 22:03

Brilliant! I was just about to post a question about this very device when I found this post. Now I can pause the Pi.

After some faffing about with PuTTY and with reference to http://ss64.com/bash/ to learn some console commands, and a bit of hacking with the vi editor in particular, I managed to find the /root/.xbindkeysrc file and insert these statements. Since this device works without these hacks in Windows, out of the box, as do other "standard" USB IR remotes, I do wonder why they (or similar keypresses) aren't built into the distro or Rune. Maybe I'll never really get Linux.

Anyway, thanks for passing on the info!
Regards,
Marmite
Music>iTunes>Minimserver>BubbleUPnP>RasPi3BRuneaudio0.4>
CambridgeAudioDACMagic>CyrusIIIi>Mission752>MyEars
MarmiteSandwich
 
Posts: 24
Joined: 19 Apr 2016, 22:50
Location: UK

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby MarmiteSandwich » 31 Aug 2016, 15:44

For anyone else considering this, and with limited/no Linux experience, here are some tips from my experience.

Firstly, forget about PuTTY and other SSH utilities to log on to your Pi, unless you are already Linux-friendly. If you have Windows, install WinSCP, which allows you to log onto RuneAudio and exchange files with your PC, through a user-friendly interface. Default userID/pwd for Rune are root/rune. Obviously you need to know the IP address of your Pi, and it helps if you have setup your router so that the Pi keeps the same IP.

Secondly, set WinSCP to show hidden files, because the one we want has a name which starts with a ".", so it is hidden.

Thirdly, when you copy the file (.xbindkeysrc) to your PC, don't start editing it with Notepad or Wordpad, since there is something about the end-of-line characters in Linux/Unix which is different to Windows. When you send it back to the Pi, xbindkeys won't read it properly. I use the PFE editor to avoid this, which has a default unix-style end-of-line.

Finally, here is a cleaned-up version of the command file which I used after some experimentation. It uses the skip and back keys for track changes and the left and right arrow cursor keys for seeking back or forward by 10s. Up and down are redundant. I couldn't find a way to stop/start (apart from the <enter> key for pause/play), or mute. I gave up experimenting since you have to reboot the Pi every time you load a new command file. I couldn't find any definition of keys which included the codes used by the OP. I have commented out the commands which do not work, to avoid trying them again.

Code: Select all
###########################
# xbindkeys configuration #
###########################

# Increase volume
"mpc volume +5"
   XF86AudioRaiseVolume

# Decrease volume
"mpc volume -5"
   XF86AudioLowerVolume

# Play
# "mpc play"
#   XF86Start

# Stop
# "mpc stop"
#   XF86Stop

# Play
# "mpc play"
#   XF86AudioPlay

# Stop
# "mpc stop"
#   XF86AudioStop

# Mute
# "mpc mute"
#   XF86AudioMute

# Previous track
"mpc prev"
   XF86AudioPrev

# Next track
"mpc next"
   XF86AudioNext

### Play / Pause <enter>
"mpc toggle"
   m:0x0 + c:36

### Forward <right>
"mpc seek +00:00:10"
   m:0x0 + c:114

### Rewind <left>
"mpc seek -00:00:10"
   m:0x0 + c:113
 
##################################
# End of xbindkeys configuration #
##################################


Would be interesting to know where those last few key codes come from, like "m:0x0 + c:113", or if anyone got stop/start or mute to work. Stop/start would resume at the beginning of the present track in my logic (or maybe at the beginning of the playlist?). Also it would be good to be able to restart the current track, without going back one and then forward one.
Marmite
Music>iTunes>Minimserver>BubbleUPnP>RasPi3BRuneaudio0.4>
CambridgeAudioDACMagic>CyrusIIIi>Mission752>MyEars
MarmiteSandwich
 
Posts: 24
Joined: 19 Apr 2016, 22:50
Location: UK

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby hondagx35 » 31 Aug 2016, 21:22

Hi MarmiteSandwich,

thank you for pointing this out for beginners.

Thirdly, when you copy the file (.xbindkeysrc) to your PC, don't start editing it with Notepad or Wordpad, ..... I use the PFE editor to avoid this, which has a default unix-style end-of-line.

Even better in my eyes is to use Notepad++.
You can set it as default editor for WinSCP, so no need to transfer the files forth and back.
You can edit them directly on the device within WinSCP.

Would be interesting to know where those last few key codes come from, like "m:0x0 + c:113"

These codes are for non XF86Audio keys.

or if anyone got stop/start or mute to work.

Mute is not possible to implement the easy way, because mpd doesn't support it out of the box as command.
Start/Stop can be done easily:
Code: Select all
# stop and start song at the beginning
"mpc stop; mpc play"
   your-remote-key


Here are supported mpc commands:
Code: Select all
Commands:
  mpc play [<position>]                                 Start playing at <position>
  mpc next                                              Play the next song in the current playlist
  mpc prev                                              Play the previous song in the current playlist
  mpc pause                                             Pauses the currently playing song
  mpc toggle                                            Toggles Play/Pause, plays if stopped
  mpc stop                                              Stop the currently playing playlists
  mpc seek [+-][HH:MM:SS]|<0-100>%                      Seeks to the specified position
  mpc shuffle                                           Shuffle the current playlist
  mpc volume [+-]<num>                                  Set volume to <num> or adjusts by [+-]<num>
  mpc repeat <on|off>                                   Toggle repeat mode, or specify state
  mpc random <on|off>                                   Toggle random mode, or specify state
  mpc single <on|off>                                   Toggle single mode, or specify state
  mpc consume <on|off>                                  Toggle consume mode, or specify state
....
See man 1 mpc for more information about mpc commands and options


I gave up experimenting since you have to reboot the Pi every time you load a new command file.

On my RP2 with local browser enabled i can restart xbindkeys without rebooting:
Code: Select all
root@runeaudio(rw):~# killall xbindkeys
root@runeaudio(rw):~# export DISPLAY=":0"
root@runeaudio(rw):~# xbindkeys


Frank
User avatar
hondagx35
 
Posts: 3026
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby MarmiteSandwich » 31 Aug 2016, 21:54

Thanks for the info, Frank.

These codes are for non XF86Audio keys.
But where can we find the list of key codes which includes these and other keys? All the key codes I can find from googling around look nothing like these codes (m:0x0 + c:113).

your-remote-key
How can I find this code?

Thanks for the mpc command list. Once I find the codes, I can use a few more of them. All help much appreciated. It's making RuneAudio better all the time.
Cheers,
Marmite
Music>iTunes>Minimserver>BubbleUPnP>RasPi3BRuneaudio0.4>
CambridgeAudioDACMagic>CyrusIIIi>Mission752>MyEars
MarmiteSandwich
 
Posts: 24
Joined: 19 Apr 2016, 22:50
Location: UK

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby MarmiteSandwich » 31 Aug 2016, 23:33

I got a "restart track" function by seeking to 0 with the up or down keys, like this:
Code: Select all
### Restart track <down>
"mpc seek 00:00:00"
   m:0x0 + c:116
 
### Restart track <up>
"mpc seek 00:00:00"
   m:0x0 + c:111
 


I think there is a bug somewhere with updating the UPnP playlist. If you go to next track, the UPnP playlist shows this, but if you go to the previous track, it plays the previous track, and the playlist is still showing the current track as unchanged.
Marmite
Music>iTunes>Minimserver>BubbleUPnP>RasPi3BRuneaudio0.4>
CambridgeAudioDACMagic>CyrusIIIi>Mission752>MyEars
MarmiteSandwich
 
Posts: 24
Joined: 19 Apr 2016, 22:50
Location: UK

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby hondagx35 » 31 Aug 2016, 23:49

Hi Marmite,

But where can we find the list of key codes which includes these and other keys?

With a display attached to HDMI and local browser enabled of course, try this
Code: Select all
export DISPLAY=":0" ; xbindkeys -k


I think there is a bug somewhere with updating the UPnP playlist.

We have to check this.

Frank
User avatar
hondagx35
 
Posts: 3026
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: IR Remote - Using Cheap USB PC Remote with Rune

Postby rern » 01 Sep 2016, 02:56

Some more tips:

xbindkeys option
    -k ....... detects a single key at a time.
    -mk ... detects multiple keys.

WinSCP
    Right-click can chmod, chown.
    Launch PuTTY SSH without retyping login and password.

By the way, @MarmiteSandwich can identify some key codes that even xbindkeys can't detect. Please share the trick.
Raspberry Pi 3 > SMSL M8 DAC
GitHub
rern
 
Posts: 361
Joined: 14 Jul 2016, 08:15

support RuneAudio Donate with PayPal

Next

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 8 guests