Open Fuzzyma opened 8 years ago
This works on Windows, however for Linux (rasberry pi) the read() command still blocks. I have tracked down the function that blocks, which is the _get_data(self, read_size) function, when it performs self._character_device.read(read_size).
When running on linux the _character_device returns a BufferedReader object, from using the io.open(path, 'rb') command. When running on windows it uses a simpler approach with io.BytesIO() which I guess does not block?
def _character_device(self):
if not self._character_file:
if WIN:
self._character_file = io.BytesIO()
return self._character_file
try:
self._character_file = io.open(
self._character_device_path, 'rb')
except IOError as err:
...
return self._character_file
I am trying to implement this on a Rasberry Pi, thus I need this to work. Anyone got any ideas of how to implement this differently?
Thank You..
As mentioned in #7 the get_gamepad method blocks further execution of the program which is often not desired. This PR intends to add a
blocking
parameter which can be used to disable this behavior. You now can do something like this:Note the array index
[0]
I have to use because it always returns only one array element. I dont know the internals of other devices or other systems. So I leave it as it is. However: For xbox one controller with win7 this could be simplified (see #8)