Add read and write functions - #4
Conversation
|
The intention in this code is that the Also, note that this class accepts an integer as device (file descriptor), which would cause the added methods (as they are implemented in the current patch) to raise. My impression is that covering this case would introduce too much avoidable complexity - avoidable by having the caller code keep track of the underlying device. So IMHO the cleanest solution is that you do not only keep track of the HIDRaw instance in DS5HidRawController, but separately also the underlying file. Does this make sense ? |
I suppose what you meant was changing it like so: From: hidraw = HIDRaw(open(filename, "w+b"))
c = TestSC(driver, None, hidraw)
...
self._hidrawdev: HIDRaw = hidrawdev
...
data = self._hidrawdev.read(self._packet_size)To: device_file = open(filename, "w+b")
hidraw = HIDRaw(device_file)
c = TestSC(driver, None, hidraw, device_file)
...
self._hidrawdev: HIDRaw = hidrawdev
self._device_file: BinaryIO = device_file
...
data = self._device_file.read(self._packet_size)Which I've now done - I suppose I'll send a PR with typing additions soon so I can tear out the vendored in copy of this project. |
Hello there, I am currently plumbing sc-controller which has bundled some libraries included this one, into which it added these two helper functions.
I intend to tear it out and make it a proper dependency.
Would it make sense to have them here in the upstream library to you, or should I figure out how to override the library with them instead?
What the write() is used for can be found here for example, in the commit that introduced it - C0rn3j/sc-controller@e550828