-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(WIP - UNTESTED) Only the basics, it's missing all the extra features. Simplicity for calibration is missing. Must go to `pause mode` first by pressing `C` and `SELECT` at the same time, then select profile, then calibrate, then confirm with trigger. Not user-friendly, need workaround for simplicity.
- Loading branch information
1 parent
bd7329c
commit 999a110
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
package/batocera/controllers/guns/openfire-guns/99-openfire-guns.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Three events at all time: | ||
# Keyboard, Mouse and Gamepad | ||
SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="OpenFIRE FIRECon Keyboard", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/openfire-guns-add" | ||
SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="OpenFIRE FIRECon Mouse", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/openfire-guns-add" | ||
SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="OpenFIRE FIRECon", ENV{ID_INPUT_JOYSTICK}="0", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_KEYBOARD}="0", ENV{ID_INPUT_KEY}="0", RUN+="/usr/bin/openfire-guns-add" | ||
|
||
# Virtual Light Gun | ||
SUBSYSTEM=="input", ACTION=="add", ATTRS{name}=="OpenFIRE FIRECon light gun", 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
config BR2_PACKAGE_OPENFIRE_GUNS | ||
bool "openfire-guns" | ||
select BR2_PACKAGE_EVSIEVE | ||
|
||
help | ||
openfire guns support |
15 changes: 15 additions & 0 deletions
15
package/batocera/controllers/guns/openfire-guns/openfire-guns.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
################################################################################ | ||
# | ||
# OpenFIRE FIRECon light guns | ||
# | ||
################################################################################ | ||
OPENFIRE_GUNS_VERSION = 1 | ||
OPENFIRE_GUNS_LICENSE = GPL | ||
OPENFIRE_GUNS_SOURCE = | ||
|
||
define openfire_GUNS_INSTALL_TARGET_CMDS | ||
$(INSTALL) -m 0644 -D $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/controllers/guns/openfire-guns/99-openfire-guns.rules $(TARGET_DIR)/etc/udev/rules.d/99-openfire-guns.rules | ||
$(INSTALL) -m 0755 -D $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/controllers/guns/openfire-guns/openfire-guns-add $(TARGET_DIR)/usr/bin/openfire-guns-add | ||
endef | ||
|
||
$(eval $(generic-package)) |
75 changes: 75 additions & 0 deletions
75
package/batocera/controllers/guns/openfire-guns/virtual-openfire-add
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
test "${ACTION}" = "add" || exit 0 | ||
echo "${DEVNAME}" | grep -E "^/dev/input/event[0-9]+$" || exit 0 | ||
|
||
PARENTHASH=$(evsieve-helper parent "${DEVNAME}" input usb) | ||
BASEFILE="/var/run/virtual-openfire-devices.${PARENTHASH}" | ||
PIDFILE="${BASEFILE}.pid" | ||
LOCKFILE="${BASEFILE}.lock" | ||
LOGFILE="${BASEFILE}.log" | ||
|
||
unlockAndExit() { | ||
rmdir "${LOCKFILE}" | ||
exit "${1}" | ||
} | ||
|
||
checkRunningPIDAndExit1() { | ||
test ! -e "${PIDFILE}" && return 0 | ||
LPID=$(cat "${PIDFILE}") | ||
test ! -d "/proc/${LPID}" && return 0 | ||
unlockAndExit 1 | ||
} | ||
|
||
trylock() { | ||
# lock | ||
N=0 | ||
while ! mkdir "${LOCKFILE}" | ||
do | ||
sleep 1 | ||
let N++ | ||
test "${N}" -gt 30 && exit 1 # give up | ||
done | ||
} | ||
|
||
trylock | ||
checkRunningPIDAndExit1 | ||
|
||
CHILDREN=$(evsieve-helper children "${PARENTHASH}" input usb) | ||
NDEVS=$(echo "${CHILDREN}" | wc -l) | ||
|
||
if test "${NDEVS}" = 2 | ||
then | ||
DEV1=$(echo "${CHILDREN}" | head -1 | cut -f 1) | ||
DEV2=$(echo "${CHILDREN}" | head -2 | tail -1 | cut -f 1) | ||
DEV3=$(echo "${CHILDREN}" | head -3 | tail -1 | cut -f 1) | ||
|
||
# Based on the enclosed instruction book from official Github | ||
# | ||
# Trigger : BTN_LEFT | ||
# A / PUMP : BTN_RIGHT | ||
# B : BTN_MIDDLE | ||
# Foot pedal / C : BTN_SIDE | ||
# Alt pedal : BTN_EXTRA | ||
# Start : KEY_1 | ||
# Select : KEY_5 | ||
# D-pad up : KEY_UP | ||
# D-pad down : KEY_DOWN | ||
# D-pad left : KEY_LEFT | ||
# D-pad right : KEY_RIGHT | ||
|
||
nohup evsieve --input "${DEV1}" "${DEV2}" "${DEV3}" persist=exit --map yield btn:middle btn:2 | ||
--map yield btn:side btn:right | ||
--map yield key:1 btn:middle | ||
--map yield key:5 btn:1 | ||
--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="OpenFIRE light gun" >/dev/null 2>"${LOGFILE}" & | ||
echo $! > "${PIDFILE}" | ||
else | ||
unlockAndExit 1 | ||
fi | ||
|
||
unlockAndExit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters