namco
Member
I'm trying to port Kill 'em and I'm having joystick problems.
When I change this code:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
to:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED || GP2X_BUTTON_UP) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED || GP2X_BUTTON_DOWN) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
The menu cursor goes "mad" and just goes up and down of its own accord, yet when I change it to this:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED || jbut.type == SDL_JOYBUTTONDOWN && GP2X_BUTTON_UP) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED || jbut.type == SDL_JOYBUTTONDOWN && GP2X_BUTTON_DOWN) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
the menu cursor does nothing when I move the joystick up and down.
Oh and jbut is defined as follows:
SDL_JoyButtonEvent jbut;
within the procedure.
When I change this code:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
to:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED || GP2X_BUTTON_UP) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED || GP2X_BUTTON_DOWN) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
The menu cursor goes "mad" and just goes up and down of its own accord, yet when I change it to this:
CODE
if (key_oncepressed[SDLK_UP] == PRESSED || jbut.type == SDL_JOYBUTTONDOWN && GP2X_BUTTON_UP) {
if (menu_cursor > 0) menu_cursor --;
else menu_cursor = menuoption_count - 1;
RenderMenu();
}
if (key_oncepressed[SDLK_DOWN] == PRESSED || jbut.type == SDL_JOYBUTTONDOWN && GP2X_BUTTON_DOWN) {
if (menu_cursor < menuoption_count - 1) menu_cursor ++;
else menu_cursor = 0;
RenderMenu();
}
the menu cursor does nothing when I move the joystick up and down.
Oh and jbut is defined as follows:
SDL_JoyButtonEvent jbut;
within the procedure.