Wired controller keeps disconnecting

It was indeed a hardware issue. Buying a new cable fixed it.