Nintendo owns the handheld market and I think the console market is mainly Sony's to lose. So, Microsoft I guess.
But if handhelds ultimately lose out to mobiles and if the NX doesn't fare better than the Wii U, I could picture Nintendo focusing strictly on software. Hell, they might even make more money as a multi-platform software developer.