forked from mist-devel/mist-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mist_cfg.c
137 lines (124 loc) · 4.75 KB
/
mist_cfg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// mist_cfg.c
// 2015, [email protected]
//// includes ////
#include <string.h>
#include "ini_parser.h"
#include "mist_cfg.h"
#include "user_io.h"
#include "data_io.h"
#include "usb/usb.h"
#include "usb/hid.h"
#include "usb/joymapping.h"
extern fileTYPE ini_file;
// call data_io_rom_upload but reload sector_buffer afterwards since the io
// operations in data_io_rom_upload may have overwritten the buffer
// mode = 0: prepare for rom upload, mode = 1: rom upload, mode = 2, end rom upload
void ini_rom_upload(char *s) {
#ifndef INI_PARSER_TEST
data_io_rom_upload(s, 1);
FileRead(&ini_file, sector_buffer);
#endif
}
//// mist_ini_parse() ////
void mist_ini_parse()
{
#ifndef INI_PARSER_TEST
hid_joystick_button_remap_init();
virtual_joystick_remap_init();
joy_key_map_init();
data_io_rom_upload(NULL, 0); // prepare upload
memset(&mist_cfg, 0, sizeof(mist_cfg));
mist_cfg.mouse_speed = 100;
minimig_cfg.kick1x_memory_detection_patch = 1;
ini_parse(&mist_ini_cfg, user_io_get_core_name());
data_io_rom_upload(NULL, 2); // upload done
#endif
}
//// vars ////
// config data
mist_cfg_t mist_cfg = {
.scandoubler_disable = 0,
.csync_disable = 0,
.mouse_boot_mode = 0,
.mouse_speed = 100,
.joystick_ignore_hat = 0,
.joystick_ignore_osd = 0,
.joystick_disable_shortcuts = 0,
.joystick0_prefer_db9 = 0,
.joystick_db9_fixed_index = 0,
.joystick_emu_fixed_index = 0,
.key_menu_as_rgui = 0,
.keyrah_mode = 0,
.reset_combo = 0,
.ypbpr = 0,
.keep_video_mode = 0,
.led_animation = 0
};
minimig_cfg_t minimig_cfg = {
.kick1x_memory_detection_patch = 0,
.clock_freq = 0,
.conf_name = {"Default","1","2","3","4"}
};
atarist_cfg_t atarist_cfg = {
.conf_name = {"Default","1","2","3","4"}
};
// mist ini sections
const ini_section_t mist_ini_sections[] = {
{1, "MIST"},
{2, "MINIMIG_CONFIG"},
{3, "ATARIST_CONFIG"}
};
// mist ini vars
const ini_var_t mist_ini_vars[] = {
// [MIST] or [<core name>]
{"LED_ANIMATION", (void*)(&(mist_cfg.led_animation)), UINT8, 0, 1, 1},
{"YPBPR", (void*)(&(mist_cfg.ypbpr)), UINT8, 0, 1, 1},
{"KEEP_VIDEO_MODE", (void*)(&(mist_cfg.keep_video_mode)), UINT8, 0, 1, 1},
{"KEYRAH_MODE", (void*)(&(mist_cfg.keyrah_mode)), UINT32, 0, 0xFFFFFFFF, 1},
{"RESET_COMBO", (void*)(&(mist_cfg.reset_combo)), UINT8, 0, 2, 1},
{"SCANDOUBLER_DISABLE", (void*)(&(mist_cfg.scandoubler_disable)), UINT8, 0, 1, 1},
{"CSYNC_DISABLE", (void*)(&(mist_cfg.csync_disable)), UINT8, 0, 1, 1},
{"MOUSE_BOOT_MODE", (void*)(&(mist_cfg.mouse_boot_mode)), UINT8, 0, 1, 1},
{"MOUSE_SPEED", (void*)(&(mist_cfg.mouse_speed)), UINT8, 10, 200, 1},
{"JOYSTICK_IGNORE_HAT", (void*)(&(mist_cfg.joystick_ignore_hat)), UINT8, 0, 1, 1},
{"JOYSTICK_DISABLE_SHORTCUTS", (void*)(&(mist_cfg.joystick_disable_shortcuts)), UINT8, 0, 1, 1},
{"JOYSTICK_IGNORE_OSD", (void*)(&(mist_cfg.joystick_ignore_osd)), UINT8, 0, 1, 1},
{"JOYSTICK0_PREFER_DB9", (void*)(&(mist_cfg.joystick0_prefer_db9)), UINT8, 0, 1, 1},
{"JOYSTICK_DB9_FIXED_INDEX", (void*)(&(mist_cfg.joystick_db9_fixed_index)), UINT8, 0, 1, 1},
{"JOYSTICK_EMU_FIXED_INDEX", (void*)(&(mist_cfg.joystick_emu_fixed_index)), UINT8, 0, 1, 1},
{"KEY_MENU_AS_RGUI", (void*)(&(mist_cfg.key_menu_as_rgui)), UINT8, 0, 1, 1},
#ifndef INI_PARSER_TEST
{"KEY_REMAP", (void*)user_io_key_remap, CUSTOM_HANDLER, 0, 0, 1},
{"HID_BUTTON_REMAP", (void*)hid_joystick_button_remap, CUSTOM_HANDLER, 0, 0, 1},
{"JOYSTICK_REMAP", (void*)virtual_joystick_remap, CUSTOM_HANDLER, 0, 0, 1},
{"JOY_KEY_MAP", (void*)joystick_key_map, CUSTOM_HANDLER, 0, 0, 1},
#endif
{"ROM", (void*)ini_rom_upload, CUSTOM_HANDLER, 0, 0, 1},
// [MINIMIG_CONFIG]
{"KICK1X_MEMORY_DETECTION_PATCH", (void*)(&(minimig_cfg.kick1x_memory_detection_patch)), UINT8, 0, 1, 2},
{"CLOCK_FREQ", (void*)(&(minimig_cfg.clock_freq)), UINT8, 0, 2, 2},
{"CONF_DEFAULT", (void*)(&(minimig_cfg.conf_name[0])), STRING, 1, 10, 2},
{"CONF_1", (void*)(&(minimig_cfg.conf_name[1])), STRING, 1, 10, 2},
{"CONF_2", (void*)(&(minimig_cfg.conf_name[2])), STRING, 1, 10, 2},
{"CONF_3", (void*)(&(minimig_cfg.conf_name[3])), STRING, 1, 10, 2},
{"CONF_4", (void*)(&(minimig_cfg.conf_name[4])), STRING, 1, 10, 2},
// [ATARIST_CONFIG]
{"CONF_DEFAULT", (void*)(&(atarist_cfg.conf_name[0])), STRING, 1, 10, 3},
{"CONF_1", (void*)(&(atarist_cfg.conf_name[1])), STRING, 1, 10, 3},
{"CONF_2", (void*)(&(atarist_cfg.conf_name[2])), STRING, 1, 10, 3},
{"CONF_3", (void*)(&(atarist_cfg.conf_name[3])), STRING, 1, 10, 3},
{"CONF_4", (void*)(&(atarist_cfg.conf_name[4])), STRING, 1, 10, 3}
};
// mist ini config
const ini_cfg_t mist_ini_cfg = {
#ifdef INI_PARSER_TEST
"test.ini",
#else
"MIST INI",
#endif
0,
mist_ini_sections,
mist_ini_vars,
(int)(sizeof(mist_ini_sections) / sizeof(ini_section_t)),
(int)(sizeof(mist_ini_vars) / sizeof(ini_var_t))
};