summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Pavlik <ryan.pavlik@collabora.com>2021-10-25 16:40:14 -0500
committerRyan Pavlik <ryan.pavlik@collabora.com>2021-10-25 16:40:14 -0500
commitdd4d2ab16302ae8e0ebab8207ca3a87677b880a5 (patch)
treea7326991c6751a4abb9aa01fc6ba60cfcad3c90b
parentf709dbfe90ad4f66c5a26e727062cc8f1955d74e (diff)
parent46273f19c948f74635255b3eb6a3ead175d48b5b (diff)
Update upstream source from tag 'upstream/1.0.0'
Update to upstream version '1.0.0' with Debian dir e1ed8e08dbbd6b638898e0c39683f9de0e5bdd6a
-rw-r--r--.gitignore11
-rw-r--r--.gitlab-ci.yml9
-rw-r--r--.reuse/dep511
-rw-r--r--70-xrhardware-hwdb.rules3
-rw-r--r--70-xrhardware.hwdb11
-rw-r--r--70-xrhardware.rules11
-rw-r--r--CHANGELOG.md21
-rw-r--r--LICENSES/BSL-1.0.txt7
-rw-r--r--LICENSES/CC0-1.0.txt121
-rw-r--r--Makefile4
-rw-r--r--README.md16
-rw-r--r--changes/.markdownlint.yaml8
-rw-r--r--xrhardware/db.py2
-rw-r--r--xrhardware/device.py83
-rw-r--r--xrhardware/generate.py5
15 files changed, 274 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore
index cb9e7e6..4394138 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,10 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2019-2021, Collabora, Ltd. and the xr-hardware contributors
+
__pycache__/
-.vscode/
-.pc/
+.*
+!.gitignore
+!.gitlab-ci.yml
+!.markdownlint.yaml
+!.reuse
+venv/
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0bb2f65..9cd5ba6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -35,3 +35,12 @@ test-db-and-generated:
- make all
# Fail the build if files are out of date.
- git diff --quiet
+
+
+reuse:
+ stage: test
+ image:
+ name: fsfe/reuse:latest
+ entrypoint: [""]
+ script:
+ - reuse lint
diff --git a/.reuse/dep5 b/.reuse/dep5
new file mode 100644
index 0000000..3b29250
--- /dev/null
+++ b/.reuse/dep5
@@ -0,0 +1,11 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: xr-hardware
+Upstream-Contact: Ryan Pavlik <ryan.pavlik@collabora.com>
+Source: https://gitlab.freedesktop.org/monado/utilities/xr-hardware
+
+Files: changes/additions/*.md
+ changes/fixes/*.md
+ changes/improvements/*.md
+Copyright: 2020-2021, Collabora, Ltd. and the xr-hardware contributors
+License: CC0-1.0
+Comment: Prevents needing a license header per fragment between releases.
diff --git a/70-xrhardware-hwdb.rules b/70-xrhardware-hwdb.rules
index 0818410..a812834 100644
--- a/70-xrhardware-hwdb.rules
+++ b/70-xrhardware-hwdb.rules
@@ -1,4 +1,7 @@
# Do not edit this file - generated by make-hwdb-rules-file.py
+#
+# Copyright 2019-2021, Collabora, Ltd. and the xr-hardware contributors
+#
# SPDX-License-Identifier: BSL-1.0
# 70-xrhardware-hwdb.rules
diff --git a/70-xrhardware.hwdb b/70-xrhardware.hwdb
index 725d5b0..2ceb1fd 100644
--- a/70-xrhardware.hwdb
+++ b/70-xrhardware.hwdb
@@ -1,4 +1,7 @@
# Do not edit this file - generated by make-hwdb-file.py
+#
+# Copyright 2019-2021, Collabora, Ltd. and the xr-hardware contributors
+#
# SPDX-License-Identifier: BSL-1.0
# This hwdb file must be used with the corresponding rules file.
@@ -68,10 +71,18 @@ usb:v2833p0021*
usb:v2833p2021*
ID_xrhardware=1
+# Oculus Rift (DK2 Sensor)
+usb:v2833p0201*
+ ID_xrhardware=1
+
# Oculus Rift (CV1)
usb:v2833p0031*
ID_xrhardware=1
+# Oculus Rift (CV1 Sensor)
+usb:v2833p0211*
+ ID_xrhardware=1
+
# Oculus Rift S
usb:v2833p0051*
ID_xrhardware=1
diff --git a/70-xrhardware.rules b/70-xrhardware.rules
index feda61e..84e2585 100644
--- a/70-xrhardware.rules
+++ b/70-xrhardware.rules
@@ -1,4 +1,7 @@
# Do not edit this file - generated by make-udev-rules.py
+#
+# Copyright 2019-2021, Collabora, Ltd. and the xr-hardware contributors
+#
# SPDX-License-Identifier: BSL-1.0
# 70-xrhardware.rules
@@ -75,10 +78,18 @@ ATTRS{idVendor}=="2833", ATTRS{idProduct}=="0021", TAG+="uaccess", ENV{ID_xrhard
ATTRS{idVendor}=="2833", ATTRS{idProduct}=="2021", TAG+="uaccess", ENV{ID_xrhardware}="1"
+# Oculus Rift (DK2 Sensor) - USB
+ATTRS{idVendor}=="2833", ATTRS{idProduct}=="0201", TAG+="uaccess", ENV{ID_xrhardware}="1"
+
+
# Oculus Rift (CV1) - USB
ATTRS{idVendor}=="2833", ATTRS{idProduct}=="0031", TAG+="uaccess", ENV{ID_xrhardware}="1"
+# Oculus Rift (CV1 Sensor) - USB
+ATTRS{idVendor}=="2833", ATTRS{idProduct}=="0211", TAG+="uaccess", ENV{ID_xrhardware}="1"
+
+
# Oculus Rift S - USB
ATTRS{idVendor}=="2833", ATTRS{idProduct}=="0051", TAG+="uaccess", ENV{ID_xrhardware}="1"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c70d1ca..810202c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,9 +2,28 @@
<!--
SPDX-License-Identifier: CC0-1.0
-SPDX-FileCopyrightText: 2020 Collabora, Ltd. and the xr-hardware contributors
+SPDX-FileCopyrightText: 2020-2021 Collabora, Ltd. and the xr-hardware contributors
-->
+## xr-hardware 1.0.0 (2021-10-25)
+
+Version bumped because there was no real reason to be pre-1.0 anymore,
+this package is widely used now.
+
+- Additions
+ - Add USB PID for Oculus Rift CV1 sensors, needed for positional tracking
+ support.
+ ([!14](https://gitlab.freedesktop.org/monado/utilities/xr-hardware/merge_requests/14))
+ - Add USB PID for Oculus Rift DK2 sensor, needed for positional tracking support.
+ ([!15](https://gitlab.freedesktop.org/monado/utilities/xr-hardware/merge_requests/15))
+- Improvements
+ - Migrate script from attrs to dataclasses (which is built-in to Python 3.7 and
+ newer)
+ ([!16](https://gitlab.freedesktop.org/monado/utilities/xr-hardware/merge_requests/16))
+ - Generate copyright header into generated files, and other minor changes to meet
+ REUSE 3.0 compliance: see <https://reuse.software>.
+ ([!17](https://gitlab.freedesktop.org/monado/utilities/xr-hardware/merge_requests/17))
+
## xr-hardware 0.4.0 (2021-02-10)
- Additions
diff --git a/LICENSES/BSL-1.0.txt b/LICENSES/BSL-1.0.txt
new file mode 100644
index 0000000..2d87ab1
--- /dev/null
+++ b/LICENSES/BSL-1.0.txt
@@ -0,0 +1,7 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt
new file mode 100644
index 0000000..0e259d4
--- /dev/null
+++ b/LICENSES/CC0-1.0.txt
@@ -0,0 +1,121 @@
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+ HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display,
+ communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+ likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+ subject to the limitations in paragraph 4(a), below;
+ v. rights protecting the extraction, dissemination, use and reuse of data
+ in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+ European Parliament and of the Council of 11 March 1996 on the legal
+ protection of databases, and under any national implementation
+ thereof, including any amended or successor version of such
+ directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+ world based on applicable law or treaty, and any national
+ implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+ surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+ warranties of any kind concerning the Work, express, implied,
+ statutory or otherwise, including without limitation warranties of
+ title, merchantability, fitness for a particular purpose, non
+ infringement, or the absence of latent or other defects, accuracy, or
+ the present or absence of errors, whether or not discoverable, all to
+ the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+ that may apply to the Work or any use thereof, including without
+ limitation any person's Copyright and Related Rights in the Work.
+ Further, Affirmer disclaims responsibility for obtaining any necessary
+ consents, permissions or other rights required for any use of the
+ Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+ party to this document and has no duty or obligation with respect to
+ this CC0 or use of the Work.
diff --git a/Makefile b/Makefile
index 0c725b9..7803cbe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
#!/usr/bin/env make -f
-# Copyright 2020 Collabora, Ltd
+# Copyright 2020-2021 Collabora, Ltd
# SPDX-License-Identifier: BSL-1.0
# Author: Ryan Pavlik <ryan.pavlik@collabora.com>
@@ -16,7 +16,7 @@ all: $(RULES_FILE) $(HWDB_FILE) $(HWDB_RULES_FILE)
test:
$(PYTHON) test-db.py
- $(PYTHON) -m flake8 .
+ $(PYTHON) -m flake8 *.py xrhardware/*.py
.PHONY: test
$(RULES_FILE): make-udev-rules.py xrhardware/db.py xrhardware/generate.py
diff --git a/README.md b/README.md
index 1098b64..38f984c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,10 @@
# XR Hardware Rules
+<!--
+SPDX-License-Identifier: CC0-1.0
+SPDX-FileCopyrightText: 2020-2021, Collabora, Ltd. and the xr-hardware contributors
+-->
+
A simple set of scripts to generate udev rules for user access to XR (VR and AR)
hardware devices.
@@ -9,8 +14,7 @@ an attempt to do the Debian stuff correctly by the book.
## "Build" requirements (to re-generate files)
-You'll need Python 3 and the `python3-attr` Debian package or equivalent
-(`pip3 install attr`, etc.)
+You'll need Python 3.7 or newer.
## Quick start: "build" and use
@@ -29,7 +33,7 @@ You'll need to at least re-plug your devices to get this to register for now.
Note that you still might see something like this in a simple `ls -l` view:
-```
+```none
crw-rw----+ 1 root root 246, 2 Jan 22 12:00 /dev/hidraw2
```
@@ -37,7 +41,7 @@ This doesn't mean it failed to work: the `+` means there's an ACL attached in
addition to the normal Unix permissions. Running `getfacl` on that device node
will reveal:
-```
+```none
# file: dev/hidraw2
# owner: root
# group: root
@@ -105,7 +109,7 @@ Plug your device in or connect it, and look at dmesg.
You'll see something like this at the end (example is a first-generation PS Move controller):
-```
+```none
[541976.201331] input: Motion Controller as /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-12/1-12:1.0/bluetooth/hci0/hci0:1/0005:054C:03D5.001A/input/input62
[541976.201426] sony 0005:054C:03D5.001A: input,hidraw6: BLUETOOTH HID v0.01 Joystick [Motion Controller] on fc:01:7c:a3:cf:06
```
@@ -127,7 +131,7 @@ is implied by default) in the Device entry. Otherwise, be sure to add
You'll see something like this at the end (example is still a first-generation PS Move controller):
-```
+```none
[542674.705441] usb 3-1.2.1: USB disconnect, device number 77
[544022.781910] usb 3-1.2.1: new full-speed USB device number 78 using xhci_hcd
[544022.888540] usb 3-1.2.1: New USB device found, idVendor=054c, idProduct=03d5, bcdDevice= 2.20
diff --git a/changes/.markdownlint.yaml b/changes/.markdownlint.yaml
new file mode 100644
index 0000000..eeed664
--- /dev/null
+++ b/changes/.markdownlint.yaml
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2021 Collabora, Ltd.
+
+# Changelog fragments will never start with a header.
+MD041: false
+
+# Don't whine about line length because proclamation will wrap us.
+MD013: false
diff --git a/xrhardware/db.py b/xrhardware/db.py
index fa16699..bf45634 100644
--- a/xrhardware/db.py
+++ b/xrhardware/db.py
@@ -38,7 +38,9 @@ def get_devices():
Device("Oculus Rift (DK1)", "2833", "0001"),
Device("Oculus Rift (DK2)", "2833", "0021"),
Device("Oculus Rift (DK2)", "2833", "2021"),
+ Device("Oculus Rift (DK2 Sensor)", "2833", "0201"),
Device("Oculus Rift (CV1)", "2833", "0031"),
+ Device("Oculus Rift (CV1 Sensor)", "2833", "0211"),
Device("Oculus Rift S", "2833", "0051"),
Device("Samsung GearVR (Gen1)", "04e8", "a500"),
diff --git a/xrhardware/device.py b/xrhardware/device.py
index ff009cc..db9403f 100644
--- a/xrhardware/device.py
+++ b/xrhardware/device.py
@@ -1,49 +1,57 @@
#!/usr/bin/env python3 -i
-# Copyright 2019-2020 Collabora, Ltd
+# Copyright 2019-2021 Collabora, Ltd
# SPDX-License-Identifier: BSL-1.0
# Author: Ryan Pavlik <ryan.pavlik@collabora.com>
"""XR Hardware device database element type."""
-import attr
+from typing import Dict, Optional
+from dataclasses import dataclass
import re
-_VID_PID_RE = re.compile(r'^[0-9a-f]{4}$')
+_VID_PID_RE = re.compile(r"^[0-9a-f]{4}$")
-_USBSERIALNAME_RE = re.compile(r'^[._0-9a-zA-Z]+$')
+_USBSERIALNAME_RE = re.compile(r"^[._0-9a-zA-Z]+$")
-def _is_four_hexits(_self, _attribute, val):
- if not _VID_PID_RE.match(val):
+def _is_four_hexits(val: Optional[str]):
+ if val is not None and not _VID_PID_RE.match(val):
raise ValueError("Must be four hexadecimal characters in lowercase")
-def _is_suitable_device_name(_self, _attribute, val):
+def _is_suitable_device_name(val: Optional[str]):
if val is None:
return
if not _USBSERIALNAME_RE.match(val):
raise ValueError(
"Must be a reasonable thing to put in a device node name: "
- "a-z, A-Z, numbers, ., _")
+ "a-z, A-Z, numbers, ., _"
+ )
-@attr.s
+@dataclass
class Device:
"""An XR hardware device that we should permit access to."""
- description = attr.ib()
- vid = attr.ib(default=None, validator=_is_four_hexits)
- pid = attr.ib(default=None, validator=_is_four_hexits)
- usb_serial_name = attr.ib(default=None, validator=_is_suitable_device_name)
- usb = attr.ib(default=True)
- bluetooth = attr.ib(default=False)
- extra_properties = attr.ib(default=None)
+ description: str
+ vid: Optional[str] = None
+ pid: Optional[str] = None
+ usb_serial_name: Optional[str] = None
+ usb: bool = True
+ bluetooth: bool = False
+ extra_properties: Optional[Dict[str, str]] = None
+
+ def __post_init__(self):
+ """Validate provided values."""
+ _is_four_hexits(self.vid)
+ _is_four_hexits(self.pid)
+ _is_suitable_device_name(self.usb_serial_name)
def get_properties_to_set(self):
"""Generate the udev properties to set for this device."""
- yield ('ID_xrhardware', 1)
+ yield ("ID_xrhardware", 1)
if self.usb_serial_name:
- yield ('ID_xrhardware_USBSERIAL_NAME', self.usb_serial_name)
+ yield ("ID_xrhardware_USBSERIAL_NAME", self.usb_serial_name)
if self.extra_properties:
for k, v in self.extra_properties.items():
yield (k, v)
@@ -55,23 +63,23 @@ class Device:
"Can't make a hwdb entry for something without a vid!")
# usb: and bluetooth: prefix come later
parts = []
- parts.append('v%s' % self.vid)
+ parts.append("v%s" % self.vid)
if self.pid:
- parts.append('p%s' % self.pid)
- parts.append('*')
- identifier_suffix = ''.join(parts)
+ parts.append("p%s" % self.pid)
+ parts.append("*")
+ identifier_suffix = "".join(parts)
if self.usb:
- yield 'usb:' + identifier_suffix
+ yield "usb:" + identifier_suffix
if self.bluetooth:
- yield 'bluetooth:' + identifier_suffix
+ yield "bluetooth:" + identifier_suffix
def make_hwdb_entry(self):
"""Return a hwdb entry for this device."""
- lines = ['# ' + self.description]
+ lines = ["# " + self.description]
lines.extend(list(self.yield_hwdb_identification()))
for k, v in self.get_properties_to_set():
- lines.append(' %s=%s' % (k, v))
- return '\n'.join(lines)
+ lines.append(" %s=%s" % (k, v))
+ return "\n".join(lines)
@property
def extended_description(self):
@@ -85,10 +93,8 @@ class Device:
def make_commented_rule(self):
"""Return a comment and udev rule for this device."""
- return '\n'.join((
- "# %s" % self.extended_description,
- self.make_rule(),
- ""))
+ rule = self.make_rule()
+ return "\n".join(("# %s" % self.extended_description, rule, ""))
def yield_rule_condition_lists(self):
"""Yield the udev rule conditions (as lists) to select this device."""
@@ -100,9 +106,10 @@ class Device:
parts.append('ATTRS{idProduct}=="%s"' % self.pid)
yield parts
- if self.bluetooth:
- yield ['KERNELS=="0005:%s:%s.*"' %
- (self.vid.upper(), self.pid.upper())]
+ if self.bluetooth and self.vid and self.pid:
+ vid = self.vid.upper()
+ pid = self.pid.upper()
+ yield ['KERNELS=="0005:%s:%s.*"' % (vid, pid)]
# Bluetooth devices don't get idVendor and idProduct,
# but they do get this which is pretty similar.
# However, these fail to trigger the rule properly for the PS Move
@@ -125,7 +132,9 @@ class Device:
rules = []
for condition in self.yield_rule_conditions():
parts = [condition, 'TAG+="uaccess"']
- parts.extend('ENV{%s}="%s"' % (k, v)
- for k, v in self.get_properties_to_set())
- rules.append(', '.join(parts))
+ parts.extend(
+ 'ENV{%s}="%s"' % (k, v)
+ for k, v in self.get_properties_to_set()
+ )
+ rules.append(", ".join(parts))
return "\n".join(rules)
diff --git a/xrhardware/generate.py b/xrhardware/generate.py
index ca29ea0..e59a214 100644
--- a/xrhardware/generate.py
+++ b/xrhardware/generate.py
@@ -1,11 +1,14 @@
#!/usr/bin/env python3
-# Copyright 2019-2020 Collabora, Ltd
+# Copyright 2019-2021 Collabora, Ltd
# SPDX-License-Identifier: BSL-1.0
# Author: Ryan Pavlik <ryan.pavlik@collabora.com>
"""XR Hardware generation helper code."""
# pylint: disable=E501
_SHARED_PREFIX = """# Do not edit this file - generated by {script}
+#
+# Copyright""" + """ 2019-2021, Collabora, Ltd. and the xr-hardware contributors
+#
# SPDX-License-Identifier: BSL-1.0
"""