From 6c6562761a447ea99bc7bc5588c9e84e7c2f0614 Mon Sep 17 00:00:00 2001 From: Tovarichtch Date: Sat, 9 Nov 2024 17:07:45 -0500 Subject: [PATCH 1/3] add new fusion gun firmware --- .../99-fusion-lightguns.rules | 19 +++ .../fusion-lightguns/fusion-lightguns-add | 137 +++++++++++++++++- 2 files changed, 152 insertions(+), 4 deletions(-) diff --git a/package/batocera/controllers/guns/fusion-lightguns/99-fusion-lightguns.rules b/package/batocera/controllers/guns/fusion-lightguns/99-fusion-lightguns.rules index 6d49cca3783..7da4aec7615 100755 --- a/package/batocera/controllers/guns/fusion-lightguns/99-fusion-lightguns.rules +++ b/package/batocera/controllers/guns/fusion-lightguns/99-fusion-lightguns.rules @@ -8,5 +8,24 @@ SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Mini P SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Mini P2 Keyboard", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 2" SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Mini P2 Mouse", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 2" +# Piggie p1 firmware +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 1 Keyboard", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 3" +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 1 Mouse", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 3" + +# Piggie p2 firmware +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 2 Keyboard", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 4" +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 2 Mouse", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 4" + +# Piggie p3 firmware +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 3 Keyboard", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 5" +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 3 Mouse", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 5" + +# Piggie p4 firmware +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 4 Keyboard", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 6" +SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Piggie 4 Mouse", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/fusion-lightguns-add 6" + +# Gamepad event must be disabled on Piggie firmware, this mode is unsupported for now +SUBSYSTEM=="input", ACTION=="add", ATTRS{name}=="Fusion Piggie [0-9]", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_JOYSTICK}="0" + # virtual lightgun SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Fusion Lightgun", MODE="0666", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_GUN}="1", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", ENV{ID_INPUT_MOUSE}="1" diff --git a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add index 2208a83892d..16b0aa829bb 100755 --- a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add +++ b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add @@ -37,10 +37,12 @@ trylock() { trylock checkRunningPIDAndExit1 -CHILDREN=$(evsieve-helper children "${PARENTHASH}" input usb) +CHILDREN=$(evsieve-helper children "${PARENTHASH}" input usb | grep -vE "Fusion Piggie [1-4]") # remove the joystick from the event cause it duplicates events NDEVS=$(echo "${CHILDREN}" | wc -l) ############ +# Old firmware +# # Player 1 ############ # Trigger : BTN_LEFT @@ -53,7 +55,7 @@ NDEVS=$(echo "${CHILDREN}" | wc -l) # Calibration button : BTN_EXTRA (mouse 5) # D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT ############ -# Player 2 +# Player 2 (1.00 firmware) ############ # Trigger : BTN_LEFT # L button 1 (Bomb) : BTN_MIDDLE @@ -65,6 +67,59 @@ NDEVS=$(echo "${CHILDREN}" | wc -l) # Calibration button : BTN_EXTRA (mouse 5) # D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT +############ +############ +# P.I.G.S. 1.05 firmware +# (based on OpenFIRE) +# +# Player 1 +############ +# Trigger : BTN_LEFT +# Pump : BTN_RIGHT +# Pedal : BTN_MIDDLE +# A : KEY_ENTER +# B : KEY_ESC +# C (calibration) : BTN_EXTRA +# Start : KEY_1 +# Select : KEY_5 +# D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT +############ +# Player 2 +############ +# Trigger : BTN_LEFT +# Pump : BTN_RIGHT +# Pedal : BTN_MIDDLE +# A : KEY_W +# B : KEY_BACKSPACE +# C : BTN_EXTRA +# Start : KEY_2 +# Select : KEY_6 +# D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT +############ +# Player 3 +############ +# Trigger : BTN_LEFT +# Pump : BTN_RIGHT +# Pedal : BTN_MIDDLE +# A : KEY_A +# B : KEY_PAGEUP +# C : BTN_EXTRA +# Start : KEY_3 +# Select : KEY_7 +# D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT +############ +# Player 4 +############ +# Trigger : BTN_LEFT +# Pump : BTN_RIGHT +# Pedal : BTN_MIDDLE +# A : KEY_S +# B : KEY_PAGEDOWN +# C : BTN_EXTRA +# Start : KEY_4 +# Select : KEY_8 +# D-pad : KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT + if test "${NDEVS}" = 2 then DEV1=$(echo "${CHILDREN}" | head -1 | cut -f 1) @@ -72,12 +127,86 @@ then if test "${PLAYER}" = "1" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right --map yield key:1 btn:middle --map yield key:5 btn:1 --map yield key:enter btn:2 --map yield key:esc btn:3 --map yield key:up btn:5 --map yield key:down btn:6 --map yield key:left btn:7 --map yield key:right btn:8 --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:1 btn:middle + --map yield key:5 btn:1 + --map yield key:enter btn:2 + --map yield key:esc btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "2" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right --map yield key:2 btn:middle --map yield key:6 btn:1 --map yield key:leftshift btn:2 --map yield key:leftctrl btn:3 --map yield key:up btn:5 --map yield key:down btn:6 --map yield key:left btn:7 --map yield key:right btn:8 --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:2 btn:middle + --map yield key:6 btn:1 + --map yield key:leftshift btn:2 + --map yield key:leftctrl btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + fi + + if test "${PLAYER}" = "3" + then + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:1 btn:middle + --map yield key:5 btn:1 + --map yield key:enter btn:2 + --map yield key:esc btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + fi + + if test "${PLAYER}" = "4" + then + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:2 btn:middle + --map yield key:6 btn:1 + --map yield key:w btn:2 + --map yield key:backspace btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + fi + + if test "${PLAYER}" = "5" + then + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:3 btn:middle + --map yield key:7 btn:1 + --map yield key:a btn:2 + --map yield key:pageup btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + fi + + if test "${PLAYER}" = "6" + then + nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right + --map yield key:4 btn:middle + --map yield key:8 btn:1 + --map yield key:s btn:2 + --map yield key:pagedown btn:3 + --map yield key:up btn:5 + --map yield key:down btn:6 + --map yield key:left btn:7 + --map yield key:right btn:8 + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi echo $! > "${PIDFILE}" From 4c0635513c5b289d0e12a72914d292cd643cddd5 Mon Sep 17 00:00:00 2001 From: Tovarichtch Date: Sun, 10 Nov 2024 10:04:42 -0500 Subject: [PATCH 2/3] Update fusion-lightguns-add --- .../fusion-lightguns/fusion-lightguns-add | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add index 16b0aa829bb..33012baf4ee 100755 --- a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add +++ b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add @@ -127,16 +127,18 @@ then if test "${PLAYER}" = "1" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:1 btn:middle - --map yield key:5 btn:1 - --map yield key:enter btn:2 - --map yield key:esc btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:1 btn:middle \ + --map yield key:5 btn:1 \ + --map yield key:enter btn:2 \ + --map yield key:esc btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "2" From d552c659cca84059a0061b2096ed405a4db25a22 Mon Sep 17 00:00:00 2001 From: Tovarichtch Date: Sun, 10 Nov 2024 16:03:59 -0500 Subject: [PATCH 3/3] make code clean again --- .../fusion-lightguns/fusion-lightguns-add | 134 ++++++++++-------- 1 file changed, 72 insertions(+), 62 deletions(-) diff --git a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add index 33012baf4ee..dd72cb51c9e 100755 --- a/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add +++ b/package/batocera/controllers/guns/fusion-lightguns/fusion-lightguns-add @@ -127,88 +127,98 @@ then if test "${PLAYER}" = "1" then - nohup evsieve \ - --input "${DEV1}" "${DEV2}" persist=exit \ - --map yield btn:middle btn:right \ - --map yield key:1 btn:middle \ - --map yield key:5 btn:1 \ - --map yield key:enter btn:2 \ - --map yield key:esc btn:3 \ - --map yield key:up btn:5 \ - --map yield key:down btn:6 \ - --map yield key:left btn:7 \ - --map yield key:right btn:8 \ - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:1 btn:middle \ + --map yield key:5 btn:1 \ + --map yield key:enter btn:2 \ + --map yield key:esc btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "2" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:2 btn:middle - --map yield key:6 btn:1 - --map yield key:leftshift btn:2 - --map yield key:leftctrl btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:2 btn:middle \ + --map yield key:6 btn:1 \ + --map yield key:leftshift btn:2 \ + --map yield key:leftctrl btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "3" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:1 btn:middle - --map yield key:5 btn:1 - --map yield key:enter btn:2 - --map yield key:esc btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:1 btn:middle \ + --map yield key:5 btn:1 \ + --map yield key:enter btn:2 \ + --map yield key:esc btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "4" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:2 btn:middle - --map yield key:6 btn:1 - --map yield key:w btn:2 - --map yield key:backspace btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:2 btn:middle \ + --map yield key:6 btn:1 \ + --map yield key:w btn:2 \ + --map yield key:backspace btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "5" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:3 btn:middle - --map yield key:7 btn:1 - --map yield key:a btn:2 - --map yield key:pageup btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:3 btn:middle \ + --map yield key:7 btn:1 \ + --map yield key:a btn:2 \ + --map yield key:pageup btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi if test "${PLAYER}" = "6" then - nohup evsieve --input "${DEV1}" "${DEV2}" persist=exit --map yield btn:middle btn:right - --map yield key:4 btn:middle - --map yield key:8 btn:1 - --map yield key:s btn:2 - --map yield key:pagedown btn:3 - --map yield key:up btn:5 - --map yield key:down btn:6 - --map yield key:left btn:7 - --map yield key:right btn:8 - --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & + nohup evsieve \ + --input "${DEV1}" "${DEV2}" persist=exit \ + --map yield btn:middle btn:right \ + --map yield key:4 btn:middle \ + --map yield key:8 btn:1 \ + --map yield key:s btn:2 \ + --map yield key:pagedown btn:3 \ + --map yield key:up btn:5 \ + --map yield key:down btn:6 \ + --map yield key:left btn:7 \ + --map yield key:right btn:8 \ + --output name="Fusion Lightgun" >/dev/null 2>"${LOGFILE}" & fi echo $! > "${PIDFILE}"