unbit / foohid-py Goto Github PK
View Code? Open in Web Editor NEWPython wrapper for the foohid OSX driver
License: MIT License
Python wrapper for the foohid OSX driver
License: MIT License
I installed foohid on my Mac and tried to run the example but it shows
SystemError: unable to create device
I think foohid is installed and works because I can run the compiled binary of mouse.c and keyboard.c in foohid examples.
Environment: OS X 10.11.4 with foohid v0.2.1 installed.
I've setup foohid and have been able to manipulate the joystick axes, but I have no clue how to go about pressing one of the gamepad's buttons
I just installed foohid by the readme. Tried to run the example and it did not worked. Had I missed something? Any tips?
Installation of foohid
:
airpill:git alanjds$ sudo pip install foohid
Password:
Downloading/unpacking foohid
Downloading foohid-0.1.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/foohid/setup.py) egg_info for package foohid
Installing collected packages: foohid
Running setup.py install for foohid
building 'foohid' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c foohid.c -o build/temp.macosx-10.9-intel-2.7/foohid.o
foohid.c:179:32: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'Py_ssize_t' (aka 'long') [-Wshorten-64-to-32]
PyObject *ret = PyTuple_New(output[1]);
~~~~~~~~~~~ ^~~~~~~~~
foohid.c:183:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'Py_ssize_t' (aka 'long') [-Wshorten-64-to-32]
PyTuple_SetItem(ret, i, PyString_FromString(ptr));
~~~~~~~~~~~~~~~ ^
2 warnings generated.
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.9-intel-2.7/foohid.o -o build/lib.macosx-10.9-intel-2.7/foohid.so -framework IOKit
Successfully installed foohid
Cleaning up...
Clone and installation of foohid-py
:
airpill:git alanjds$ git clone https://github.com/unbit/foohid-py
Cloning into 'foohid-py'...
remote: Counting objects: 21, done.
remote: Total 21 (delta 0), reused 0 (delta 0), pack-reused 21
Unpacking objects: 100% (21/21), done.
Checking connectivity... done.
airpill:git alanjds$ cd foohid-py/
airpill:foohid-py (master) alanjds$ sudo python setup.py install
running install
running build
running build_ext
building 'foohid' extension
creating build
creating build/temp.macosx-10.9-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c foohid.c -o build/temp.macosx-10.9-intel-2.7/foohid.o
foohid.c:179:32: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to
'Py_ssize_t' (aka 'long') [-Wshorten-64-to-32]
PyObject *ret = PyTuple_New(output[1]);
~~~~~~~~~~~ ^~~~~~~~~
foohid.c:183:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to
'Py_ssize_t' (aka 'long') [-Wshorten-64-to-32]
PyTuple_SetItem(ret, i, PyString_FromString(ptr));
~~~~~~~~~~~~~~~ ^
2 warnings generated.
creating build/lib.macosx-10.9-intel-2.7
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.9-intel-2.7/foohid.o -o build/lib.macosx-10.9-intel-2.7/foohid.so -framework IOKit
running install_lib
copying build/lib.macosx-10.9-intel-2.7/foohid.so -> /Library/Python/2.7/site-packages
running install_egg_info
Removing /Library/Python/2.7/site-packages/foohid-0.1-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/foohid-0.1-py2.7.egg-info
airpill:foohid-py (master) alanjds$
Running the tests:
airpill:foohid-py (master) alanjds$ python test_list.py
Traceback (most recent call last):
File "test_list.py", line 4, in <module>
foohid.create("FooHID {0}".format(i), "xxx")
SystemError: unable to open it_unbit_foohid service
airpill:foohid-py (master) alanjds$ python test_mouse.py
Traceback (most recent call last):
File "test_mouse.py", line 38, in <module>
foohid.create("FooHID simple mouse", struct.pack('{0}B'.format(len(mouse)), *mouse))
SystemError: unable to open it_unbit_foohid service
airpill:foohid-py (master) alanjds$ python test_joypad.py
Traceback (most recent call last):
File "test_joypad.py", line 36, in <module>
foohid.create("FooHID simple joypad", struct.pack('{0}B'.format(len(joypad)), *joypad))
SystemError: unable to open it_unbit_foohid service
airpill:foohid-py (master) alanjds$
From the USB HID descriptor you put in test_joypad I was able to decipher that there are 16 buttons on the sample joypad. I could not understand how you designate new axes but I assume it has to do with the 0x09 descriptor. More documentation on what each descriptor and value means for the Joypad would be of great help. Also documentation on the struct.pack format required to update the entire Joypad would be of great help. This kernel extension is marvelous but it needs more documentation.
I am receiving the same error that seemed to be a problem in 2015.
I am running macOS Sierra 10.12.5 on a mid 2015 macbook pro.
Foohid will run for a short amount of time before displaying:
Traceback (most recent call last): File "test_joypad.py", line 36, in <module> foohid.create("FooHID simple joypad", struct.pack('{0}B'.format(len(joypad)), *joypad), "SN 123", 2, 3) SystemError: unable to open it_unbit_foohid service
I have followed the troubleshooting steps multiple times and also tried uninstalling/reinstalling the module with pip.
Any way to properly install the kext file now? There's nothing under releases
`Collecting foohid
Using cached foohid-0.1.tar.gz (1.9 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for foohid, since package 'wheel' is not installed.
Installing collected packages: foohid
Running setup.py install for foohid ... error
error: subprocess-exited-with-error
× Running setup.py install for foohid did not run successfully.
│ exit code: 1
╰─> [37 lines of output]
running install
/Users/macdaddy/Documents/Code/..../lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_ext
building 'foohid' extension
creating build
creating build/temp.macosx-12-arm64-cpython-310
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/Users/macdaddy/Documents/Code/.../include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c foohid.c -o build/temp.macosx-12-arm64-cpython-310/foohid.o
foohid.c:14:51: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
kern_return_t ret = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching(FOOHID_SERVICE), &iterator);
^~~~~~~~~~~~~~~~~~~~
kIOMainPortDefault
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
const mach_port_t kIOMasterPortDefault
^
foohid.c:183:29: error: implicit declaration of function 'PyString_FromString' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
PyTuple_SetItem(ret, i, PyString_FromString(ptr));
^
foohid.c:183:29: note: did you mean 'PyLong_FromString'?
/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10/longobject.h:103:24: note: 'PyLong_FromString' declared here
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
^
foohid.c:183:29: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'PyObject *' (aka 'struct _object *') [-Wint-conversion]
PyTuple_SetItem(ret, i, PyString_FromString(ptr));
^~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10/tupleobject.h:33:67: note: passing argument to parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
foohid.c:211:2: error: implicit declaration of function 'Py_InitModule' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
Py_InitModule("foohid", foohidMethods);
^
foohid.c:212:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
3 warnings and 2 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> foohid
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.`
I tried installing the library using pip and this was the output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.