Touchscreens have become more and more common in all applications. However, on a boat that rolls and pitches constantly, touchscreens are not always the best choice. Yes, in the harbor or calm seas, it is nice to pan and zoom the map or adjust the settings using a touchscreen, but when the going gets a bit rougher, it is very hard to manage the chart plotter by trying to hit the buttons on a screen. Chart plotter may also be a bit out of reach behind the wheel. I have a 15.6″ touchscreen on my boat, but I have found it to be far from optimal when actually driving the boat. Therefore I designed a very low cost remote control device for OpenCPN.
The OpenCPN remote control is based on an off-the-shelf numpad keyboard. I have used Trust model 22221, but you can use any keypad. Mine is a wired version with a USB plug, but a wireless version should work as well. I have mapped OpenCPN functions that I feel are the most important to the keyboard and printed stickers with icons for each of the functions.
The supported functions are as follows (from top left to bottom right). There is also an OPT key that changes the function of certain keys.
- First row
- ESC / Close window with OPT key
- TAB
- Next WP (waypoint)
- Drop mark at ship position / Drop mark at cursor position with OPT key)
- Second row
- Show/hide depths
- Show/hide texts
- Show/hide bottom features
- No function
- Third row
- No function
- Pan chart up
- No function
- Zoom out
- Fourth row
- Pan chart left / Previous chart group with OPT key
- Auto-follow on/off
- Pan chart right / Next chart group with OPT key
- Zoom in
- Fifth row
- OPT key (when held down, changes the function of certain other keys)
- Pan chart down
- No function / Shut down computer with OPT key (small script needed)
- ENTER
- Sixth row
- Focus on left canvas (needed to target certain commands like pan and zoom to a specific canvas)
- Show virtual keyboard (small script needed)
- Focus on right canvas
- ENTER
The configuration of the numpad remote control in Linux works as follows
- Check what is the keycode of each of the numpad keys using xev command (type xev to Linux shell and it will start showing the keypresses in real-time)
- Use xmodmap to map the numpad keys to appropriate OpenCPN keys. Add a file .Xmodmap with the mappings to your home directory. Below are the mappings I have in .Xmodmap (these are based on the Trust numpad, a different numpad may require different mappings)
keycode 180 = Escape KP_Delete
keycode 163 = KP_Insert
keycode 148 = KP_Home KP_Home
keycode 77 = s
keycode 106 = t KP_Prior
keycode 63 = a
keycode 79 = NoSymbol NoSymbol NoSymbol
keycode 80 = Up
keycode 83 = Left Left Left
keycode 84 = F2
keycode 85 = Right Right Right
keycode 87 = Shift_L NoSymbol Shift_L
keycode 88 = Down
keycode 89 = NoSymbol KP_End
keycode 90 = KP_Left
keycode 65 = space KP_Separator
keycode 91 = KP_Right
keycode 81 = NoSymbol NoSymbol NoSymbol
3. Add the following line to autostart file at /etc/xdg/openbox/ folder. In case you are using some other window manager than Openbox, you will need to locate the place where the command is run at startup.
xmodmap ~/.Xmodmap &
4. To enable window close action, you will also need to make one change to Linux keybinds. On Openbox, the change is done to rc.xml file at ~/.config/openbox by adding a mapping as follows
<keybind key="A-F4">
<action name="Close"/>
</keybind>
5. Print and attach the icon stickers for your numpad. My editable and directly printable layout file that is optimized for the Trust numpad can be found here.