Added joypad events and changed event handling from O(n) to O(1)

Added joypad events and changed event handling complexity from O(n) to O(1) as described [here](http://stackoverflow.com/questions/11445226/better-optimization-technique-using-if-else-or-dictionary).