Fix gamemode warning, send no pulsate separately
This commit is contained in:
parent
1cb36e2c4a
commit
bab993b94d
|
@ -27,17 +27,17 @@ class blackwidow(object):
|
||||||
if self.device is None:
|
if self.device is None:
|
||||||
self.device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID_BLACK_WIDOW_2013)
|
self.device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID_BLACK_WIDOW_2013)
|
||||||
if self.device is None:
|
if self.device is None:
|
||||||
LOG("No device found.\n")
|
LOG("No device found\n")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
LOG("Found device Black Widow 2013.\n")
|
LOG("Found device: Black Widow 2013\n")
|
||||||
detected_keyboard = PRODUCT_ID_BLACK_WIDOW_2013
|
detected_keyboard = PRODUCT_ID_BLACK_WIDOW_2013
|
||||||
else:
|
else:
|
||||||
LOG("Found device Black Widow.\n")
|
LOG("Found device: Black Widow\n")
|
||||||
detected_keyboard = PRODUCT_ID_BLACK_WIDOW
|
detected_keyboard = PRODUCT_ID_BLACK_WIDOW
|
||||||
|
|
||||||
if self.device.is_kernel_driver_active(USB_INTERFACE):
|
if self.device.is_kernel_driver_active(USB_INTERFACE):
|
||||||
LOG("Kernel driver active. Detaching it.\n")
|
LOG("Kernel driver active; detaching it\n")
|
||||||
|
|
||||||
self.device.detach_kernel_driver(USB_INTERFACE)
|
self.device.detach_kernel_driver(USB_INTERFACE)
|
||||||
self.kernel_driver_detached = True
|
self.kernel_driver_detached = True
|
||||||
|
@ -74,9 +74,9 @@ class blackwidow(object):
|
||||||
try:
|
try:
|
||||||
result = self.device.ctrl_transfer(USB_REQUEST_TYPE, USB_REQUEST, wValue=USB_VALUE, wIndex=USB_INDEX, data_or_wLength=USB_BUFFER)
|
result = self.device.ctrl_transfer(USB_REQUEST_TYPE, USB_REQUEST, wValue=USB_VALUE, wIndex=USB_INDEX, data_or_wLength=USB_BUFFER)
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("Could not send data.\n")
|
sys.stderr.write("Could not send data\n")
|
||||||
if result == len(USB_BUFFER):
|
if result == len(USB_BUFFER):
|
||||||
LOG("Data sent successfully.\n")
|
LOG("Data sent successfully\n")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if isinstance(c, list):
|
if isinstance(c, list):
|
||||||
|
@ -117,22 +117,28 @@ def main():
|
||||||
LOG("Sending led pulsate command\n")
|
LOG("Sending led pulsate command\n")
|
||||||
bw.send(pulsate)
|
bw.send(pulsate)
|
||||||
elif options.led == "bright":
|
elif options.led == "bright":
|
||||||
LOG("Sending led bright command\n")
|
LOG("Sending no pulsate command and led bright command\n")
|
||||||
bw.send(no_pulsate + brightness + 'FF')
|
bw.send(no_pulsate)
|
||||||
|
bw.send(brightness + 'FF')
|
||||||
elif options.led == "normal":
|
elif options.led == "normal":
|
||||||
LOG("Sending led normal command\n")
|
LOG("Sending no pulsate command and led normal command\n")
|
||||||
bw.send(no_pulsate + brightness + 'a8')
|
bw.send(no_pulsate)
|
||||||
|
bw.send(brightness + 'a8')
|
||||||
elif options.led == "dim":
|
elif options.led == "dim":
|
||||||
LOG("Sending led dim command\n")
|
LOG("Sending no pulsate command and led dim command\n")
|
||||||
bw.send(no_pulsate + brightness + '54')
|
bw.send(no_pulsate)
|
||||||
|
bw.send(brightness + '54')
|
||||||
elif options.led == "off":
|
elif options.led == "off":
|
||||||
LOG("Sending led off command\n")
|
LOG("Sending no pulsate command and led off command\n")
|
||||||
bw.send(no_pulsate + brightness + '00')
|
bw.send(no_pulsate)
|
||||||
|
bw.send(brightness + '00')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
brightness_level = int(options.led)
|
brightness_level = int(options.led)
|
||||||
if brightness_level >= 0 and brightness_level <= 0xFF:
|
if brightness_level >= 0 and brightness_level <= 0xFF:
|
||||||
bw.send(no_pulsate + brightness + "{0:#0{1}x}".format(brightness_level,4)[2:])
|
LOG("Sending no pulsate command and led command with custom brightness\n")
|
||||||
|
bw.send(no_pulsate)
|
||||||
|
bw.send(brightness + "{0:#0{1}x}".format(brightness_level,4)[2:])
|
||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -144,16 +150,16 @@ def main():
|
||||||
else:
|
else:
|
||||||
if False: # condition for BlackWidow 2016
|
if False: # condition for BlackWidow 2016
|
||||||
if options.backlight == "bright":
|
if options.backlight == "bright":
|
||||||
LOG("Sending led bright command\n")
|
LOG("Sending blacklight command\n")
|
||||||
bw.send(backlight + 'FF')
|
bw.send(backlight + 'FF')
|
||||||
elif options.backlight == "normal":
|
elif options.backlight == "normal":
|
||||||
LOG("Sending led normal command\n")
|
LOG("Sending blacklight command\n")
|
||||||
bw.send(backlight + 'a8')
|
bw.send(backlight + 'a8')
|
||||||
elif options.backlight == "dim":
|
elif options.backlight == "dim":
|
||||||
LOG("Sending led dim command\n")
|
LOG("Sending blacklight command\n")
|
||||||
bw.send(backlight + '54')
|
bw.send(backlight + '54')
|
||||||
elif options.backlight == "off":
|
elif options.backlight == "off":
|
||||||
LOG("Sending led off command\n")
|
LOG("Sending blacklight command\n")
|
||||||
bw.send(backlight + '00')
|
bw.send(backlight + '00')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -170,7 +176,7 @@ def main():
|
||||||
# enable/disable game mode
|
# enable/disable game mode
|
||||||
if options.gamemode == "unmodified":
|
if options.gamemode == "unmodified":
|
||||||
pass
|
pass
|
||||||
if options.gamemode == "on":
|
elif options.gamemode == "on":
|
||||||
bw.send(gamemode + '01')
|
bw.send(gamemode + '01')
|
||||||
elif options.gamemode == "off":
|
elif options.gamemode == "off":
|
||||||
bw.send(gamemode + '00')
|
bw.send(gamemode + '00')
|
||||||
|
|
Loading…
Reference in New Issue