The first precept is explained in the Tipitaka as the Vinaya rule Parajika 3.
No matter what the motivation is, if you intentionally cause someone's death, it's a breach of the first precept. In intentional killing, the motivation is irrelevant. Even if someone is dying and is in pain, and motivated by compassion and desiring that he doesn't experience pain, someone would to advise him to fast to death, if he were to do that, the former would have broken the first precept. If one uninentionally kills someone, the first precept is not broken.
Here is the rendering of the rule: http://www.accesstoinsight.org/lib/auth ... 4.html#Pr3
Another rule that relates to this is the rule Pacittiya 74 that forbids hitting someone out of anger. This means any violence, done to another out of anger, that doesn't include intention to kill, being that such violence is under the Pj 3 rule. In doing violence like this, without intention to kill, motivation is a factor. If one does such violence out of anger, that is unwolesome. If one does such violence in self-defense, it is not an offense, even if anger arises in one's mind.
Rendering of the rule: http://www.accesstoinsight.org/lib/auth ... .html#Pc74
Presumably, there is also no offense in defending others, having in mind Buddha's words that one should protect one's family and friends (that he gives e.g. in the Sigalovada Sutta). So, to adress your concrete example, there would be nothing unwholesome in "pulling the trigger" and shooting him in the arm, so he can't push the button.
Having all this in mind, if you would to see someone going to push the button and kill beings, and then taking a weapon and pulling the trigger to shoot him in the arm in order to stop him, with no intention to kill him, with the primary motivation to protect beings from him, there would be nothing wrong with that, even if you unintentionally kill him, or if your motivation becomes mixed with anger.