← Back to team overview

kicad-developers team mailing list archive

Re: Code execution context


Hello Markus,

This is exciting news, as some of our users are also big fans of
3dconnexion products[1]

Others have looked in to what it would take in the past, but there were
some questions about the need for proprietary drivers on some platforms[2]

It sounds like this websocket interface is a new approach that doesn't
require any additional libraries for KiCad to link against?
Does the hardware use some other daemon process to bridge between the
device driver and websockets?

As you may know, KiCad uses wxWidgets as a framework, so you probably want
to plug in to the wx event loop on the main thread.
There are some guidelines on this in their docs[3].

You probably want to check out ./common/view/wx_view_controls.cpp to see
how existing input events are handled by the 2D canvases.
I guess your new code would hook in here somewhere, and provide additional
event handlers to manage the data from the 3D device.
Your communication thread should be able to post wxWidgets events to the
main thread and then we can consume them here.

By the way: although the wx docs use wxThread, I think this general concept
should work with C++ standard libraries threads just fine.
The documentation for wxEvtHandler::QueueEvent may also be useful[4]

Hope this helps!


[1] https://gitlab.com/kicad/code/kicad/-/issues/4951
[2] https://lists.launchpad.net/kicad-developers/msg29464.html

On Thu, Feb 25, 2021 at 1:47 AM Markus Bonk <markus_bonk@xxxxxxxxxxxxxxx>

> Hi,
> I am currently investigating adding support for 3D input devices to
> pcbnew. The plan is to use a websocket interface (boost/beast) to
> communicate with the 3D device. Effectively the communication runs on an
> extra thread. Somewhere the event code will need to switch to executing on
> the main thread.
> One way of achieving this on say win32 might be to add functors to a queue
> post a message to a message window handler in the main thread which empties
> the queue and invokes the functor.
> Is such a mechanism already in place in KiCAD? What is the KiCAD
> recommended solution to the issue?
> Thanks
> -Markus
> ------------------------------
> *Markus Bonk*
> Senior Software Engineer
> Clarita-Bernhard-Str. 18
> 81249 München
> Germany
> markus_bonk@xxxxxxxxxxxxxxx <%7BE-mail%7D>
> www.3dconnexion.com
> Geschäftsführer: Antonio Pascucci
> Sitz der Gesellschaft: München
> Registergericht: München HRB 99232
> This email and any files transmitted with are from 3Dconnexion GmbH. The
> contents of this email and any attachments are confidential to the intended
> recipient. They may not be disclosed to or used by or copied in any way by
> anyone other than the intended recipient. If this email is received in
> error, please contact 3Dconnexion GmbH by calling +49 89 8974542-0 and then
> delete it. Please note that neither 3Dconnexion GmbH nor the sender accepts
> any responsibility for viruses and it is your responsibility to scan or
> otherwise check this email and any attachments. Any opinion expressed in
> this email are those of the individual and not necessarily those of
> 3Dconnexion GmbH.
> 3Dconnexion GmbH processes and stores for commercial purposes your
> personal data, collected upon your consent, in accordance with its privacy
> policy available at https://www.3dconnexion.eu/privacy.html, which has
> been drafted in accordance with Regulation (EU) no. 679/2016 and all
> applicable local data protection laws and regulations of the countries
> where the company operates. To revoke your consent or exercise all your
> rights with regards to personal data, please contact us at
> privacy@xxxxxxxxxxxxxxx.
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp

GIF image

Follow ups