There are a lot of examples of analog joypad for cocos2d. But I need a simple 8-directional (8-positional) digital one.
Take a look at SneakyInput for cocos2D, which has both analog and D-pad implementations. If you happen to be using it already, simply set the following properties for a digital implementation:
joystick.isDPad = YES;
joystick.numberofDirections = 8; //8-directional