While I think this is possible, I also think the Android side programming would be daunting to say the least. I also think that it is likely to not be compatible with every game/app out there since not all game developers will use the same code behind to handle their joystick inputs.
If you google Android joystick, there are some really nifty stick on joysticks that can be had on the cheap that would serve the same purpose.