From 515379acad55b82c908e7672d49d0a34e3506e8b Mon Sep 17 00:00:00 2001 From: tiopex Date: Tue, 10 Oct 2023 13:45:26 +0200 Subject: [PATCH 1/4] add Linux Joystick Mapper --- board/miyoo/main/apps/joymap/joymap.sh | 2 ++ .../main/gmenu2x/sections/applications/joymap | 3 +++ board/miyoo/main/joymap.map | 15 +++++++++++++++ configs/miyoo_musl_defconfig | 1 - configs/miyoo_uclibc_defconfig | 2 +- package/Config.in | 1 + package/joymap/Config.in | 4 ++++ package/joymap/joymap.mk | 12 ++++++++++++ 8 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 board/miyoo/main/apps/joymap/joymap.sh create mode 100644 board/miyoo/main/gmenu2x/sections/applications/joymap create mode 100644 board/miyoo/main/joymap.map create mode 100644 package/joymap/Config.in create mode 100644 package/joymap/joymap.mk diff --git a/board/miyoo/main/apps/joymap/joymap.sh b/board/miyoo/main/apps/joymap/joymap.sh new file mode 100644 index 000000000..f2ceedf8f --- /dev/null +++ b/board/miyoo/main/apps/joymap/joymap.sh @@ -0,0 +1,2 @@ +#!/bin/busybox sh +loadmap /mnt/joymap.map -b \ No newline at end of file diff --git a/board/miyoo/main/gmenu2x/sections/applications/joymap b/board/miyoo/main/gmenu2x/sections/applications/joymap new file mode 100644 index 000000000..4ef9e87f6 --- /dev/null +++ b/board/miyoo/main/gmenu2x/sections/applications/joymap @@ -0,0 +1,3 @@ +title=Joymap +description=Joy to keyboard mapper +exec=/mnt/apps/joymap/joymap.sh diff --git a/board/miyoo/main/joymap.map b/board/miyoo/main/joymap.map new file mode 100644 index 000000000..77ef81cb3 --- /dev/null +++ b/board/miyoo/main/joymap.map @@ -0,0 +1,15 @@ +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=18 target=kbd button="" +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=21 target=kbd button="" +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" + + +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 diff --git a/configs/miyoo_musl_defconfig b/configs/miyoo_musl_defconfig index 33c56fc62..1457d013b 100644 --- a/configs/miyoo_musl_defconfig +++ b/configs/miyoo_musl_defconfig @@ -77,7 +77,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 diff --git a/configs/miyoo_uclibc_defconfig b/configs/miyoo_uclibc_defconfig index 6d7cfb9a5..f6b185f4f 100644 --- a/configs/miyoo_uclibc_defconfig +++ b/configs/miyoo_uclibc_defconfig @@ -76,7 +76,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 diff --git a/package/Config.in b/package/Config.in index 4fd805653..936d9a338 100644 --- a/package/Config.in +++ b/package/Config.in @@ -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" diff --git a/package/joymap/Config.in b/package/joymap/Config.in new file mode 100644 index 000000000..287d93107 --- /dev/null +++ b/package/joymap/Config.in @@ -0,0 +1,4 @@ +config BR2_PACKAGE_JOYMAP + bool "joymap" + help + Joymap will translate your joystick movements into the equivilent keystrokes diff --git a/package/joymap/joymap.mk b/package/joymap/joymap.mk new file mode 100644 index 000000000..d3ec9a43e --- /dev/null +++ b/package/joymap/joymap.mk @@ -0,0 +1,12 @@ +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 +endef + +define JOYMAP_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/loadmap $(TARGET_DIR)/usr/bin +endef + +$(eval $(generic-package)) \ No newline at end of file From 96ee5d94832a99a55958f7c7b7755e52e9a0ae5f Mon Sep 17 00:00:00 2001 From: tiopex Date: Wed, 11 Oct 2023 09:23:38 +0200 Subject: [PATCH 2/4] Add input_info app to discover buttons src numbers, add '-d' parameter to dynamically (during use) compute calibration value so that events are reported in the range -32767 to 32767 --- board/miyoo/main/apps/joymap/joymap.sh | 2 +- board/miyoo/main/joymap.map | 6 ++---- package/joymap/joymap.mk | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/board/miyoo/main/apps/joymap/joymap.sh b/board/miyoo/main/apps/joymap/joymap.sh index f2ceedf8f..7a1d56a56 100644 --- a/board/miyoo/main/apps/joymap/joymap.sh +++ b/board/miyoo/main/apps/joymap/joymap.sh @@ -1,2 +1,2 @@ #!/bin/busybox sh -loadmap /mnt/joymap.map -b \ No newline at end of file +loadmap /mnt/joymap.map -d -b \ No newline at end of file diff --git a/board/miyoo/main/joymap.map b/board/miyoo/main/joymap.map index 77ef81cb3..37043f44e 100644 --- a/board/miyoo/main/joymap.map +++ b/board/miyoo/main/joymap.map @@ -1,15 +1,13 @@ +#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=18 target=kbd button="" 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=21 target=kbd button="" 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 diff --git a/package/joymap/joymap.mk b/package/joymap/joymap.mk index d3ec9a43e..7ed1f4c24 100644 --- a/package/joymap/joymap.mk +++ b/package/joymap/joymap.mk @@ -3,10 +3,12 @@ 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)) \ No newline at end of file From 1f903c9fca5632c2562a37c62e9d018222aae541 Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Fri, 13 Oct 2023 00:16:06 +0200 Subject: [PATCH 3/4] add ShanWan gamepad for `joymap.map` --- board/miyoo/main/apps/joymap/input_info.sh | 2 ++ board/miyoo/main/joymap.map | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 board/miyoo/main/apps/joymap/input_info.sh diff --git a/board/miyoo/main/apps/joymap/input_info.sh b/board/miyoo/main/apps/joymap/input_info.sh new file mode 100644 index 000000000..0ec3b4619 --- /dev/null +++ b/board/miyoo/main/apps/joymap/input_info.sh @@ -0,0 +1,2 @@ +#!/bin/sh +input_info /dev/input/event1 >> /mnt/input.log diff --git a/board/miyoo/main/joymap.map b/board/miyoo/main/joymap.map index 37043f44e..6cf1b3639 100644 --- a/board/miyoo/main/joymap.map +++ b/board/miyoo/main/joymap.map @@ -11,3 +11,25 @@ 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 \ No newline at end of file From 704865b07c2e4577cf414f035beb886dc7d8877d Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:07:39 +0200 Subject: [PATCH 4/4] joymap.sh - kill SIGINT `loadmap` on second run --- board/miyoo/main/apps/joymap/joymap.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/board/miyoo/main/apps/joymap/joymap.sh b/board/miyoo/main/apps/joymap/joymap.sh index 7a1d56a56..6049f6aa7 100644 --- a/board/miyoo/main/apps/joymap/joymap.sh +++ b/board/miyoo/main/apps/joymap/joymap.sh @@ -1,2 +1,7 @@ #!/bin/busybox sh -loadmap /mnt/joymap.map -d -b \ No newline at end of file + +if pgrep "loadmap" 2> /dev/null; then + killall -2 loadmap +else + loadmap /mnt/joymap.map -d -b +fi