本文整理汇总了Python中pywinusb.hid.find_all_hid_devices函数的典型用法代码示例。如果您正苦于以下问题:Python find_all_hid_devices函数的具体用法?Python find_all_hid_devices怎么用?Python find_all_hid_devices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_all_hid_devices函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: find_vec_usb_footpedal
def find_vec_usb_footpedal():
all_hids = hid.find_all_hid_devices()
for index, device in enumerate(all_hids):
if (device.vendor_id == 0x05f3 and device.product_id == 0x00ff):
print("Found VEC USB Footpedal")
return all_hids[index]
raise Exception("VEC USB Footpedal not found");
开发者ID:armstrap,项目名称:armstrap-pyvirtualbench,代码行数:7,代码来源:hands_free_dmm.py
示例2: __init__
def __init__(self, button_pressed_func, device_unplugged):
"""
Init Function
:param button_pressed_func: function that will be called after get_btn_press is called
:return:
"""
self.cl = ControllerLinks()
self.wait_for_button = False
self.poll = False
self.last_USB = None
self.data_to_make_link = None
# Hid device stuff
self.devices = hid.find_all_hid_devices()
self.device = None
#return func to notify UI that a key has been captured
self.BPF = button_pressed_func
# Called if the device is unplugged
self.device_unplugged = device_unplugged
#launch thread to generate keys
self.GenerateThread = threading.Thread(target=self.generate_key_events,name="Bob")
self.StopThread = threading.Event()
self.GenerateThread.start()
开发者ID:DavidA94,项目名称:countertop,代码行数:26,代码来源:controller.py
示例3: __init__
def __init__(self):
self.buttons = [[1,24,0], # 1
[2,40,0], # 2
[3,72,0], # 3
[4,136,0], # 4
[5,8,1], # 5
[6,8,2], # 6
[7,8,4], # 7
[8,8,8], # 8
[9,8,16], # 9
[10,8,32]] # 10
self.down = False
self.hats = [["up",0,0],
["left",6,0],
["right",2,0],
["down",4,0]]
# initialize connection to joystick
all_hids = hid.find_all_hid_devices()
self.jdev = False
for device in all_hids:
if (device.product_name == "Logitech Dual Action"):
self.jdev = device
if not self.jdev:
print "Logitech Dual Action joystick not found."
开发者ID:AlistairBoettiger,项目名称:storm-control,代码行数:26,代码来源:dualAction.py
示例4: main
def main(fn=None):
if fn == None:
devices = []
try:
for device in hid.find_all_hid_devices():
if device.vendor_id != 0x21A1:
continue
if device.product_name == 'Brain Waves':
devices.append(device)
device.open()
device.set_raw_data_handler(sample_handler)
elif device.product_name == 'EPOC BCI':
print 'foo'
devices.append(device)
device.open()
device.set_raw_data_handler(bci_handler)
while True:#device.is_plugged() and count < 1000:
time.sleep(0.1)
finally:
for device in devices:
device.close()
else:
for line in file(fn, 'r').readlines():
data = [0] + [int(x, 16) for x in line.strip().split(' ')]
sample_handler(data)
开发者ID:mcquoidellum,项目名称:Emokit,代码行数:25,代码来源:read.py
示例5: getAllConnectedInterface
def getAllConnectedInterface(vid, pid):
"""
returns all the connected devices which matches PyWinUSB.vid/PyWinUSB.pid.
returns an array of PyWinUSB (Interface) objects
"""
all_devices = hid.find_all_hid_devices()
# find devices with good vid/pid
all_mbed_devices = []
for d in all_devices:
if (d.vendor_id == vid) and (d.product_id == pid):
all_mbed_devices.append(d)
boards = []
for dev in all_mbed_devices:
try:
dev.open(shared=False)
report = dev.find_output_reports()
if len(report) == 1:
new_board = PyWinUSB()
new_board.report = report[0]
new_board.vendor_name = dev.vendor_name
new_board.product_name = dev.product_name
new_board.vid = dev.vendor_id
new_board.pid = dev.product_id
new_board.device = dev
new_board.device.set_raw_data_handler(new_board.rx_handler)
boards.append(new_board)
except Exception as e:
logging.error("Receiving Exception: %s", e)
dev.close()
return boards
开发者ID:sw17ch,项目名称:pyOCD,代码行数:34,代码来源:pywinusb_backend.py
示例6: get_available_devices
def get_available_devices():
devices = []
if WINDOWS:
try:
for device in hid.find_all_hid_devices():
if device.product_name == 'Emotiv RAW DATA':
devices.append(device.device_path)
finally:
pass
else:
serials = {}
for name in os.listdir("/sys/class/hidraw"):
realInputPath = os.path.realpath("/sys/class/hidraw/" + name)
path = '/'.join(realInputPath.split('/')[:-4])
try:
if os.path.isfile(path + "/manufacturer"):
with open(path + "/manufacturer", 'r') as f:
manufacturer = f.readline()
if "emotiv" in manufacturer.lower():
with open(path + "/serial", 'r') as f:
serial = f.readline().strip()
if serial not in serials:
serials[serial] = []
serials[serial].append(name)
except IOError as e:
print("Couldn't open file: %s" % e)
for serial, names in serials.items():
device_path = '/dev/'+names[1]
devices.append(device_path)
return devices
开发者ID:pyacq,项目名称:pyacq,代码行数:32,代码来源:test_eeg_emotiv.py
示例7: __init__
def __init__(self, **kwds):
"""
Define arrays for translating joystick events and find the joystick HID.
"""
super().__init__(self, **kwds)
self.buttons = [[1,24,0], # 1
[2,40,0], # 2
[3,72,0], # 3
[4,136,0], # 4
[5,8,1], # 5
[6,8,2], # 6
[7,8,4], # 7
[8,8,8], # 8
[9,8,16], # 9
[10,8,32]] # 10
self.down = False
self.hats = [["up",0,0],
["left",6,0],
["right",2,0],
["down",4,0]]
# initialize connection to joystick
all_hids = hid.find_all_hid_devices()
self.jdev = False
for device in all_hids:
if (device.product_name == "Logitech Dual Action"):
self.jdev = device
if not self.jdev:
print("Logitech Dual Action joystick not found.")
开发者ID:ZhuangLab,项目名称:storm-control,代码行数:30,代码来源:dualAction.py
示例8: get_available_devices
def get_available_devices(cls):
devices = OrderedDict()
if WINDOWS:
try:
for device in hid.find_all_hid_devices():
print "device : ", device
if (device.product_name == 'Emotiv RAW DATA' or device.product_name == 'EPOC BCI'):
devices['Emotiv '+device.serial_number] = get_info(device)
finally:
pass
else:
serials = { }
for name in os.listdir("/sys/class/hidraw"):
realInputPath = os.path.realpath("/sys/class/hidraw/" + name)
path = '/'.join(realInputPath.split('/')[:-4])
try:
with open(path + "/manufacturer", 'r') as f:
manufacturer = f.readline()
if "emotiv" in manufacturer.lower():
with open(path + "/serial", 'r') as f:
serial = f.readline().strip()
if serial not in serials:
serials[serial] = [ ]
serials[serial].append(name)
except IOError as e:
print "Couldn't open file: %s" % e
for serial, names in serials.items():
device_path = '/dev/'+names[1]
info = get_info(device_path)
devices['Emotiv '+device_path] = info
return devices
开发者ID:Hemisphere-Project,项目名称:Telemir-DatabitMe,代码行数:35,代码来源:emotiv.py
示例9: getAllConnectedInterface
def getAllConnectedInterface(board_id = None):
"""
returns all the connected CMSIS-DAP devices
"""
all_devices = hid.find_all_hid_devices()
# find devices with good vid/pid
all_mbed_devices = []
for d in all_devices:
if (d.product_name.find("CMSIS-DAP") >= 0):
all_mbed_devices.append(d)
boards = []
for dev in all_mbed_devices:
try:
dev.open(shared=False)
report = dev.find_output_reports()
if (len(report) == 1):
new_board = PyWinUSB()
new_board.report = report[0]
new_board.vendor_name = dev.vendor_name
new_board.product_name = dev.product_name
new_board.serial_number = dev.serial_number
new_board.vid = dev.vendor_id
new_board.pid = dev.product_id
new_board.device = dev
new_board.device.set_raw_data_handler(new_board.rx_handler)
boards.append(new_board)
except Exception as e:
logging.error("Receiving Exception: %s", e)
dev.close()
return boards
开发者ID:inakypg,项目名称:pyOCD,代码行数:34,代码来源:pywinusb_backend.py
示例10: setupWin
def setupWin(self):
devices = []
try:
for device in hid.find_all_hid_devices():
if device.vendor_id != 0x21A1:
continue
if device.product_name == 'Brain Waves':
devices.append(device)
device.open()
self.serialNum = device.serial_number
device.set_raw_data_handler(self.handler)
elif device.product_name == 'EPOC BCI':
devices.append(device)
device.open()
self.serialNum = device.serial_number
device.set_raw_data_handler(self.handler)
elif device.product_name == '00000000000':
devices.append(device)
device.open()
self.serialNum = device.serial_number
device.set_raw_data_handler(self.handler)
gevent.spawn(self.setupCrypto, self.serialNum)
gevent.spawn(self.updateStdout)
while self._goOn:
try:
gevent.sleep(0)
except KeyboardInterrupt:
self._goOn = False
for device in devices:
device.close()
finally:
for device in devices:
device.close()
开发者ID:robintibor,项目名称:emokit,代码行数:33,代码来源:emotiv.py
示例11: setup_windows
def setup_windows(self):
"""
Setup for headset on the Windows platform.
"""
devices = []
try:
for device in hid.find_all_hid_devices():
is_emotiv = False
if "Emotiv" in device.vendor_name:
is_emotiv = True
if "Emotiv" in device.product_name:
is_emotiv = True
if "EPOC" in device.product_name:
is_emotiv = True
if "Brain Waves" in device.product_name:
is_emotiv = True
if device.product_name == '00000000000':
is_emotiv = True
if "EEG Signals" in device.product_name:
is_emotiv = True
if is_emotiv:
devices.append(device)
if len(devices) > 0:
device = devices[1]
device.open()
self.serial_number = device.serial_number
device.set_raw_data_handler(self.handler)
crypto = gevent.spawn(self.setup_crypto, self.serial_number)
console_updater = gevent.spawn(self.update_console)
while self.running:
try:
gevent.sleep(DEVICE_POLL_INTERVAL)
except KeyboardInterrupt:
self.running = False
else:
print("Could not find device")
print("-------------------------")
for device in hid.find_all_hid_devices():
print(device.vendor_name)
print(device.product_name)
print(device.vendor_id)
print(device.product_id)
print(device.serial_number)
print("-------------------------")
print("Please include this information if you open a new issue.")
except Exception, ex:
print(ex.message)
开发者ID:SeifMostafa,项目名称:emokit,代码行数:47,代码来源:emotiv.py
示例12: raw_test
def raw_test():
GRAND_PIANO = 0
CHURCH_ORGAN = 19
global instrument
instrument = GRAND_PIANO
pygame.init()
pygame.midi.init()
global midi_out
port = pygame.midi.get_default_output_id()
print ("using output_id :%s:" % port)
midi_out = pygame.midi.Output(port, 0)
midi_out.set_instrument(instrument)
# simple test
# browse devices...
all_hids = hid.find_all_hid_devices()
if all_hids:
# while True:
print("Choose a device to monitor raw input reports:\n")
print("0 => Exit")
for index, device in enumerate(all_hids):
device_name = unicode("{0.vendor_name} {0.product_name}" \
"(vID=0x{1:04x}, pID=0x{2:04x})"\
"".format(device, device.vendor_id, device.product_id))
print("{0} => {1}".format(index+1, device_name))
if 'DJ' in device_name:
print "DETECTED DJ DECK"
index_option = index+1
# print("\n\tDevice ('0' to '%d', '0' to exit?) " \
# "[press enter after number]:" % len(all_hids))
# index_option = raw_input()
# if index_option.isdigit() and int(index_option) <= len(all_hids):
# invalid
# break;
int_option = int(index_option)
global prevdata
prevdata=[0,0,0,8,128,128,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,224,13,11];
if int_option:
device = all_hids[int_option-1]
try:
device.open()
#set custom raw data handler
device.set_raw_data_handler(sample_handler)
print("\nWaiting for data...\nPress any (system keyboard) key to stop...")
while device.is_plugged():
#just keep the device opened to receive events
sleep(600)
return
finally:
device.close()
else:
print("There's not any non system HID class device available")
开发者ID:audiogramastudios,项目名称:cheapmidi,代码行数:59,代码来源:DJ-win-midi.py
示例13: show_hids
def show_hids(self):
all_hids = hid.find_all_hid_devices()
if all_hids:
self.logText.append( "Available HID devices:" )
for hid_device in all_hids:
self.logText.append( " vId={0:04X}, pId= {1:04X}".format(
hid_device.vendor_id, hid_device.product_id ))
else:
self.logText.append( "No HID USB devices attached now" )
开发者ID:mull3rcw,项目名称:python_mt_unitTest,代码行数:9,代码来源:pnp_qt.py
示例14: detect_device
def detect_device():
all_hids = hid.find_all_hid_devices()
pads = []
for hids in all_hids:
tmp = 1
matchObj = re.match(r'HID\\VID_0B43&PID_0003', hids.instance_id, re.M)
if matchObj:
pads.append(hids)
return pads
开发者ID:tb2097,项目名称:emsusb2,代码行数:9,代码来源:emsusb2.py
示例15: get_devices
def get_devices(self):
"""
Called to get the usb devices on the machine
:return: List of the HIDDevices
"""
self.devices = hid.find_all_hid_devices()
device_names = []
for device in self.devices:
device_names.append(device.product_name)
return tuple(device_names)
开发者ID:DavidA94,项目名称:countertop,代码行数:10,代码来源:controller.py
示例16: __init__
def __init__(self):
# initialize connection to joystick
all_hids = hid.find_all_hid_devices()
self.jdev = False
for device in all_hids:
if (device.product_name == "Logitech Dual Action"):
self.jdev = device
if not self.jdev:
print "Gamepad 310 joystick not found."
开发者ID:AlistairBoettiger,项目名称:storm-control,代码行数:10,代码来源:rawData.py
示例17: raw_test
def raw_test():
# browse devices...
all_hids = hid.find_all_hid_devices()
if not all_hids:
print("There's not any non system HID class device available")
else:
while True:
print("Choose a device to monitor raw input reports:\n")
print("0 => Exit")
for index, device in enumerate(all_hids):
device_name = unicode("{0.vendor_name} {0.product_name}" \
"(vID=0x{1:04x}, pID=0x{2:04x}, pVer={0.instance_id})"\
"".format(device, device.vendor_id, device.product_id, device))
print("{0} => {1}".format(index+1, device_name))
print("\n\tDevice ('0' to '%d', '0' to exit?) " \
"[press enter after number]:" % len(all_hids))
index_option = raw_input()
if index_option.isdigit() and int(index_option) <= len(all_hids):
# invalid
break
int_option = int(index_option)
if int_option:
device = all_hids[int_option-1]
try:
device.open()
#set custom raw data handler
device.set_raw_data_handler(sample_handler)
print("\nWaiting for data...\nPress any (system keyboard) key to stop...")
while not kbhit() and device.is_plugged():
#just keep the device opened to receive events
for report in device.find_output_reports():
for target_usage in range(len(report)):
# found out target!
# report[target_usage] = 1 # yes, changing values is that easy
# at this point you could change different usages at a time...
# and finally send the prepared output report
report.send()
# now toggle back the signal
#report[target_usage] = 0
# report.send()
print(report)
sleep(1)
#sleep(1000)
pass
return
finally:
device.close()
开发者ID:tuzzer,项目名称:SculptureLearning,代码行数:53,代码来源:rawhid.py
示例18: __init__
def __init__(self, verbose = False, **kwds):
"""
Create the arrays for translating the joystick objects and try and
find the joystick among the HID devices that are attached to the computer.
"""
super().__init__(**kwds)
# initialize internal variables
self.buttons = [["A", False, 2], #[name, state bit]
["B", False, 3],
["X", False, 1],
["Y", False, 4]]
self.actions = [["left joystick press", False, 7], #[name, state, bit]
["right joystick press", False, 8],
["left upper trigger", False, 1],
["right upper trigger", False, 2],
["left lower trigger", False, 3],
["right lower trigger", False, 4],
["back", False, 5],
["start", False, 6]]
self.hats = [["up", False], #[name, state]
["right",False],
["down",False],
["left",False]]
self.hats_dictionary = {0: [True, False, False, False],
1: [True, True, False, False],
2: [False, True, False, False],
3: [False, True, True, False],
4: [False, False, True, False],
5: [False, False, True, True],
6: [False, False, False, True],
7: [True, False, False, True],
8: [False, False, False, False]}
self.joysticks = [["right joystick", [128, 128]], #[name, [state 1, state 2]]
["left joystick", [128, 128]]]
self.data = [0, 128, 127, 128, 127, 8, 0, 0, 255] #default data
self.events_to_send = []
self.verbose = verbose
# initialize connection to joystick
all_hids = hid.find_all_hid_devices()
self.jdev = False
if self.verbose:
print("Searching for HID devices")
for device in all_hids:
if self.verbose:
print(device.product_name)
if (device.product_name == "Logitech Dual Action"):
self.jdev = device
if not self.jdev:
print("Gamepad 310 joystick not found.")
开发者ID:ZhuangLab,项目名称:storm-control,代码行数:53,代码来源:gamepad310.py
示例19: list_devices
def list_devices():
"""Return a list of the supported devices connected
Returns:
A list of string names of the devices supported which were found. Empty if no supported devices found
"""
devices = []
all_hids = hid.find_all_hid_devices()
if all_hids:
for index, device in enumerate(all_hids):
for device_name,spec in device_specs.iteritems():
if device.vendor_id == spec.hid_id[0] and device.product_id == spec.hid_id[1]:
devices.append(device_name)
return devices
开发者ID:johnhw,项目名称:pyspacenavigator,代码行数:14,代码来源:spacenavigator.py
示例20: __init__
def __init__(self, **kwds):
"""
Find the joystick in the list of HID devices.
"""
super().__init__(self, **kwds)
# initialize connection to joystick
all_hids = hid.find_all_hid_devices()
self.jdev = False
for device in all_hids:
if (device.product_name == "Logitech Dual Action"):
self.jdev = device
if not self.jdev:
print("Gamepad 310 joystick not found.")
开发者ID:ZhuangLab,项目名称:storm-control,代码行数:15,代码来源:rawData.py
注:本文中的pywinusb.hid.find_all_hid_devices函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论