libstb-hal: Fix compatibility issues with struct input_event time assignment

libarmbox:

- Added conditional compilation to handle different definitions of
  struct input_event in input.h
- Ensured gettimeofday() is always used to obtain the current time
- Correctly assigned time values to input_event based on
  platform-specific definitions
- Improved debug information to output correct event time

Had issues building with a different build system and platforms, but wanted to ensure
it works independently of the build system. This still needs to be
tested as my testing capabilities are limited and I cannot
rule out side effects. Hence, the additional debug outputs.
This commit is contained in:
2024-05-15 01:42:48 +02:00
parent a061ffcd5c
commit 9183928d85

View File

@@ -790,12 +790,41 @@ void hdmi_cec::rc_sync(int fd)
{
struct input_event ev;
gettimeofday(&ev.time, NULL);
struct timeval tv;
gettimeofday(&tv, NULL);
// Depending on the structure definition in input.h, assign the time values
#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
ev.time.tv_sec = tv.tv_sec;
ev.time.tv_usec = tv.tv_usec;
#else
ev.__sec = tv.tv_sec;
ev.__usec = tv.tv_usec;
#endif
ev.type = EV_SYN;
ev.code = SYN_REPORT;
ev.value = 0;
write(fd, &ev, sizeof(ev));
ssize_t bytes_written = write(fd, &ev, sizeof(ev));
// Debugging information
if (bytes_written != sizeof(ev))
{
hal_info(RED "[CEC] Error writing sync event to device\n" NORMAL);
}
else
{
hal_info(GREEN "[CEC] Sync event written successfully\n" NORMAL);
#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
hal_info(GREEN "[CEC] Event time: %ld.%06ld\n" NORMAL, ev.time.tv_sec, ev.time.tv_usec);
#else
hal_info(GREEN "[CEC] Event time: %ld.%06ld\n" NORMAL, ev.__sec, ev.__usec);
#endif
}
}
void hdmi_cec::send_key(unsigned char key, unsigned char destination)
{