I've actually thought about the same situation.
The best I have come up with is saying in your best "what, are you stupid??" voice:
"Dude - There's a f'ing cop right there."
while looking over his shoulder down the block.
Then if you can draw and fire smooth enough, he shouldn't even hear the shot you place in his ear.
I would think if you were going to rob or murder someone, the possibility of an officer nearby would automatically make you turn to look.
Who knows if you'd have the presence of mind to pull it off, but with a gun pointed at you, you can be pretty certain you won't be able to draw and shoot before he can pull the trigger.
I myself don't think I'd try to grab or control his weapon if he was looking at me unless I had ABSOLUTELY no other option.