* Update the status of the gamepad input devices. */
| 1076 | * Update the status of the gamepad input devices. |
| 1077 | */ |
| 1078 | static void |
| 1079 | UpdateGamepad(void) |
| 1080 | { |
| 1081 | // don't update during movie playback |
| 1082 | if (FCEUMOV_Mode (MOVIEMODE_PLAY)) |
| 1083 | { |
| 1084 | return; |
| 1085 | } |
| 1086 | |
| 1087 | static int rapid = 0; |
| 1088 | uint32 JS = 0; |
| 1089 | int x; |
| 1090 | int wg; |
| 1091 | |
| 1092 | rapid ^= 1; |
| 1093 | |
| 1094 | int opposite_dirs; |
| 1095 | g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs); |
| 1096 | |
| 1097 | // go through each of the four game pads |
| 1098 | for (wg = 0; wg < 4; wg++) |
| 1099 | { |
| 1100 | bool left = false; |
| 1101 | bool up = false; |
| 1102 | // a, b, select, start, up, down, left, right |
| 1103 | for (x = 0; x < 8; x++) |
| 1104 | { |
| 1105 | if (DTestButton (&GamePad[wg].bmap[x])) |
| 1106 | { |
| 1107 | //printf("GamePad%i Button Hit: %i \n", wg, x ); |
| 1108 | if(opposite_dirs == 0) |
| 1109 | { |
| 1110 | // test for left+right and up+down |
| 1111 | if(x == 4){ |
| 1112 | up = true; |
| 1113 | } |
| 1114 | if((x == 5) && (up == true)){ |
| 1115 | continue; |
| 1116 | } |
| 1117 | if(x == 6){ |
| 1118 | left = true; |
| 1119 | } |
| 1120 | if((x == 7) && (left == true)){ |
| 1121 | continue; |
| 1122 | } |
| 1123 | } |
| 1124 | JS |= (1 << x) << (wg << 3); |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | int four_button_exit; |
| 1129 | g_config->getOption("SDL.ABStartSelectExit", &four_button_exit); |
| 1130 | // if a+b+start+select is pressed, exit |
| 1131 | if (four_button_exit && JS == 15) { |
| 1132 | FCEUI_printf("all buttons pressed, exiting\n"); |
| 1133 | CloseGame(); |
| 1134 | FCEUI_Kill(); |
| 1135 | exit(0); |
no test coverage detected