diff --git a/src/VirtualKeyboard.c b/src/VirtualKeyboard.c index 93ce6d8..75e2686 100644 --- a/src/VirtualKeyboard.c +++ b/src/VirtualKeyboard.c @@ -199,15 +199,30 @@ struct virtkey *get_key_internal() i = y/key_h*KEY_COLS + x/key_w; #ifdef HW_RVL - if (ordenador.vk_rumble) WPAD_Rumble(joy_n, 1); - SDL_Delay(90); - if (ordenador.vk_rumble) WPAD_Rumble(joy_n, 0); + if (ordenador.vk_rumble) + { + if (joy_n < 2) + { + WPAD_Rumble(joy_n, 1); + SDL_Delay(90); + WPAD_Rumble(joy_n, 0); + } + else if (joy_n > 3)//gamepad + { + PAD_ControlMotor(joy_n-4,PAD_MOTOR_RUMBLE); + SDL_Delay(90); + PAD_ControlMotor(joy_n-4,PAD_MOTOR_STOP); + } + } #endif #ifdef HW_DOL - if (ordenador.vk_rumble) PAD_ControlMotor(joy_n,PAD_MOTOR_RUMBLE); - SDL_Delay(90); - if (ordenador.vk_rumble) PAD_ControlMotor(joy_n,PAD_MOTOR_STOP); + if (ordenador.vk_rumble) + { + PAD_ControlMotor(joy_n,PAD_MOTOR_RUMBLE); + SDL_Delay(90); + PAD_ControlMotor(joy_n,PAD_MOTOR_STOP); + } #endif virtkey_t *key = &keys[i]; @@ -251,11 +266,14 @@ void virtkey_ir_run(void) int key_sel = 0; int joy_n; SDL_Joystick *joy; - static int joy_bottons_last[2][5]; - static char countdown_rumble[2]; + static int joy_bottons_last[6][5]; + static char countdown_rumble[6]; for(joy_n=0;joy_n3) + PAD_ControlMotor(joy_n-4,PAD_MOTOR_RUMBLE); #else //HW_DOL PAD_ControlMotor(joy_n,PAD_MOTOR_RUMBLE); #endif @@ -1676,7 +1730,10 @@ inline void read_keyboard () { if (((cur_ticks - last_ticks[joy_n] > 90) && rumble_on[joy_n] && !fire_pressed[joy_n]) ||(!fire_on[joy_n] && !rumble_on[joy_n] && fire_pressed[joy_n])) { #ifdef HW_RVL + if (joy_n <2) WPAD_Rumble(joy_n, 0); + else if (joy_n>3) + PAD_ControlMotor(joy_n-4,PAD_MOTOR_STOP); #else //HW_DOL PAD_ControlMotor(joy_n,PAD_MOTOR_STOP); #endif @@ -1687,7 +1744,10 @@ inline void read_keyboard () { if ((cur_ticks - last_ticks[joy_n] > 90) && rumble_on[joy_n] && fire_pressed[joy_n]) { #ifdef HW_RVL + if (joy_n <2) WPAD_Rumble(joy_n, 0); + else if (joy_n>3) + PAD_ControlMotor(joy_n-4,PAD_MOTOR_STOP); #else //HW_DOL PAD_ControlMotor(joy_n,PAD_MOTOR_STOP); #endif @@ -1696,68 +1756,69 @@ inline void read_keyboard () { } } - #endif + } + #endif //GEKKO - if (ordenador.key[SDLK_SPACE]|| joybutton_matrix[0][SDLK_SPACE] || joybutton_matrix[1][SDLK_SPACE]) ordenador.k15|=1; - if (ordenador.key[SDLK_LCTRL]|| joybutton_matrix[0][SDLK_LCTRL] || joybutton_matrix[1][SDLK_LCTRL]) ordenador.k15|=2; //Symbol shift - if (ordenador.key[SDLK_m] || joybutton_matrix[0][SDLK_m] || joybutton_matrix[1][SDLK_m]) ordenador.k15|=4; - if (ordenador.key[SDLK_n] || joybutton_matrix[0][SDLK_n] || joybutton_matrix[1][SDLK_n]) ordenador.k15|=8; - if (ordenador.key[SDLK_b] || joybutton_matrix[0][SDLK_b] || joybutton_matrix[1][SDLK_b]) ordenador.k15|=16; + if (ordenador.key[SDLK_SPACE]|| joybutton_matrix[0][SDLK_SPACE] || joybutton_matrix[1][SDLK_SPACE] || joybutton_matrix[4][SDLK_SPACE] || joybutton_matrix[5][SDLK_SPACE])ordenador.k15|=1; + if (ordenador.key[SDLK_LCTRL]|| joybutton_matrix[0][SDLK_LCTRL] || joybutton_matrix[1][SDLK_LCTRL] || joybutton_matrix[4][SDLK_LCTRL] || joybutton_matrix[5][SDLK_LCTRL]) ordenador.k15|=2; //Symbol shift + if (ordenador.key[SDLK_m] || joybutton_matrix[0][SDLK_m] || joybutton_matrix[1][SDLK_m] || joybutton_matrix[4][SDLK_m] || joybutton_matrix[5][SDLK_m]) ordenador.k15|=4; + if (ordenador.key[SDLK_n] || joybutton_matrix[0][SDLK_n] || joybutton_matrix[1][SDLK_n] || joybutton_matrix[4][SDLK_n] || joybutton_matrix[5][SDLK_n]) ordenador.k15|=8; + if (ordenador.key[SDLK_b] || joybutton_matrix[0][SDLK_b] || joybutton_matrix[1][SDLK_b] || joybutton_matrix[4][SDLK_b] || joybutton_matrix[5][SDLK_b]) ordenador.k15|=16; if (ordenador.key[SDLK_PERIOD]) ordenador.k15|=6; if (ordenador.key[SDLK_COMMA]) ordenador.k15|=10; //if (ordenador.key[SDLK_SEMICOLON]|| joybutton_matrix[0][SDLK_SEMICOLON] || joybutton_matrix[1][SDLK_SEMICOLON]) {ordenador.k13|=2; ordenador.k15|=2;} //if (ordenador.key[SDLK_QUOTEDBL]|| joybutton_matrix[0][SDLK_QUOTEDBL] || joybutton_matrix[1][SDLK_QUOTEDBL]) {ordenador.k13|=1; ordenador.k15|=2;} if (ordenador.key[SDLK_RETURN] || joybutton_matrix[0][SDLK_RETURN] || joybutton_matrix[1][SDLK_RETURN]) ordenador.k14|=1; - if (ordenador.key[SDLK_l] || joybutton_matrix[0][SDLK_l] || joybutton_matrix[1][SDLK_l]) ordenador.k14|=2; - if (ordenador.key[SDLK_k] || joybutton_matrix[0][SDLK_k] || joybutton_matrix[1][SDLK_k]) ordenador.k14|=4; - if (ordenador.key[SDLK_j] || joybutton_matrix[0][SDLK_j] || joybutton_matrix[1][SDLK_j]) ordenador.k14|=8; - if (ordenador.key[SDLK_h] || joybutton_matrix[0][SDLK_h] || joybutton_matrix[1][SDLK_h]) ordenador.k14|=16; + if (ordenador.key[SDLK_l] || joybutton_matrix[0][SDLK_l] || joybutton_matrix[1][SDLK_l] || joybutton_matrix[4][SDLK_l] || joybutton_matrix[5][SDLK_l]) ordenador.k14|=2; + if (ordenador.key[SDLK_k] || joybutton_matrix[0][SDLK_k] || joybutton_matrix[1][SDLK_k] || joybutton_matrix[4][SDLK_k] || joybutton_matrix[5][SDLK_k]) ordenador.k14|=4; + if (ordenador.key[SDLK_j] || joybutton_matrix[0][SDLK_j] || joybutton_matrix[1][SDLK_j] || joybutton_matrix[4][SDLK_j] || joybutton_matrix[5][SDLK_j]) ordenador.k14|=8; + if (ordenador.key[SDLK_h] || joybutton_matrix[0][SDLK_h] || joybutton_matrix[1][SDLK_h] || joybutton_matrix[4][SDLK_h] || joybutton_matrix[5][SDLK_h]) ordenador.k14|=16; - if (ordenador.key[SDLK_p] || joybutton_matrix[0][SDLK_p] || joybutton_matrix[1][SDLK_p]) ordenador.k13|=1; - if (ordenador.key[SDLK_o] || joybutton_matrix[0][SDLK_o] || joybutton_matrix[1][SDLK_o]) ordenador.k13|=2; - if (ordenador.key[SDLK_i] || joybutton_matrix[0][SDLK_i] || joybutton_matrix[1][SDLK_i]) ordenador.k13|=4; - if (ordenador.key[SDLK_u] || joybutton_matrix[0][SDLK_u] || joybutton_matrix[1][SDLK_u]) ordenador.k13|=8; - if (ordenador.key[SDLK_y] || joybutton_matrix[0][SDLK_y] || joybutton_matrix[1][SDLK_y]) ordenador.k13|=16; + if (ordenador.key[SDLK_p] || joybutton_matrix[0][SDLK_p] || joybutton_matrix[1][SDLK_p] || joybutton_matrix[4][SDLK_p] || joybutton_matrix[5][SDLK_p]) ordenador.k13|=1; + if (ordenador.key[SDLK_o] || joybutton_matrix[0][SDLK_o] || joybutton_matrix[1][SDLK_o] || joybutton_matrix[4][SDLK_o] || joybutton_matrix[5][SDLK_o]) ordenador.k13|=2; + if (ordenador.key[SDLK_i] || joybutton_matrix[0][SDLK_i] || joybutton_matrix[1][SDLK_i] || joybutton_matrix[4][SDLK_i] || joybutton_matrix[5][SDLK_i]) ordenador.k13|=4; + if (ordenador.key[SDLK_u] || joybutton_matrix[0][SDLK_u] || joybutton_matrix[1][SDLK_u] || joybutton_matrix[4][SDLK_u] || joybutton_matrix[5][SDLK_u]) ordenador.k13|=8; + if (ordenador.key[SDLK_y] || joybutton_matrix[0][SDLK_y] || joybutton_matrix[1][SDLK_y] || joybutton_matrix[4][SDLK_y] || joybutton_matrix[5][SDLK_y]) ordenador.k13|=16; - if (ordenador.key[SDLK_0] || joybutton_matrix[0][SDLK_0] || joybutton_matrix[1][SDLK_0]) ordenador.k12|=1; - if (ordenador.key[SDLK_9] || joybutton_matrix[0][SDLK_9] || joybutton_matrix[1][SDLK_9]) ordenador.k12|=2; - if (ordenador.key[SDLK_8] || joybutton_matrix[0][SDLK_8] || joybutton_matrix[1][SDLK_8]) ordenador.k12|=4; - if (ordenador.key[SDLK_7] || joybutton_matrix[0][SDLK_7] || joybutton_matrix[1][SDLK_7]) ordenador.k12|=8; - if (ordenador.key[SDLK_6] || joybutton_matrix[0][SDLK_6] || joybutton_matrix[1][SDLK_6]) ordenador.k12|=16; - if (ordenador.key[SDLK_BACKSPACE] || joybutton_matrix[0][SDLK_BACKSPACE] || joybutton_matrix[1][SDLK_BACKSPACE]) {ordenador.k12|=1; ordenador.k8 |=1;} + if (ordenador.key[SDLK_0] || joybutton_matrix[0][SDLK_0] || joybutton_matrix[1][SDLK_0] || joybutton_matrix[4][SDLK_0] || joybutton_matrix[5][SDLK_0]) ordenador.k12|=1; + if (ordenador.key[SDLK_9] || joybutton_matrix[0][SDLK_9] || joybutton_matrix[1][SDLK_9] || joybutton_matrix[4][SDLK_9] || joybutton_matrix[5][SDLK_9]) ordenador.k12|=2; + if (ordenador.key[SDLK_8] || joybutton_matrix[0][SDLK_8] || joybutton_matrix[1][SDLK_8] || joybutton_matrix[4][SDLK_8] || joybutton_matrix[5][SDLK_8]) ordenador.k12|=4; + if (ordenador.key[SDLK_7] || joybutton_matrix[0][SDLK_7] || joybutton_matrix[1][SDLK_7] || joybutton_matrix[4][SDLK_7] || joybutton_matrix[5][SDLK_7]) ordenador.k12|=8; + if (ordenador.key[SDLK_6] || joybutton_matrix[0][SDLK_6] || joybutton_matrix[1][SDLK_6] || joybutton_matrix[4][SDLK_6] || joybutton_matrix[5][SDLK_6]) ordenador.k12|=16; + if (ordenador.key[SDLK_BACKSPACE] || joybutton_matrix[0][SDLK_BACKSPACE] || joybutton_matrix[1][SDLK_BACKSPACE] || joybutton_matrix[4][SDLK_BACKSPACE] || joybutton_matrix[5][SDLK_BACKSPACE]) {ordenador.k12|=1; ordenador.k8 |=1;} - if (ordenador.key[SDLK_1] || joybutton_matrix[0][SDLK_1] || joybutton_matrix[1][SDLK_1]) ordenador.k11|=1; - if (ordenador.key[SDLK_2] || joybutton_matrix[0][SDLK_2] || joybutton_matrix[1][SDLK_2]) ordenador.k11|=2; - if (ordenador.key[SDLK_3] || joybutton_matrix[0][SDLK_3] || joybutton_matrix[1][SDLK_3]) ordenador.k11|=4; - if (ordenador.key[SDLK_4] || joybutton_matrix[0][SDLK_4] || joybutton_matrix[1][SDLK_4]) ordenador.k11|=8; - if (ordenador.key[SDLK_5] || joybutton_matrix[0][SDLK_5] || joybutton_matrix[1][SDLK_5]) ordenador.k11|=16; + if (ordenador.key[SDLK_1] || joybutton_matrix[0][SDLK_1] || joybutton_matrix[1][SDLK_1] || joybutton_matrix[4][SDLK_1] || joybutton_matrix[5][SDLK_1]) ordenador.k11|=1; + if (ordenador.key[SDLK_2] || joybutton_matrix[0][SDLK_2] || joybutton_matrix[1][SDLK_2] || joybutton_matrix[4][SDLK_2] || joybutton_matrix[5][SDLK_2]) ordenador.k11|=2; + if (ordenador.key[SDLK_3] || joybutton_matrix[0][SDLK_3] || joybutton_matrix[1][SDLK_3] || joybutton_matrix[4][SDLK_3] || joybutton_matrix[5][SDLK_3]) ordenador.k11|=4; + if (ordenador.key[SDLK_4] || joybutton_matrix[0][SDLK_4] || joybutton_matrix[1][SDLK_4] || joybutton_matrix[4][SDLK_4] || joybutton_matrix[5][SDLK_4]) ordenador.k11|=8; + if (ordenador.key[SDLK_5] || joybutton_matrix[0][SDLK_5] || joybutton_matrix[1][SDLK_5] || joybutton_matrix[4][SDLK_5] || joybutton_matrix[5][SDLK_5]) ordenador.k11|=16; - if (ordenador.key[SDLK_q] || joybutton_matrix[0][SDLK_q] || joybutton_matrix[1][SDLK_q]) ordenador.k10|=1; - if (ordenador.key[SDLK_w] || joybutton_matrix[0][SDLK_w] || joybutton_matrix[1][SDLK_w]) ordenador.k10|=2; - if (ordenador.key[SDLK_e] || joybutton_matrix[0][SDLK_e] || joybutton_matrix[1][SDLK_e]) ordenador.k10|=4; - if (ordenador.key[SDLK_r] || joybutton_matrix[0][SDLK_r] || joybutton_matrix[1][SDLK_r]) ordenador.k10|=8; + if (ordenador.key[SDLK_q] || joybutton_matrix[0][SDLK_q] || joybutton_matrix[1][SDLK_q] || joybutton_matrix[4][SDLK_q] || joybutton_matrix[5][SDLK_q]) ordenador.k10|=1; + if (ordenador.key[SDLK_w] || joybutton_matrix[0][SDLK_w] || joybutton_matrix[1][SDLK_w] || joybutton_matrix[4][SDLK_w] || joybutton_matrix[5][SDLK_w]) ordenador.k10|=2; + if (ordenador.key[SDLK_e] || joybutton_matrix[0][SDLK_e] || joybutton_matrix[1][SDLK_e] || joybutton_matrix[4][SDLK_e] || joybutton_matrix[5][SDLK_e]) ordenador.k10|=4; + if (ordenador.key[SDLK_r] || joybutton_matrix[0][SDLK_r] || joybutton_matrix[1][SDLK_r] || joybutton_matrix[4][SDLK_r] || joybutton_matrix[5][SDLK_r]) ordenador.k10|=8; if (ordenador.key[SDLK_t] || joybutton_matrix[0][SDLK_t] || joybutton_matrix[1][SDLK_t]) ordenador.k10|=16; - if (ordenador.key[SDLK_a] || joybutton_matrix[0][SDLK_a] || joybutton_matrix[1][SDLK_a]) ordenador.k9 |=1; - if (ordenador.key[SDLK_s] || joybutton_matrix[0][SDLK_s] || joybutton_matrix[1][SDLK_s]) ordenador.k9 |=2; - if (ordenador.key[SDLK_d] || joybutton_matrix[0][SDLK_d] || joybutton_matrix[1][SDLK_d]) ordenador.k9 |=4; - if (ordenador.key[SDLK_f] || joybutton_matrix[0][SDLK_f] || joybutton_matrix[1][SDLK_f]) ordenador.k9 |=8; - if (ordenador.key[SDLK_g] || joybutton_matrix[0][SDLK_g] || joybutton_matrix[1][SDLK_g]) ordenador.k9 |=16; + if (ordenador.key[SDLK_a] || joybutton_matrix[0][SDLK_a] || joybutton_matrix[1][SDLK_a] || joybutton_matrix[4][SDLK_a] || joybutton_matrix[5][SDLK_a]) ordenador.k9 |=1; + if (ordenador.key[SDLK_s] || joybutton_matrix[0][SDLK_s] || joybutton_matrix[1][SDLK_s] || joybutton_matrix[4][SDLK_s] || joybutton_matrix[5][SDLK_s]) ordenador.k9 |=2; + if (ordenador.key[SDLK_d] || joybutton_matrix[0][SDLK_d] || joybutton_matrix[1][SDLK_d] || joybutton_matrix[4][SDLK_d] || joybutton_matrix[5][SDLK_d]) ordenador.k9 |=4; + if (ordenador.key[SDLK_f] || joybutton_matrix[0][SDLK_f] || joybutton_matrix[1][SDLK_f] || joybutton_matrix[4][SDLK_f] || joybutton_matrix[5][SDLK_f]) ordenador.k9 |=8; + if (ordenador.key[SDLK_g] || joybutton_matrix[0][SDLK_g] || joybutton_matrix[1][SDLK_g] || joybutton_matrix[4][SDLK_g] || joybutton_matrix[5][SDLK_g]) ordenador.k9 |=16; - if (ordenador.key[SDLK_RSHIFT]||ordenador.key[SDLK_LSHIFT]|| joybutton_matrix[0][SDLK_LSHIFT] || joybutton_matrix[1][SDLK_LSHIFT]) ordenador.k8 |=1; //Caps shift - if (ordenador.key[SDLK_z] || joybutton_matrix[0][SDLK_z] || joybutton_matrix[1][SDLK_z]) ordenador.k8 |=2; - if (ordenador.key[SDLK_x] || joybutton_matrix[0][SDLK_x] || joybutton_matrix[1][SDLK_x]) ordenador.k8 |=4; - if (ordenador.key[SDLK_c] || joybutton_matrix[0][SDLK_c] || joybutton_matrix[1][SDLK_c]) ordenador.k8 |=8; - if (ordenador.key[SDLK_v] || joybutton_matrix[0][SDLK_v] || joybutton_matrix[1][SDLK_v]) ordenador.k8 |=16; + if (ordenador.key[SDLK_RSHIFT]||ordenador.key[SDLK_LSHIFT]|| joybutton_matrix[0][SDLK_LSHIFT] || joybutton_matrix[1][SDLK_LSHIFT] || joybutton_matrix[4][SDLK_LSHIFT] || joybutton_matrix[5][SDLK_LSHIFT]) ordenador.k8 |=1; //Caps shift + if (ordenador.key[SDLK_z] || joybutton_matrix[0][SDLK_z] || joybutton_matrix[1][SDLK_z] || joybutton_matrix[4][SDLK_z] || joybutton_matrix[5][SDLK_z]) ordenador.k8 |=2; + if (ordenador.key[SDLK_x] || joybutton_matrix[0][SDLK_x] || joybutton_matrix[1][SDLK_x] || joybutton_matrix[4][SDLK_x] || joybutton_matrix[5][SDLK_x]) ordenador.k8 |=4; + if (ordenador.key[SDLK_c] || joybutton_matrix[0][SDLK_c] || joybutton_matrix[1][SDLK_c] || joybutton_matrix[4][SDLK_c] || joybutton_matrix[5][SDLK_c]) ordenador.k8 |=8; + if (ordenador.key[SDLK_v] || joybutton_matrix[0][SDLK_v] || joybutton_matrix[1][SDLK_v] || joybutton_matrix[4][SDLK_v] || joybutton_matrix[5][SDLK_v]) ordenador.k8 |=16; if (ordenador.key[SDLK_UP]) {ordenador.k12 |=8;ordenador.k8|=1;} if (ordenador.key[SDLK_DOWN]) {ordenador.k12 |=16;ordenador.k8|=1;} if (ordenador.key[SDLK_LEFT]) {ordenador.k11 |=16;ordenador.k8|=1;} if (ordenador.key[SDLK_RIGHT]) {ordenador.k12 |=4;ordenador.k8|=1;} - if (ordenador.key[SDLK_TAB]|| joybutton_matrix[0][SDLK_TAB] || joybutton_matrix[1][SDLK_TAB]) {ordenador.k15|=2;ordenador.k8|=1;} //Extended mode - if (ordenador.key[SDLK_INSERT]|| joybutton_matrix[0][SDLK_INSERT] || joybutton_matrix[1][SDLK_INSERT]) {ordenador.k11|=1;ordenador.k8|=1;} //Edit + if (ordenador.key[SDLK_TAB]|| joybutton_matrix[0][SDLK_TAB] || joybutton_matrix[1][SDLK_TAB] || joybutton_matrix[4][SDLK_TAB] || joybutton_matrix[5][SDLK_TAB]) {ordenador.k15|=2;ordenador.k8|=1;} //Extended mode + if (ordenador.key[SDLK_INSERT]|| joybutton_matrix[0][SDLK_INSERT] || joybutton_matrix[1][SDLK_INSERT] || joybutton_matrix[4][SDLK_INSERT] || joybutton_matrix[5][SDLK_INSERT]) {ordenador.k11|=1;ordenador.k8|=1;} //Edit ordenador.s8 = (ordenador.s8 & 0xE0) | (ordenador.k8 ^ 0x1F); ordenador.s9 = (ordenador.s9 & 0xE0) | (ordenador.k9 ^ 0x1F); @@ -1780,13 +1841,17 @@ inline void read_keyboard () { //VK activation/deactivation - static char old_plus_button[2]; - char plus_button[2]; + static char old_plus_button[6]; + char plus_button[6]; if (!ordenador.vk_auto) for(joy_n=0;joy_n6) ordenador.joystick_number = 6; //Open max 6 joysticks (4 wimotes + 2 gamecube controllers) + #else if (ordenador.joystick_number>2) ordenador.joystick_number = 2; //Open max 2 joysticks + #endif printf("Try to open %d joysticks \n", ordenador.joystick_number); for (bucle=0;buclese_basic,10); fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10); fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10); +#ifdef HW_RVL + fprintf(fconfig,"joystick5=%c%c",48+object->joystick[4],10); //Gamecube controller 1 + fprintf(fconfig,"joystick6=%c%c",48+object->joystick[5],10); //Gamecube controller 2 +#endif fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,10); fprintf(fconfig,"fuller_box_sound=%c%c",48+object->fuller_box_sound,10); fprintf(fconfig,"currah_microspeech=%c%c",48+object->currah_active,10); @@ -803,8 +811,16 @@ int save_config(struct computer *object, char *filename) { fprintf(fconfig,"rewind_on_reset=%c%c",48+object->rewind_on_reset,10); fprintf(fconfig,"joypad1=%c%c",48+object->joypad_as_joystick[0],10); fprintf(fconfig,"joypad2=%c%c",48+object->joypad_as_joystick[1],10); +#ifdef HW_RVL + fprintf(fconfig,"joypad5=%c%c",48+object->joypad_as_joystick[4],10); //Gamecube controller 1 + fprintf(fconfig,"joypad6=%c%c",48+object->joypad_as_joystick[5],10); //Gamecube controller 1 +#endif fprintf(fconfig,"rumble1=%c%c",48+object->rumble[0],10); fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10); +#ifdef HW_RVL + fprintf(fconfig,"rumble5=%c%c",48+object->rumble[4],10); //Gamecube controller 1 + fprintf(fconfig,"rumble6=%c%c",48+object->rumble[5],10); //Gamecube controller 1 +#endif fprintf(fconfig,"port=%c%c",48+object->port,10); fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10); fprintf(fconfig,"ignore_z80_joy_conf=%c%c",48+object->ignore_z80_joy_conf,10); @@ -812,9 +828,14 @@ int save_config(struct computer *object, char *filename) { fprintf(fconfig,"vk_auto=%c%c",48+object->vk_auto,10); fprintf(fconfig,"vk_rumble=%c%c",48+object->vk_rumble,10); - for (joy_n=0; joy_n<2; joy_n++) + for (joy_n=0; joy_njoybuttonkey[joy_n][key],10); + } fclose(fconfig); return 0; @@ -839,18 +860,34 @@ int save_config_game(struct computer *object, char *filename, int overwrite) { fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10); fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10); +#ifdef HW_RVL + fprintf(fconfig,"joystick5=%c%c",48+object->joystick[4],10); //Gamecube controller 1 + fprintf(fconfig,"joystick6=%c%c",48+object->joystick[5],10); //Gamecube controller 2 +#endif fprintf(fconfig,"joypad1=%c%c",48+object->joypad_as_joystick[0],10); fprintf(fconfig,"joypad2=%c%c",48+object->joypad_as_joystick[1],10); +#ifdef HW_RVL + fprintf(fconfig,"joypad5=%c%c",48+object->joypad_as_joystick[4],10); //Gamecube controller 1 + fprintf(fconfig,"joypad6=%c%c",48+object->joypad_as_joystick[5],10); //Gamecube controller 1 +#endif fprintf(fconfig,"rumble1=%c%c",48+object->rumble[0],10); fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10); +#ifdef HW_RVL + fprintf(fconfig,"rumble5=%c%c",48+object->rumble[4],10); //Gamecube controller 1 + fprintf(fconfig,"rumble6=%c%c",48+object->rumble[5],10); //Gamecube controller 1 +#endif - for (joy_n=0; joy_n<2; joy_n++) + for (joy_n=0; joy_njoybuttonkey[joy_n][key],10); + } fclose(fconfig); return 0; - } void load_config_network(struct computer *object) { @@ -975,9 +1012,9 @@ int load_config(struct computer *object, char *filename) { char line[256],carac,done; int pos, key_sdl=0; FILE *fconfig; - unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255, + unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,joystick5=255,joystick6=255,ay_emul=255,mdr_active=255, dblscan=255,framerate =255, screen =255, text=255, precision=255, bw=255, tap_fast=255, audio_mode=255, - joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255, turbo=225, vk_auto=255, vk_rumble=255, + joypad1=255, joypad2=255, joypad5=255, joypad6=255,rumble1=255, rumble2=255, rumble5=255, rumble6=255,joy_n=255, key_n=255, port=255, autoconf=255, turbo=225, vk_auto=255, vk_rumble=255, rewind_on_reset=255, pause_instant_load =255, ignore_z80_joy_conf=255, gui_volume=255, fuller_box_sound=255, currah_active = 255, se_basic =255, currah_volume = 255; if (filename) strcpy(config_path,filename); @@ -1036,6 +1073,14 @@ int load_config(struct computer *object, char *filename) { joystick2=line[10]-'0'; continue; } + if (!strncmp(line,"joystick5=",10)) { + joystick5=line[10]-'0'; + continue; + } + if (!strncmp(line,"joystick6=",10)) { + joystick6=line[10]-'0'; + continue; + } if (!strncmp(line,"ay_sound=",9)) { ay_emul=line[9]-'0'; continue; @@ -1112,6 +1157,14 @@ int load_config(struct computer *object, char *filename) { joypad2=line[8]-'0'; continue; } + if (!strncmp(line,"joypad5=",8)) { + joypad5=line[8]-'0'; + continue; + } + if (!strncmp(line,"joypad6=",8)) { + joypad6=line[8]-'0'; + continue; + } if (!strncmp(line,"rumble1=",8)) { rumble1=line[8]-'0'; continue; @@ -1120,6 +1173,14 @@ int load_config(struct computer *object, char *filename) { rumble2=line[8]-'0'; continue; } + if (!strncmp(line,"rumble5=",8)) { + rumble5=line[8]-'0'; + continue; + } + if (!strncmp(line,"rumble6=",8)) { + rumble6=line[8]-'0'; + continue; + } if (!strncmp(line,"port=",5)) { port=line[5]-'0'; continue; @@ -1146,7 +1207,7 @@ int load_config(struct computer *object, char *filename) { } if (!strncmp(line,"joybutton_",10)) { sscanf(line, "joybutton_%c_%c=%3d",&joy_n ,&key_n, &key_sdl); - if ((joy_n<50) && (joy_n>47) && (key_n<120) && (key_n>96)) + if ((joy_n<54) && (joy_n>47) && (key_n<120) && (key_n>96)) object->joybuttonkey[joy_n-48][key_n-97]=key_sdl; continue; } @@ -1170,6 +1231,12 @@ int load_config(struct computer *object, char *filename) { if (joystick2<6) { object->joystick[1]=joystick2; } + if (joystick5<6) { + object->joystick[4]=joystick5; + } + if (joystick6<6) { + object->joystick[5]=joystick6; + } if (ay_emul<2) { object->ay_emul=ay_emul; } @@ -1229,12 +1296,24 @@ int load_config(struct computer *object, char *filename) { if (joypad2<2) { object->joypad_as_joystick[1]=joypad2; } + if (joypad5<2) { + object->joypad_as_joystick[4]=joypad5; + } + if (joypad6<2) { + object->joypad_as_joystick[5]=joypad6; + } if (rumble1<2) { object->rumble[0]=rumble1; } if (rumble2<2) { object->rumble[1]=rumble2; } + if (rumble5<2) { + object->rumble[4]=rumble5; + } + if (rumble6<2) { + object->rumble[5]=rumble6; + } if (port<5) { object->port=port; } diff --git a/src/gui_sdl.c b/src/gui_sdl.c index ee69742..105e37c 100644 --- a/src/gui_sdl.c +++ b/src/gui_sdl.c @@ -79,7 +79,11 @@ static const char *main_menu_messages[] = { /*03*/ "^|Load|Save|Delete", /*04*/ "#1------------------------", /*05*/ "Controller configuration", - /*06*/ "^|Controller1|Controller2", +#ifdef HW_RVL + /*06*/ "^|Wiimote1|Wiimote2|GCube1|GCube2", +#else + /*06*/ "^|Controller1|Controller2", +#endif /*07*/ "Tape settings", /*08*/ "Emulation settings", /*09*/ "Screen settings", @@ -193,6 +197,20 @@ static const char *input_messages[] = { NULL }; +static const char *input_messages_gamecube_controller[] = { + /*00*/ "Joystick type", + /*01*/ "^|Curs|Kemps|Sincl1|Sincl2|Fuller|QAOP", + /*02*/ "Bind key to button", + /*03*/ "^|A|B|X|Y|Z", + /*04*/ "Bind key to D-pad", + /*05*/ "^|Up|Down|Left|Right", + /*06*/ "Use D-pad as Joystick", + /*07*/ "^|On|Off", + /*08*/ "Rumble", + /*09*/ "^|On|Off", + NULL +}; + static const char *microdrive_messages[] = { /*00*/ "Microdrive", /*01*/ "^|Insert|Load|Make|Delete", @@ -880,7 +898,7 @@ static void setup_joystick(int joy, unsigned int sdl_key, int joy_key) if (ordenador.joybuttonkey[joy][loop] == sdl_key) ordenador.joybuttonkey[joy][loop] =0; ordenador.joybuttonkey[joy][joy_key] = sdl_key; - + printf("Configurated button %d of controller %d as SDL_KEY %d\n", joy_key, joy, sdl_key); } static void input_options(int joy) @@ -896,6 +914,8 @@ static void input_options(int joy) struct virtkey *virtualkey; + if ((joy != 0) && (joy != 1)) return; //only wiimote + do { memset(submenus, 0, sizeof(submenus)); @@ -944,8 +964,65 @@ static void input_options(int joy) setup_joystick(joy, sdl_key, joy_key); } while (opt == 2 || opt == 4 || opt == 6 || opt == 8); +} + +static void input_options_gamecube_controller(int joy) +{ + const unsigned int gamecube_controller_to_sdl[] = {0, 1, 2, 3, 4}; + const unsigned int pad_to_sdl[] = {19, 20, 21, 22}; + int joy_key = 1; + unsigned int sdl_key; + unsigned int submenus[5]; + int opt; + struct virtkey *virtualkey; + if ((joy != 4) && (joy != 5)) return; //only gamecube controllers + + do { + memset(submenus, 0, sizeof(submenus)); + + submenus[0] = ordenador.joystick[joy]; + submenus[3] = !ordenador.joypad_as_joystick[joy]; + submenus[4] = !ordenador.rumble[joy]; + + opt = menu_select_title("Gamecube controller configuration", + input_messages_gamecube_controller, submenus); + if (opt < 0) + return; + + ordenador.joystick[joy] = submenus[0]; + ordenador.joypad_as_joystick[joy] = !submenus[3]; + ordenador.rumble[joy] = !submenus[4]; + + if (opt == 0 || opt == 6|| opt == 8) + return; + + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 90; + + virtualkey = get_key(); + if (virtualkey == NULL) + return; + sdl_key = virtualkey->sdl_code; + + if (virtualkey->sdl_code==1) //"Done" selected + {if (virtualkey->caps_on) sdl_key = 304; //Caps Shit + else if (virtualkey->sym_on) sdl_key = 306; //Sym Shit + else return; } + + switch(opt) + { + case 2: // buttons + joy_key = gamecube_controller_to_sdl[submenus[1]]; break; + case 4: // D-pad + joy_key = pad_to_sdl[submenus[2]]; break; + default: + break; + } + + setup_joystick(joy, sdl_key, joy_key); + } while (opt == 2 || opt == 4); } static int select_mdr() @@ -2476,7 +2553,8 @@ void main_menu() retorno = save_load_snapshot(submenus[1]); break; case 5: - input_options(submenus[2]); + if (submenus[2]<2) input_options(submenus[2]); + else input_options_gamecube_controller(submenus[2]+2); break; case 7: tape_settings(); diff --git a/src/menu_sdl.c b/src/menu_sdl.c index b04fed9..c14cd24 100644 --- a/src/menu_sdl.c +++ b/src/menu_sdl.c @@ -1156,12 +1156,14 @@ uint32_t menu_wait_key_press(int *joy_n_p) SDL_Joystick *joy; static int joy_keys_changed; static int joy_keys_last; - static int joy_bottons_last[2][8]; - + static int joy_bottons_last[6][8]; SDL_JoystickUpdate(); /* Wii-specific, sorry */ for (nr = 0; nr < ordenador.joystick_number; nr++) { + #ifdef HW_RVL + if ((nr == 2) || (nr == 3)) continue; // No wimote 3 and 4 + #endif joy = ordenador.joystick_sdl[nr]; if (!joy) continue; @@ -1196,7 +1198,8 @@ uint32_t menu_wait_key_press(int *joy_n_p) if (axis1 < -15000 ) keys |= KEY_UP; else if( axis1 > 15000 ) keys |= KEY_DOWN; - + if (nr<2) + { if ((!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0]) || /* A */ (!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[nr][1]) || /* 2 */ (!SDL_JoystickGetButton(joy, 9) && joy_bottons_last[nr][2]) || /* CA */ @@ -1222,6 +1225,21 @@ uint32_t menu_wait_key_press(int *joy_n_p) joy_bottons_last[nr][5] =SDL_JoystickGetButton(joy, 11) ; /* CX */ joy_bottons_last[nr][6] =SDL_JoystickGetButton(joy, 12) ; /* CY */ joy_bottons_last[nr][7] =SDL_JoystickGetButton(joy, 1) ; /* B */ + } + else + { + if ((!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0])) /* Gamecube button A */ + keys |= KEY_SELECT; + if ((!SDL_JoystickGetButton(joy, 1) && joy_bottons_last[nr][1])) /* Gamecube button B */ + keys |= KEY_ESCAPE; + if (SDL_JoystickGetButton(joy, 2) != 0) /* Gamecube button X */ + keys |= KEY_PAGEUP; + if (SDL_JoystickGetButton(joy, 3) != 0) /* Gamecube button Y */ + keys |= KEY_PAGEDOWN; + + joy_bottons_last[nr][0]=SDL_JoystickGetButton(joy, 0) ; /* Gamecube button A */ + joy_bottons_last[nr][1] =SDL_JoystickGetButton(joy, 1) ; /* Gamecube button B */ + } joy_keys_changed = keys != joy_keys_last; @@ -1239,6 +1257,11 @@ uint32_t menu_wait_key_press(int *joy_n_p) //Quick scrolling if (!joy_n_p) //We do not want fast scrolling with the vk for (nr = 0; nr < ordenador.joystick_number; nr++) { + + #ifdef HW_RVL + if ((nr == 2) || (nr == 3)) continue; // No wimote 3 and 4 + #endif + joy = ordenador.joystick_sdl[nr]; Sint16 axis3 = SDL_JoystickGetAxis(joy, 3);