It's well established by the Courts that the 2nd amendment can be subjected to more rigorous limitation than can, for example, the 1st amendment.
It would in all likelihood be unconstitutional for example, to deny a felon or an insane person free speech or free press rights.
In order for a firearm too be protected by the second amendment it must have some reasonable relationship to the preservation or efficiency of a well regulated militia, in common use of the time, and supplied by the citizen.
United States v. Miller