Straight from China, K40s usually use old bootleg CorelDraw with a special plug in (sometimes requiring a hardware dongle), or "Moshidraw" – which is pretty much universally despised. Either option is crap, unstable, difficult to use, closed source, proprietary protocols, etc. Plus the controller hardware is usually dubious.
Getting rid of the provided electronics and putting in a RAMPS / Smoothieboard / GRBL / Marlin / or anything-but-the-crap-it-came-with is one of the higher priority upgrades in terms of usability. It would be nice to have Duet on that list of choices. My K40 is ripped apart undergoing this process (planning on using my spare Smoothieboard for it)
Once the controller is changed out, Laserweb is one of the better choices for cutting and raster control. Open source, cross platform, g-code based, under active development, good wiki, etc. https://github.com/LaserWeb/LaserWeb3 It plays nicely with Smoothieware in particular because of some of the additional laser power control features in it, like integrating the power level with the acceleration curves (something not possble with RAMPS / Grbl). Adding that into Duet would bring it on par with Smoothieware for laser cutting. I'd start there to see what needs to be added for full laser cutter / rastering support.
Some older K40s use an analog pot / voltage for laser power control, with no direct way for the controller to vary the power. More recent ones have a different power supply design which runs PWM (I think 20Khz ?) to control power. There's also a separate laser fire contact closure to ground trigger. Some people set their controller to PWM the trigger to adjust laser power, other configurations maintain separate trigger and power control signals. (there's also a laser enable input, which is usually wired to a toggle switch on the control panel.).
The laser has a minimum value for the laser to fire, usually around 20-25% power level, which is another thing that needs to be considered when implementing the PWM control.
I'm not fond of the cabling that came with my K40, so having a drop in replacement that uses the same cables isn't a bonus for me. I am not sure all the variations and evolution of the K40 all use the same cabling – they are at least three different controller boards, with several revisions of each, out in the wild. But at the very least, the flat ribbon cable used to drive one of steppers and end stops is inadequate, fragile and does not stay connected well during high speed moves.
With a new controller you're probably also going to want to add some cabling for some of the common upgrades: another axis for a z-lift bed or rotational axis, cooling water temperature and flow monitoring, toggles for case lighting, targeting laser(s), air assist, exhaust ventilation, water pump, etc. It would be nice to be able to have those integrated with Duet through the unused GPIO / mosfets (probably most of it can be done with existing config options).
K40s don't come with any sort of safety interlocks, which is insanely risky, so that's also something to consider adding (although they can be added inline with the laser enable switch for a purely hardware solution).
One final thought: make sure to really triple check the grounding before firing up a K40. The laser's ground return path is through the ammeter in the control panel (!) and then to ground (which is also tied to chassis ground). If that ground path ever disconnects, there's the potential for 20+KV to be floating around in the control panel / metal frame. Yikes. I was uncomfortable with that so I added a separate isolated current meter and safety spark-gap -- which I'd like to hook into the controller eventually via an analog input so I could close the feedback loop on the laser power control.