Created
May 11, 2017 09:30
-
-
Save mcardillo55/ffbe7ce33c273d611d67b0fd83eb2ca3 to your computer and use it in GitHub Desktop.
Revisions
-
mcardillo55 revised this gist
May 11, 2017 . No changes.There are no files selected for viewing
-
mcardillo55 created this gist
May 11, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ # Author: Mike Cardillo, 2017 # Email: [email protected] # Desc: Control speed of the Razer 'wave' effect by sending custom values to # the razerkbd driver and varying the sleep() time. import pyshark import time import os, sys RAZERKBD_SYSFS_PATH = '/sys/bus/hid/drivers/razerkbd/0003:1532:0221.0013/' PCAP_FILE = '/home/mike/razer_packets.pcapng' cap = pyshark.FileCapture(PCAP_FILE) slow_wave_pattern = [] for idx, cur_cap in enumerate(cap): if idx == 966: # This is when the pattern repeats. break cap_data = cur_cap.data.usb_data_fragment if cap_data.binary_value[8] == 255: # First 8 bytes are control bytes and not included # Next are row index, row start and row stop # Then 22 RGB values slow_wave_pattern.append(cap_data.binary_value[9:78]) print("done analyzing") print(len(slow_wave_pattern)) while True: for pattern in slow_wave_pattern: if pattern[0] == 0: with open(os.path.join(RAZERKBD_SYSFS_PATH, 'matrix_effect_custom'), 'w') as enable_custom_effect: enable_custom_effect.write('1') with open(os.path.join(RAZERKBD_SYSFS_PATH, 'matrix_custom_frame'), 'wb') as custom_frame: custom_frame.write(pattern) sys.stdout.flush() time.sleep(0.0010)