Skip to content

Commit

Permalink
Merge pull request #45 from tiopex/master
Browse files Browse the repository at this point in the history
Add joy to keyboard button mapper
  • Loading branch information
tiopex authored Oct 25, 2023
2 parents 1d2b3e0 + 704865b commit 1cdeb8b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 2 deletions.
2 changes: 2 additions & 0 deletions board/miyoo/main/apps/joymap/input_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
input_info /dev/input/event1 >> /mnt/input.log
7 changes: 7 additions & 0 deletions board/miyoo/main/apps/joymap/joymap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/busybox sh

if pgrep "loadmap" 2> /dev/null; then
killall -2 loadmap
else
loadmap /mnt/joymap.map -d -b
fi
3 changes: 3 additions & 0 deletions board/miyoo/main/gmenu2x/sections/applications/joymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title=Joymap
description=Joy to keyboard mapper
exec=/mnt/apps/joymap/joymap.sh
35 changes: 35 additions & 0 deletions board/miyoo/main/joymap.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#Microsoft X-Box One S pad
button vendor=0x045e product=0x2ea src=16 target=kbd button="leftalt"
button vendor=0x045e product=0x2ea src=17 target=kbd button="leftctrl"
button vendor=0x045e product=0x2ea src=19 target=kbd button="leftshift"
button vendor=0x045e product=0x2ea src=20 target=kbd button="space"
button vendor=0x045e product=0x2ea src=22 target=kbd button="tab"
button vendor=0x045e product=0x2ea src=23 target=kbd button="backspace"
button vendor=0x045e product=0x2ea src=24 target=kbd button="rightalt"
button vendor=0x045e product=0x2ea src=25 target=kbd button="rightshift"
button vendor=0x045e product=0x2ea src=26 target=kbd button="esc"
button vendor=0x045e product=0x2ea src=27 target=kbd button="enter"
axis vendor=0x045e product=0x2ea src=16 target=kbd plus="right" minus="left" flags=trinary
axis vendor=0x045e product=0x2ea src=17 target=kbd plus="down" minus="up" flags=trinary

#Generic USB 2.4GHz gamepad (device "ShanWan PC/PS3/Android")
##mapping for 13 physical buttons and 6 axis (D-PAD + 2 analog sticks)
button vendor=0x2563 product=0x0575 src=16 target=kbd button="leftshift" #Δ
button vendor=0x2563 product=0x0575 src=17 target=kbd button="leftalt" #O
button vendor=0x2563 product=0x0575 src=18 target=kbd button="leftctrl" #X
button vendor=0x2563 product=0x0575 src=19 target=kbd button="space" #█
button vendor=0x2563 product=0x0575 src=20 target=kbd button="tab" #L1
button vendor=0x2563 product=0x0575 src=21 target=kbd button="backspace" #R1
button vendor=0x2563 product=0x0575 src=22 target=kbd button="pgup" #L2
button vendor=0x2563 product=0x0575 src=23 target=kbd button="pgdn" #R2
button vendor=0x2563 product=0x0575 src=24 target=kbd button="esc" #SELECT
button vendor=0x2563 product=0x0575 src=25 target=kbd button="enter" #START
button vendor=0x2563 product=0x0575 src=26 target=kbd button="rightalt" #L3
button vendor=0x2563 product=0x0575 src=27 target=kbd button="rightshift" #R3
button vendor=0x2563 product=0x0575 src=28 target=kbd button="rightctrl" #ANALOG switch digital/analog button
axis vendor=0x2563 product=0x0575 src=0 target=kbd minus="left" plus="right" min=0 max=255 deadzone=129 flags=trinary #D-PAD or RStick ANALOG
axis vendor=0x2563 product=0x0575 src=1 target=kbd minus="up" plus="down" min=0 max=255 deadzone=129 flags=trinary #D-PAD or RStick ANALOG
axis vendor=0x2563 product=0x0575 src=2 target=kbd minus="left" plus="right" min=0 max=255 deadzone=129 flags=trinary #LStick
axis vendor=0x2563 product=0x0575 src=5 target=kbd minus="up" plus="down" min=0 max=255 deadzone=129 flags=trinary #LStick
axis vendor=0x2563 product=0x0575 src=16 target=kbd minus="left" plus="right" flags=trinary #D-PAD ANALOG
axis vendor=0x2563 product=0x0575 src=17 target=kbd minus="up" plus="down" flags=trinary #D-PAD ANALOG
1 change: 0 additions & 1 deletion configs/miyoo_musl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ BR2_PACKAGE_SDL_SOUND=y
BR2_PACKAGE_SDL_SOUND_PLAYSOUND=y
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_DBUS=y
BR2_PACKAGE_JOY2KEY=y
BR2_PACKAGE_LINUXCONSOLETOOLS=y
BR2_PACKAGE_LINUXCONSOLETOOLS_JOYSTICK=y
BR2_PACKAGE_PARTED=y
Expand Down
2 changes: 1 addition & 1 deletion configs/miyoo_uclibc_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ BR2_PACKAGE_SDL_SOUND=y
BR2_PACKAGE_SDL_SOUND_PLAYSOUND=y
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_DBUS=y
BR2_PACKAGE_JOY2KEY=y
BR2_PACKAGE_JOYMAP=y
BR2_PACKAGE_LINUXCONSOLETOOLS=y
BR2_PACKAGE_LINUXCONSOLETOOLS_JOYSTICK=y
BR2_PACKAGE_PARTED=y
Expand Down
1 change: 1 addition & 0 deletions package/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ endmenu
source "package/irda-utils/Config.in"
source "package/iucode-tool/Config.in"
source "package/joy2key/Config.in"
source "package/joymap/Config.in"
source "package/kbd/Config.in"
source "package/lcdproc/Config.in"
source "package/libiec61850/Config.in"
Expand Down
4 changes: 4 additions & 0 deletions package/joymap/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config BR2_PACKAGE_JOYMAP
bool "joymap"
help
Joymap will translate your joystick movements into the equivilent keystrokes
14 changes: 14 additions & 0 deletions package/joymap/joymap.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
JOYMAP_VERSION = origin/master
JOYMAP_SITE_METHOD = git
JOYMAP_SITE = https://git.code.sf.net/p/linuxjoymap/git
define JOYMAP_BUILD_CMDS
$(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" LD="$(TARGET_LD)" -C $(@D) -f Makefile
"$(TARGET_CC)" $(@D)/tools/input_info.c -o $(@D)/tools/input_info
endef

define JOYMAP_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/loadmap $(TARGET_DIR)/usr/bin
$(INSTALL) -D -m 0755 $(@D)/tools/input_info $(TARGET_DIR)/usr/bin
endef

$(eval $(generic-package))

0 comments on commit 1cdeb8b

Please sign in to comment.