def get_device_names(start=0):
    """Returns a list of tuples containing (index, devicename).
    """
    names = []
    for d in range(start, 16):
        filename = "/dev/input/event%d" % (d,)
        if os.path.exists(filename):
            try:
                    fd = os.open(filename, os.O_RDWR)
                    try:
                        name = fcntl.ioctl(fd, EVIOCGNAME, chr(0) * 256)
                    finally:
                        os.close(fd)
                    name = name.replace(chr(0), '')
            except (OSError, IOError): # probably no permissions
                continue
            else:
                names.append((d, name))
    return names
dataset/ETHPy150Open kdart/pycopia/core/pycopia/OS/Linux/Input.py/get_device_names/original