improved mac uefi keys handling

This commit is contained in:
Devaev Maxim
2021-04-22 03:21:06 +03:00
parent e6ecbb2a9c
commit 4279ae5bc3
3 changed files with 68 additions and 8 deletions

32
hid/src/tools.h Normal file
View File

@@ -0,0 +1,32 @@
/*****************************************************************************
# #
# KVMD - The main Pi-KVM daemon. #
# #
# Copyright (C) 2018-2021 Maxim Devaev <mdevaev@gmail.com> #
# #
# 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 <https://www.gnu.org/licenses/>. #
# #
*****************************************************************************/
#pragma once
bool is_micros_timed_out(unsigned long start_ts, unsigned long timeout) {
unsigned long now = micros();
return (
(now >= start_ts && now - start_ts > timeout)
|| (now < start_ts && ((unsigned long)-1) - start_ts + now > timeout)
);
}