aboutsummaryrefslogtreecommitdiffstats
cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
From 435e78aaf6745e4da0fe3d4455473011626c77d1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 30 Nov 2019 11:21:20 -0800
Subject: [PATCH] Fix build on 32bit arches with 64bit time_t

time element is deprecated on new input_event structure in kernel's
input.h [1]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f

Upstream-Status: Submitted [https://github.com/gvalkov/python-evdev/pull/112]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 evdev/input.c  | 13 +++++++++----
 evdev/uinput.c |  9 ++++++++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/evdev/input.c b/evdev/input.c
index 67b9348..432db92 100644
--- a/evdev/input.c
+++ b/evdev/input.c
@@ -24,6 +24,11 @@
 #include <linux/input.h>
 #endif
 
+#ifndef input_event_sec
+#define input_event_sec time.tv_sec
+#define input_event_usec time.tv_usec
+#endif
+
 #define MAX_NAME_SIZE 256
 
 extern char*  EV_NAME[EV_CNT];
@@ -60,8 +65,8 @@ device_read(PyObject *self, PyObject *args)
         return NULL;
     }
 
-    PyObject* sec  = PyLong_FromLong(event.time.tv_sec);
-    PyObject* usec = PyLong_FromLong(event.time.tv_usec);
+    PyObject* sec  = PyLong_FromLong(event.input_event_sec);
+    PyObject* usec = PyLong_FromLong(event.input_event_usec);
     PyObject* val  = PyLong_FromLong(event.value);
     PyObject* py_input_event = NULL;
 
@@ -102,8 +107,8 @@ device_read_many(PyObject *self, PyObject *args)
 
     // Construct a list of event tuples, which we'll make sense of in Python
     for (unsigned i = 0 ; i < nread/event_size ; i++) {
-        sec  = PyLong_FromLong(event[i].time.tv_sec);
-        usec = PyLong_FromLong(event[i].time.tv_usec);
+        sec  = PyLong_FromLong(event[i].input_event_sec);
+        usec = PyLong_FromLong(event[i].input_event_usec);
         val  = PyLong_FromLong(event[i].value);
 
         py_input_event = Py_BuildValue("OOhhO", sec, usec, event[i].type, event[i].code, val);
diff --git a/evdev/uinput.c b/evdev/uinput.c
index 192568d..56fe86c 100644
--- a/evdev/uinput.c
+++ b/evdev/uinput.c
@@ -16,6 +16,10 @@
 #include <linux/uinput.h>
 #endif
 
+#ifndef input_event_sec
+#define input_event_sec time.tv_sec
+#define input_event_usec time.tv_usec
+#endif
 
 // Workaround for installing on kernels newer than 4.4.
 #ifndef FF_MAX_EFFECTS
@@ -232,8 +236,11 @@ uinput_write(PyObject *self, PyObject *args)
     if (!ret) return NULL;
 
     struct input_event event;
+    struct timeval tval;
     memset(&event, 0, sizeof(event));
-    gettimeofday(&event.time, 0);
+    gettimeofday(&tval, 0);
+    event.input_event_usec = tval.tv_usec;
+    event.input_event_sec = tval.tv_sec;
     event.type = type;
     event.code = code;
     event.value = value;