With all due respect, yes you were.
You heard shots outside, you grabbed your gun and ran out the door gun in hand. To be brutally blunt and honest here, stupid move. What if there really was a criminal out there shooting? You didn't think about that, though, did you? You would have ran head first into a shootout with the guy.
You can try to back pedal all you want, but, the end result is you got "gun = superman complex" You ran out there to be nosy and be Mr. Bigshot with your gun. THEN, you have the gall to get upset with your local LEO who arrives on scene of an unknown shooter and wants to check out the only one they see standing around with a gun??
Taking your gun is the ONLY thing I see wrong with the LEO's actions. But, since you exasperated things by trying to play "front-porch Matlock" with the LEO, you hold some blame for the loss of your gun in the process IMHO. I'll bet had you simply complied with the officer's commands, you'd still have your gun and your day would have gone much smoother. Live to fight another day in other words.
In every encounter I've seen, on every forum, in every thread about LEO vs. citizens, 100% of the time, then end result is that the scene is the WRONG place to try to pretend you're a lawyer. Play nice, be respectful, and if you truly feel the LEO is in the wrong, follow proper channels. With a REAL lawyer if needed. That's not giving up any of your rights. That's not cowering down to anyone or anything. It's simply being smart enough to know where and when to pick your battles.
When you make an arse out of yourself, get arrested, you just look like sour grapes when you try regular channels later on, you take away from your standing. But, if you act like a civilized adult throughout the process, you give your standing more bite.