mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-12-26 08:31:55 +01:00
gamecube controller support
This commit is contained in:
parent
42c3df0ccd
commit
02e416169c
@ -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);
|
||||
if (ordenador.vk_rumble)
|
||||
{
|
||||
if (joy_n < 2)
|
||||
{
|
||||
WPAD_Rumble(joy_n, 1);
|
||||
SDL_Delay(90);
|
||||
if (ordenador.vk_rumble) WPAD_Rumble(joy_n, 0);
|
||||
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);
|
||||
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);
|
||||
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_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
key_sel = 0;
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
169
src/computer.c
169
src/computer.c
@ -54,7 +54,7 @@ extern FILE *fdebug;
|
||||
#endif
|
||||
|
||||
int countdown_buffer;
|
||||
unsigned char joybutton_matrix[2][322];
|
||||
unsigned char joybutton_matrix[6][322];
|
||||
|
||||
void update_npixels()
|
||||
{
|
||||
@ -106,6 +106,8 @@ void computer_init () { //Called only on start-up
|
||||
ordenador.joystick[1] = 0; // Cursor
|
||||
ordenador.joypad_as_joystick[0]= 1;
|
||||
ordenador.joypad_as_joystick[1]= 1;
|
||||
ordenador.joypad_as_joystick[4]= 1; //Gamecube controller 1
|
||||
ordenador.joypad_as_joystick[5]= 1; //Gamecube controller 2
|
||||
#ifdef HW_RVL
|
||||
ordenador.vk_auto = 1; //auto Vk
|
||||
ordenador.vk_rumble = 1; //enabled
|
||||
@ -188,6 +190,8 @@ void computer_init () { //Called only on start-up
|
||||
#ifdef HW_RVL
|
||||
ordenador.joybuttonkey[0][3]=SDLK_LALT; //Fire button to wiimote1 button 2
|
||||
ordenador.joybuttonkey[1][3]=SDLK_LALT; //Fire button to wiimote1 button 2
|
||||
ordenador.joybuttonkey[4][0]=SDLK_LALT; //Fire button to gamecube controller button A
|
||||
ordenador.joybuttonkey[5][0]=SDLK_LALT; //Fire button to gamecube controller button A
|
||||
#else // HW_DOL - Win
|
||||
ordenador.joybuttonkey[0][0]=SDLK_LALT; //Fire button to gamepad button A
|
||||
ordenador.joybuttonkey[1][0]=SDLK_LALT; //Fire button to gamepad button A
|
||||
@ -1184,7 +1188,7 @@ inline void paint_one_pixel(unsigned char *colour,unsigned char *address ) {
|
||||
inline void pause() {
|
||||
unsigned int temporal_io;
|
||||
SDL_Event evento,*pevento;
|
||||
unsigned char minus_pressed[2]={2,2};
|
||||
unsigned char minus_pressed[6]={2,2,2,2,2,2};
|
||||
int joy_n;
|
||||
|
||||
pevento=&evento;
|
||||
@ -1196,17 +1200,32 @@ inline void pause() {
|
||||
|
||||
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
#ifdef HW_DOL //Gamecube button "Z"
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4 ) && minus_pressed[joy_n]==2) minus_pressed[joy_n] = 1; //Released
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4 ) && minus_pressed[joy_n]==1) minus_pressed[joy_n] = 0; //Pressed
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4 ) && minus_pressed[joy_n]==0) return; //Released
|
||||
#else //HW_RVL - WIN // Wii button "-"
|
||||
if (joy_n<2)
|
||||
{
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4) &&
|
||||
!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 17) && minus_pressed[joy_n]==2) minus_pressed[joy_n]= 1; //Released
|
||||
if ((SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4) ||
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 17)) && minus_pressed[joy_n]==1) minus_pressed[joy_n] = 0; //Pressed
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4) &&
|
||||
!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 17) && minus_pressed[joy_n]==0) return; //Released
|
||||
}
|
||||
else //Gamecube pad button "L"
|
||||
{
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6)
|
||||
&& minus_pressed[joy_n]==2) minus_pressed[joy_n]= 1; //Released
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6)
|
||||
&& minus_pressed[joy_n]==1) minus_pressed[joy_n] = 0; //Pressed
|
||||
if (!SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6)
|
||||
&& minus_pressed[joy_n]==0) return; //Released
|
||||
}
|
||||
#endif
|
||||
}
|
||||
memset(&evento,0, sizeof(SDL_Event));
|
||||
@ -1254,11 +1273,13 @@ inline void read_keyboard () {
|
||||
SDL_Event evento,*pevento;
|
||||
enum joystate_x {JOY_CENTER_X, JOY_LEFT, JOY_RIGHT};
|
||||
enum joystate_y {JOY_CENTER_Y, JOY_UP, JOY_DOWN};
|
||||
int joy_axis_x[2],joy_axis_y[2], joy_n, joybutton_n;
|
||||
unsigned char status_hat[2];
|
||||
int fire_on[2];
|
||||
int joy_axis_x[6],joy_axis_y[6], joy_n, joybutton_n;
|
||||
unsigned char status_hat[6];
|
||||
int fire_on[6];
|
||||
fire_on[0]=0;
|
||||
fire_on[1]=0;
|
||||
fire_on[4]=0;
|
||||
fire_on[5]=0;
|
||||
|
||||
|
||||
ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 =
|
||||
@ -1281,18 +1302,34 @@ inline void read_keyboard () {
|
||||
|
||||
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
#ifdef HW_DOL
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 7)) //Gamecube button "Start"
|
||||
{if (ordenador.vk_is_active) virtkey_ir_deactivate();main_menu(); }
|
||||
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4)) //Gamecube button "Z"
|
||||
pause();
|
||||
#else //HW_RVL - WIN
|
||||
if (joy_n<2)
|
||||
{
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6) ||//Wii button "Home"
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 19))
|
||||
{if (ordenador.vk_is_active) virtkey_ir_deactivate();main_menu(); }
|
||||
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4) ||//Wii button "-"
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 17))
|
||||
pause();
|
||||
}
|
||||
else //Gamecube pad
|
||||
{
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 7))//gamecube button "Start"
|
||||
{if (ordenador.vk_is_active) virtkey_ir_deactivate();main_menu(); }
|
||||
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6))//gamecube button "L"
|
||||
pause();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HW_RVL) || defined(HW_DOL)
|
||||
@ -1326,6 +1363,8 @@ inline void read_keyboard () {
|
||||
}
|
||||
|
||||
#ifndef HW_DOL // HW_RVL - WIN
|
||||
if (joy_n<2)
|
||||
{
|
||||
for(joybutton_n=7;joybutton_n<17;joybutton_n++)
|
||||
{
|
||||
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][joybutton_n])] =
|
||||
@ -1338,6 +1377,9 @@ inline void read_keyboard () {
|
||||
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][18])] =
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18);
|
||||
}
|
||||
}
|
||||
else joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][4])] = //"Z" gamepad button
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 4);
|
||||
#endif
|
||||
}
|
||||
//JOY HAT
|
||||
@ -1535,6 +1577,10 @@ inline void read_keyboard () {
|
||||
}
|
||||
}
|
||||
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
|
||||
if (!ordenador.joypad_as_joystick[joy_n])
|
||||
{ //No Joypad
|
||||
@ -1639,17 +1685,22 @@ inline void read_keyboard () {
|
||||
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k15|=1; fire_on[joy_n]=1;}//fire button
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GEKKO
|
||||
//Wiimote Rumble
|
||||
static Uint32 last_ticks[2];
|
||||
static Uint32 last_ticks[6];
|
||||
Uint32 cur_ticks;
|
||||
static int rumble_on[2];
|
||||
static int fire_pressed[2];
|
||||
static int rumble_on[6];
|
||||
static int fire_pressed[6];
|
||||
|
||||
|
||||
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
|
||||
if (ordenador.rumble[joy_n])
|
||||
{
|
||||
@ -1658,7 +1709,10 @@ inline void read_keyboard () {
|
||||
if (fire_on[joy_n] && !rumble_on[joy_n] && !fire_pressed[joy_n])
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if (joy_n <2)
|
||||
WPAD_Rumble(joy_n, 1);
|
||||
else if (joy_n>3)
|
||||
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_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
|
||||
plus_button[joy_n] = SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 5) || //Wii button "+" - Gamecube "R"
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18);
|
||||
|
||||
|
@ -38,7 +38,7 @@ enum taptypes {TAP_TAP, TAP_TZX};
|
||||
enum block_type {NOBLOCK, PROG, VAR, DATA};
|
||||
|
||||
extern int countdown_buffer;
|
||||
extern unsigned char joybutton_matrix[2][322];
|
||||
extern unsigned char joybutton_matrix[6][322];
|
||||
|
||||
struct computer {
|
||||
|
||||
@ -164,7 +164,7 @@ struct computer {
|
||||
unsigned char mode128k; // 0=48K, 1=128K, 2=+2, 3=+3 4=sp
|
||||
unsigned char videosystem; //0=PAL, 1=NTSC
|
||||
unsigned char se_basic; //0=0ff; 1=0n
|
||||
unsigned char joystick[2]; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2, 4=Fuller, 5=QAOP
|
||||
unsigned char joystick[6]; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2, 4=Fuller, 5=QAOP
|
||||
unsigned char port254;
|
||||
|
||||
|
||||
@ -268,12 +268,12 @@ struct computer {
|
||||
unsigned int kbd_buffer_pointer;
|
||||
unsigned char *key;
|
||||
unsigned char joystick_number;
|
||||
SDL_Joystick *joystick_sdl[2];
|
||||
unsigned char joy_axis_x_state[2];
|
||||
unsigned char joy_axis_y_state[2];
|
||||
unsigned int joybuttonkey[2][23];
|
||||
unsigned char joypad_as_joystick[2];
|
||||
unsigned char rumble[2];
|
||||
SDL_Joystick *joystick_sdl[6];
|
||||
unsigned char joy_axis_x_state[6];
|
||||
unsigned char joy_axis_y_state[6];
|
||||
unsigned int joybuttonkey[6][23];
|
||||
unsigned char joypad_as_joystick[6];
|
||||
unsigned char rumble[6];
|
||||
unsigned char vk_auto;
|
||||
unsigned char vk_rumble;
|
||||
unsigned char vk_is_active;
|
||||
|
@ -560,7 +560,11 @@ if (sound_type==SOUND_SDL)
|
||||
// Open joystick
|
||||
ordenador.joystick_number = SDL_NumJoysticks();
|
||||
printf("Found %d joysticks \n", ordenador.joystick_number);
|
||||
#ifdef HW_RVL
|
||||
if (ordenador.joystick_number>6) 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;bucle<ordenador.joystick_number;bucle++) {
|
||||
ordenador.joystick_sdl [bucle] = SDL_JoystickOpen(bucle);
|
||||
@ -784,6 +788,10 @@ int save_config(struct computer *object, char *filename) {
|
||||
fprintf(fconfig,"se_basic=%c%c",48+object->se_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_n<ordenador.joystick_number; joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
for (key=0; key<23; key++)
|
||||
fprintf(fconfig,"joybutton_%c_%c=%.3d%c",joy_n+48,key+97, object->joybuttonkey[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_n<ordenador.joystick_number; joy_n++)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
||||
#endif
|
||||
for (key=0; key<23; key++)
|
||||
fprintf(fconfig,"joybutton_%c_%c=%.3d%c",joy_n+48,key+97, object->joybuttonkey[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;
|
||||
}
|
||||
|
@ -79,7 +79,11 @@ static const char *main_menu_messages[] = {
|
||||
/*03*/ "^|Load|Save|Delete",
|
||||
/*04*/ "#1------------------------",
|
||||
/*05*/ "Controller configuration",
|
||||
#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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user