11
22/*
33 * Python bindings to certain linux input subsystem functions.
4- *
4+ *
55 * While everything here can be implemented in pure Python with struct and
66 * fcntl.ioctl, imho, it is much more straightforward to do so in C.
7- *
7+ *
88 */
99
1010#include <Python.h>
@@ -51,7 +51,7 @@ device_read(PyObject *self, PyObject *args)
5151 struct input_event event ;
5252
5353 // get device file descriptor (O_RDONLY|O_NONBLOCK)
54- if (PyArg_ParseTuple (args , "i" , & fd ) < 0 )
54+ if (PyArg_ParseTuple (args , "i" , & fd ) < 0 )
5555 return NULL ;
5656
5757 read (fd , & event , sizeof (event ));
@@ -62,15 +62,15 @@ device_read(PyObject *self, PyObject *args)
6262 return Py_None ;
6363 }
6464
65- PyObject * sec = PyLong_FromLong (event .time .tv_sec );
65+ PyObject * sec = PyLong_FromLong (event .time .tv_sec );
6666 PyObject * usec = PyLong_FromLong (event .time .tv_usec );
6767 PyObject * val = PyLong_FromLong (event .value );
6868
6969 return Py_BuildValue ("OOhhO" , sec , usec , event .type , event .code , val );
7070}
7171
7272
73- // Read multiple input events from a device and return a list of tuples
73+ // Read multiple input events from a device and return a list of tuples
7474static PyObject *
7575device_read_many (PyObject * self , PyObject * args )
7676{
@@ -80,7 +80,7 @@ device_read_many(PyObject *self, PyObject *args)
8080 int ret = PyArg_ParseTuple (args , "i" , & fd );
8181 if (!ret ) return NULL ;
8282
83- PyObject * event_list = PyList_New (0 );
83+ PyObject * event_list = PyList_New (0 );
8484 PyObject * py_input_event = NULL ;
8585 PyObject * sec = NULL ;
8686 PyObject * usec = NULL ;
@@ -95,7 +95,7 @@ device_read_many(PyObject *self, PyObject *args)
9595
9696 // Construct a list of event tuples, which we'll make sense of in Python
9797 for (i = 0 ; i < nread /event_size ; i ++ ) {
98- sec = PyLong_FromLong (event [i ].time .tv_sec );
98+ sec = PyLong_FromLong (event [i ].time .tv_sec );
9999 usec = PyLong_FromLong (event [i ].time .tv_usec );
100100 val = PyLong_FromLong (event [i ].value );
101101
@@ -151,17 +151,17 @@ ioctl_devinfo(PyObject *self, PyObject *args)
151151
152152 if (ioctl (fd , EVIOCGID , & iid ) < 0 ) goto on_err ;
153153 if (ioctl (fd , EVIOCGNAME (sizeof (name )), name ) < 0 ) goto on_err ;
154- if (ioctl (fd , EVIOCGBIT (0 , EV_MAX ), ev_mask ) < 0 ) goto on_err ;
154+ if (ioctl (fd , EVIOCGBIT (0 , EV_MAX ), ev_mask ) < 0 ) goto on_err ;
155155
156156 // Build a dictionary of the device's capabilities
157157 for (i = 0 ; i < EV_MAX ; i ++ ) {
158158 if (test_bit (ev_mask , i )) {
159- capability = PyLong_FromLong (i );
159+ capability = PyLong_FromLong (i );
160160 eventcodes = PyList_New (0 );
161161
162162 memset (& key_mask , 0 , sizeof (key_mask ));
163163 ioctl (fd , EVIOCGBIT (i , KEY_MAX ), key_mask );
164- for (j = 0 ; j < KEY_MAX ; j ++ )
164+ for (j = 0 ; j < KEY_MAX ; j ++ )
165165 if (test_bit (key_mask , j ))
166166 PyList_Append (eventcodes , PyLong_FromLong (j ));
167167
@@ -170,7 +170,7 @@ ioctl_devinfo(PyObject *self, PyObject *args)
170170 }
171171
172172 // Uinput devices do not have a physical topology associated with them
173- if (!nophys )
173+ if (!nophys )
174174 if (ioctl (fd , EVIOCGPHYS (sizeof (phys )), phys ) < 0 ) goto on_err ;
175175 else
176176 phys [0 ] = ' ' ;
0 commit comments