summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO6
-rw-r--r--PKGBUILD6
-rwxr-xr-xk780swap69
3 files changed, 50 insertions, 31 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 604c3f09878..43aa73357fb 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = k780-fnkeyctl
pkgdesc = Logitech K780 Fn-key configuration
- pkgver = 1
- pkgrel = 3
+ pkgver = 2
+ pkgrel = 1
url = https://google.com
arch = i686
arch = x86_64
@@ -10,7 +10,7 @@ pkgbase = k780-fnkeyctl
source = k780swap
source = 99-k780-config.rules
source = k780-fnkeyctl.sh
- sha256sums = 14bbd131bc286b56cfcf7587b4c9a9102d9faa82756332e68b244ddb17da817e
+ sha256sums = e16229978da17479bb9d4917c8abcd640893a506451350f389a3ccb6e202e5d3
sha256sums = 5966a4678955de2a914a4ad2156330050b5ff12be11977568a3bd62c022029a3
sha256sums = 98e2a3962c1d085e5e37b9b45b7a19734e3d0678554c0e1bfe12d753da860e19
diff --git a/PKGBUILD b/PKGBUILD
index 4791ca4d073..09f68ff178b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Fabien Devaux <fdev31@gmail.com>
pkgname=k780-fnkeyctl
-pkgver=1
-pkgrel=3
+pkgver=2
+pkgrel=1
pkgdesc="Logitech K780 Fn-key configuration"
arch=('i686' 'x86_64')
url="https://google.com"
@@ -11,7 +11,7 @@ depends=('libusb')
source=(k780swap
99-k780-config.rules
k780-fnkeyctl.sh)
-sha256sums=(14bbd131bc286b56cfcf7587b4c9a9102d9faa82756332e68b244ddb17da817e
+sha256sums=(e16229978da17479bb9d4917c8abcd640893a506451350f389a3ccb6e202e5d3
5966a4678955de2a914a4ad2156330050b5ff12be11977568a3bd62c022029a3
98e2a3962c1d085e5e37b9b45b7a19734e3d0678554c0e1bfe12d753da860e19)
diff --git a/k780swap b/k780swap
index ae975aa6061..0315f0ad39b 100755
--- a/k780swap
+++ b/k780swap
@@ -3,43 +3,62 @@
import sys
import time
import usb.core
+import atexit
-unifying=0xc52b
-activate = len(sys.argv) == 1
+DEVINDEX=2 # index of the device in unifying receiver
+ # 0xff for the receiver
-IFACE=2
-# find keyboard
-dev = usb.core.find(idVendor=0x046d, idProduct=unifying)
+class HIDpp:
+ def __init__(self, req_type, request, value, index):
+ self.__rt = req_type
+ self.__r = request
+ self.__v = value
+ self.__i = index
+ self.dev = None
+ atexit.register(self.clean)
-if dev is None:
- raise ValueError('Keyboard not found')
+ def clean(self):
+ self.dev.reset()
+ if self.reattach:
+ self.dev.attach_kernel_driver(self.__i)
-reattach = dev.is_kernel_driver_active(IFACE)
-if reattach:
- dev.detach_kernel_driver(IFACE)
+ def set_device(self, device):
+ if self.dev is not None:
+ self.clean()
+ self.dev = device
+ cfg = dev[0]
+ self.iface = cfg[(self.__i,0)]
+ self.reattach = self.dev.is_kernel_driver_active(self.__i)
+ if self.reattach:
+ dev.detach_kernel_driver(self.__i)
-# set the right interface
+ def send_short(self, subid, *args):
+ """
+ subid: 0-7f = reports & notifications // 80-ff = registers
+ """
+ report_id = 0x10 # short, 0x11 = long
+ data = [report_id, DEVINDEX, subid] + list(args)
+ self.dev.ctrl_transfer(self.__rt, self.__r, self.__v, self.__i, data)
-cfg = dev[0]
-iface = cfg[(IFACE,0)]
+ def read(self):
+ return self.iface[0].read(1000, 10000)
-dev.set_interface_altsetting(iface)
+activate = len(sys.argv) == 1
-# send frame
+# find unifying receiver
+dev = usb.core.find(idVendor=0x046d, idProduct=0xc52b)
-ON=[16, 2, 12, 26, 0, 0, 0]
-OFF=[16, 2, 12, 28, 1, 0, 0]
+if dev is None:
+ raise ValueError('Keyboard not found')
-dev.ctrl_transfer(33, 9, 528, 2, ON if activate else OFF)
+kbd = HIDpp(0x21, 0x9, 0x0210, 2)
-# have to wait (Why ??) and sometimes repeat !
+kbd.set_device(dev)
if activate:
- time.sleep(10)
+ kbd.send_short(0x0c, 0x1e, 0, 0, 0)
else:
- time.sleep(1)
-
-dev.reset()
-if reattach:
- dev.attach_kernel_driver(IFACE)
+ kbd.send_short(0x0c, 0x1e, 1, 0, 0)
+kbd.read()
+time.sleep(1)