mirror of
https://github.com/BernardoGiordano/Checkpoint
synced 2024-11-13 21:27:06 +00:00
Implement led notifications
This commit is contained in:
parent
72d23d5bdb
commit
dc37a8b07d
6 changed files with 65 additions and 3 deletions
|
@ -35,5 +35,6 @@
|
|||
#include "pksmbridge.hpp"
|
||||
|
||||
extern u128 g_currentUId;
|
||||
extern bool g_notificationLedAvailable;
|
||||
|
||||
#endif
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
void servicesExit(void);
|
||||
Result servicesInit(void);
|
||||
HidsysNotificationLedPattern blinkLedPattern(u8 times);
|
||||
void blinkLed(u8 times);
|
||||
|
||||
namespace StringUtils
|
||||
{
|
||||
|
|
|
@ -33,6 +33,9 @@ static const char *s_http_port = "8000";
|
|||
|
||||
static void handle_populate(struct mg_connection *nc, struct http_message *hm)
|
||||
{
|
||||
// populate gets called at startup, assume a new connection has been started
|
||||
blinkLed(2);
|
||||
|
||||
auto json = Configuration::getInstance().getJson();
|
||||
auto map = getCompleteTitleList();
|
||||
json["title_list"] = map;
|
||||
|
|
|
@ -387,9 +387,12 @@ void Gui::draw(void)
|
|||
SDLH_DrawText(24, 100, 360, theme().c6, "\ue000 to enter the selected title");
|
||||
SDLH_DrawText(24, 100, 390, theme().c6, "\ue001 to exit the selected title");
|
||||
SDLH_DrawText(24, 616, 450, theme().c6, "\ue002 to delete a backup");
|
||||
SDLH_DrawText(24, 16*6 + checkpoint_w + 8 + ver_w + inst_w, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - inst_h, COLOR_GOLD,
|
||||
StringUtils::format("Configuration server running on %s:8000", getConsoleIP()).c_str());
|
||||
}
|
||||
if (gethostid() != INADDR_LOOPBACK)
|
||||
{
|
||||
SDLH_DrawText(24, 16*6 + checkpoint_w + 8 + ver_w + inst_w, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - inst_h, COLOR_GOLD,
|
||||
StringUtils::format("Configuration server running on %s:8000", getConsoleIP()).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
SDLH_DrawRect(0, 672, checkpoint_w + ver_w + 2*16 + 8, 40, lightBlack);
|
||||
SDLH_DrawText(26, 16, 672 + (40 - checkpoint_h) / 2 + 2, theme().c6, "checkpoint");
|
||||
|
|
|
@ -247,6 +247,7 @@ void io::backup(size_t index, u128 uid)
|
|||
FileSystem::unmount();
|
||||
if (!MS::multipleSelectionEnabled())
|
||||
{
|
||||
blinkLed(4);
|
||||
Gui::showInfo("Progress correctly saved to disk.");
|
||||
}
|
||||
auto systemKeyboardAvailable = KeyboardManager::get().isSystemKeyboardAvailable();
|
||||
|
|
|
@ -26,12 +26,20 @@
|
|||
|
||||
#include "util.hpp"
|
||||
|
||||
bool g_notificationLedAvailable = false;
|
||||
|
||||
void servicesExit(void)
|
||||
{
|
||||
CheatManager::exit();
|
||||
|
||||
// debug
|
||||
socketExit();
|
||||
|
||||
freeIcons();
|
||||
if (g_notificationLedAvailable)
|
||||
{
|
||||
hidsysExit();
|
||||
}
|
||||
nsExit();
|
||||
Account::exit();
|
||||
Gui::exit();
|
||||
|
@ -74,6 +82,11 @@ Result servicesInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(res = hidsysInitialize()))
|
||||
{
|
||||
g_notificationLedAvailable = true;
|
||||
}
|
||||
|
||||
CheatManager::init();
|
||||
|
||||
Configuration::getInstance();
|
||||
|
@ -117,4 +130,43 @@ std::string StringUtils::removeNotAscii(std::string str)
|
|||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
HidsysNotificationLedPattern blinkLedPattern(u8 times)
|
||||
{
|
||||
HidsysNotificationLedPattern pattern;
|
||||
memset(&pattern, 0, sizeof(pattern));
|
||||
|
||||
pattern.baseMiniCycleDuration = 0x1; // 12.5ms.
|
||||
pattern.totalMiniCycles = 0x2; // 2 mini cycles.
|
||||
pattern.totalFullCycles = times; // Repeat n times.
|
||||
pattern.startIntensity = 0x0; // 0%.
|
||||
|
||||
pattern.miniCycles[0].ledIntensity = 0xF; // 100%.
|
||||
pattern.miniCycles[0].transitionSteps = 0xF; // 15 steps. Total 187.5ms.
|
||||
pattern.miniCycles[0].finalStepDuration = 0x0; // Forced 12.5ms.
|
||||
pattern.miniCycles[1].ledIntensity = 0x0; // 0%.
|
||||
pattern.miniCycles[1].transitionSteps = 0xF; // 15 steps. Total 187.5ms.
|
||||
pattern.miniCycles[1].finalStepDuration = 0x0; // Forced 12.5ms.
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
void blinkLed(u8 times)
|
||||
{
|
||||
if (g_notificationLedAvailable)
|
||||
{
|
||||
size_t n;
|
||||
u64 uniquePadIds[2];
|
||||
HidsysNotificationLedPattern pattern = blinkLedPattern(times);
|
||||
memset(uniquePadIds, 0, sizeof(uniquePadIds));
|
||||
Result res = hidsysGetUniquePadsFromNpad(hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1, uniquePadIds, 2, &n);
|
||||
if (R_SUCCEEDED(res))
|
||||
{
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
hidsysSetNotificationLedPattern(&pattern, uniquePadIds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue