Also, remember pilots are by nature usually very superstitious people and some, as I know for example at least in my case, I liked my trusty T/C Twins cap for good luck if for no other reason.
Also, as mentioned above, there is some un-written tradition of pilots in the military wearing ball caps, and for those that don't have to wear a helmet, I'm all for that, although the thing about saluting might be conflicted since the flight suit is still a military uniform. I think while on the flight deck it's no problem, but off the plane the military cover comes back on, at least in the Marine C-130 squads. Marines are sticklers for removing your headgear indoors even when in civies, while the Navy and Air Force units are good about allowance for such things. I've seen many in both wear all sorts of ball caps and I figure that as long as the cap isn't too terribly ragged, which some seem to think is the in-fashion statement nowadays, I don't see a problem with them.
And then again, from back in my days in small little Cessna trainers, wearing my headset would start wearing on my head and the hat helped cushion it. I had a decent head set, perhaps not near as much as some had, but regardless after awhile I think any headset if worn long enough would begin to rub. That and the protection from the sun which believe it or not offered a noticable reduction in havint to squint even if worn with sunglasses, I just came to regard it as part of my flight bag.
Check out Bat-21 with Glover and Hackman, Danny has got a ballcap on when in his O-2.