summary refs log tree commit diff
path: root/pkgs/tools/misc/sixpair
diff options
context:
space:
mode:
authorTom Smeets <tom@tsmeets.nl>2018-07-06 00:04:27 +0200
committerxeji <36407913+xeji@users.noreply.github.com>2018-07-06 00:04:27 +0200
commitcdebd1c61f9dc713406ced66923bf9dd678d813c (patch)
tree793aacdf5ef07bf9d0681ffe571db0a8c183ce36 /pkgs/tools/misc/sixpair
parentb1abb5a8c256a8cd2361ca7aea06111776bc3cbe (diff)
downloadnixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar.gz
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar.bz2
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar.lz
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar.xz
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.tar.zst
nixpkgs-cdebd1c61f9dc713406ced66923bf9dd678d813c.zip
sixpair: init at 2007-04-18 (#43072)
This is a small c program used for pairing with a wireless PlayStation 3 controller via bluetooth.
I included a patch that replaces the depricated 'hcitool' command with 'bluetoothctl'.

For further info visit: http://www.pabr.org/sixlinux/
Diffstat (limited to 'pkgs/tools/misc/sixpair')
-rw-r--r--pkgs/tools/misc/sixpair/default.nix38
-rw-r--r--pkgs/tools/misc/sixpair/hcitool.patch19
2 files changed, 57 insertions, 0 deletions
diff --git a/pkgs/tools/misc/sixpair/default.nix b/pkgs/tools/misc/sixpair/default.nix
new file mode 100644
index 00000000000..055fa9418a9
--- /dev/null
+++ b/pkgs/tools/misc/sixpair/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, libusb }:
+stdenv.mkDerivation {
+  name = "sixpair-2007-04-18";
+
+  src = fetchurl {
+    url = http://www.pabr.org/sixlinux/sixpair.c;
+    sha256 = "1b0a3k7gs544cbji7n29jxlrsscwfx6s1r2sgwdl6hmkc1l9gagr";
+  };
+
+  # hcitool is depricated
+  patches = [ ./hcitool.patch ];
+
+  buildInputs = [ libusb ];
+
+  unpackPhase = ''
+    cp $src sixpair.c
+  '';
+
+  buildPhase = ''
+    cc -o sixpair sixpair.c -lusb
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp sixpair $out/bin/sixpair
+  '';
+
+  meta = {
+    description = "Pair with SIXAXIS controllers over USB";
+    longDescription = ''
+      This command-line utility searches USB buses for SIXAXIS controllers and tells them to connect to a new Bluetooth master.
+    '';
+    homepage = http://www.pabr.org/sixlinux/;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ stdenv.lib.maintainers.tomsmeets ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/tools/misc/sixpair/hcitool.patch b/pkgs/tools/misc/sixpair/hcitool.patch
new file mode 100644
index 00000000000..b66e791dd0e
--- /dev/null
+++ b/pkgs/tools/misc/sixpair/hcitool.patch
@@ -0,0 +1,19 @@
+diff --git a/sixpair.c b/sixpair.c
+index b009a6f..78b7ef0 100644
+--- a/sixpair.c
++++ b/sixpair.c
+@@ -76,11 +76,11 @@ void process_device(int argc, char **argv, struct usb_device *dev,
+       exit(1);
+     }
+   } else {
+-    FILE *f = popen("hcitool dev", "r");
++    FILE *f = popen("bluetoothctl list", "r");
+     if ( !f ||
+-	 fscanf(f, "%*s\n%*s %x:%x:%x:%x:%x:%x",
++	 fscanf(f, "%*s %x:%x:%x:%x:%x:%x",
+ 		&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]) != 6 ) {
+-      printf("Unable to retrieve local bd_addr from `hcitool dev`.\n");
++      printf("Unable to retrieve local bd_addr from `bluetoothctl list`.\n");
+       printf("Please enable Bluetooth or specify an address manually.\n");
+       exit(1);
+     }