1)Resolution
In the source your provide you do :
screen=SDL_SetVideoMode(320,240,16,SDL_HWSURFACE|SDL_DOUBLEBUF);
screen=SDL_SetVideoMode(320,240,16,SDL_FULLSCREEN);
of course you should call it only once and I suggest you do this, instead:
screen=SDL_SetVideoMode(640,480,16,SDL_HWSURFACE|SDL_DOUBLEBUF);
Because 640x480 is the only resolution supported by all adapters (VGA_SOG,HDTV thru components cable, etc...)
2)Joypad
Your mistake is to read ucAnalogButtons[]. You should read usDigitalButtons for half of them:
while(!done)
{
XInput_GetEvents();
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_Y]) { debugPrint("Y"); done=1; }
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_X]) debugPrint("X");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_A]) debugPrint("A");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_B]) debugPrint("B");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_BLACK]) debugPrint("0");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_WHITE]) debugPrint("1");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_LEFT_TRIGGER]) debugPrint("LT");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_RIGHT_TRIGGER]) debugPrint("RT");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_UP) debugPrint("U");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_DOWN) debugPrint("D");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_RIGHT) debugPrint("R");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_LEFT) debugPrint("L");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_LEFT_THUMB) debugPrint("LS");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_RIGHT_THUMB) debugPrint("RS");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_START) debugPrint("S");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_BACK) debugPrint("B");
//if you fried your port 0, just add simultaneous detection of port 1 (it's free):
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_Y]) { debugPrint("Y"); done=1; }
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_X]) debugPrint("X");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_A]) debugPrint("A");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_B]) debugPrint("B");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_BLACK]) debugPrint("0");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_WHITE]) debugPrint("1");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_LEFT_TRIGGER]) debugPrint("LT");
if (g_Pads[1].PressedButtons.ucAnalogButtons[XPAD_RIGHT_TRIGGER]) debugPrint("RT");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_DPAD_UP) debugPrint("U");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_DPAD_DOWN) debugPrint("D");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_DPAD_RIGHT) debugPrint("R");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_DPAD_LEFT) debugPrint("L");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_LEFT_THUMB) debugPrint("LS");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_RIGHT_THUMB) debugPrint("RS");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_START) debugPrint("S");
if (g_Pads[1].PressedButtons.usDigitalButtons&XPAD_BACK) debugPrint("B");
}