DevTerm’s arrows and buttons are good for navigating in command line. But they don’t react to key press.
Luckly we can borrow idea from RetroPie distribution: joy2key.py
In the following bash script, ‘joy2key.py’ will be forked and run along with Midnight Commander.
And the python script will push keycode to programs that you are using in background. So they can react to arrows and buttons without C/C++ coding.
Here is steps:
((1)) clone RetroPie repository to /home/pi/RetroPie-Setup
You don’t need to proceed the long installation process. Since we will just borrow only some scripts.
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
((2)) save the following script to file and run.(Actually I saved the following script to ~/.zshrc so that whenever I run ‘zsh’, Midnight commander will launch.)
# Joystick information
export SDL_GAMECONTROLLERCONFIG="03000000af1e00002400000010010000,ClockworkPI DevTerm,platform:Linux,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftx:a0,lefty:a1,"
# left right up down a:<CR> b:<space> x:<F10> y:<F9>
readonly CONFIG=(kcub1 kcuf1 kcuu1 kcud1 0x0d 0x20 kf10 kf9)
if [[ -f $JOY2KEY_SCRIPTLOC ]]; then
echo "Can't import Joy2Key Script! Error!"
echo "Script not found in: $JOY2KEY_SCRIPTLOC"
# hide cursor
echo -en "\e[?25l"
# Run Midnight Commander.
# If mc is closed, then stop the joy2key process in background.
By this simple script, we can use arrows/buttons in command line. And it may work in X-Window.
I found the above script does not run latest RetroPie-Setup. I’ll try to adjust with new retropie.
The arrow key always send arrow keys?!
The switch change the gamepad into sending key event instead of joystick event, and the “D Pad” will send arrow key event, Start/Select and ABXY will send other key event.
You can try yourself really fast, it takes litteraly less than a minute to move the switch and see what it is doing.
Sorry, terminology problem (not a gamer here). I refered to the “D-Pad” as “arrow keys” because they’re keys with arrows, which is of course very ambiguous since another set of “arrow keys” is already present on the keyboard.
I wanted to use D-Pad arrows and Buttons (A/B/X/Y) in command line without X-window env.
It is quite useful for me to use them because they are at top-most in keypad. It is better than Arrows at right-bottom.
And also I can reassign custom keycode on each buttons by adjusting ascii code as arguments to joy2key_sdl.py.
You can also use AntiMicroX (in the repos as antimicro) to configure keyboard emulation if that’s more comfortable for you. You will, however, need to ignore the rather excessive set of axis and buttons the device descriptor reports.
Not compatible with pure text mode, but if you usually just put a terminal fullscreen in X, it does the trick.
Hi, when I try to run the retropi setup I get the message 'Unknown platform - please manually set the __platform variable to one of the following", and then a long list of platforms. Did you have to do this? If so, what platform did you pick?
Because RetroPie is being actively developed, I chose to stick to specific version of Repository.
It’s hash value is “c70801758a42fc0d017d9022e68c524578602b25”.
You may have to dig into for other version.