determine_hidraw_number.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 import os,time,subprocess
00003 
00004 HYDRA_INDEX = -1
00005 
00006 cmd = "ls /dev/hidraw*"
00007 p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout #cmd is your script
00008 devices = p.readlines()
00009 # What if there are no hidraw devices?
00010 
00011 for i in range(len(devices)):
00012   cmd = "cat /sys/class/hidraw/hidraw"+str(i)+"/device/uevent"
00013   p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout #cmd is your script
00014   lines= p.readlines()
00015   #print lines
00016   if 'HID_NAME=Razer Razer Hydra\n' in lines:
00017     HYDRA_INDEX = i
00018     break
00019 
00020 
00021 print "device %d is the Razer Hydra"%(HYDRA_INDEX)
00022 #cmd = "./open_hydra_port"
00023 #p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout #cmd is your script
00024 


razer_hydra
Author(s): Adam Leeper
autogenerated on Mon Oct 6 2014 04:01:06