@@ -54,11 +54,11 @@ static PyObject *pysuinput_press(PyObject *self, PyObject *args)
5454{
5555 PyObject * py_driver ;
5656 struct suinput_driver * c_driver ;
57- uint16_t code ;
58- if (!PyArg_ParseTuple (args , "OH" , & py_driver , & code ))
57+ uint16_t keycode ;
58+ if (!PyArg_ParseTuple (args , "OH" , & py_driver , & keycode ))
5959 return NULL ;
6060 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
61- if (suinput_press (c_driver , code ) == -1 )
61+ if (suinput_press (c_driver , keycode ) == -1 )
6262 return PyErr_SetFromErrno (PyExc_IOError );
6363 Py_RETURN_NONE ;
6464}
@@ -67,11 +67,11 @@ static PyObject *pysuinput_release(PyObject *self, PyObject *args)
6767{
6868 PyObject * py_driver ;
6969 struct suinput_driver * c_driver ;
70- uint16_t code ;
71- if (!PyArg_ParseTuple (args , "OH" , & py_driver , & code ))
70+ uint16_t keycode ;
71+ if (!PyArg_ParseTuple (args , "OH" , & py_driver , & keycode ))
7272 return NULL ;
7373 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
74- if (suinput_release (c_driver , code ) == -1 )
74+ if (suinput_release (c_driver , keycode ) == -1 )
7575 return PyErr_SetFromErrno (PyExc_IOError );
7676 Py_RETURN_NONE ;
7777}
@@ -80,11 +80,11 @@ static PyObject *pysuinput_click(PyObject *self, PyObject *args)
8080{
8181 PyObject * py_driver ;
8282 struct suinput_driver * c_driver ;
83- uint16_t code ;
84- if (!PyArg_ParseTuple (args , "OH" , & py_driver , & code ))
83+ uint16_t keycode ;
84+ if (!PyArg_ParseTuple (args , "OH" , & py_driver , & keycode ))
8585 return NULL ;
8686 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
87- if (suinput_click (c_driver , code ) == -1 )
87+ if (suinput_click (c_driver , keycode ) == -1 )
8888 return PyErr_SetFromErrno (PyExc_IOError );
8989 Py_RETURN_NONE ;
9090}
@@ -108,11 +108,11 @@ static PyObject *pysuinput_press_release(PyObject *self, PyObject *args)
108108{
109109 PyObject * py_driver ;
110110 struct suinput_driver * c_driver ;
111- int16_t code ;
112- if (!PyArg_ParseTuple (args , "Oh" , & py_driver , & code ))
111+ int16_t keycode ;
112+ if (!PyArg_ParseTuple (args , "Oh" , & py_driver , & keycode ))
113113 return NULL ;
114114 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
115- if (suinput_press_release (c_driver , code ) == -1 )
115+ if (suinput_press_release (c_driver , keycode ) == -1 )
116116 return PyErr_SetFromErrno (PyExc_IOError );
117117 Py_RETURN_NONE ;
118118}
@@ -121,11 +121,11 @@ static PyObject *pysuinput_toggle(PyObject *self, PyObject *args)
121121{
122122 PyObject * py_driver ;
123123 struct suinput_driver * c_driver ;
124- uint16_t code ;
125- if (!PyArg_ParseTuple (args , "OH" , & py_driver , & code ))
124+ uint16_t keycode ;
125+ if (!PyArg_ParseTuple (args , "OH" , & py_driver , & keycode ))
126126 return NULL ;
127127 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
128- if (suinput_toggle (c_driver , code ) == -1 )
128+ if (suinput_toggle (c_driver , keycode ) == -1 )
129129 return PyErr_SetFromErrno (PyExc_IOError );
130130 Py_RETURN_NONE ;
131131}
@@ -134,121 +134,64 @@ static PyObject *pysuinput_is_pressed(PyObject *self, PyObject *args)
134134{
135135 PyObject * py_driver ;
136136 struct suinput_driver * c_driver ;
137- uint16_t code ;
138- if (!PyArg_ParseTuple (args , "OH" , & py_driver , & code ))
137+ uint16_t keycode ;
138+ if (!PyArg_ParseTuple (args , "OH" , & py_driver , & keycode ))
139139 return NULL ;
140140 c_driver = (struct suinput_driver * )PyCObject_AsVoidPtr (py_driver );
141- return PyBool_FromLong (suinput_is_pressed (c_driver , code ));
142- }
143-
144- static PyObject * pysuinput_is_valid_code (PyObject * self , PyObject * args )
145- {
146- uint16_t code ;
147- if (!PyArg_ParseTuple (args , "H" , & code ))
148- return NULL ;
149- return PyBool_FromLong (suinput_is_valid_code (code ));
141+ return PyBool_FromLong (suinput_is_pressed (c_driver , keycode ));
150142}
151143
152144static PyMethodDef pysuinputMethods [] = {
153145 {"open" , pysuinput_open , METH_VARARGS ,
154146 "open(name, bustype, vendor, product, version)\n\n"
155- "Creates and opens a connection to the event device. Returns an uinput\n"
156- "file descriptor on success. On error, -1 is returned, and errno is set\n"
157- "appropriately.\n"
158- "\n"
159- "All possible values of `bustype` are defined as constants prefixed\n"
160- "by BUS_.\n"
147+ "Return an input driver.\n"
148+ "All possible values of bustype are defined as constants prefixed\n"
149+ "by BUS_, vendor, product and version are unsigned 16 bit integers."
150+ "close() must be called for every object returned by this function."
161151 },
162152
163153 {"close" , pysuinput_close , METH_VARARGS ,
164154 "close(driver)\n\n"
165- "Destroys and closes a connection to the event device. Returns 0 on\n"
166- "success. On error, -1 is returned, and errno is set appropriately.\n"
167- "\n"
168- "Behaviour is undefined when passed a file descriptor not returned by\n"
169- "suinput_open()."
155+ "Close and destroy the driver."
170156 },
171157
172158 {"click" , pysuinput_click , METH_VARARGS ,
173- "click(driver, code)\n\n"
174- "Sends a press and release events to the event device. Returns 0 on\n"
175- "success. On error, -1 is returned, and errno is set appropriately.\n"
176- "\n"
177- "Behaviour is undefined when passed a file descriptor not returned by\n"
178- "suinput_open().\n"
179- "\n"
180- "All possible values of `code` are defined as constants in\n"
181- "uinput.codes -module.\n"
182- "\n"
183- "This function is provided as a convenience and has effectively the\n"
184- "same result as calling suinput_press() and suinput_release()\n"
185- "sequentially."
159+ "click(driver, keycode)\n\n"
160+ "Send a press and a release event."
186161 },
187162
188163 {"press" , pysuinput_press , METH_VARARGS ,
189- "press(driver, code)\n\n"
190- "Sends a press event to the event device. Event is repeated after\n"
191- "a short delay until a release event is sent. Returns 0 on success.\n"
192- "On error, -1 is returned, and errno is set appropriately.\n"
193- "\n"
194- "Behaviour is undefined when passed a file descriptor not returned by\n"
195- "suinput_open().\n"
196- "\n"
197- "All possible values of `code` are defined as constants in\n"
198- "uinput.codes -module."
164+ "press(driver, keycode)\n\n"
165+ "Send a press event.\n"
166+ "Event is repeated after a short delay until a release event is sent."
199167 },
200168
201169 {"release" , pysuinput_release , METH_VARARGS ,
202- "release(driver, code)\n\n"
203- "Sends a release event to the event device. Returns 0 on success.\n"
204- "On error, -1 is returned, and errno is set appropriately.\n"
205- "\n"
206- "Behaviour is undefined when passed a file descriptor not returned by\n"
207- "suinput_open().\n"
208- "\n"
209- "All possible values of `code` are defined as constants in\n"
210- "uinput.codes -module."
170+ "release(driver, keycode)\n\n"
171+ "Send a release event."
211172 },
212173
213174 {"move_pointer" , pysuinput_move_pointer , METH_VARARGS ,
214175 "move_pointer(driver, x, y)\n\n"
215- "Sends a relative pointer motion event to the event device. Values\n"
216- "increase towards right-bottom. Returns 0 on success. On error, -1\n"
217- "is returned, and errno is set appropriately.\n"
218- "\n"
219- "Behaviour is undefined when passed a file descriptor not returned by\n"
220- "suinput_open()."
176+ "Move pointer towards bottom-right."
221177 },
222178
223179 {"press_release" , pysuinput_press_release , METH_VARARGS ,
224- "press_release(driver, signed_code)\n\n"
225- "Sends a press or a release event to the event device. The sign of\n"
226- "`code` determines which type of event is sent. Positive `code`\n"
227- "means press and negative `code` means release. Returns 0 on\n"
228- "success. On error, -1 is returned, and errno is set appropriately.\n"
229- "\n"
230- "Behaviour is undefined when passed a file descriptor not returned by\n"
231- "suinput_open().\n"
232- "\n"
233- "All possible absolute values of `code` are defined as constants in\n"
234- "uinput.codes -module.\n"
235- "\n"
236- "This function is provided as a convenience and has effectively the\n"
237- "same result as calling suinput_press() when the value of `code` is\n"
238- "positive and suinput_release() when negative."
239-
180+ "press_release(driver, signed_keycode)\n\n"
181+ "Send a press event if signed_keycode > 0, otherwise send\n"
182+ "a release event."
240183 },
241184
242185 {"toggle" , pysuinput_toggle , METH_VARARGS ,
243- ""
186+ "toggle(driver, keycode)\n\n"
187+ "Press button if it is not pressed currently, release it otherwise."
244188 },
245189
246190 {"is_pressed" , pysuinput_is_pressed , METH_VARARGS ,
247- ""
248- },
249-
250- {"is_valid_code" , pysuinput_is_valid_code , METH_VARARGS ,
251- ""
191+ "is_pressed(driver, keycode)\n\n"
192+ "Return True if button is pressed, False otherwise.\n"
193+ "keycode must be one of the constant values defined in\n"
194+ "uinput.keycodes -module."
252195 },
253196
254197 {NULL , NULL , 0 , NULL }
0 commit comments