Option to disable vk rumble, path is now remembered, optimization of path variables

This commit is contained in:
fabio.olimpieri 2013-01-18 16:23:46 +00:00
parent c5487fa51d
commit e68cedeed9
7 changed files with 64 additions and 38 deletions

View File

@ -164,9 +164,9 @@ struct virtkey *get_key_internal()
i = y/key_h*KEY_COLS + x/key_w;
#ifdef GEKKO
WPAD_Rumble(0, 1);
if (ordenador.vk_rumble) WPAD_Rumble(0, 1);
SDL_Delay(90);
WPAD_Rumble(0, 0);
if (ordenador.vk_rumble) WPAD_Rumble(0, 0);
#endif
virtkey_t *key = &keys[i];
@ -214,7 +214,7 @@ void virtkey_ir_run(void)
static char countdown_rumble=0;
#ifdef GEKKO
if (countdown_rumble > 0) {countdown_rumble--; if (countdown_rumble==0) WPAD_Rumble(0, 0);}
if (countdown_rumble > 0) {countdown_rumble--; if ((countdown_rumble==0)&&(ordenador.vk_rumble)) WPAD_Rumble(0, 0);}
#endif
joy = ordenador.joystick_sdl[0];
@ -239,7 +239,7 @@ void virtkey_ir_run(void)
if ((x>0)&&(x< KEY_COLS*key_w)&&(y>0)&&(y< KEY_ROWS*key_h))
{
#ifdef GEKKO
WPAD_Rumble(0, 1);
if (ordenador.vk_rumble) WPAD_Rumble(0, 1);
#endif
countdown_rumble=5;

View File

@ -107,6 +107,7 @@ void computer_init () { //Called only on start-up
ordenador.joystick[0] = 1; //Kemposton
ordenador.joystick[1] = 0; // Cursor
ordenador.vk_auto = 0; //Vk called by +
ordenador.vk_rumble = 1; //enabled
ordenador.rumble[0] = 0;
ordenador.rumble[1] = 0;
ordenador.turbo = 0;

View File

@ -236,6 +236,7 @@ struct computer {
unsigned char joypad_as_joystick[2];
unsigned char rumble[2];
unsigned char vk_auto;
unsigned char vk_rumble;
unsigned char vk_is_active;
unsigned char port; //SD, USB, SMB or FTP
unsigned char smb_enable;

View File

@ -714,7 +714,7 @@ int save_config(struct computer *object, char *filename) {
fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10);
fprintf(fconfig,"turbo=%c%c",48+object->turbo,10);
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 (key=0; key<22; key++)
@ -882,7 +882,7 @@ int load_config(struct computer *object, char *filename) {
FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=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;
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;
if (filename) strcpy(config_path,filename);
else return -2;
@ -1012,6 +1012,10 @@ int load_config(struct computer *object, char *filename) {
vk_auto=line[8]-'0';
continue;
}
if (!strncmp(line,"vk_rumble=",10)) {
vk_rumble=line[10]-'0';
continue;
}
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<119) && (key_n>96))
@ -1093,7 +1097,9 @@ int load_config(struct computer *object, char *filename) {
if (vk_auto<2) {
object->vk_auto=vk_auto;
}
if (vk_rumble<2) {
object->vk_rumble=vk_rumble;
}
fclose(fconfig);
return 0;
}

View File

@ -148,16 +148,16 @@ static const char *microdrive_messages[] = {
static const char *tools_messages[] = {
/*00*/ "Screen shot",
/*01*/ "^|Save1|Save2|Load|Delete",
/*02*/ " ",
/*03*/ "Insert poke",
/*04*/ " ",
/*05*/ "Load poke file",
/*06*/ " ",
/*07*/ "Port",
/*08*/ "^|default|sd|usb|smb|ftp",
/*09*/ " ",
/*10*/ "Auto virtual keyboard",
/*11*/ "^|on|off",
/*02*/ "Port",
/*03*/ "^|default|sd|usb|smb|ftp",
/*04*/ "Auto virtual keyboard",
/*05*/ "^|on|off",
/*06*/ "Keyboard rumble",
/*07*/ "^|on|off",
/*08*/ " ",
/*09*/ "Load poke file",
/*10*/ " ",
/*11*/ "Insert poke",
/*12*/ " ",
/*13*/ "Help",
NULL
@ -1386,7 +1386,7 @@ int parse_poke (const char *filename)
static int load_poke_file()
{
const char *dir = path_poke;
char *dir = path_poke;
int ritorno, retorno2;
ritorno=0;
retorno2=0; //Stay in menu as default
@ -1455,7 +1455,7 @@ switch (which)
static int tools()
{
int opt , retorno;
int submenus[3];
int submenus[4];
memset(submenus, 0, sizeof(submenus));
@ -1464,6 +1464,7 @@ static int tools()
submenus[1] = ordenador.port;
submenus[2] = !ordenador.vk_auto;
submenus[3] = !ordenador.vk_rumble;
opt = menu_select_title("Tools menu",
tools_messages, submenus);
@ -1472,18 +1473,19 @@ static int tools()
set_port(submenus[1]);
ordenador.vk_auto = !submenus[2];
ordenador.vk_rumble = !submenus[3];
switch(opt)
{
case 0:
retorno = manage_scr(submenus[0]);
break;
case 3: // Insert poke
retorno = do_poke_sdl();
break;
case 5: // Load poke file
case 9: // Load poke file
retorno = load_poke_file();
break;
case 11: // Insert poke
retorno = do_poke_sdl();
break;
case 13:
help();
retorno = -1;
@ -1519,7 +1521,7 @@ void virtual_keyboard(void)
static int save_load_snapshot(int which)
{
const char *dir = path_snaps;
char *dir = path_snaps;
const char *tape = ordenador.last_selected_file;
char *ptr;
char db[256];
@ -1616,7 +1618,7 @@ static int save_load_snapshot(int which)
static int save_load_game_configurations(int which)
{
const char *dir = path_confs;
char *dir = path_confs;
const char *tape = ordenador.last_selected_file;
char *ptr;
char db[256];

View File

@ -1171,7 +1171,7 @@ static const char *menu_select_file_internal_zip(char *path,
ptr_selected_file= strrchr(selected_file,'/');
if (ptr_selected_file) ptr_selected_file++;
else ptr_selected_file = selected_file;
snprintf(buf,64,"file:%s",ptr_selected_file);
snprintf(buf,64,"Selected file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr);
}
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
@ -1269,7 +1269,7 @@ static const char *menu_select_file_internal_zip(char *path,
return write_filename;
}
static const char *menu_select_file_internal(const char *dir_path,
static const char *menu_select_file_internal(char *dir_path,
int x, int y, int x2, int y2, const char *selected_file, int draw_scr)
{
const char **file_list = get_file_list(dir_path);
@ -1277,6 +1277,7 @@ static const char *menu_select_file_internal(const char *dir_path,
char *out;
char *out_zip;
const char *ptr_selected_file;
char *updir;
int opt;
int i;
char buf[64];
@ -1289,7 +1290,7 @@ static const char *menu_select_file_internal(const char *dir_path,
ptr_selected_file= strrchr(selected_file,'/');
if (ptr_selected_file) ptr_selected_file++;
else ptr_selected_file = selected_file;
snprintf(buf,64,"file:%s",ptr_selected_file);
snprintf(buf,64,"Selected file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr);
}
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
@ -1305,23 +1306,38 @@ static const char *menu_select_file_internal(const char *dir_path,
if (!sel)
return NULL;
if (!strcmp(sel,"[..]")) //selected "[..]"
{
free((void*)sel);
updir=strrchr(dir_path,'/');
if ((updir!=NULL)&&(updir!=dir_path)) // or "/" and not root dir
*updir=0; //trunk dir_path at last /
return menu_select_file(dir_path, selected_file, draw_scr);
}
/* If this is a folder, enter it recursively */
if (sel[0] == '[')
{
char buf[255];
int len = strlen(sel);
int s;
/* Remove trailing ] */
sel[len-1] = '\0';
s = snprintf(buf, 128, "%s/%s", dir_path, sel + 1);
if ((strlen(dir_path) + len) < 2049)
{
strcat(dir_path, "/");
strcat(dir_path, sel+1);
}
else
{
free((void*)sel);
return NULL;
}
/* We don't need this anymore */
free((void*)sel);
/* Too deep recursion! */
if (s >= sizeof(buf))
return NULL;
return menu_select_file(buf, selected_file, draw_scr);
return menu_select_file(dir_path, selected_file, draw_scr);
}
@ -1345,7 +1361,7 @@ static const char *menu_select_file_internal(const char *dir_path,
else return out;
}
const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr)
const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr)
{
if (dir_path == NULL)
dir_path = "";

View File

@ -51,7 +51,7 @@ void print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const ch
/* Various option selects */
int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus);
int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr);
const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr);
uint32_t menu_wait_key_press();