How does Karma work for an inventor who changed lives of millions? Consider an inventor who has nothing to do with spirituality but her innovation helped change lives of millions. Her innovation helps people even after her death. Further, innovations can be used for evil as well.
The Buddhist version of karma may not be the same as the version of karma in other Indian religions.

It's not a system of cosmic justice. If you invented something to help millions of people, you would not get more rewards compared to someone who helped just 10 people. 

In Buddhism, karma is about cause and effect, due to intention and volition (see this page). It's about one's state of mind and its expressions in actions and words. It's not about the impact made on the world or on others.

This means that one who has unintentionally helped others, but out of originally evil intentions in mind, he would experience negative karmic results.

On the other hand, if one had good intentions, but his actions inadvertently harmed others, he would still experience positive karmic results.

It's all about intentions.

From the Dhammapada:


  Verse 1: All mental phenomena have mind as their forerunner; they
  have mind as their chief; they are mind-made. If one speaks or acts
  with an evil mind, 'dukkha' follows him just as the wheel follows the
  hoofprint of the ox that draws the cart.
  
  Verse 124: If there is no wound on the hand, one may handle
  poison; poison does not affect one who has no wound; there can be no
  evil for one who has no evil intention.


From the Nibbedhika Sutta:


  "Intention, I tell you, is kamma. Intending, one does kamma by way of
  body, speech, &amp; intellect.