mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-08-28 19:44:21 -05:00
Implement RPi basic version-special code
This commit is contained in:
@@ -67,47 +67,61 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top
|
||||
return false;
|
||||
}
|
||||
|
||||
while(std::getline(file, line)) {
|
||||
std::istringstream kvp(line);
|
||||
std::string key;
|
||||
bool result = true;
|
||||
|
||||
if(std::getline(kvp, key, '=')) {
|
||||
std::string value;
|
||||
try {
|
||||
while(std::getline(file, line)) {
|
||||
std::istringstream kvp(line);
|
||||
std::string key;
|
||||
|
||||
if(std::getline(kvp, value)) {
|
||||
if(std::getline(kvp, key, '=')) {
|
||||
std::string value;
|
||||
|
||||
if(load_screen_info(key, value, "bot_", bottom_info))
|
||||
continue;
|
||||
if(load_screen_info(key, value, "joint_", joint_info))
|
||||
continue;
|
||||
if(load_screen_info(key, value, "top_", top_info))
|
||||
continue;
|
||||
if(std::getline(kvp, value)) {
|
||||
|
||||
if(key == "split") {
|
||||
display_data.split = std::stoi(value);
|
||||
continue;
|
||||
if(load_screen_info(key, value, "bot_", bottom_info))
|
||||
continue;
|
||||
if(load_screen_info(key, value, "joint_", joint_info))
|
||||
continue;
|
||||
if(load_screen_info(key, value, "top_", top_info))
|
||||
continue;
|
||||
|
||||
if(key == "split") {
|
||||
display_data.split = std::stoi(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(audio_data->load_audio_data(key, value))
|
||||
continue;
|
||||
}
|
||||
|
||||
if(audio_data->load_audio_data(key, value))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
UpdateOutText(out_text_data, "File " + path + name + " load failed.\nDefaults re-loaded.", "Load failed\nDefaults re-loaded", TEXT_KIND_ERROR);
|
||||
result = false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void defaults_reload(FrontendData *frontend_data, AudioData* audio_data) {
|
||||
reset_screen_info(frontend_data->top_screen->m_info);
|
||||
reset_screen_info(frontend_data->bot_screen->m_info);
|
||||
reset_screen_info(frontend_data->joint_screen->m_info);
|
||||
audio_data->reset();
|
||||
reset_display_data(&frontend_data->display_data);
|
||||
if(frontend_data->display_data.mono_app_mode)
|
||||
frontend_data->joint_screen->m_info.is_fullscreen = true;
|
||||
frontend_data->reload = true;
|
||||
}
|
||||
|
||||
static void load_layout_file(int load_index, FrontendData *frontend_data, AudioData* audio_data, OutTextData &out_text_data, bool skip_io, bool do_print) {
|
||||
if(skip_io)
|
||||
return;
|
||||
|
||||
reset_screen_info(frontend_data->top_screen->m_info);
|
||||
reset_screen_info(frontend_data->bot_screen->m_info);
|
||||
reset_screen_info(frontend_data->joint_screen->m_info);
|
||||
audio_data->reset();
|
||||
reset_display_data(&frontend_data->display_data);
|
||||
frontend_data->reload = true;
|
||||
defaults_reload(frontend_data, audio_data);
|
||||
|
||||
if(load_index == SIMPLE_RESET_DATA_INDEX) {
|
||||
UpdateOutText(out_text_data, "Reset detected. Defaults re-loaded", "Reset detected\nDefaults re-loaded", TEXT_KIND_WARNING);
|
||||
@@ -122,6 +136,8 @@ static void load_layout_file(int load_index, FrontendData *frontend_data, AudioD
|
||||
std::string load_name = load_layout_name(load_index, name_load_success);
|
||||
UpdateOutText(out_text_data, "Layout loaded from: " + layout_path + layout_name, "Layout " + load_name + " loaded", TEXT_KIND_SUCCESS);
|
||||
}
|
||||
else if(!op_success)
|
||||
defaults_reload(frontend_data, audio_data);
|
||||
}
|
||||
|
||||
static bool save(const std::string path, const std::string name, const std::string save_name, const ScreenInfo &top_info, const ScreenInfo &bottom_info, const ScreenInfo &joint_info, DisplayData &display_data, AudioData *audio_data, OutTextData &out_text_data) {
|
||||
@@ -222,13 +238,14 @@ static void soundCall(AudioData *audio_data, CaptureData* capture_data) {
|
||||
audio.stop();
|
||||
}
|
||||
|
||||
static void mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data) {
|
||||
static void mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, bool mono_app) {
|
||||
VideoOutputData *out_buf;
|
||||
double last_frame_time = 0.0;
|
||||
int num_elements_fps_array = 0;
|
||||
int curr_out, prev_out = NUM_CONCURRENT_DATA_BUFFERS - 1;
|
||||
FrontendData frontend_data;
|
||||
reset_display_data(&frontend_data.display_data);
|
||||
frontend_data.display_data.mono_app_mode = mono_app;
|
||||
frontend_data.reload = true;
|
||||
bool skip_io = false;
|
||||
int num_allowed_blanks = MAX_ALLOWED_BLANKS;
|
||||
@@ -367,10 +384,61 @@ static void mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data
|
||||
delete out_buf;
|
||||
}
|
||||
|
||||
static bool parse_existence_arg(int &index, char **argv, bool &target, bool existence_value, std::string to_check) {
|
||||
if(argv[index] != to_check)
|
||||
return false;
|
||||
target = existence_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool parse_int_arg(int &index, int argc, char **argv, int &target, std::string to_check) {
|
||||
if(argv[index] != to_check)
|
||||
return false;
|
||||
if((++index) >= argc)
|
||||
return true;
|
||||
try {
|
||||
target = std::stoi(argv[index]);
|
||||
}
|
||||
catch(...) {
|
||||
std::cerr << "Error with input for: " << to_check << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#if defined(__linux__) && defined(XLIB_BASED)
|
||||
XInitThreads();
|
||||
#endif
|
||||
bool mono_app = false;
|
||||
int page_up_id = -1;
|
||||
int page_down_id = -1;
|
||||
int enter_id = -1;
|
||||
int power_id = -1;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if(parse_existence_arg(i, argv, mono_app, true, "--mono_app"))
|
||||
continue;
|
||||
#ifdef RASPI
|
||||
if(parse_int_arg(i, argc, argv, page_up_id, "--pi_select"))
|
||||
continue;
|
||||
if(parse_int_arg(i, argc, argv, page_down_id, "--pi_menu"))
|
||||
continue;
|
||||
if(parse_int_arg(i, argc, argv, enter_id, "--pi_enter"))
|
||||
continue;
|
||||
if(parse_int_arg(i, argc, argv, power_id, "--pi_power"))
|
||||
continue;
|
||||
#endif
|
||||
std::cout << "Help:" << std::endl;
|
||||
std::cout << " --mono_app Enables special mode for when only this application" << std::endl;
|
||||
std::cout << " should run on the system. Disabled by default." << std::endl;
|
||||
#ifdef RASPI
|
||||
std::cout << " --pi_select ID Specifies ID for the select GPIO button." << std::endl;
|
||||
std::cout << " --pi_menu ID Specifies ID for the menu GPIO button." << std::endl;
|
||||
std::cout << " --pi_enter ID Specifies ID for the enter GPIO button." << std::endl;
|
||||
std::cout << " --pi_power ID Specifies ID for the poweroff GPIO button." << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
init_extra_buttons_poll(page_up_id, page_down_id, enter_id, power_id);
|
||||
AudioData audio_data;
|
||||
audio_data.reset();
|
||||
CaptureData* capture_data = new CaptureData;
|
||||
@@ -378,10 +446,11 @@ int main(int argc, char **argv) {
|
||||
std::thread capture_thread(captureCall, capture_data);
|
||||
std::thread audio_thread(soundCall, &audio_data, capture_data);
|
||||
|
||||
mainVideoOutputCall(&audio_data, capture_data);
|
||||
mainVideoOutputCall(&audio_data, capture_data, mono_app);
|
||||
audio_thread.join();
|
||||
capture_thread.join();
|
||||
delete capture_data;
|
||||
end_extra_buttons_poll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user