1{ config, lib, ... }:
2let
3 cfg = config.hardware.xpadneo;
4in
5{
6 options.hardware.xpadneo = {
7 enable = lib.mkEnableOption "the xpadneo driver for Xbox One wireless controllers";
8 };
9
10 config = lib.mkIf cfg.enable {
11 boot = {
12 # Must disable Enhanced Retransmission Mode to support bluetooth pairing
13 # https://wiki.archlinux.org/index.php/Gamepad#Connect_Xbox_Wireless_Controller_with_Bluetooth
14 extraModprobeConfig = lib.mkIf (
15 config.hardware.bluetooth.enable
16 && (lib.versionOlder config.boot.kernelPackages.kernel.version "5.12")
17 ) "options bluetooth disable_ertm=1";
18
19 extraModulePackages = with config.boot.kernelPackages; [ xpadneo ];
20 kernelModules = [ "hid_xpadneo" ];
21 };
22 };
23
24 meta = {
25 maintainers = with lib.maintainers; [ kira-bruneau ];
26 };
27}