I've always been particularly confused by the contract clauses which specify that all work of the employee during their time at the company is property of the company itself. Does this mean that if I develop some completely unrelated software in my spare time while working as a programmer at a large company, that the software I created at home also belongs to my employer? What if I was to write a book during that sam…
In most states, the answer is "yes, it probably does". It varies from state to state, of course, and the definition of "completely unrelated". In the nicer states, it's about what is related to your employers business, or the demonstrable/anticipated research and development of your employer. Most engineers get this very wrong, or have no idea about all the things their company does.
The only common country i'm aware of in which the answer is definitely "no, it belongs to you", is switzerland.
As for legal battles, plenty. Most of the time, the company wins. I'd say 70-30.
Usually because most companies are willing to come to arrangements to avoid litigation, so when they don't, it's often something egregious (one way or the other, be it company trying to claim something they shouldn't, or employee trying to sell something employer should definitely own).