2018-05-09 09:25:01 +00:00
|
|
|
/*
|
2019-05-06 20:51:09 +00:00
|
|
|
* This file is part of Checkpoint
|
|
|
|
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
|
|
|
* * Requiring preservation of specified reasonable legal notices or
|
|
|
|
* author attributions in that material or in the Appropriate Legal
|
|
|
|
* Notices displayed by works containing it.
|
|
|
|
* * Prohibiting misrepresentation of the origin of that material,
|
|
|
|
* or requiring that modified versions of such material be marked in
|
|
|
|
* reasonable ways as different from the original version.
|
|
|
|
*/
|
2018-05-09 09:25:01 +00:00
|
|
|
|
2018-06-10 20:24:37 +00:00
|
|
|
#include "main.hpp"
|
2019-07-02 21:42:48 +00:00
|
|
|
#include "MainScreen.hpp"
|
2019-07-04 07:44:29 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "ftp.h"
|
|
|
|
}
|
2018-06-10 20:24:37 +00:00
|
|
|
|
2019-07-04 21:21:12 +00:00
|
|
|
static void networkLoop(void)
|
|
|
|
{
|
|
|
|
while (appletMainLoop() && !g_shouldExitNetworkLoop) {
|
2019-07-04 21:09:46 +00:00
|
|
|
Configuration::getInstance().pollServer();
|
2019-07-05 19:08:15 +00:00
|
|
|
if (g_ftpAvailable && Configuration::getInstance().isFTPEnabled()) {
|
2019-07-04 21:09:46 +00:00
|
|
|
ftp_loop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-16 09:02:10 +00:00
|
|
|
int main(void)
|
2018-05-09 09:25:01 +00:00
|
|
|
{
|
|
|
|
Result res = servicesInit();
|
2019-05-06 20:51:09 +00:00
|
|
|
if (R_FAILED(res)) {
|
2018-05-09 09:25:01 +00:00
|
|
|
servicesExit();
|
2019-07-17 18:29:29 +00:00
|
|
|
exit(res);
|
2018-05-09 09:25:01 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 06:57:25 +00:00
|
|
|
g_screen = std::make_unique<MainScreen>();
|
2019-06-16 09:02:10 +00:00
|
|
|
|
2018-09-03 19:35:35 +00:00
|
|
|
loadTitles();
|
2019-04-12 21:39:55 +00:00
|
|
|
// get the user IDs
|
|
|
|
std::vector<u128> userIds = Account::ids();
|
|
|
|
// set g_currentUId to a default user in case we loaded at least one user
|
2019-05-06 20:51:09 +00:00
|
|
|
if (g_currentUId == 0)
|
|
|
|
g_currentUId = userIds.at(0);
|
2018-05-09 09:25:01 +00:00
|
|
|
|
2019-07-04 21:09:46 +00:00
|
|
|
Thread networkThread;
|
|
|
|
threadCreate(&networkThread, (ThreadFunc)networkLoop, nullptr, 16 * 1000, 0x2C, -2);
|
|
|
|
threadStart(&networkThread);
|
|
|
|
|
2019-05-06 20:51:09 +00:00
|
|
|
while (appletMainLoop() && !(hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS)) {
|
2018-06-12 14:01:38 +00:00
|
|
|
touchPosition touch;
|
2019-06-16 09:02:10 +00:00
|
|
|
hidScanInput();
|
2018-06-12 14:01:38 +00:00
|
|
|
hidTouchRead(&touch, 0);
|
2019-04-12 21:39:55 +00:00
|
|
|
|
2019-07-04 06:57:25 +00:00
|
|
|
g_screen->doDraw();
|
|
|
|
g_screen->doUpdate(&touch);
|
2019-06-16 09:02:10 +00:00
|
|
|
SDLH_Render();
|
2018-05-09 09:25:01 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 21:09:46 +00:00
|
|
|
g_shouldExitNetworkLoop = true;
|
|
|
|
threadWaitForExit(&networkThread);
|
|
|
|
threadClose(&networkThread);
|
|
|
|
|
2018-05-09 09:25:01 +00:00
|
|
|
servicesExit();
|
2019-07-17 18:29:29 +00:00
|
|
|
exit(0);
|
2018-05-09 09:25:01 +00:00
|
|
|
}
|