summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)AuthorFilesLines
2017-09-25python: Add missing binding for evemu_get_abs_current_valueBenjamin Berg1-0/+11
Add a binding to get the current value of an EV_ABS value. https://bugs.freedesktop.org/show_bug.cgi?id=102615 Signed-off-by: Benjamin Berg <bberg@redhat.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-11-10python: encode/decode C strings for Python 3Peter Hutterer1-6/+23
Python3 uses unicode and byte arrays need to be explicitly encoded/decoded in Python3 to avoid the ctypes TypeError when converting between python strings and C strings. https://bugs.freedesktop.org/show_bug.cgi?id=97458 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-11-10python: fix ctypes NULL-pointer checksPeter Hutterer1-6/+5
NULL-pointers are None, not 0. This only worked because we kept falling through until some other later condition triggered and happened to return the correct value at all times (usually because the type/code ended up as -1) Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-11-09python: use "is None" instead of "== None"Peter Hutterer1-6/+6
A fairly subtle difference, but "is None" is preferred. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-11-08python: automatically rewind the fd at the end of the event sequencePeter Hutterer3-0/+15
Allows running through the event sequence more than once without any extra handling. In modern recordings the description and the event file is in the same file and there is no extra fd handling for the events. So simple code to check events would look like this: d = evemu.Device("/path/to/file", create=False) for e in d.events(): check_for_something() for e in d.events(): check_for_something_else() Simply rewinding the fd is sufficient here to avoid the caller having to keep a copy of the events. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Martin <consume.noise@gmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-11-08python/test: don't use 'e' for an fd and the eventPeter Hutterer1-2/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Martin <consume.noise@gmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-10-25test: rename a duplicate function namePeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Martin <consume.noise@gmail.com>
2014-11-07python: check for fileno(), not read() and document itPeter Hutterer1-4/+13
We use fileno() on the various file arguments, not read() so check for that. And document it in the API that we need real file objects here, not just something that's file-like. Reported-by: Dan Callaghan Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-07python: fix a couple of comment claiming we need rootPeter Hutterer1-3/+6
We do, but technically we just need the right permissions Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-07python: add docstrings to evemu.DevicePeter Hutterer1-0/+45
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-07python: switch from type() == str to not isinstance(int)Peter Hutterer1-8/+8
Switch to isinstance to be more liberal in what we can accept. Anything that looks like an int should be used as such, anything else we assume to be a string that needs parsing. event_get_value() would do that for us but we can't call it unconditionally - some events don't have names so they cannot resolve. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-07python: remove out-of-date commentPeter Hutterer1-11/+0
This was probably true at some point but it's not anymore now. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-07python: drop now unused import of evemu.event_namesPeter Hutterer1-1/+0
Module was dropped in 606d2135c5 after removing the need for it by using C wrappers around libevdev instead. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-11-05python: add InputEvent.matches(type, code) for comparisonsPeter Hutterer2-0/+49
Allows for: if e.matches("EV_REL", "REL_X"): print("Relative X events") but it'll happily take integers as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-29python: widen the tests for some int/str values where there shouldn't bePeter Hutterer1-0/+17
The API is forgiving to int/str where there shouldn't be any, so make sure we test for that. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-29python: remove deprecated make-event-names.py and the generated event_name.pyBenjamin Tissoires2-210/+3
Nobody uses this file anymore, and it was never been a public python API. We can safely kill it and remove the need to generate some files from input.h. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-29python: replace input_prop_get_value/get_name with the C implementationPeter Hutterer1-6/+14
Relying on an external lib removes the pain to maintain our own input.h implementation. The functions accept both strings and integer values in both directions of conversion. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-29python: replace event_get_value/event_get_name with the C implementationPeter Hutterer1-7/+41
Relying on an external lib removes the pain to maintain our own input.h implementation. The functions accept both strings and integer values in both directions of conversion. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-29python: add wrappers around some libevdev utility functionsBenjamin Tissoires1-0/+41
So we can get rid of the generated mapping tables. Requires newest libevdev for libevdev_property_from_name() Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-29python: honor LD_LIBRARY_PATH in the test runnerPeter Hutterer2-2/+2
ctypes.util.find_library doesn't honor LD_LIBRARY_PATH, instantiating directly (like we do for for libevemu already) does. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-21Drop some trailing whitespacesPeter Hutterer2-6/+6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-14python: add all .pyc files to CLEANFILESPeter Hutterer1-2/+12
Splitting the python_sources into a separate variable. No functional change, just nicer to read than base_python_PYTHON in the CLEANFILES. Python2 and Python3 have different behaviors for the pyc files, in Python3 they're inside a __pycache__ folder and named e.g. const.cpython-33.pyc. We can just delete the folder itself here, not worrying about the specific names. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14python: move event-names.py generation into the toplevel python makefilePeter Hutterer2-13/+8
Just to have things together Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14python: explicitly specify file listsPeter Hutterer1-2/+16
Don't use a wildcard, avoids accidentally shipping files we shouldn't, and clearly lists what we intend to ship. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14python: deprecate evemu.constPeter Hutterer1-0/+4
It's now unused in internal code. Leave it there to avoid breakage of older clients, but otherwise ignore it for the future. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14python: fix evemu.Device.has_prop() for string argumentsPeter Hutterer1-1/+2
Using 'prop' instead of 'event_code' would be more sensible but it'd break API, python allows named arguments. Introduced in 385b6e3d8cd257e878cbe82e4bd0f38d8b8b1ca7 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14python: drop evemu.const usages for device bitsPeter Hutterer3-63/+40
We have make-event-names.py that generates the required mappings, there is no need for having a hand-updated file around that provides some of these constants. Previously we compared the event names as well as the event values in test_case.py. That was useful when we were using two different sources (event_names.py and the hand-maintained const.py). Now we generate the dicts from the same source. We have separate tests for evemu.event_get_(value|name) so we don't need the this extra comparison against the names in test_get_abs_* and friends anymore. Special note on get_expected_propbits(): we previously returned a dict with the absolute axes as keys. This is fixed here, we now return a dict with the actual property bits as keys. Since all values were always False and both absbits and propbits are just numbers this never got noticed before. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-14configure.ac: add '--disable-python-bindings' optionPeter Seiderer2-0/+5
Needed for target systems without python support. Signed-off-by: Peter Seiderer <ps.report@gmx.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: fix typo in input_prop_get_value()Benjamin Tissoires1-1/+1
obviously, the function returns the value, not the name. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: move the library name to the class that loads itPeter Hutterer1-2/+3
With the goal of deprecating the evemu.const file. This is the only class that cares about the name of the lib, so define it here. Something fancier involving Makefiles and generation from base.py.in is possible, but probably more trouble than it's worth. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: hardcode the encoding in the two places we need itPeter Hutterer2-3/+2
Prep work for being able to deprecate evemu.const. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: add wrappers to get input prop names/valuesPeter Hutterer3-1/+44
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: put a warning comment for private API into the generated filePeter Hutterer1-1/+3
Inserting a tab in front of the top comment to have textwrap.dedent() work correctly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: drop an erroneous quote + parenthesisPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: update the __all__ listing for the evemu modulePeter Hutterer1-1/+4
Export the new class and the two public conversion functions. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: be forgiving about invalid event types/codes in the public APIPeter Hutterer2-3/+32
Return None if not found instead of throwing a KeyError which reveals too much of the internal implementation anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: rename _map to _type_map for better clarityPeter Hutterer1-3/+3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12python: prefix event map names with underscoresPeter Hutterer2-12/+12
Closest thing that python has to "private". These are generated and we reserve the right to modify the generation in the future, so make sure they're private by default. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-12configure.ac: add '--disable-tests' optionPeter Seiderer1-0/+3
For toolchains without c++ support add option to disable tests, because this is the only place c++ is needed (to test the c++ binding). Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Seiderer <ps.report@gmx.net> - renamed "tests" into "enable_tests" - used yes/no instead of true/false Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08python: fix path for make-event-names.pyBenjamin Tissoires1-1/+1
While applying 381080815829 (python: move make-event-names to the python directory), I made a mistake in the path. It should be read $(srcdir)/make-event-names.py without the "/src/" Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08python: allow strings as event codes/types in evemu.DevicePeter Hutterer2-0/+51
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08python: add top-level wrappers for getting code/type names and valuesPeter Hutterer1-0/+20
Rather than having those hidden in a submodule, expose them as evemu functions, with a defined behaviour and different naming for getting values vs names. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08python: fix a typoPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08python: move make-event-names to the python directoryPeter Hutterer2-2/+185
Nothing in the C code uses it anymore Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-08make-event-names: drop C header generationPeter Hutterer1-1/+1
If you're dealing with C, use libevdev. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> - edited python/evemu/Makefile.am to remove the unused arguments Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-05python: use the evemu lib to print the event descriptionPeter Hutterer1-11/+17
Instead of our manual printf format, use the library. That's a bit convoluted since evemu_write_event expects a FILE*, so we need to create a temporary file just for the str() function. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-08-05python: use the evemu_read_event wrapper to convert recordingsPeter Hutterer1-0/+13
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-07-28python: add a wrapper around evemu_read_eventPeter Hutterer3-3/+42
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-07-28python: add an extra flag to evemu.Device.__init__ to avoid uinput creationPeter Hutterer2-2/+19
If we're just reading a file for info, we don't need to create a uinput device. This means we can now use the conversion script without being root. Oh, the progress! Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-07-28python: move the generated event_names.py to the python bitsPeter Hutterer2-0/+7
The conversion script now requires manually setting PYTHONPATH unless the evemu python bits are installed systemwide, but it's not used that often anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>