Reworked Custom Controls, now allows mapping to any key.

This commit is contained in:
Dimitris Panokostas 2017-04-23 22:23:19 +02:00
parent 9918df5a8e
commit 8ed901d54d
19 changed files with 517 additions and 420 deletions

View file

@ -19,7 +19,8 @@ extern long int version;
#define MAX_PATHS 8
struct multipath {
struct multipath
{
TCHAR path[MAX_PATHS][PATH_MAX];
};
@ -125,7 +126,9 @@ struct floppyslot
#define ASPECTMULT 1024
#define WH_NATIVE 1
struct wh {
struct wh
{
int x, y;
int width, height;
int special;
@ -183,9 +186,21 @@ struct uaedev_config_data
int unitnum; // scsi unit number (if tape currently)
};
enum {
CP_GENERIC = 1, CP_CDTV, CP_CD32, CP_A500, CP_A500P, CP_A600, CP_A1000,
CP_A1200, CP_A2000, CP_A3000, CP_A3000T, CP_A4000, CP_A4000T
enum
{
CP_GENERIC = 1,
CP_CDTV,
CP_CD32,
CP_A500,
CP_A500P,
CP_A600,
CP_A1000,
CP_A1200,
CP_A2000,
CP_A3000,
CP_A3000T,
CP_A4000,
CP_A4000T
};
#define IDE_A600A1200 1
@ -538,24 +553,22 @@ struct uae_prefs
/* Target specific options */
#ifdef AMIBERRY
int gfx_correct_aspect;
int gfx_fullscreen_ratio;
int kbd_led_num;
int kbd_led_scr;
int kbd_led_cap;
int scaling_method;
bool customControls;
int custom_up;
int custom_down;
int custom_left;
int custom_right;
int custom_a;
int custom_b;
int custom_x;
int custom_y;
int custom_l;
int custom_r;
int custom_play;
TCHAR custom_up[256];
TCHAR custom_down[256];
TCHAR custom_left[256];
TCHAR custom_right[256];
TCHAR custom_a[256];
TCHAR custom_b[256];
TCHAR custom_x[256];
TCHAR custom_y[256];
TCHAR custom_l[256];
TCHAR custom_r[256];
TCHAR custom_play[256];
TCHAR open_gui[256];
TCHAR quit_amiberry[256];
#endif
@ -589,87 +602,87 @@ struct uae_prefs
};
extern int config_changed;
extern void config_check_vsync(void);
extern void set_config_changed(void);
extern void config_check_vsync();
extern void set_config_changed();
/* Contains the filename of .uaerc */
extern TCHAR optionsfile[];
extern void save_options(struct zfile *, struct uae_prefs *, int);
extern void save_options(struct zfile*, struct uae_prefs*, int);
extern void cfgfile_write(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
extern void cfgfile_dwrite(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
extern void cfgfile_target_write(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
extern void cfgfile_target_dwrite(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
extern void cfgfile_write(struct zfile*, const TCHAR* option, const TCHAR* format, ...);
extern void cfgfile_dwrite(struct zfile*, const TCHAR* option, const TCHAR* format, ...);
extern void cfgfile_target_write(struct zfile*, const TCHAR* option, const TCHAR* format, ...);
extern void cfgfile_target_dwrite(struct zfile*, const TCHAR* option, const TCHAR* format, ...);
extern void cfgfile_write_bool(struct zfile *f, const TCHAR *option, bool b);
extern void cfgfile_dwrite_bool(struct zfile *f, const TCHAR *option, bool b);
extern void cfgfile_target_write_bool(struct zfile *f, const TCHAR *option, bool b);
extern void cfgfile_target_dwrite_bool(struct zfile *f, const TCHAR *option, bool b);
extern void cfgfile_write_bool(struct zfile* f, const TCHAR* option, bool b);
extern void cfgfile_dwrite_bool(struct zfile* f, const TCHAR* option, bool b);
extern void cfgfile_target_write_bool(struct zfile* f, const TCHAR* option, bool b);
extern void cfgfile_target_dwrite_bool(struct zfile* f, const TCHAR* option, bool b);
extern void cfgfile_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
extern void cfgfile_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
extern void cfgfile_target_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
extern void cfgfile_target_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
extern void cfgfile_write_str(struct zfile* f, const TCHAR* option, const TCHAR* value);
extern void cfgfile_dwrite_str(struct zfile* f, const TCHAR* option, const TCHAR* value);
extern void cfgfile_target_write_str(struct zfile* f, const TCHAR* option, const TCHAR* value);
extern void cfgfile_target_dwrite_str(struct zfile* f, const TCHAR* option, const TCHAR* value);
extern void cfgfile_backup(const TCHAR *path);
extern struct uaedev_config_data *add_filesys_config(struct uae_prefs *p, int index, struct uaedev_config_info*);
extern bool get_hd_geometry(struct uaedev_config_info *);
extern void uci_set_defaults(struct uaedev_config_info *uci, bool rdb);
extern void cfgfile_backup(const TCHAR* path);
extern struct uaedev_config_data* add_filesys_config(struct uae_prefs* p, int index, struct uaedev_config_info*);
extern bool get_hd_geometry(struct uaedev_config_info*);
extern void uci_set_defaults(struct uaedev_config_info* uci, bool rdb);
extern void error_log(const TCHAR*, ...);
extern TCHAR *get_error_log(void);
extern bool is_error_log(void);
extern TCHAR* get_error_log();
extern bool is_error_log();
extern void default_prefs(struct uae_prefs *, int);
extern void discard_prefs(struct uae_prefs *, int);
extern void default_prefs(struct uae_prefs*, int);
extern void discard_prefs(struct uae_prefs*, int);
int parse_cmdline_option(struct uae_prefs *, TCHAR, const TCHAR*);
int parse_cmdline_option(struct uae_prefs*, TCHAR, const TCHAR*);
extern int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location);
extern int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
extern int cfgfile_strval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
extern int cfgfile_string(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
extern TCHAR *cfgfile_subst_path(const TCHAR *path, const TCHAR *subst, const TCHAR *file);
extern int cfgfile_yesno(const TCHAR* option, const TCHAR* value, const TCHAR* name, bool* location);
extern int cfgfile_intval(const TCHAR* option, const TCHAR* value, const TCHAR* name, int* location, int scale);
extern int cfgfile_strval(const TCHAR* option, const TCHAR* value, const TCHAR* name, int* location, const TCHAR* table[], int more);
extern int cfgfile_string(const TCHAR* option, const TCHAR* value, const TCHAR* name, TCHAR* location, int maxsz);
extern TCHAR* cfgfile_subst_path(const TCHAR* path, const TCHAR* subst, const TCHAR* file);
extern TCHAR *target_expand_environment(const TCHAR *path);
extern int target_parse_option(struct uae_prefs *, const TCHAR *option, const TCHAR *value);
extern void target_save_options(struct zfile*, struct uae_prefs *);
extern void target_default_options(struct uae_prefs *, int type);
extern void target_fixup_options(struct uae_prefs *);
extern int target_cfgfile_load(struct uae_prefs *, const TCHAR *filename, int type, int isdefault);
extern void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type);
extern TCHAR* target_expand_environment(const TCHAR* path);
extern int target_parse_option(struct uae_prefs*, const TCHAR* option, const TCHAR* value);
extern void target_save_options(struct zfile*, struct uae_prefs*);
extern void target_default_options(struct uae_prefs*, int type);
extern void target_fixup_options(struct uae_prefs*);
extern int target_cfgfile_load(struct uae_prefs*, const TCHAR* filename, int type, int isdefault);
extern void cfgfile_save_options(struct zfile* f, struct uae_prefs* p, int type);
extern int target_get_display(const TCHAR*);
extern const TCHAR *target_get_display_name(int, bool);
extern const TCHAR* target_get_display_name(int, bool);
extern int cfgfile_load(struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig);
extern int cfgfile_save(struct uae_prefs *p, const TCHAR *filename, int);
extern void cfgfile_parse_line(struct uae_prefs *p, TCHAR *, int);
extern void cfgfile_parse_lines(struct uae_prefs *p, const TCHAR *, int);
extern int cfgfile_parse_option(struct uae_prefs *p, TCHAR *option, TCHAR *value, int);
extern int cfgfile_get_description(const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type);
extern int cfgfile_load(struct uae_prefs* p, const TCHAR* filename, int* type, int ignorelink, int userconfig);
extern int cfgfile_save(struct uae_prefs* p, const TCHAR* filename, int);
extern void cfgfile_parse_line(struct uae_prefs* p, TCHAR*, int);
extern void cfgfile_parse_lines(struct uae_prefs* p, const TCHAR*, int);
extern int cfgfile_parse_option(struct uae_prefs* p, TCHAR* option, TCHAR* value, int);
extern int cfgfile_get_description(const TCHAR* filename, TCHAR* description, TCHAR* hostlink, TCHAR* hardwarelink, int* type);
extern void cfgfile_show_usage(void);
extern int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize);
extern int cfgfile_searchconfig(const TCHAR* in, int index, TCHAR* out, int outsize);
extern uae_u32 cfgfile_uaelib(int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
extern uae_u32 cfgfile_uaelib_modify(uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize);
extern uae_u32 cfgfile_modify(uae_u32 index, TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
extern void cfgfile_addcfgparam(TCHAR *);
extern int built_in_prefs(struct uae_prefs *p, int model, int config, int compa, int romcheck);
extern int built_in_chipset_prefs(struct uae_prefs *p);
extern int cmdlineparser(const TCHAR *s, TCHAR *outp[], int max);
extern uae_u32 cfgfile_modify(uae_u32 index, TCHAR* parms, uae_u32 size, TCHAR* out, uae_u32 outsize);
extern void cfgfile_addcfgparam(TCHAR*);
extern int built_in_prefs(struct uae_prefs* p, int model, int config, int compa, int romcheck);
extern int built_in_chipset_prefs(struct uae_prefs* p);
extern int cmdlineparser(const TCHAR* s, TCHAR* outp[], int max);
extern int cfgfile_configuration_change(int);
extern void fixup_prefs_dimensions(struct uae_prefs *prefs);
extern void fixup_prefs(struct uae_prefs *prefs);
extern void fixup_cpu(struct uae_prefs *prefs);
extern void fixup_prefs_dimensions(struct uae_prefs* prefs);
extern void fixup_prefs(struct uae_prefs* prefs);
extern void fixup_cpu(struct uae_prefs* prefs);
extern void check_prefs_changed_custom(void);
extern void check_prefs_changed_cpu(void);
extern void check_prefs_changed_audio(void);
extern void check_prefs_changed_cd(void);
extern int check_prefs_changed_gfx(void);
extern void check_prefs_changed_custom();
extern void check_prefs_changed_cpu();
extern void check_prefs_changed_audio();
extern void check_prefs_changed_cd();
extern int check_prefs_changed_gfx();
extern struct uae_prefs currprefs, changed_prefs;
extern int machdep_init(void);
extern void machdep_free(void);
extern int machdep_init();
extern void machdep_free();
#endif /* OPTIONS_H */

View file

@ -6661,17 +6661,17 @@ void inputdevice_copyconfig(const struct uae_prefs* src, struct uae_prefs* dst)
dst->input_tablet = src->input_tablet;
dst->customControls = src->customControls;
dst->custom_up = src->custom_up;
dst->custom_down = src->custom_down;
dst->custom_left = src->custom_left;
dst->custom_right = src->custom_right;
dst->custom_a = src->custom_a;
dst->custom_b = src->custom_b;
dst->custom_x = src->custom_x;
dst->custom_y = src->custom_y;
dst->custom_l = src->custom_l;
dst->custom_r = src->custom_r;
dst->custom_play = src->custom_play;
strcpy(dst->custom_up, src->custom_up);
strcpy(dst->custom_down, src->custom_down);
strcpy(dst->custom_left, src->custom_left);
strcpy(dst->custom_right, src->custom_right);
strcpy(dst->custom_a, src->custom_a);
strcpy(dst->custom_b, src->custom_b);
strcpy(dst->custom_x, src->custom_x);
strcpy(dst->custom_y, src->custom_y);
strcpy(dst->custom_l, src->custom_l);
strcpy(dst->custom_r, src->custom_r);
strcpy(dst->custom_play, src->custom_play);
strcpy(dst->open_gui, src->open_gui);
strcpy(dst->quit_amiberry, src->quit_amiberry);

View file

@ -51,7 +51,7 @@ extern void SetLastActiveConfig(const char* filename);
int pause_emulation;
/* Keyboard */
map<int, int> customControlMap; // No SDLK_LAST. SDL2 migration guide suggests std::map
map<int, TCHAR[256]> customControlMap; // No SDLK_LAST. SDL2 migration guide suggests std::map
char start_path_data[MAX_DPATH];
char currentDir[MAX_DPATH];
@ -242,17 +242,17 @@ void target_fixup_options(struct uae_prefs* p)
void target_default_options(struct uae_prefs* p, int type)
{
p->customControls = false;
p->custom_up = 0;
p->custom_down = 0;
p->custom_left = 0;
p->custom_right = 0;
p->custom_a = 0;
p->custom_b = 0;
p->custom_x = 0;
p->custom_y = 0;
p->custom_l = 0;
p->custom_r = 0;
p->custom_play = 0;
_tcscpy(p->custom_up, "");
_tcscpy(p->custom_down, "");
_tcscpy(p->custom_left, "");
_tcscpy(p->custom_right, "");
_tcscpy(p->custom_a, "");
_tcscpy(p->custom_b, "");
_tcscpy(p->custom_x, "");
_tcscpy(p->custom_y, "");
_tcscpy(p->custom_l, "");
_tcscpy(p->custom_r, "");
_tcscpy(p->custom_play, "");
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
@ -265,7 +265,6 @@ void target_default_options(struct uae_prefs* p, int type)
void target_save_options(struct zfile* f, struct uae_prefs* p)
{
cfgfile_write(f, _T("amiberry.gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
cfgfile_write(f, _T("amiberry.kbd_led_num"), _T("%d"), p->kbd_led_num);
cfgfile_write(f, _T("amiberry.kbd_led_scr"), _T("%d"), p->kbd_led_scr);
cfgfile_write(f, _T("amiberry.scaling_method"), _T("%d"), p->scaling_method);
@ -299,9 +298,6 @@ TCHAR* target_expand_environment(const TCHAR* path)
int target_parse_option(struct uae_prefs* p, const char* option, const char* value)
{
if (cfgfile_intval(option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_num", &p->kbd_led_num, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_scr", &p->kbd_led_scr, 1))
@ -315,27 +311,27 @@ int target_parse_option(struct uae_prefs* p, const char* option, const char* val
if (cfgfile_yesno(option, value, "custom_controls", &p->customControls))
return 1;
if (cfgfile_intval(option, value, "custom_up", &p->custom_up, 1))
if (cfgfile_string(option, value, "custom_up", p->custom_up, sizeof p->custom_up))
return 1;
if (cfgfile_intval(option, value, "custom_down", &p->custom_down, 1))
if (cfgfile_string(option, value, "custom_down", p->custom_down, sizeof p->custom_down))
return 1;
if (cfgfile_intval(option, value, "custom_left", &p->custom_left, 1))
if (cfgfile_string(option, value, "custom_left", p->custom_left, sizeof p->custom_left))
return 1;
if (cfgfile_intval(option, value, "custom_right", &p->custom_right, 1))
if (cfgfile_string(option, value, "custom_right", p->custom_right, sizeof p->custom_right))
return 1;
if (cfgfile_intval(option, value, "custom_a", &p->custom_a, 1))
if (cfgfile_string(option, value, "custom_a", p->custom_a, sizeof p->custom_a))
return 1;
if (cfgfile_intval(option, value, "custom_b", &p->custom_b, 1))
if (cfgfile_string(option, value, "custom_b", p->custom_b, sizeof p->custom_b))
return 1;
if (cfgfile_intval(option, value, "custom_x", &p->custom_x, 1))
if (cfgfile_string(option, value, "custom_x", p->custom_x, sizeof p->custom_x))
return 1;
if (cfgfile_intval(option, value, "custom_y", &p->custom_y, 1))
if (cfgfile_string(option, value, "custom_y", p->custom_y, sizeof p->custom_y))
return 1;
if (cfgfile_intval(option, value, "custom_l", &p->custom_l, 1))
if (cfgfile_string(option, value, "custom_l", p->custom_l, sizeof p->custom_l))
return 1;
if (cfgfile_intval(option, value, "custom_r", &p->custom_r, 1))
if (cfgfile_string(option, value, "custom_r", p->custom_r, sizeof p->custom_r))
return 1;
if (cfgfile_intval(option, value, "custom_play", &p->custom_play, 1))
if (cfgfile_string(option, value, "custom_play", p->custom_play, sizeof p->custom_play))
return 1;
return 0;
}
@ -641,7 +637,7 @@ void loadAdfDir()
{
fscanf(f1, "Diskfile=");
get_string(f1, disk, sizeof disk);
FILE * f = fopen(disk, "rb");
FILE* f = fopen(disk, "rb");
if (f != nullptr)
{
fclose(f);
@ -657,7 +653,7 @@ void loadAdfDir()
{
fscanf(f1, "CDfile=");
get_string(f1, cd, sizeof cd);
FILE * f = fopen(cd, "rb");
FILE* f = fopen(cd, "rb");
if (f != nullptr)
{
fclose(f);
@ -681,7 +677,7 @@ uae_u32 emulib_target_getcpurate(uae_u32 v, uae_u32* low)
*low = 1e+9; /* We have nano seconds */
return 0;
}
if (v == 2)
{
struct timespec ts;
@ -766,17 +762,17 @@ int main(int argc, char* argv[])
void PopulateCustomControlMap()
{
customControlMap[VK_UP] = currprefs.custom_up;
customControlMap[VK_DOWN] = currprefs.custom_down;
customControlMap[VK_LEFT] = currprefs.custom_left;
customControlMap[VK_RIGHT] = currprefs.custom_right;
customControlMap[VK_Green] = currprefs.custom_a;
customControlMap[VK_Blue] = currprefs.custom_b;
customControlMap[VK_Red] = currprefs.custom_x;
customControlMap[VK_Yellow] = currprefs.custom_y;
customControlMap[VK_LShoulder] = currprefs.custom_l;
customControlMap[VK_RShoulder] = currprefs.custom_r;
customControlMap[VK_Play] = currprefs.custom_play;
strcpy(customControlMap[VK_UP], currprefs.custom_up);
strcpy(customControlMap[VK_DOWN], currprefs.custom_down);
strcpy(customControlMap[VK_LEFT], currprefs.custom_left);
strcpy(customControlMap[VK_RIGHT], currprefs.custom_right);
strcpy(customControlMap[VK_Green], currprefs.custom_a);
strcpy(customControlMap[VK_Blue], currprefs.custom_b);
strcpy(customControlMap[VK_Red], currprefs.custom_x);
strcpy(customControlMap[VK_Yellow], currprefs.custom_y);
strcpy(customControlMap[VK_LShoulder], currprefs.custom_l);
strcpy(customControlMap[VK_RShoulder], currprefs.custom_r);
strcpy(customControlMap[VK_Play], currprefs.custom_play);
}
int handle_msgpump()
@ -799,12 +795,12 @@ int handle_msgpump()
uae_quit();
break;
//case SDL_JOYBUTTONDOWN:
// if (currprefs.button_for_menu != -1 && rEvent.jbutton.button == currprefs.button_for_menu)
// inputdevice_add_inputcode(AKS_ENTERGUI, 1);
// if (currprefs.button_for_quit != -1 && rEvent.jbutton.button == currprefs.button_for_quit)
// inputdevice_add_inputcode(AKS_QUIT, 1);
// break;
//case SDL_JOYBUTTONDOWN:
// if (currprefs.button_for_menu != -1 && rEvent.jbutton.button == currprefs.button_for_menu)
// inputdevice_add_inputcode(AKS_ENTERGUI, 1);
// if (currprefs.button_for_quit != -1 && rEvent.jbutton.button == currprefs.button_for_quit)
// inputdevice_add_inputcode(AKS_QUIT, 1);
// break;
case SDL_KEYDOWN:
if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_APPLICATION]))
@ -831,7 +827,7 @@ int handle_msgpump()
// Treat CAPSLOCK as a toggle. If on, set off and vice/versa
ioctl(0, KDGKBLED, &kbd_flags);
ioctl(0, KDGETLED, &kbd_led_status);
if ((kbd_flags & 07) & LED_CAP)
if (kbd_flags & 07 & LED_CAP)
{
// On, so turn off
kbd_led_status &= ~LED_CAP;
@ -880,25 +876,25 @@ int handle_msgpump()
break;
case SDL_KEYUP:
if (currprefs.customControls)
if (currprefs.customControls)
{
keycode = customControlMap[rEvent.key.keysym.sym];
if (keycode < 0)
{
keycode = customControlMap[rEvent.key.keysym.sym];
if (keycode < 0)
{
// Simulate mouse or joystick
SimulateMouseOrJoy(keycode, 0);
break;
}
if (keycode > 0)
{
// Send mapped key release
inputdevice_do_keyboard(keycode, 0);
break;
}
// Simulate mouse or joystick
SimulateMouseOrJoy(keycode, 0);
break;
}
if (keycode > 0)
{
// Send mapped key release
inputdevice_do_keyboard(keycode, 0);
break;
}
}
translate_amiberry_keys(rEvent.key.keysym.sym, 0);
break;
translate_amiberry_keys(rEvent.key.keysym.sym, 0);
break;
case SDL_MOUSEBUTTONDOWN:
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)

View file

@ -54,12 +54,12 @@ struct my_opendir_s *my_opendir (const char* name)
mod = xmalloc (struct my_opendir_s, 1);
if (!mod)
return NULL;
return nullptr;
mod->h = opendir(name);
if (mod->h == NULL)
if (mod->h == nullptr)
{
xfree (mod);
return NULL;
return nullptr;
}
return mod;
}
@ -68,20 +68,18 @@ struct my_opendir_s *my_opendir (const char* name)
void my_closedir (struct my_opendir_s *mod)
{
if (mod)
closedir((DIR *) mod->h);
closedir(static_cast<DIR *>(mod->h));
xfree (mod);
}
int my_readdir (struct my_opendir_s *mod, char* name)
{
struct dirent *de;
if (!mod)
if (!mod)
return 0;
de = readdir((DIR *) mod->h);
if(de == 0)
struct dirent *de = readdir(static_cast<DIR *>(mod->h));
if(de == nullptr)
return 0;
strcpy(name, de->d_name);
return 1;
@ -97,35 +95,35 @@ struct my_openfile_s
void my_close (struct my_openfile_s *mos)
{
if(mos)
close((int) mos->h);
close(int(mos->h));
xfree (mos);
}
uae_s64 int my_lseek (struct my_openfile_s *mos, uae_s64 int offset, int pos)
{
return lseek((int) mos->h, offset, pos);
return lseek(int(mos->h), offset, pos);
}
uae_s64 int my_fsize (struct my_openfile_s *mos)
{
uae_s64 pos = lseek((int) mos->h, 0, SEEK_CUR);
uae_s64 size = lseek((int) mos->h, 0, SEEK_END);
lseek((int) mos->h, pos, SEEK_SET);
uae_s64 pos = lseek(int(mos->h), 0, SEEK_CUR);
uae_s64 size = lseek(int(mos->h), 0, SEEK_END);
lseek(int(mos->h), pos, SEEK_SET);
return size;
}
unsigned int my_read (struct my_openfile_s *mos, void *b, unsigned int size)
{
return read((int) mos->h, b, size);
return read(int(mos->h), b, size);
}
unsigned int my_write (struct my_openfile_s *mos, void *b, unsigned int size)
{
return write((int) mos->h, b, size);
return write(int(mos->h), b, size);
}
@ -168,12 +166,12 @@ struct my_openfile_s *my_open (const TCHAR *name, int flags)
mos = xmalloc (struct my_openfile_s, 1);
if (!mos)
return NULL;
mos->h = (void *) open(name, flags);
return nullptr;
mos->h = reinterpret_cast<void *>(open(name, flags));
if (!mos->h)
{
xfree (mos);
mos = NULL;
mos = nullptr;
}
return mos;
}

View file

@ -123,9 +123,8 @@ void ClearAvailableROMList()
static void addrom(struct romdata* rd, const char* path)
{
AvailableROM* tmp;
char tmpName[MAX_DPATH];
tmp = new AvailableROM();
AvailableROM* tmp = new AvailableROM();
getromname(rd, tmpName);
strcpy(tmp->Name, tmpName);
if (path != nullptr)
@ -144,7 +143,6 @@ struct romscandata
static struct romdata* scan_single_rom_2(struct zfile* f)
{
uae_u8 buffer[20] = {0};
uae_u8* rombuf;
int cl = 0, size;
struct romdata* rd = nullptr;
@ -169,7 +167,7 @@ static struct romdata* scan_single_rom_2(struct zfile* f)
{
zfile_fseek(f, 0, SEEK_SET);
}
rombuf = xcalloc(uae_u8, size);
uae_u8* rombuf = xcalloc(uae_u8, size);
if (!rombuf)
return nullptr;
zfile_fread(rombuf, 1, size, f);
@ -183,9 +181,7 @@ static struct romdata* scan_single_rom_2(struct zfile* f)
rd = getromdatabydata(rombuf, size);
if (!rd && (size & 65535) == 0)
{
/* check byteswap */
int i;
for (i = 0; i < size; i += 2)
for (int i = 0; i < size; i += 2)
{
uae_u8 b = rombuf[i];
rombuf[i] = rombuf[i + 1];
@ -200,15 +196,13 @@ static struct romdata* scan_single_rom_2(struct zfile* f)
static struct romdata* scan_single_rom(char* path)
{
struct zfile* z;
char tmp[MAX_DPATH];
struct romdata* rd;
strcpy(tmp, path);
rd = getromdatabypath(path);
struct romdata* rd = getromdatabypath(path);
if (rd && rd->crc32 == 0xffffffff)
return rd;
z = zfile_fopen(path, "rb", ZFD_NORMAL);
struct zfile* z = zfile_fopen(path, "rb", ZFD_NORMAL);
if (!z)
return nullptr;
return scan_single_rom_2(z);
@ -240,11 +234,10 @@ static int isromext(char* path)
static int scan_rom_2(struct zfile* f, void* dummy)
{
char* path = zfile_getname(f);
struct romdata* rd;
if (!isromext(path))
return 0;
rd = scan_single_rom_2(f);
struct romdata* rd = scan_single_rom_2(f);
if (rd)
addrom(rd, path);
return 0;
@ -252,14 +245,12 @@ static int scan_rom_2(struct zfile* f, void* dummy)
static void scan_rom(char* path)
{
struct romdata* rd;
if (!isromext(path))
{
//write_log("ROMSCAN: skipping file '%s', unknown extension\n", path);
return;
}
rd = getarcadiarombyname(path);
struct romdata* rd = getarcadiarombyname(path);
if (rd)
addrom(rd, path);
else
@ -440,9 +431,8 @@ static void after_leave_gui()
// Check if we have to set or clear autofire
int new_af = changed_prefs.input_autofire_linecnt == 0 ? 0 : 1;
int update = 0;
int num;
for (num = 0; num < 2; ++num)
for (int num = 0; num < 2; ++num)
{
if (changed_prefs.jports[num].id == JSEM_JOYS && changed_prefs.jports[num].autofire != new_af)
{
@ -718,14 +708,10 @@ void FilterFiles(vector<string>* files, const char* filter[])
bool DevicenameExists(const char* name)
{
int i;
struct uaedev_config_data* uci;
struct uaedev_config_info* ci;
for (i = 0; i < MAX_HD_DEVICES; ++i)
for (int i = 0; i < MAX_HD_DEVICES; ++i)
{
uci = &changed_prefs.mountconfig[i];
ci = &uci->ci;
struct uaedev_config_data* uci = &changed_prefs.mountconfig[i];
struct uaedev_config_info* ci = &uci->ci;
if (ci->devname && ci->devname[0])
{
@ -770,11 +756,10 @@ bool hardfile_testrdb(const TCHAR* filename)
bool isrdb = false;
struct zfile* f = zfile_fopen(filename, _T("rb"), ZFD_NORMAL);
uae_u8 tmp[8];
int i;
if (!f)
return false;
for (i = 0; i < 16; i++)
for (int i = 0; i < 16; i++)
{
zfile_fseek(f, i * 512, SEEK_SET);
memset(tmp, 0, sizeof tmp);

View file

@ -546,10 +546,8 @@ struct inputdevice_functions inputdevicefunc_joystick = {
int input_get_default_joystick(struct uae_input_device* uid, int num, int port, int af, int mode, bool gp, bool joymouseswap)
{
int h, v;
h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;;
v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
int h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;;
int v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
setid(uid, num, ID_AXIS_OFFSET + 0, 0, port, h, gp);
setid(uid, num, ID_AXIS_OFFSET + 1, 0, port, v, gp);

View file

@ -263,7 +263,7 @@ static void CreateFilesysHardfileLoop()
}
bool CreateFilesysHardfile(void)
bool CreateFilesysHardfile()
{
string strroot;
char tmp[32];
@ -307,7 +307,6 @@ bool CreateFilesysHardfile(void)
fwrite(&zero, 1, 1, newFile);
fclose(newFile);
struct uaedev_config_data* uci;
struct uaedev_config_info ci;
uci_set_defaults(&ci, false);
@ -317,7 +316,7 @@ bool CreateFilesysHardfile(void)
ci.surfaces = (size / 1024) + 1;
ci.bootpri = bp;
uci = add_filesys_config(&changed_prefs, -1, &ci);
struct uaedev_config_data * uci = add_filesys_config(&changed_prefs, -1, &ci);
if (uci)
{
struct hardfiledata* hfd = get_hardfile_data(uci->configoffset);

View file

@ -312,7 +312,7 @@ static void EditFilesysHardfileLoop()
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
default:
break;
}
}
@ -338,7 +338,7 @@ bool EditFilesysHardfile(int unit_no)
{
struct mountedinfo mi;
struct uaedev_config_data* uci;
std::string strdevname, strroot;
string strdevname, strroot;
char tmp[32];
dialogResult = false;
@ -348,10 +348,8 @@ bool EditFilesysHardfile(int unit_no)
if (unit_no >= 0)
{
struct uaedev_config_info* ci;
uci = &changed_prefs.mountconfig[unit_no];
ci = &uci->ci;
struct uaedev_config_info * ci = &uci->ci;
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
strdevname.assign(ci->devname);

View file

@ -153,7 +153,7 @@ static void InitEditFilesysVirtual()
posX += lblDevice->getWidth() + 8;
wndEditFilesysVirtual->add(txtDevice, posX, posY);
posX += txtDevice->getWidth() + DISTANCE_BORDER*2;
posX += txtDevice->getWidth() + DISTANCE_BORDER * 2;
wndEditFilesysVirtual->add(chkReadWrite, posX, posY + 1);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
@ -249,7 +249,7 @@ static void EditFilesysVirtualLoop()
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
default:
break;
}
}
@ -275,7 +275,7 @@ bool EditFilesysVirtual(int unit_no)
{
struct mountedinfo mi;
struct uaedev_config_data* uci;
std::string strdevname, strvolname, strroot;
string strdevname, strvolname, strroot;
char tmp[32];
dialogResult = false;
@ -285,10 +285,8 @@ bool EditFilesysVirtual(int unit_no)
if (unit_no >= 0)
{
struct uaedev_config_info* ci;
uci = &changed_prefs.mountconfig[unit_no];
ci = &uci->ci;
struct uaedev_config_info * ci = &uci->ci;
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
strdevname.assign(ci->devname);

View file

@ -200,8 +200,7 @@ class ConfigsListActionListener : public gcn::ActionListener
public:
void action(const gcn::ActionEvent& actionEvent) override
{
int selected_item;
selected_item = lstConfigs->getSelected();
int selected_item = lstConfigs->getSelected();
if (!txtName->getText().compare(ConfigFilesList[selected_item]->Name))
{
//-----------------------------------------------

View file

@ -79,7 +79,7 @@ public:
return lstMRUDiskList.size();
}
std::string getElementAt(int i) override
string getElementAt(int i) override
{
if (i < 0 || i >= lstMRUDiskList.size())
return "---";
@ -523,17 +523,15 @@ void ExitPanelFloppy()
static void AdjustDropDownControls()
{
int i, j;
bIgnoreListChange = true;
for (i = 0; i < 4; ++i)
for (int i = 0; i < 4; ++i)
{
cboDFxFile[i]->clearSelected();
if (changed_prefs.floppyslots[i].dfxtype != DRV_NONE && strlen(changed_prefs.floppyslots[i].df) > 0)
{
for (j = 0; j < lstMRUDiskList.size(); ++j)
for (int j = 0; j < lstMRUDiskList.size(); ++j)
{
if (!lstMRUDiskList[j].compare(changed_prefs.floppyslots[i].df))
{

View file

@ -66,14 +66,12 @@ static gcn::Slider* sldCDVol;
static int GetHDType(int index)
{
int type;
struct uaedev_config_data* uci;
struct mountedinfo mi;
type = get_filesys_unitconfig(&changed_prefs, index, &mi);
int type = get_filesys_unitconfig(&changed_prefs, index, &mi);
if (type < 0)
{
uci = &changed_prefs.mountconfig[index];
struct uaedev_config_data* uci = &changed_prefs.mountconfig[index];
type = uci->ci.type == UAEDEV_DIR ? FILESYS_VIRTUAL : FILESYS_HARDFILE;
}
return type;
@ -330,7 +328,6 @@ static CDFileActionListener* cdFileActionListener;
void InitPanelHD(const struct _ConfigCategory& category)
{
int row, col;
int posX;
int posY = DISTANCE_BORDER;
char tmp[20];
@ -432,7 +429,7 @@ void InitPanelHD(const struct _ConfigCategory& category)
sldCDVol->addActionListener(genericActionListener);
lblCDVolInfo = new gcn::Label("80 %");
posX = DISTANCE_BORDER + 2 + SMALL_BUTTON_WIDTH + 34;
int posX = DISTANCE_BORDER + 2 + SMALL_BUTTON_WIDTH + 34;
for (col = 0; col < COL_COUNT; ++col)
{
category.panel->add(lblList[col], posX, posY);
@ -480,12 +477,12 @@ void InitPanelHD(const struct _ConfigCategory& category)
void ExitPanelHD()
{
int row, col;
int col;
for (col = 0; col < COL_COUNT; ++col)
delete lblList[col];
for (row = 0; row < MAX_HD_DEVICES; ++row)
for (int row = 0; row < MAX_HD_DEVICES; ++row)
{
delete listCmdProps[row];
delete listCmdDelete[row];
@ -521,12 +518,10 @@ void ExitPanelHD()
static void AdjustDropDownControls()
{
int i;
cboCDFile->clearSelected();
if (changed_prefs.cdslots[0].inuse && strlen(changed_prefs.cdslots[0].name) > 0)
{
for (i = 0; i < lstMRUCDList.size(); ++i)
for (int i = 0; i < lstMRUCDList.size(); ++i)
{
if (!lstMRUCDList[i].compare(changed_prefs.cdslots[0].name))
{
@ -539,22 +534,19 @@ static void AdjustDropDownControls()
void RefreshPanelHD()
{
int row, col;
char tmp[32];
struct mountedinfo mi;
struct uaedev_config_data* uci;
struct uaedev_config_info* ci;
int nosize = 0, type;
int nosize = 0;
AdjustDropDownControls();
for (row = 0; row < MAX_HD_DEVICES; ++row)
for (int row = 0; row < MAX_HD_DEVICES; ++row)
{
if (row < changed_prefs.mountitems)
{
uci = &changed_prefs.mountconfig[row];
ci = &uci->ci;
type = get_filesys_unitconfig(&changed_prefs, row, &mi);
struct uaedev_config_data* uci = &changed_prefs.mountconfig[row];
struct uaedev_config_info* ci = &uci->ci;
int type = get_filesys_unitconfig(&changed_prefs, row, &mi);
if (type < 0)
{
type = uci->ci.type == UAEDEV_DIR ? FILESYS_VIRTUAL : FILESYS_HARDFILE;
@ -601,7 +593,7 @@ void RefreshPanelHD()
else
{
// Empty slot
for (col = 0; col < COL_COUNT; ++col)
for (int col = 0; col < COL_COUNT; ++col)
listCells[row][col]->setText("");
listCmdProps[row]->setEnabled(false);
listCmdDelete[row]->setEnabled(false);

View file

@ -14,8 +14,6 @@
#include "gui_handling.h"
#include "keyboard.h"
#include "inputdevice.h"
#include "config.h"
static const char* mousespeed_list[] = {".25", ".5", "1x", "2x", "4x"};
static const int mousespeed_values[] = {2, 5, 10, 20, 40};
@ -33,27 +31,48 @@ static gcn::Slider* sldMouseSpeed;
static gcn::UaeCheckBox* chkCustomCtrl;
static gcn::Label* lblA;
static gcn::UaeDropDown* cboA;
static gcn::TextField* txtA;
static gcn::Button* cmdA;
static gcn::Label* lblB;
static gcn::UaeDropDown* cboB;
static gcn::TextField* txtB;
static gcn::Button* cmdB;
static gcn::Label* lblX;
static gcn::UaeDropDown* cboX;
static gcn::TextField* txtX;
static gcn::Button* cmdX;
static gcn::Label* lblY;
static gcn::UaeDropDown* cboY;
static gcn::TextField* txtY;
static gcn::Button* cmdY;
static gcn::Label* lblL;
static gcn::UaeDropDown* cboL;
static gcn::TextField* txtL;
static gcn::Button* cmdL;
static gcn::Label* lblR;
static gcn::UaeDropDown* cboR;
static gcn::TextField* txtR;
static gcn::Button* cmdR;
static gcn::Label* lblUp;
static gcn::UaeDropDown* cboUp;
static gcn::TextField* txtUp;
static gcn::Button* cmdUp;
static gcn::Label* lblDown;
static gcn::UaeDropDown* cboDown;
static gcn::TextField* txtDown;
static gcn::Button* cmdDown;
static gcn::Label* lblLeft;
static gcn::UaeDropDown* cboLeft;
static gcn::TextField* txtLeft;
static gcn::Button* cmdLeft;
static gcn::Label* lblRight;
static gcn::UaeDropDown* cboRight;
static gcn::Label* lblStart;
static gcn::UaeDropDown* cboPlay;
static gcn::TextField* txtRight;
static gcn::Button* cmdRight;
static gcn::Label* lblPlay;
static gcn::TextField* txtPlay;
static gcn::Button* cmdPlay;
class StringListModel : public gcn::ListModel
{
@ -84,7 +103,7 @@ public:
}
};
static const char* inputport_list[] = {"Mouse", "Arrow keys as mouse", "Arrow keys as joystick", "Arrow keys as CD32 contr.", "none"};
static const char* inputport_list[] = {"Mouse", "Arrows as mouse", "Arrows as joystick", "Arrows as CD32 contr.", "none"};
StringListModel ctrlPortList(inputport_list, 5);
const char* autofireValues[] = {"Off", "Slow", "Medium", "Fast"};
@ -233,38 +252,126 @@ public:
else if (actionEvent.getSource() == chkCustomCtrl)
changed_prefs.customControls = chkCustomCtrl->isSelected();
else if (actionEvent.getSource() == cboA)
changed_prefs.custom_a = amigaKey[cboA->getSelected()];
else if (actionEvent.getSource() == cmdA)
//changed_prefs.custom_a = amigaKey[txtA->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to A", "Cancel");
if (key != nullptr)
{
txtA->setText(key);
strcpy(changed_prefs.custom_a, key);
}
}
else if (actionEvent.getSource() == cboB)
changed_prefs.custom_b = amigaKey[cboB->getSelected()];
else if (actionEvent.getSource() == cmdB)
//changed_prefs.custom_b = amigaKey[txtB->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to B", "Cancel");
if (key != nullptr)
{
txtB->setText(key);
strcpy(changed_prefs.custom_b, key);
}
}
else if (actionEvent.getSource() == cboX)
changed_prefs.custom_x = amigaKey[cboX->getSelected()];
else if (actionEvent.getSource() == cmdX)
//changed_prefs.custom_x = amigaKey[txtX->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to X", "Cancel");
if (key != nullptr)
{
txtX->setText(key);
strcpy(changed_prefs.custom_x, key);
}
}
else if (actionEvent.getSource() == cboY)
changed_prefs.custom_y = amigaKey[cboY->getSelected()];
else if (actionEvent.getSource() == cmdY)
//changed_prefs.custom_y = amigaKey[txtY->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Y", "Cancel");
if (key != nullptr)
{
txtY->setText(key);
strcpy(changed_prefs.custom_y, key);
}
}
else if (actionEvent.getSource() == cboL)
changed_prefs.custom_l = amigaKey[cboL->getSelected()];
else if (actionEvent.getSource() == cmdL)
//changed_prefs.custom_l = amigaKey[txtL->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to LShoulder", "Cancel");
if (key != nullptr)
{
txtL->setText(key);
strcpy(changed_prefs.custom_l, key);
}
}
else if (actionEvent.getSource() == cboR)
changed_prefs.custom_r = amigaKey[cboR->getSelected()];
else if (actionEvent.getSource() == cmdR)
//changed_prefs.custom_r = amigaKey[txtR->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to RShoulder", "Cancel");
if (key != nullptr)
{
txtR->setText(key);
strcpy(changed_prefs.custom_r, key);
}
}
else if (actionEvent.getSource() == cboUp)
changed_prefs.custom_up = amigaKey[cboUp->getSelected()];
else if (actionEvent.getSource() == cmdUp)
//changed_prefs.custom_up = amigaKey[txtUp->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Up", "Cancel");
if (key != nullptr)
{
txtUp->setText(key);
strcpy(changed_prefs.custom_up, key);
}
}
else if (actionEvent.getSource() == cboDown)
changed_prefs.custom_down = amigaKey[cboDown->getSelected()];
else if (actionEvent.getSource() == cmdDown)
//changed_prefs.custom_down = amigaKey[txtDown->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Down", "Cancel");
if (key != nullptr)
{
txtDown->setText(key);
strcpy(changed_prefs.custom_down, key);
}
}
else if (actionEvent.getSource() == cboLeft)
changed_prefs.custom_left = amigaKey[cboLeft->getSelected()];
else if (actionEvent.getSource() == cmdLeft)
//changed_prefs.custom_left = amigaKey[txtLeft->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Left", "Cancel");
if (key != nullptr)
{
txtLeft->setText(key);
strcpy(changed_prefs.custom_left, key);
}
}
else if (actionEvent.getSource() == cboRight)
changed_prefs.custom_right = amigaKey[cboRight->getSelected()];
else if (actionEvent.getSource() == cmdRight)
//changed_prefs.custom_right = amigaKey[txtRight->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Right", "Cancel");
if (key != nullptr)
{
txtRight->setText(key);
strcpy(changed_prefs.custom_right, key);
}
}
else if (actionEvent.getSource() == cboPlay)
changed_prefs.custom_play = amigaKey[cboPlay->getSelected()];
else if (actionEvent.getSource() == txtPlay)
//changed_prefs.custom_play = amigaKey[txtPlay->getSelected()];
{
const char* key = ShowMessageForInput("Press a key/button", "Press a key or button to map to Play", "Cancel");
if (key != nullptr)
{
txtPlay->setText(key);
strcpy(changed_prefs.custom_play, key);
}
}
}
};
@ -277,8 +384,7 @@ void InitPanelInput(const struct _ConfigCategory& category)
if (ctrlPortList.getNumberOfElements() < 4 + inputdevice_get_device_total(IDTYPE_JOYSTICK))
{
int i;
for (i = 0; i < inputdevice_get_device_total(IDTYPE_JOYSTICK) - 1; i++)
for (int i = 0; i < inputdevice_get_device_total(IDTYPE_JOYSTICK) - 1; i++)
{
ctrlPortList.AddElement(inputdevice_get_device_name(IDTYPE_JOYSTICK, i + 1));
}
@ -333,115 +439,147 @@ void InitPanelInput(const struct _ConfigCategory& category)
lblA = new gcn::Label("Green:");
lblA->setSize(80, LABEL_HEIGHT);
lblA->setAlignment(gcn::Graphics::RIGHT);
cboA = new gcn::UaeDropDown(&mappingList);
//cboA->setSize(150, DROPDOWN_HEIGHT);
cboA->setBaseColor(gui_baseCol);
cboA->setBackgroundColor(colTextboxBackground);
cboA->setId("cboA");
cboA->addActionListener(inputActionListener);
txtA = new gcn::TextField();
txtA->setEnabled(false);
txtA->setSize(85, txtA->getHeight());
txtA->setBackgroundColor(colTextboxBackground);
cmdA = new gcn::Button("...");
cmdA->setId("cmdA");
cmdA->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdA->setBaseColor(gui_baseCol);
cmdA->addActionListener(inputActionListener);
lblB = new gcn::Label("Blue:");
lblB->setSize(80, LABEL_HEIGHT);
lblB->setAlignment(gcn::Graphics::RIGHT);
cboB = new gcn::UaeDropDown(&mappingList);
//cboB->setSize(150, DROPDOWN_HEIGHT);
cboB->setBaseColor(gui_baseCol);
cboB->setBackgroundColor(colTextboxBackground);
cboB->setId("cboB");
cboB->addActionListener(inputActionListener);
txtB = new gcn::TextField();
txtB->setEnabled(false);
txtB->setSize(85, txtB->getHeight());
txtB->setBackgroundColor(colTextboxBackground);
cmdB = new gcn::Button("...");
cmdB->setId("cmdB");
cmdB->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdB->setBaseColor(gui_baseCol);
cmdB->addActionListener(inputActionListener);
lblX = new gcn::Label("Red:");
lblX->setSize(80, LABEL_HEIGHT);
lblX->setAlignment(gcn::Graphics::RIGHT);
cboX = new gcn::UaeDropDown(&mappingList);
//cboX->setSize(150, DROPDOWN_HEIGHT);
cboX->setBaseColor(gui_baseCol);
cboX->setBackgroundColor(colTextboxBackground);
cboX->setId("cboX");
cboX->addActionListener(inputActionListener);
txtX = new gcn::TextField();
txtX->setEnabled(false);
txtX->setSize(85, txtX->getHeight());
txtX->setBackgroundColor(colTextboxBackground);
cmdX = new gcn::Button("...");
cmdX->setId("cmdX");
cmdX->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdX->setBaseColor(gui_baseCol);
cmdX->addActionListener(inputActionListener);
lblY = new gcn::Label("Yellow:");
lblY->setSize(80, LABEL_HEIGHT);
lblY->setAlignment(gcn::Graphics::RIGHT);
cboY = new gcn::UaeDropDown(&mappingList);
//cboY->setSize(150, DROPDOWN_HEIGHT);
cboY->setBaseColor(gui_baseCol);
cboY->setBackgroundColor(colTextboxBackground);
cboY->setId("cboY");
cboY->addActionListener(inputActionListener);
txtY = new gcn::TextField();
txtY->setEnabled(false);
txtY->setSize(85, txtY->getHeight());
txtY->setBackgroundColor(colTextboxBackground);
cmdY = new gcn::Button("...");
cmdY->setId("cmdY");
cmdY->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdY->setBaseColor(gui_baseCol);
cmdY->addActionListener(inputActionListener);
lblL = new gcn::Label("LShoulder:");
lblL->setSize(80, LABEL_HEIGHT);
lblL->setAlignment(gcn::Graphics::RIGHT);
cboL = new gcn::UaeDropDown(&mappingList);
//cboL->setSize(150, DROPDOWN_HEIGHT);
cboL->setBaseColor(gui_baseCol);
cboL->setBackgroundColor(colTextboxBackground);
cboL->setId("cboL");
cboL->addActionListener(inputActionListener);
txtL = new gcn::TextField();
txtL->setEnabled(false);
txtL->setSize(85, txtL->getHeight());
txtL->setBackgroundColor(colTextboxBackground);
cmdL = new gcn::Button("...");
cmdL->setId("cmdL");
cmdL->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdL->setBaseColor(gui_baseCol);
cmdL->addActionListener(inputActionListener);
lblR = new gcn::Label("RShoulder:");
lblR->setSize(80, LABEL_HEIGHT);
lblR->setAlignment(gcn::Graphics::RIGHT);
cboR = new gcn::UaeDropDown(&mappingList);
//cboR->setSize(150, DROPDOWN_HEIGHT);
cboR->setBaseColor(gui_baseCol);
cboR->setBackgroundColor(colTextboxBackground);
cboR->setId("cboR");
cboR->addActionListener(inputActionListener);
txtR = new gcn::TextField();
txtR->setEnabled(false);
txtR->setSize(85, txtR->getHeight());
txtR->setBackgroundColor(colTextboxBackground);
cmdR = new gcn::Button("...");
cmdR->setId("cmdR");
cmdR->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdR->setBaseColor(gui_baseCol);
cmdR->addActionListener(inputActionListener);
lblUp = new gcn::Label("Up:");
lblUp->setSize(80, LABEL_HEIGHT);
lblUp->setAlignment(gcn::Graphics::RIGHT);
cboUp = new gcn::UaeDropDown(&mappingList);
//cboUp->setSize(150, DROPDOWN_HEIGHT);
cboUp->setBaseColor(gui_baseCol);
cboUp->setBackgroundColor(colTextboxBackground);
cboUp->setId("cboUp");
cboUp->addActionListener(inputActionListener);
txtUp = new gcn::TextField();
txtUp->setEnabled(false);
txtUp->setSize(85, txtUp->getHeight());
txtUp->setBackgroundColor(colTextboxBackground);
cmdUp = new gcn::Button("...");
cmdUp->setId("cmdUp");
cmdUp->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdUp->setBaseColor(gui_baseCol);
cmdUp->addActionListener(inputActionListener);
lblDown = new gcn::Label("Down:");
lblDown->setSize(80, LABEL_HEIGHT);
lblDown->setAlignment(gcn::Graphics::RIGHT);
cboDown = new gcn::UaeDropDown(&mappingList);
//cboDown->setSize(150, DROPDOWN_HEIGHT);
cboDown->setBaseColor(gui_baseCol);
cboDown->setBackgroundColor(colTextboxBackground);
cboDown->setId("cboDown");
cboDown->addActionListener(inputActionListener);
txtDown = new gcn::TextField();
txtDown->setEnabled(false);
txtDown->setSize(85, txtDown->getHeight());
txtDown->setBackgroundColor(colTextboxBackground);
cmdDown = new gcn::Button("...");
cmdDown->setId("cmdDown");
cmdDown->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdDown->setBaseColor(gui_baseCol);
cmdDown->addActionListener(inputActionListener);
lblLeft = new gcn::Label("Left:");
lblLeft->setSize(80, LABEL_HEIGHT);
lblLeft->setAlignment(gcn::Graphics::RIGHT);
cboLeft = new gcn::UaeDropDown(&mappingList);
//cboLeft->setSize(150, DROPDOWN_HEIGHT);
cboLeft->setBaseColor(gui_baseCol);
cboLeft->setBackgroundColor(colTextboxBackground);
cboLeft->setId("cboLeft");
cboLeft->addActionListener(inputActionListener);
txtLeft = new gcn::TextField();
txtLeft->setEnabled(false);
txtLeft->setSize(85, txtLeft->getHeight());
txtLeft->setBackgroundColor(colTextboxBackground);
cmdLeft = new gcn::Button("...");
cmdLeft->setId("cmdLeft");
cmdLeft->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdLeft->setBaseColor(gui_baseCol);
cmdLeft->addActionListener(inputActionListener);
lblRight = new gcn::Label("Right:");
lblRight->setSize(80, LABEL_HEIGHT);
lblRight->setAlignment(gcn::Graphics::RIGHT);
cboRight = new gcn::UaeDropDown(&mappingList);
//cboRight->setSize(150, DROPDOWN_HEIGHT);
cboRight->setBaseColor(gui_baseCol);
cboRight->setBackgroundColor(colTextboxBackground);
cboRight->setId("cboRight");
cboRight->addActionListener(inputActionListener);
txtRight = new gcn::TextField();
txtRight->setEnabled(false);
txtRight->setSize(85, txtRight->getHeight());
txtRight->setBackgroundColor(colTextboxBackground);
cmdDown = new gcn::Button("...");
cmdDown->setId("cmdDown");
cmdDown->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdDown->setBaseColor(gui_baseCol);
cmdDown->addActionListener(inputActionListener);
lblStart = new gcn::Label("Play:");
lblStart->setSize(80, LABEL_HEIGHT);
lblStart->setAlignment(gcn::Graphics::RIGHT);
cboPlay = new gcn::UaeDropDown(&mappingList);
//cboPlay->setSize(150, DROPDOWN_HEIGHT);
cboPlay->setBaseColor(gui_baseCol);
cboPlay->setBackgroundColor(colTextboxBackground);
cboPlay->setId("cboPlay");
cboPlay->addActionListener(inputActionListener);
lblPlay = new gcn::Label("Play:");
lblPlay->setSize(80, LABEL_HEIGHT);
lblPlay->setAlignment(gcn::Graphics::RIGHT);
txtPlay = new gcn::TextField();
txtPlay->setEnabled(false);
txtPlay->setSize(85, txtPlay->getHeight());
txtPlay->setBackgroundColor(colTextboxBackground);
cmdDown = new gcn::Button("...");
cmdDown->setId("cmdDown");
cmdDown->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdDown->setBaseColor(gui_baseCol);
cmdDown->addActionListener(inputActionListener);
int posY = DISTANCE_BORDER;
int posColumn2;
category.panel->add(lblPort0, DISTANCE_BORDER, posY);
category.panel->add(cboPort0, DISTANCE_BORDER + lblPort0->getWidth() + 8, posY);
posY += cboPort0->getHeight() + DISTANCE_NEXT_Y;
@ -461,35 +599,35 @@ void InitPanelInput(const struct _ConfigCategory& category)
category.panel->add(chkCustomCtrl, DISTANCE_BORDER + lblA->getWidth() + 8, posY);
posY += chkCustomCtrl->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblA, DISTANCE_BORDER, posY);
category.panel->add(cboA, DISTANCE_BORDER + lblA->getWidth() + 8, posY);
category.panel->add(txtA, DISTANCE_BORDER + lblA->getWidth() + 8, posY);
posColumn2 = cboA->getX() + cboA->getWidth() + 12;
int posColumn2 = txtA->getX() + txtA->getWidth() + 12;
category.panel->add(lblB, posColumn2, posY);
category.panel->add(cboB, posColumn2 + lblB->getWidth() + 8, posY);
posY += cboA->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(txtB, posColumn2 + lblB->getWidth() + 8, posY);
posY += txtA->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblX, DISTANCE_BORDER, posY);
category.panel->add(cboX, DISTANCE_BORDER + lblX->getWidth() + 8, posY);
category.panel->add(txtX, DISTANCE_BORDER + lblX->getWidth() + 8, posY);
category.panel->add(lblY, posColumn2, posY);
category.panel->add(cboY, posColumn2 + lblY->getWidth() + 8, posY);
posY += cboX->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(txtY, posColumn2 + lblY->getWidth() + 8, posY);
posY += txtX->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblL, DISTANCE_BORDER, posY);
category.panel->add(cboL, DISTANCE_BORDER + lblL->getWidth() + 8, posY);
category.panel->add(txtL, DISTANCE_BORDER + lblL->getWidth() + 8, posY);
category.panel->add(lblR, posColumn2, posY);
category.panel->add(cboR, posColumn2 + lblR->getWidth() + 8, posY);
posY += cboL->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(txtR, posColumn2 + lblR->getWidth() + 8, posY);
posY += txtL->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblUp, DISTANCE_BORDER, posY);
category.panel->add(cboUp, DISTANCE_BORDER + lblUp->getWidth() + 8, posY);
category.panel->add(txtUp, DISTANCE_BORDER + lblUp->getWidth() + 8, posY);
category.panel->add(lblDown, posColumn2, posY);
category.panel->add(cboDown, posColumn2 + lblDown->getWidth() + 8, posY);
posY += cboUp->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(txtDown, posColumn2 + lblDown->getWidth() + 8, posY);
posY += txtUp->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblLeft, DISTANCE_BORDER, posY);
category.panel->add(cboLeft, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY);
category.panel->add(txtLeft, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY);
category.panel->add(lblRight, posColumn2, posY);
category.panel->add(cboRight, posColumn2 + lblRight->getWidth() + 8, posY);
posY += cboLeft->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblStart, DISTANCE_BORDER, posY);
category.panel->add(cboPlay, DISTANCE_BORDER + lblStart->getWidth() + 8, posY);
category.panel->add(txtRight, posColumn2 + lblRight->getWidth() + 8, posY);
posY += txtLeft->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblPlay, DISTANCE_BORDER, posY);
category.panel->add(txtPlay, DISTANCE_BORDER + lblPlay->getWidth() + 8, posY);
RefreshPanelInput();
}
@ -510,26 +648,26 @@ void ExitPanelInput()
delete chkCustomCtrl;
delete lblA;
delete cboA;
delete txtA;
delete lblB;
delete cboB;
delete txtB;
delete lblX;
delete cboX;
delete txtX;
delete lblY;
delete cboY;
delete txtY;
delete lblL;
delete cboL;
delete txtL;
delete lblR;
delete cboR;
delete txtR;
delete lblUp;
delete cboUp;
delete txtUp;
delete lblDown;
delete cboDown;
delete txtDown;
delete lblLeft;
delete cboLeft;
delete txtLeft;
delete lblRight;
delete cboRight;
delete cboPlay;
delete txtRight;
delete txtPlay;
delete inputActionListener;
}
@ -537,8 +675,6 @@ void ExitPanelInput()
void RefreshPanelInput()
{
int i;
// Set current device in port 0
switch (changed_prefs.jports[0].id)
{
@ -594,7 +730,7 @@ void RefreshPanelInput()
else
cboAutofire->setSelected(3);
for (i = 0; i < 5; ++i)
for (int i = 0; i < 5; ++i)
{
if (changed_prefs.input_joymouse_multiplier == mousespeed_values[i])
{
@ -606,15 +742,15 @@ void RefreshPanelInput()
chkCustomCtrl->setSelected(changed_prefs.customControls);
cboA->setSelected(GetAmigaKeyIndex(changed_prefs.custom_a));
cboB->setSelected(GetAmigaKeyIndex(changed_prefs.custom_b));
cboX->setSelected(GetAmigaKeyIndex(changed_prefs.custom_x));
cboY->setSelected(GetAmigaKeyIndex(changed_prefs.custom_y));
cboL->setSelected(GetAmigaKeyIndex(changed_prefs.custom_l));
cboR->setSelected(GetAmigaKeyIndex(changed_prefs.custom_r));
cboUp->setSelected(GetAmigaKeyIndex(changed_prefs.custom_up));
cboDown->setSelected(GetAmigaKeyIndex(changed_prefs.custom_down));
cboLeft->setSelected(GetAmigaKeyIndex(changed_prefs.custom_left));
cboRight->setSelected(GetAmigaKeyIndex(changed_prefs.custom_right));
cboPlay->setSelected(GetAmigaKeyIndex(changed_prefs.custom_play));
txtA->setText(changed_prefs.custom_a);
txtB->setText(changed_prefs.custom_b);
txtX->setText(changed_prefs.custom_x);
txtY->setText(changed_prefs.custom_y);
txtL->setText(changed_prefs.custom_l);
txtR->setText(changed_prefs.custom_r);
txtUp->setText(changed_prefs.custom_up);
txtDown->setText(changed_prefs.custom_down);
txtLeft->setText(changed_prefs.custom_left);
txtRight->setText(changed_prefs.custom_right);
txtPlay->setText(changed_prefs.custom_play);
}

View file

@ -89,8 +89,7 @@ public:
{
if (actionEvent.getSource() == cmdOK)
{
int selected_item;
selected_item = lstFiles->getSelected();
int selected_item = lstFiles->getSelected();
if (createNew)
{
char tmp[MAX_PATH];
@ -124,14 +123,13 @@ static FileButtonActionListener* fileButtonActionListener;
static void checkfoldername(char* current)
{
char* ptr;
char actualpath[MAX_PATH];
DIR* dir;
if ((dir = opendir(current)))
{
fileList->changeDir(current);
ptr = realpath(current, actualpath);
char * ptr = realpath(current, actualpath);
strcpy(workingDir, ptr);
closedir(dir);
}
@ -161,10 +159,9 @@ class SelectFileActionListener : public gcn::ActionListener
public:
void action(const gcn::ActionEvent& actionEvent) override
{
int selected_item;
char foldername[MAX_PATH] = "";
selected_item = lstFiles->getSelected();
int selected_item = lstFiles->getSelected();
strcpy(foldername, workingDir);
strcat(foldername, "/");
strcat(foldername, fileList->getElementAt(selected_item).c_str());

View file

@ -80,14 +80,13 @@ static DirListModel dirList(".");
static void checkfoldername(char* current)
{
char* ptr;
char actualpath[PATH_MAX];
DIR* dir;
if ((dir = opendir(current)))
{
dirList = current;
ptr = realpath(current, actualpath);
char * ptr = realpath(current, actualpath);
strcpy(workingDir, ptr);
closedir(dir);
}
@ -102,10 +101,9 @@ class ListBoxActionListener : public gcn::ActionListener
public:
void action(const gcn::ActionEvent& actionEvent) override
{
int selected_item;
char foldername[MAX_PATH] = "";
selected_item = lstFolders->getSelected();
int selected_item = lstFolders->getSelected();
strcpy(foldername, workingDir);
strcat(foldername, "/");
strcat(foldername, dirList.getElementAt(selected_item).c_str());

View file

@ -175,7 +175,7 @@ static void ShowMessageLoop()
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
default:
break;
}
}
@ -235,4 +235,4 @@ const char* ShowMessageForInput(const char* title, const char* line1, const char
ExitShowMessage();
return dialogControlPressed;
}
}

View file

@ -425,8 +425,7 @@ namespace widgets
public:
void focusGained(const gcn::Event& event) override
{
int i;
for (i = 0; categories[i].category != nullptr; ++i)
for (int i = 0; categories[i].category != nullptr; ++i)
{
if (event.getSource() == categories[i].selector)
{
@ -600,9 +599,7 @@ namespace widgets
void RefreshAllPanels()
{
int i;
for (i = 0; categories[i].category != nullptr; ++i)
for (int i = 0; categories[i].category != nullptr; ++i)
{
if (categories[i].RefreshFunc != nullptr)
(*categories[i].RefreshFunc)();

View file

@ -2,12 +2,8 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "autoconf.h"
#include "options.h"
#include "gui.h"
#include "sounddep/sound.h"
#include "include/memory.h"
#include "newcpu.h"
#include "custom.h"
#include "uae.h"
@ -32,8 +28,7 @@ static void replace(char* str, char replace, char toreplace)
int create_configfilename(char* dest, char* basename, int fromDir)
{
char* p;
p = basename + strlen(basename) - 1;
char* p = basename + strlen(basename) - 1;
while (*p != '/')
p--;
p++;