I know a few libraries does the same as you suggested. But I need to write my own. and I think it needs some of a low-level programming and that's what I am looking for.
@KMagic, thanks for the reply.
I am not looking for that.
I will consider my job half done if I plug the joystick and my programme detects any key pressed.