void-packages/srcpkgs/evemu/patches/time64.patch
Đoàn Trần Công Danh a03d116397 srcpkgs/e*: convert patches to -Np1
```sh

git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

98 lines
2.7 KiB
Diff

--- a/src/evemu.c 2017-06-02 10:02:09.000000000 +0200
+++ b/src/evemu.c 2020-12-11 16:11:53.764932154 +0100
@@ -53,6 +53,7 @@
#include <ctype.h>
#include <unistd.h>
#include <sys/utsname.h>
+#include <inttypes.h>
#include "version.h"
@@ -750,7 +751,8 @@
libevdev_event_code_get_name(ev->type, ev->code),
ev->value);
} else {
- time = millis(&ev->time);
+ struct timeval tv = {ev->input_event_sec, ev->input_event_usec};
+ time = millis(&tv);
dt = time - last_ms;
last_ms = time;
rc = fprintf(fp, "# ------------ %s (%d) ---------- %+ldms\n",
@@ -770,8 +772,8 @@
int evemu_write_event(FILE *fp, const struct input_event *ev)
{
int rc;
- rc = fprintf(fp, "E: %lu.%06u %04x %04x %04d ",
- ev->time.tv_sec, (unsigned)ev->time.tv_usec,
+ rc = fprintf(fp, "E: %" PRIu64 ".%06" PRIu32 " %04x %04x %04d ",
+ (uint64_t)ev->input_event_sec, (uint32_t)ev->input_event_usec,
ev->type, ev->code, ev->value);
rc += write_event_desc(fp, ev);
return rc;
@@ -800,13 +802,16 @@
if (ret < 0)
return ret;
if (ret == sizeof(ev)) {
+ struct timeval tv = {ev.input_event_sec, ev.input_event_usec};
long time;
if (offset == 0)
- offset = time_to_long(&ev.time) - 1;
+ offset = time_to_long(&tv) - 1;
- time = time_to_long(&ev.time);
- ev.time = long_to_time(time - offset);
+ time = time_to_long(&tv);
+ tv = long_to_time(time - offset);
+ ev.input_event_sec = tv.tv_sec;
+ ev.input_event_usec = tv.tv_usec;
evemu_write_event(fp, &ev);
fflush(fp);
}
@@ -839,8 +844,8 @@
return -1;
}
- ev->time.tv_sec = sec;
- ev->time.tv_usec = usec;
+ ev->input_event_sec = sec;
+ ev->input_event_usec = usec;
ev->type = type;
ev->code = code;
ev->value = value;
@@ -852,8 +857,8 @@
int evemu_create_event(struct input_event *ev, int type, int code, int value)
{
- ev->time.tv_sec = 0;
- ev->time.tv_usec = 0;
+ ev->input_event_sec = 0;
+ ev->input_event_usec = 0;
ev->type = type;
ev->code = code;
ev->value = value;
@@ -882,14 +887,20 @@
return ret;
if (evtime) {
- if (evtime->tv_sec == 0 && evtime->tv_usec == 0)
- *evtime = ev->time;
- usec = time_to_long(&ev->time) - time_to_long(evtime);
+ struct timeval tv;
+ if (evtime->tv_sec == 0 && evtime->tv_usec == 0) {
+ evtime->tv_sec = ev->input_event_sec;
+ evtime->tv_usec = ev->input_event_usec;
+ }
+ tv.tv_sec = ev->input_event_sec;
+ tv.tv_usec = ev->input_event_usec;
+ usec = time_to_long(&tv) - time_to_long(evtime);
if (usec > ERROR_MARGIN * 2) {
if (usec > s2us(10))
error(INFO, "Sleeping for %lds.\n", us2s(usec));
usleep(usec - ERROR_MARGIN);
- *evtime = ev->time;
+ evtime->tv_sec = ev->input_event_sec;
+ evtime->tv_usec = ev->input_event_usec;
}
}