forked from OnionUI/Onion
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#ifndef STORYTELLER_APP_LOCK__ | ||
#define STORYTELLER_APP_LOCK__ | ||
|
||
#include "./time_helper.h" | ||
#include "system/display.h" | ||
|
||
static bool applockIsLocked = false; | ||
|
||
bool applock_isLocked(void) | ||
{ | ||
return applockIsLocked; | ||
} | ||
|
||
#include "./sdl_helper.h" | ||
|
||
|
||
static long applockTimer = 0; | ||
static long applockTimerScreenOn = 0; | ||
|
||
void applock_startScreenTimer(void) | ||
{ | ||
applockTimerScreenOn = get_time(); | ||
display_setScreen(true); | ||
} | ||
|
||
void applock_stopScreenTimer(void) | ||
{ | ||
applockTimerScreenOn = 0; | ||
} | ||
|
||
void applock_endScreenTimer(void) | ||
{ | ||
applock_stopScreenTimer(); | ||
display_setScreen(false); | ||
} | ||
|
||
void applock_startTimer(void) | ||
{ | ||
applockTimer = get_time(); | ||
if(applockIsLocked && !display_enabled) { | ||
applock_startScreenTimer(); | ||
} | ||
} | ||
|
||
void applock_stopTimer(void) | ||
{ | ||
applockTimer = 0; | ||
} | ||
|
||
void applock_lock(void) | ||
{ | ||
applock_stopTimer(); | ||
applockIsLocked = true; | ||
video_applyToVideo(); | ||
} | ||
|
||
void applock_unlock(void) | ||
{ | ||
applock_stopTimer(); | ||
applockIsLocked = false; | ||
video_applyToVideo(); | ||
} | ||
|
||
void applock_checkLock(void) | ||
{ | ||
long time = get_time(), laps; | ||
|
||
if(applockTimerScreenOn > 0) { | ||
laps = time - applockTimerScreenOn; | ||
if(laps > 3) { | ||
applock_endScreenTimer(); | ||
} | ||
} | ||
|
||
if(applockTimer == 0) { | ||
return; | ||
} | ||
|
||
if(applockIsLocked && !display_enabled && applockTimerScreenOn == 0) { | ||
applock_startScreenTimer(); | ||
} | ||
|
||
laps = time - applockTimer; | ||
|
||
if(laps > 2) { | ||
if(applockIsLocked) { | ||
applock_unlock(); | ||
} else { | ||
applock_lock(); | ||
if(!display_enabled) { | ||
applock_startScreenTimer(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif // STORYTELLER_APP_LOCK__ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters