Skip to content

Commit

Permalink
Fix brightness and screenshot shortcuts in MainUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemiii91 committed Jun 24, 2024
1 parent dd3729a commit c6f437f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################

TARGET=Onion
VERSION=4.3.1
VERSION=4.3.1-1
RA_SUBVERSION=1.15.0.13

###########################################################
Expand Down
28 changes: 9 additions & 19 deletions src/keymon/keymon.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <dirent.h>
#include <fcntl.h>
#include <poll.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
Expand Down Expand Up @@ -58,7 +57,6 @@ void takeScreenshot(void)
{
super_short_pulse();
display_setBrightnessRaw(0);
display_reset();
msleep(10);
osd_hideBar();
screenshot_recent();
Expand Down Expand Up @@ -337,16 +335,6 @@ void turnOffScreen(void)
suspend_exec(stay_awake ? -1 : timeout);
}

static void *runWritingSettingsThread(void *param)
{
bool *isWritingSettingsThreadActive = (bool *)param;
*isWritingSettingsThreadActive = true;
settings_shm_write();
settings_save();
*isWritingSettingsThreadActive = false;
return 0;
}

//
// Main
//
Expand Down Expand Up @@ -410,9 +398,8 @@ int main(void)
bool delete_flag = false;
bool settings_changed = false;

int save_settings_timestamp = 0;
volatile bool needWriteSettings = false;
volatile bool isWritingSettingsThreadActive = false;
pthread_t writingSettingsThread;

time_t fav_last_modified = time(NULL);

Expand Down Expand Up @@ -764,12 +751,15 @@ int main(void)
else if (volDown_state == RELEASED && volUp_state == RELEASED)
comboKey_volume = false;

if (settings_changed || needWriteSettings) {
if (settings_changed) {
settings_shm_write();
needWriteSettings = true;
if (!isWritingSettingsThreadActive) {
needWriteSettings = false;
pthread_create(&writingSettingsThread, NULL, runWritingSettingsThread, &isWritingSettingsThreadActive);
}
save_settings_timestamp = ticks;
}

if (needWriteSettings && (ticks - save_settings_timestamp) > 150) {
settings_save();
needWriteSettings = false;
}

if ((val == PRESSED) && (system_state == MODE_MAIN_UI)) {
Expand Down

0 comments on commit c6f437f

Please sign in to comment.