mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
rcinput: ensure backward compatibility
supplement to commit:
rcinput: Fix build issues with _TIME_BITS=64
- Ensured compatibility with various definitions of input_event structure
as per input.h.
- Added conditional compilation to check for input_event_sec macro.
- Used input_event_sec and input_event_usec macros if defined.
- Provided fallback to direct timeval members for versions without
the macros.
This ensures compatibility with both newer and older kernel versions,
different C library implementations, and possible standard settings of
build systems. Addressing different definitions of the input_event structure
maintains robustness across kernel, library, and build system configurations.
Origin commit data
------------------
Branch: ni/coolstream
Commit: f65209c56c
Author: Thilo Graf <dbt@novatux.de>
Date: 2024-09-02 (Mon, 02 Sep 2024)
Origin message was:
------------------
rcinput: ensure backward compatibility
supplement to commit:
rcinput: Fix build issues with _TIME_BITS=64
- Ensured compatibility with various definitions of input_event structure
as per input.h.
- Added conditional compilation to check for input_event_sec macro.
- Used input_event_sec and input_event_usec macros if defined.
- Provided fallback to direct timeval members for versions without
the macros.
This ensures compatibility with both newer and older kernel versions,
different C library implementations, and possible standard settings of
build systems. Addressing different definitions of the input_event structure
maintains robustness across kernel, library, and build system configurations.
------------------
This commit was generated by Migit
This commit is contained in:
@@ -1343,10 +1343,21 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
||||
* Everything would be much easier if we could use the post-kernel 3.4
|
||||
* EVIOCSCLOCKID ioctl :-) */
|
||||
struct timespec t1;
|
||||
// Check if input_event_sec macro is defined
|
||||
#ifdef input_event_sec
|
||||
// Use input_event_sec and input_event_usec macros if they are defined
|
||||
now_pressed = ev.input_event_sec * 1000000ULL + ev.input_event_usec;
|
||||
#else
|
||||
// Fallback for older versions that use timeval directly
|
||||
now_pressed = ev.time.tv_sec * 1000000ULL + ev.time.tv_usec;
|
||||
#endif
|
||||
|
||||
// Get the current time using clock_gettime
|
||||
if (!clock_gettime(CLOCK_MONOTONIC, &t1)) {
|
||||
struct timeval t2;
|
||||
// Get the current time using gettimeofday
|
||||
gettimeofday(&t2, NULL);
|
||||
// Calculate now_pressed using timespec and timeval
|
||||
now_pressed += t1.tv_sec * 1000000ULL + t1.tv_nsec / 1000;
|
||||
now_pressed -= (t2.tv_usec + t2.tv_sec * 1000000ULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user