njz3 / vJoy

Virtual Joystick
http://vjoystick.sourceforge.net
MIT License
310 stars 40 forks source link

Add a pybind11 genered compiled Python extension for vJoy developers #28

Closed code-monet closed 3 weeks ago

code-monet commented 3 weeks ago

There are a number of Python wrappers for the DLL in the SDK, and most of them are not up-to-date for the newest vJoy DLL. These wrappers are also hard to maintain and may hide bugs in the ctypes bindings code.

Using pybind11 has several advantages:

  1. Speed, from being a compiled extension. All the wrapping to make the code Python friendly is done in C++ rather than in Python (ctypes approach)
  2. Compile-time checking of C++ to Python conversion via pybind11
  3. Greatly reduced boilerplate code for the bindings.

To enable this, a "modern" C++ API with exceptions is added.

Currently developers are expected to build the Python extension themselves. An x64 compiled version is included in the added Python example (generated for Python 3.12 but should work with adjacent Python versions, did not test).

njz3 commented 3 weeks ago

What was the need to update to .Net 4.8 instead of keeping 4.5.2? Is it a requirement for the new python interace?

code-monet commented 3 weeks ago

Probably no need to update, that's just the version I have installed for development. If you prefer, I'll install 4.5.2 and undo the retarget commits.

njz3 commented 3 weeks ago

That's ok for me to move to 4.8 as it is available on windows since 7.