mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
* android: Implement play time tacking Co-Authored-By: Reg Tiangha <rtiangha@users.noreply.github.com> * Moved playtime manager from `citra_qt` to `common` * Reimplemented Android play time to use existing logic from desktop * Updated license headers * When getting current game ID fails, silently error rather than crashing * playTimeManagerStart: Check that `play_time_manager` is initialized before using it --------- Co-authored-by: Kleidis <167202775+kleidis@users.noreply.github.com> Co-authored-by: Reg Tiangha <rtiangha@users.noreply.github.com>
42 lines
983 B
C++
42 lines
983 B
C++
// Copyright Citra Emulator Project / Azahar Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include "common/common_funcs.h"
|
|
#include "common/common_types.h"
|
|
#include "common/polyfill_thread.h"
|
|
|
|
namespace PlayTime {
|
|
|
|
using ProgramId = u64;
|
|
using PlayTime = u64;
|
|
using PlayTimeDatabase = std::map<ProgramId, PlayTime>;
|
|
|
|
class PlayTimeManager {
|
|
public:
|
|
explicit PlayTimeManager();
|
|
~PlayTimeManager();
|
|
|
|
PlayTimeManager(const PlayTimeManager&) = delete;
|
|
PlayTimeManager& operator=(const PlayTimeManager&) = delete;
|
|
|
|
u64 GetPlayTime(u64 program_id) const;
|
|
void ResetProgramPlayTime(u64 program_id);
|
|
void SetProgramId(u64 program_id);
|
|
void Start();
|
|
void Stop();
|
|
|
|
private:
|
|
void AutoTimestamp(std::stop_token stop_token);
|
|
void Save();
|
|
|
|
PlayTimeDatabase database;
|
|
u64 running_program_id;
|
|
std::jthread play_time_thread;
|
|
};
|
|
|
|
} // namespace PlayTime
|