diff options
author | Stephen Martin | 2015-06-08 10:51:44 -0500 |
---|---|---|
committer | Stephen Martin | 2015-06-08 10:51:44 -0500 |
commit | df800f2c82bec4972384c17d76f653c41c5ca719 (patch) | |
tree | de89d0de0f54392e95d07e777983e311e25bb84c | |
download | aur-df800f2c82bec4972384c17d76f653c41c5ca719.tar.gz |
Updated to aur4
-rw-r--r-- | .SRCINFO | 23 | ||||
-rw-r--r-- | 99-blackwidow.rules | 1 | ||||
-rw-r--r-- | PKGBUILD | 40 | ||||
-rw-r--r-- | blackwidow_enable.py | 105 | ||||
-rwxr-xr-x | macroPrompt.sh | 15 | ||||
-rwxr-xr-x | macroRun.sh | 7 | ||||
-rw-r--r-- | razer-blackwidow-macro-scripts.install | 10 |
7 files changed, 201 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..1cff62109635 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,23 @@ +pkgbase = razer-blackwidow-macro-scripts + pkgdesc = Scripts to create and execute macros for the macro keys of the razer-blackwidow ultimate 2013 keyboard + pkgver = 2 + pkgrel = 1 + url = http://www.google.com + install = razer-blackwidow-macro-scripts.install + arch = any + license = Public Domain + depends = xmacro + depends = python2-pyusb + provides = blackwidow-enable-macro-keys + conflicts = blackwidow-enable-macro-keys + source = macroPrompt.sh + source = macroRun.sh + source = 99-blackwidow.rules + source = blackwidow_enable.py + md5sums = 22cb7243cdefe7229b5960ae92caf671 + md5sums = 8a56b47c6d20999e886761d6ddac6379 + md5sums = ee48c52536d7ff63992beac14ab2532c + md5sums = d7c158214ee3a849e00fc25a034ed93a + +pkgname = razer-blackwidow-macro-scripts + diff --git a/99-blackwidow.rules b/99-blackwidow.rules new file mode 100644 index 000000000000..9e4af850d10c --- /dev/null +++ b/99-blackwidow.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEM=="input",ATTRS{idVendor}=="1532", ATTRS{idProduct}=="011a", RUN+="/usr/bin/blackwidow-enable" diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..ccb6a227c536 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,40 @@ +# This is an example PKGBUILD file. Use this as a start to creating your own, +# and remove these comments. For more information, see 'man PKGBUILD'. +# NOTE: Please fill out the license field for your package! If it is unknown, +# then please put 'unknown'. + +# Maintainer: Stephen Martin <hwkiller at gmail dot com> +pkgname=razer-blackwidow-macro-scripts +pkgver=2 +pkgrel=1 +pkgdesc="Scripts to create and execute macros for the macro keys of the razer-blackwidow ultimate 2013 keyboard" +arch=('any') +url='http://www.google.com' +license=('Public Domain') +groups=() +depends=('xmacro' 'python2-pyusb') +provides=('blackwidow-enable-macro-keys') +conflicts=('blackwidow-enable-macro-keys') +install='razer-blackwidow-macro-scripts.install' +source=('macroPrompt.sh' + 'macroRun.sh' + '99-blackwidow.rules' + 'blackwidow_enable.py') +md5sums=('22cb7243cdefe7229b5960ae92caf671' + '8a56b47c6d20999e886761d6ddac6379' + 'ee48c52536d7ff63992beac14ab2532c' + 'd7c158214ee3a849e00fc25a034ed93a') + +prepare(){ + cd $srcdir + sed 's^#!/usr/bin/python^#!/usr/bin/env python2^g' \ + -i "$srcdir/blackwidow_enable.py" +} + +package() { + cd "$srcdir" + install -D -m 644 macroPrompt.sh $pkgdir/usr/bin/macroPrompt.sh + install -D -m 644 macroRun.sh $pkgdir/usr/bin/macroRun.sh + install -D -m 644 99-blackwidow.rules $pkgdir/usr/lib/udev/rules.d/99-blackwidow.rules + install -D -m 755 blackwidow_enable.py $pkgdir/usr/bin/blackwidow-enable +} diff --git a/blackwidow_enable.py b/blackwidow_enable.py new file mode 100644 index 000000000000..7fcd415d04be --- /dev/null +++ b/blackwidow_enable.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python2 + +# blackwidow_enable.py +# +# Enables the M1-5 and FN keys to send scancodes on the Razer BlackWidow +# and BlackWidow Ultimate keyboards. +# +# Requires the PyUSB library. +# +# By Michael Fincham <michael@finch.am> 2012-03-05 +# This code is released in to the public domain. + +import sys +import usb + +USB_VENDOR = 0x1532 # Razer +USB_PRODUCT = 0x011a # BlackWidow / BlackWidow Ultimate +#USB_PRODUCT = 0x010d # BlackWidow / BlackWidow Ultimate +#USB_PRODUCT = 0x011b # BlackWidow / BlackWidow Ultimate + +# These values are from the USB HID 1.11 spec section 7.2. +# <http://www.usb.org/developers/devclass_docs/HID1_11.pdf> +USB_REQUEST_TYPE = 0x21 # Host To Device | Class | Interface +USB_REQUEST = 0x09 # SET_REPORT + +# These values are from the manufacturer's driver. +USB_VALUE = 0x0300 +USB_INDEX = 0x2 +USB_INTERFACE = 2 + +# These magic bytes are also from the manufacturer's driver. +#USB_BUFFER = b"\x00\x00\x00\x00\x00\x01\x00\x04\x03\x00\x00\x00\x00\x00\ +#\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +#\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +#\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +#\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00" +# +USB_BUFFER = b"\ +\x00\x00\x00\x00\x00\x02\x00\x04\x02\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00" +def find_keyboard_device(): + for bus in usb.busses(): + for device in bus.devices: + if device.idVendor == USB_VENDOR and \ + device.idProduct == USB_PRODUCT: + return device + + +def main(): + + device = find_keyboard_device() + if device == None: + sys.stderr.write("BlackWidow not found.\n") + sys.exit(1) + + try: + handle = device.open() + interface = device.configurations[0].interfaces[USB_INTERFACE][0] + endpoint = interface.endpoints[0] + except: + sys.stderr.write("Could not select configuration endpoint.\n") + sys.exit(1) + + try: + handle.detachKernelDriver(interface) + except usb.USBError: + pass # This is usually because the enabler was run before and the kernel is still detached + except Exception: + sys.stderr.write("A very unusual error happened trying to detch the kernel driver.\n") + sys.exit(1) + + try: + handle.claimInterface(interface) + except: + sys.stderr.write("Unable to claim the configuration interface. Do you have the appropriate privileges?\n") + sys.exit(1) + + result = 0 + + try: + result = handle.controlMsg(requestType=USB_REQUEST_TYPE, + request=USB_REQUEST, + value=USB_VALUE, + index=USB_INDEX, + buffer=USB_BUFFER) + except: + sys.stderr.write("Could not write the magic bytes to the BlackWidow.\n") + + if result == len(USB_BUFFER): + sys.stderr.write("Configured BlackWidow.\n") + + try: + handle.releaseInterface() + except: + sys.stderr.write("Unable to release interface.\n") + sys.exit(1) + + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/macroPrompt.sh b/macroPrompt.sh new file mode 100755 index 000000000000..ca76fc233548 --- /dev/null +++ b/macroPrompt.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +macroDir=~/.config/xmacro +if [ ! -d ${macroDir} ];then + mkdir -p ${macrodir} +fi + +echo "Which macro button should this be assigned to? [1-5]" +read macroNumber + +fileName=macro${macroNumber}.rec + +xmacrorec2 -o ${macroDir}/${fileName} + + diff --git a/macroRun.sh b/macroRun.sh new file mode 100755 index 000000000000..24415773e15c --- /dev/null +++ b/macroRun.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +macroNumber=$1 +macroName=macro${macroNumber}.rec +macroDir=~/.config/xmacro + +xmacroplay :0 < $macroDir/${macroName} diff --git a/razer-blackwidow-macro-scripts.install b/razer-blackwidow-macro-scripts.install new file mode 100644 index 000000000000..2c96c8e0e2f0 --- /dev/null +++ b/razer-blackwidow-macro-scripts.install @@ -0,0 +1,10 @@ +post_install() { + echo "UDev will configure the keys" + echo 'Bind a key to execute macroPrompt.sh, then bind a key to execute macroRun.sh $macroNumber' +} + +post_upgrade(){ + echo "UDev will configure the keys" + echo 'Bind a key to execute macroPrompt.sh, then bind a key to execute macroRun.sh $macroNumber' + +} |