Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/checkpatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Kernel Coding Style Check

on: [pull_request, push]

jobs:
check-style:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download checkpatch.pl
run: wget https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl

- name: Run checkpatch.pl
run: perl checkpatch.pl --strict --no-tree <(git format-patch --stdout origin/master)
2 changes: 1 addition & 1 deletion hid-xpadneo/dkms.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DEST_MODULE_LOCATION[0]="/kernel/drivers/hid"
MAKE[0]="make -C '${kernel_source_dir}' M='${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/src' VERSION='${PACKAGE_VERSION}' modules"
CLEAN="make -C '${kernel_source_dir}' M='${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/src' clean"

BUILD_EXCLUSIVE_KERNEL_MIN="4.18.0"
BUILD_EXCLUSIVE_KERNEL_MIN="5.12.0"
BUILD_EXCLUSIVE_CONFIG="CONFIG_HID CONFIG_INPUT_FF_MEMLESS CONFIG_POWER_SUPPLY"

AUTOINSTALL="yes"
Expand Down
22 changes: 2 additions & 20 deletions hid-xpadneo/dkms.post_install
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
#!/bin/sh

#TODO Remove ERTM after kernel patch is deployed in the wild
# DKMS now defaults to kernel 5.12 minimum, remove ERTM override
ERTM_OVERRIDE="/etc/modprobe.d/99-xpadneo-bluetooth.conf"
DISABLE_ERTM="/sys/module/bluetooth/parameters/disable_ertm"

if [ "$(uname -r | awk -F. '{ printf "%03d%03d",$1,$2 }')" -ge 005012 ]; then
echo "Not disabling ERTM, kernel version doesn't require it..."
elif [ "$(readlink "${ERTM_OVERRIDE}" 2>/dev/null)" = "/dev/null" ]; then
echo "Not disabling ERTM, local override in place..."
elif [ -L "${ERTM_OVERRIDE}" ]; then
echo >&2 "WARNING: '${ERTM_OVERRIDE}' is an arbitrary symlink, this is not supported."
echo >&2 "Skipping ERTM fixup, you're expected to manage the options on your own..."
else
echo "Disabling ERTM permanently (requires reboot)..."
echo "options bluetooth disable_ertm=y" >"${ERTM_OVERRIDE}"
echo "HINT: If you want to prevent this in the future, run 'ln -snf /dev/null ${ERTM_OVERRIDE}'."

if [ -w "${DISABLE_ERTM}" ]; then
echo "Disabling ERTM instantly..."
echo "Y" >"${DISABLE_ERTM}"
fi
fi
[ -L "${ERTM_OVERRIDE}" ] || { echo "Forcing removal of ERTM override..."; rm -f "${ERTM_OVERRIDE}"; }

echo "Installing modalias database..."
install -D -m 0644 -t /etc/modprobe.d etc-modprobe.d/xpadneo.conf
Expand Down
3 changes: 1 addition & 2 deletions hid-xpadneo/dkms.post_remove
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh

#TODO Remove ERTM after kernel patch is deployed in the wild
# DKMS now defaults to kernel 5.12 minimum, remove ERTM override
ERTM_OVERRIDE="/etc/modprobe.d/99-xpadneo-bluetooth.conf"

[ -L "${ERTM_OVERRIDE}" ] || { echo "Uninstalling ERTM override..."; rm -f "${ERTM_OVERRIDE}"; }

echo "Uninstalling modalias database..."
Expand Down
15 changes: 15 additions & 0 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,13 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h
__set_bit(BTN_PADDLES(3), xdata->gamepad->keybit);
}

/* expose current profile as buttons */
__set_bit(BTN_PROFILES(0), xdata->gamepad->keybit);
__set_bit(BTN_PROFILES(1), xdata->gamepad->keybit);
__set_bit(BTN_PROFILES(2), xdata->gamepad->keybit);
__set_bit(BTN_PROFILES(3), xdata->gamepad->keybit);
input_report_key(xdata->gamepad, BTN_PROFILES(0), 1);

return 0;
}

Expand Down Expand Up @@ -1098,6 +1105,14 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
xpadneo_core_missing(xdata, XPADNEO_MISSING_KEYBOARD);

stop_processing:
/* report the profile change */
if (xdata->last_profile != xdata->profile) {
if (xdata->last_profile < 4)
input_report_key(gamepad, BTN_PROFILES(xdata->last_profile), 0);
input_report_key(gamepad, BTN_PROFILES(xdata->profile), 1);
xdata->last_profile = xdata->profile;
}

return 1;
}

Expand Down
9 changes: 5 additions & 4 deletions hid-xpadneo/src/xpadneo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ do { \
} while (0)

/* button aliases */
#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b))
#define BTN_SHARE KEY_F12
#define BTN_XBOX BTN_MODE
#define BTN_PROFILES(b) (BTN_TRIGGER_HAPPY33+(b))
#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b))
#define BTN_SHARE KEY_F12
#define BTN_XBOX BTN_MODE

/* module parameter "trigger_rumble_mode" */
#define PARAM_TRIGGER_RUMBLE_PRESSURE 0
Expand Down Expand Up @@ -159,7 +160,7 @@ struct xpadneo_devdata {

/* profile switching */
bool xbox_button_down, profile_switched;
u8 profile;
u8 last_profile, profile;

/* mouse mode */
bool mouse_mode;
Expand Down
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if [[ ! -d /sys/devices/virtual/misc/uhid ]]; then

fi

if [ "$(uname -r | awk -F. '{ printf "%03d%03d",$1,$2 }')" -ge 005012 ]; then

>&2 echo "WARNING: kernel 5.12 or lower will not be supported due to known ERTM issues"

fi

echo "* deploying DKMS package"
make "${MAKE_OPTS[@]}" VERSION="${VERSION}" install || maybe_already_installed

Expand Down
Loading