コード例 #1
0
        def _get_filtered_lsusb_list():
            """
            A copy of pylib/backends/openrazer._get_filtered_lsusb_list so the troubleshooter
            can run independently.

            Uses 'lsusb' to parse the devices and identify VID:PIDs that are not registered
            by the daemon, usually because they are not compatible yet.
            """
            all_usb_ids = []
            reg_ids = []
            unreg_ids = []

            # Strip lsusb to just get VIDs and PIDs
            try:
                lsusb = subprocess.Popen(
                    "lsusb",
                    stdout=subprocess.PIPE).communicate()[0].decode("utf-8")
            except FileNotFoundError:
                print(
                    "'lsusb' not available, unable to determine if product is connected."
                )
                return None

            for usb in lsusb.split("\n"):
                if len(usb) > 0:
                    try:
                        vidpid = usb.split(" ")[5].split(":")
                        all_usb_ids.append(
                            [vidpid[0].upper(), vidpid[1].upper()])
                    except AttributeError:
                        pass

            # Get VIDs and PIDs of current devices to exclude them.
            devices = rclient.DeviceManager().devices
            for device in devices:
                try:
                    vid = str(hex(device._vid))[2:].upper().rjust(4, '0')
                    pid = str(hex(device._pid))[2:].upper().rjust(4, '0')
                except Exception as e:
                    print("Got exception parsing VID/PID: " + str(e))
                    continue

                reg_ids.append([vid, pid])

            # Identify Razer VIDs that are not registered in the daemon
            for usb in all_usb_ids:
                if usb[0] != "1532":
                    continue

                if usb in reg_ids:
                    continue

                unreg_ids.append(usb)

            return unreg_ids
コード例 #2
0
ファイル: device.py プロジェクト: yiafre212/razerCommander
# probably not necessary vvvv
import os
import io
import logging
logging.basicConfig(level=logging.DEBUG)
from . import macro_logic

import openrazer.client as rclient
#import razer.client.constants as razer_constants

device_manager = rclient.DeviceManager()
devlist = []
for device in device_manager.devices:
    devlist.append(device)


def getSyncFX():
    return bool(device_manager.sync_effects)


def setSyncFX(value):
    if type(value) != bool:
        print('ERROR: device: setSyncFX: the value passed is not a boolean!')
        return False
    device_manager.sync_effects = value


# This class represents a single device (ie: a keyboard)
class Device:
    def __init__(self, device):
        self.device = device
コード例 #3
0
#!/usr/bin/python3
#
# Use this script to step through each key for a keyboard
# to document which key corresponds to a position.
#

import openrazer.client as rclient
print("Successfully imported openrazer.client")

devman = rclient.DeviceManager()
print("Successfully connected to Device Manager.")

print("\nCurrently connected devices:")
devices = devman.devices
uid = 0
for d in devices:
    print("[{0}] {1} ({2} / {3})".format(uid, d.name, d.type, d.serial))
    uid += 1
print(" ")

use_id = input("Enter device ID: ")
device = devman.devices[int(use_id)]

print(
    "\nThis script will step through each avaliable co-ordinate. Note down what the key is then press ENTER to continue."
)
print("\n----------------------------------------\n")
print(device.name + " (type: " + device.type + ")")
if not device.has("lighting_led_matrix"):
    print("Sorry, this device does not support the matrix.")
    exit()