Skip to content

Commit 6799dd8

Browse files
committed
Add comments and remove extra newlines
1 parent 2c5d62d commit 6799dd8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎evdev/uinput.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ uinput_set_phys(PyObject *self, PyObject *args)
7474
}
7575

7676

77+
// Different kernel versions have different device setup methods. You can read
78+
// more about it here:
79+
// https://github.com/torvalds/linux/commit/052876f8e5aec887d22c4d06e54aa5531ffcec75
80+
81+
// Setup function for kernel >= v4.5
7782
#if defined(UI_DEV_SETUP) && defined(UI_ABS_SETUP)
78-
// New variant is not supported in old linux kernels and FreeBSD
7983
static PyObject *
8084
uinput_setup(PyObject *self, PyObject *args) {
8185
int fd, len, i;
@@ -110,7 +114,6 @@ uinput_setup(PyObject *self, PyObject *args) {
110114
goto on_err;
111115
}
112116

113-
114117
// Setup evdev:
115118
struct uinput_setup usetup;
116119

@@ -125,16 +128,16 @@ uinput_setup(PyObject *self, PyObject *args) {
125128
if(ioctl(fd, UI_DEV_SETUP, &usetup) < 0)
126129
goto on_err;
127130

128-
129131
Py_RETURN_NONE;
130132

131133
on_err:
132134
_uinput_close(fd);
133135
PyErr_SetFromErrno(PyExc_IOError);
134136
return NULL;
135137
}
138+
139+
// Fallback setup function (Linux <= 4.5 and FreeBSD).
136140
#else
137-
// Old variant (fallback):
138141
static PyObject *
139142
uinput_setup(PyObject *self, PyObject *args) {
140143
int fd, len, i, abscode;

0 commit comments

Comments
 (0)