Beispiel #1
0
	def __init__(self, device, handle, daemon):
		USBDevice.__init__(self, device, handle)
		SCController.__init__(self, self, CONTROLIDX, ENDPOINT)
		self.daemon = daemon
		self._ready = False
		self._last_tup = None
		
		self.claim_by(klass=3, subclass=0, protocol=0)
		self.read_serial()
Beispiel #2
0
    def __init__(self, device, handle, daemon):
        self.daemon = daemon
        USBDevice.__init__(self, device, handle)
        SCController.__init__(self, self, CONTROLIDX, ENDPOINT)
        self._ready = False
        self._last_tup = None
        daemon.add_mainloop(self._timer)

        self.claim_by(klass=3, subclass=0, protocol=0)
        self.read_serial()
Beispiel #3
0
    def __init__(self, device, handle, daemon):
        self.daemon = daemon
        USBDevice.__init__(self, device, handle)

        self.claim_by(klass=3, subclass=0, protocol=0)
        self._controllers = {}
        self._no_serial = []
        for i in xrange(0, Dongle.MAX_ENDPOINTS):
            # Steam dongle apparently can do only 4 controllers at once
            self.set_input_interrupt(FIRST_ENDPOINT + i, 64, self._on_input)
Beispiel #4
0
	def __init__(self, device, handle, daemon):
		self.daemon = daemon
		USBDevice.__init__(self, device, handle)
		
		self.claim_by(klass=3, subclass=0, protocol=0)
		self._controllers = {}
		self._no_serial = []
		for i in xrange(0, Dongle.MAX_ENDPOINTS):
			# Steam dongle apparently can do only 4 controllers at once
			self.set_input_interrupt(FIRST_ENDPOINT + i, 64, self._on_input)
    def __init__(self,
                 device,
                 daemon,
                 handle,
                 config_file,
                 config,
                 test_mode=False):
        USBDevice.__init__(self, device, handle)
        self._ready = False
        self.daemon = daemon
        self.config_file = config_file

        id = None
        max_size = 64
        for inter in self.device[0]:
            for setting in inter:
                if setting.getClass() == DEV_CLASS_HID:
                    for endpoint in setting:
                        if endpoint.getAttributes() == TRANSFER_TYPE_INTERRUPT:
                            if id is None or endpoint.getAddress() > id:
                                id = endpoint.getAddress()
                                max_size = endpoint.getMaxPacketSize()

        if id is None:
            raise NotHIDDevice()

        log.debug("Endpoint: %s", id)

        vid, pid = self.device.getVendorID(), self.device.getProductID()
        if (vid, pid) in BLACKLIST:
            raise NotHIDDevice("Blacklisted device: %x:%x", vid, pid)
        self._packet_size = 64
        self._load_hid_descriptor(config, max_size, vid, pid, test_mode)
        self.claim_by(klass=DEV_CLASS_HID, subclass=0, protocol=0)
        Controller.__init__(self)

        if test_mode:
            self.set_input_interrupt(id, self._packet_size, self.test_input)

            print "Buttons:", " ".join([
                str(x + FIRST_BUTTON)
                for x in xrange(self._decoder.buttons.button_count)
            ])
            print "Axes:", " ".join([
                str(x) for x in xrange(
                    len([
                        a for a in self._decoder.axes
                        if a.mode != AxisMode.DISABLED
                    ]))
            ])
        else:
            self._id = self._generate_id()
            self.set_input_interrupt(id, self._packet_size, self.input)
            self.daemon.add_controller(self)
            self._ready = True
Beispiel #6
0
	def __init__(self, device, daemon, handle, config_file, config, test_mode=False):
		USBDevice.__init__(self, device, handle)
		self._ready = False
		self.daemon = daemon
		self.config_file = config_file
		
		id = None
		max_size = 64
		for inter in self.device[0]:
			for setting in inter:
				if setting.getClass() == DEV_CLASS_HID:
					for endpoint in setting:
						if endpoint.getAttributes() == TRANSFER_TYPE_INTERRUPT:
							if id is None or endpoint.getAddress() > id:
								id = endpoint.getAddress()
								max_size = endpoint.getMaxPacketSize()
		
		if id is None:
			raise NotHIDDevice()
		
		log.debug("Endpoint: %s", id)
		
		vid, pid = self.device.getVendorID(), self.device.getProductID()
		if (vid, pid) in BLACKLIST:
			raise NotHIDDevice("Blacklisted device: %x:%x", vid, pid)
		self._packet_size = 64
		self._load_hid_descriptor(config, max_size, vid, pid, test_mode)
		self.claim_by(klass=DEV_CLASS_HID, subclass=0, protocol=0)
		Controller.__init__(self)
		
		if test_mode:
			self.set_input_interrupt(id, self._packet_size, self.test_input)
				
			print "Buttons:", " ".join([ str(x + FIRST_BUTTON)
					for x in xrange(self._decoder.buttons.button_count) ])
			print "Axes:", " ".join([ str(x)
					for x in xrange(len([
						a for a in self._decoder.axes
						if a.mode != AxisMode.DISABLED
					]))])
		else:
			self._id = self._generate_id()
			self.set_input_interrupt(id, self._packet_size, self.input)
			self.daemon.add_controller(self)
			self._ready = True
Beispiel #7
0
 def close(self):
     if self._ready:
         self.daemon.remove_controller(self)
         self._ready = False
     self.daemon.remove_mainloop(self._timer)
     USBDevice.close(self)
Beispiel #8
0
	def close(self):
		if self._ready:
			self.daemon.remove_controller(self)
			self._ready = False
		self.daemon.remove_mainloop(self._timer)
		USBDevice.close(self)
Beispiel #9
0
 def close(self):
     # Called when dongle is removed
     for c in self._controllers.values():
         self.daemon.remove_controller(c)
     self._controllers = {}
     USBDevice.close(self)
Beispiel #10
0
	def close(self):
		# Called when dongle is removed
		for c in self._controllers.values():
			self.daemon.remove_controller(c)
		self._controllers = {}
		USBDevice.close(self)
Beispiel #11
0
	def close(self):
		# Called when pad is disconnected
		USBDevice.close(self)
		if self._ready:
			self.daemon.remove_controller(self)
			self._ready = False
Beispiel #12
0
	def close(self):
		# Called when pad is disconnected
		USBDevice.close(self)
		if self._ready:
			self.daemon.remove_controller(self)
			self._ready = False
Beispiel #13
0
	def close(self):
		if self._ready:
			self.daemon.remove_controller(self)
			self._ready = False
		USBDevice.close(self)