Beispiel #1
0
    def test_has_event(self):
        l = Libevdev(self.fd)
        self.assertTrue(l.has_event("EV_SYN", "SYN_REPORT"))

        type_supported = -1
        for i in range(1, 5):
            if l.has_event(i):
                type_supported = i
                break

        self.assertGreater(type_supported, 0)

        codes_supported = 0
        for i in range(150):
            if l.has_event(type_supported, i):
                codes_supported += 1

        self.assertGreater(codes_supported, 0)
Beispiel #2
0
    def setUp(self):
        want_fd = None
        for i in range(20):
            try:
                fd = open("/dev/input/event{}".format(i), "rb")
                l = Libevdev(fd)
                if l.has_event("EV_ABS", "ABS_Y"):
                    want_fd = fd
                    break
                fd.close()
            except IOError:
                # Not all eventX nodes are guaranteed to exist
                pass

        self.assertIsNotNone(want_fd)
        self.fd = want_fd
Beispiel #3
0
    def test_enable_event_code(self):
        l = Libevdev(self.fd)

        self.assertFalse(l.has_event("EV_REL", "REL_RY"))
        l.enable("EV_REL", "REL_RY")
        self.assertTrue(l.has_event("EV_REL", "REL_RY"))
        l.disable("EV_REL", "REL_RY")
        self.assertFalse(l.has_event("EV_REL", "REL_RY"))

        data = {"minimum": 100,
                "maximum": 200,
                "value": 300,
                "fuzz": 400,
                "flat": 500,
                "resolution": 600}
        self.assertFalse(l.has_event("EV_ABS", "ABS_RY"))
        l.enable("EV_ABS", "ABS_RY", data)
        self.assertTrue(l.has_event("EV_ABS", "ABS_RY"))
        l.disable("EV_ABS", "ABS_RY")
        self.assertFalse(l.has_event("EV_ABS", "ABS_RY"))