We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Probesysfs provider requires getconf
<!--
The issue tracker is a tool to address bugs.
Please use the #kivy IRC channel on freenode or Stack Overflow for
support questions, more information at https://git.io/vM1yQ.

Before opening a new issue, make sure you do the following:
    * check that your issue isn't already filed: https://git.io/vM1iE
    * prepare a short, runnable example that reproduces the issue
    * reproduce the problem with the latest development version of Kivy
    * double-check that the issue is indeed a bug and not a support request
-->

### Versions

* Python: 3.6.4
* OS: Linux
* Kivy: 1.10.0
* Kivy installation method: setuptools

### Description

Kivy's probesysfs provider requires getconf, provided by glibc, to get the platform's LONG_BIT value.

This dependency precludes the use of other C libraries, such as musl, as well as platforms that choose not to install getconf.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kivy/input/providers/probesysfs.py`
Content:
```
1 '''
2 Auto Create Input Provider Config Entry for Available MT Hardware (linux only).
3 ===============================================================================
4 
5 Thanks to Marc Tardif for the probing code, taken from scan-for-mt-device.
6 
7 The device discovery is done by this provider. However, the reading of
8 input can be performed by other providers like: hidinput, mtdev and
9 linuxwacom. mtdev is used prior to other providers. For more
10 information about mtdev, check :py:class:`~kivy.input.providers.mtdev`.
11 
12 Here is an example of auto creation::
13 
14     [input]
15     # using mtdev
16     device_%(name)s = probesysfs,provider=mtdev
17     # using hidinput
18     device_%(name)s = probesysfs,provider=hidinput
19     # using mtdev with a match on name
20     device_%(name)s = probesysfs,provider=mtdev,match=acer
21 
22     # using hidinput with custom parameters to hidinput (all on one line)
23     %(name)s = probesysfs,
24         provider=hidinput,param=min_pressure=1,param=max_pressure=99
25 
26     # you can also match your wacom touchscreen
27     touch = probesysfs,match=E3 Finger,provider=linuxwacom,
28         select_all=1,param=mode=touch
29     # and your wacom pen
30     pen = probesysfs,match=E3 Pen,provider=linuxwacom,
31         select_all=1,param=mode=pen
32 
33 By default, ProbeSysfs module will enumerate hardware from the /sys/class/input
34 device, and configure hardware with ABS_MT_POSITION_X capability. But for
35 example, the wacom screen doesn't support this capability. You can prevent this
36 behavior by putting select_all=1 in your config line. Add use_mouse=1 to also
37 include touchscreen hardware that offers core pointer functionality.
38 '''
39 
40 __all__ = ('ProbeSysfsHardwareProbe', )
41 
42 import os
43 from os.path import sep
44 
45 if 'KIVY_DOC' in os.environ:
46 
47     ProbeSysfsHardwareProbe = None
48 
49 else:
50     from re import match, IGNORECASE
51     from glob import glob
52     from subprocess import Popen, PIPE
53     from kivy.logger import Logger
54     from kivy.input.provider import MotionEventProvider
55     from kivy.input.providers.mouse import MouseMotionEventProvider
56     from kivy.input.factory import MotionEventFactory
57     from kivy.config import _is_rpi
58 
59     EventLoop = None
60 
61     # See linux/input.h
62     ABS_MT_POSITION_X = 0x35
63 
64     _cache_input = None
65     _cache_xinput = None
66 
67     class Input(object):
68 
69         def __init__(self, path):
70             query_xinput()
71             self.path = path
72 
73         @property
74         def device(self):
75             base = os.path.basename(self.path)
76             return os.path.join("/dev", "input", base)
77 
78         @property
79         def name(self):
80             path = os.path.join(self.path, "device", "name")
81             return read_line(path)
82 
83         def get_capabilities(self):
84             path = os.path.join(self.path, "device", "capabilities", "abs")
85             line = "0"
86             try:
87                 line = read_line(path)
88             except OSError:
89                 return []
90 
91             capabilities = []
92             long_bit = getconf("LONG_BIT")
93             for i, word in enumerate(line.split(" ")):
94                 word = int(word, 16)
95                 subcapabilities = [bool(word & 1 << i)
96                                    for i in range(long_bit)]
97                 capabilities[:0] = subcapabilities
98 
99             return capabilities
100 
101         def has_capability(self, capability):
102             capabilities = self.get_capabilities()
103             return len(capabilities) > capability and capabilities[capability]
104 
105         @property
106         def is_mouse(self):
107             return self.device in _cache_xinput
108 
109     def getout(*args):
110         try:
111             return Popen(args, stdout=PIPE).communicate()[0]
112         except OSError:
113             return ''
114 
115     def getconf(var):
116         output = getout("getconf", var)
117         return int(output)
118 
119     def query_xinput():
120         global _cache_xinput
121         if _cache_xinput is None:
122             _cache_xinput = []
123             devids = getout('xinput', '--list', '--id-only')
124             for did in devids.splitlines():
125                 devprops = getout('xinput', '--list-props', did)
126                 evpath = None
127                 for prop in devprops.splitlines():
128                     prop = prop.strip()
129                     if (prop.startswith(b'Device Enabled') and
130                             prop.endswith(b'0')):
131                         evpath = None
132                         break
133                     if prop.startswith(b'Device Node'):
134                         try:
135                             evpath = prop.split('"')[1]
136                         except Exception:
137                             evpath = None
138                 if evpath:
139                     _cache_xinput.append(evpath)
140 
141     def get_inputs(path):
142         global _cache_input
143         if _cache_input is None:
144             event_glob = os.path.join(path, "event*")
145             _cache_input = [Input(x) for x in glob(event_glob)]
146         return _cache_input
147 
148     def read_line(path):
149         f = open(path)
150         try:
151             return f.readline().strip()
152         finally:
153             f.close()
154 
155     class ProbeSysfsHardwareProbe(MotionEventProvider):
156 
157         def __new__(self, device, args):
158             # hack to not return an instance of this provider.
159             # :)
160             instance = super(ProbeSysfsHardwareProbe, self).__new__(self)
161             instance.__init__(device, args)
162 
163         def __init__(self, device, args):
164             super(ProbeSysfsHardwareProbe, self).__init__(device, args)
165             self.provider = 'mtdev'
166             self.match = None
167             self.input_path = '/sys/class/input'
168             self.select_all = True if _is_rpi else False
169             self.use_mouse = False
170             self.use_regex = False
171             self.args = []
172 
173             args = args.split(',')
174             for arg in args:
175                 if arg == '':
176                     continue
177                 arg = arg.split('=', 1)
178                 # ensure it's a key = value
179                 if len(arg) != 2:
180                     Logger.error('ProbeSysfs: invalid parameters %s, not'
181                                  ' key=value format' % arg)
182                     continue
183 
184                 key, value = arg
185                 if key == 'match':
186                     self.match = value
187                 elif key == 'provider':
188                     self.provider = value
189                 elif key == 'use_regex':
190                     self.use_regex = bool(int(value))
191                 elif key == 'select_all':
192                     self.select_all = bool(int(value))
193                 elif key == 'use_mouse':
194                     self.use_mouse = bool(int(value))
195                 elif key == 'param':
196                     self.args.append(value)
197                 else:
198                     Logger.error('ProbeSysfs: unknown %s option' % key)
199                     continue
200 
201             self.probe()
202 
203         def should_use_mouse(self):
204             return (self.use_mouse or
205                     not any(p for p in EventLoop.input_providers
206                             if isinstance(p, MouseMotionEventProvider)))
207 
208         def probe(self):
209             global EventLoop
210             from kivy.base import EventLoop
211 
212             inputs = get_inputs(self.input_path)
213             Logger.debug('ProbeSysfs: using probesysfs!')
214 
215             use_mouse = self.should_use_mouse()
216 
217             if not self.select_all:
218                 inputs = [x for x in inputs if
219                           x.has_capability(ABS_MT_POSITION_X) and
220                           (use_mouse or not x.is_mouse)]
221             for device in inputs:
222                 Logger.debug('ProbeSysfs: found device: %s at %s' % (
223                     device.name, device.device))
224 
225                 # must ignore ?
226                 if self.match:
227                     if self.use_regex:
228                         if not match(self.match, device.name, IGNORECASE):
229                             Logger.debug('ProbeSysfs: device not match the'
230                                          ' rule in config, ignoring.')
231                             continue
232                     else:
233                         if self.match not in device.name:
234                             continue
235 
236                 Logger.info('ProbeSysfs: device match: %s' % device.device)
237 
238                 d = device.device
239                 devicename = self.device % dict(name=d.split(sep)[-1])
240 
241                 provider = MotionEventFactory.get(self.provider)
242                 if provider is None:
243                     Logger.info('ProbeSysfs: unable to found provider %s' %
244                                 self.provider)
245                     Logger.info('ProbeSysfs: fallback on hidinput')
246                     provider = MotionEventFactory.get('hidinput')
247                 if provider is None:
248                     Logger.critical('ProbeSysfs: no input provider found'
249                                     ' to handle this device !')
250                     continue
251 
252                 instance = provider(devicename, '%s,%s' % (
253                     device.device, ','.join(self.args)))
254                 if instance:
255                     EventLoop.add_input_provider(instance)
256 
257     MotionEventFactory.register('probesysfs', ProbeSysfsHardwareProbe)
258
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kivy/input/providers/probesysfs.py b/kivy/input/providers/probesysfs.py
--- a/kivy/input/providers/probesysfs.py
+++ b/kivy/input/providers/probesysfs.py
@@ -47,6 +47,7 @@
     ProbeSysfsHardwareProbe = None
 
 else:
+    import ctypes
     from re import match, IGNORECASE
     from glob import glob
     from subprocess import Popen, PIPE
@@ -89,7 +90,7 @@
                 return []
 
             capabilities = []
-            long_bit = getconf("LONG_BIT")
+            long_bit = ctypes.sizeof(ctypes.c_long) * 8
             for i, word in enumerate(line.split(" ")):
                 word = int(word, 16)
                 subcapabilities = [bool(word & 1 << i)
@@ -112,10 +113,6 @@
         except OSError:
             return ''
 
-    def getconf(var):
-        output = getout("getconf", var)
-        return int(output)
-
     def query_xinput():
         global _cache_xinput
         if _cache_xinput is None:

{"golden_diff": "diff --git a/kivy/input/providers/probesysfs.py b/kivy/input/providers/probesysfs.py\n--- a/kivy/input/providers/probesysfs.py\n+++ b/kivy/input/providers/probesysfs.py\n@@ -47,6 +47,7 @@\n     ProbeSysfsHardwareProbe = None\n \n else:\n+    import ctypes\n     from re import match, IGNORECASE\n     from glob import glob\n     from subprocess import Popen, PIPE\n@@ -89,7 +90,7 @@\n                 return []\n \n             capabilities = []\n-            long_bit = getconf(\"LONG_BIT\")\n+            long_bit = ctypes.sizeof(ctypes.c_long) * 8\n             for i, word in enumerate(line.split(\" \")):\n                 word = int(word, 16)\n                 subcapabilities = [bool(word & 1 << i)\n@@ -112,10 +113,6 @@\n         except OSError:\n             return ''\n \n-    def getconf(var):\n-        output = getout(\"getconf\", var)\n-        return int(output)\n-\n     def query_xinput():\n         global _cache_xinput\n         if _cache_xinput is None:\n", "issue": "Probesysfs provider requires getconf\n<!--\r\nThe issue tracker is a tool to address bugs.\r\nPlease use the #kivy IRC channel on freenode or Stack Overflow for\r\nsupport questions, more information at https://git.io/vM1yQ.\r\n\r\nBefore opening a new issue, make sure you do the following:\r\n    * check that your issue isn't already filed: https://git.io/vM1iE\r\n    * prepare a short, runnable example that reproduces the issue\r\n    * reproduce the problem with the latest development version of Kivy\r\n    * double-check that the issue is indeed a bug and not a support request\r\n-->\r\n\r\n### Versions\r\n\r\n* Python: 3.6.4\r\n* OS: Linux\r\n* Kivy: 1.10.0\r\n* Kivy installation method: setuptools\r\n\r\n### Description\r\n\r\nKivy's probesysfs provider requires getconf, provided by glibc, to get the platform's LONG_BIT value.\r\n\r\nThis dependency precludes the use of other C libraries, such as musl, as well as platforms that choose not to install getconf.\r\n\n", "before_files": [{"content": "'''\nAuto Create Input Provider Config Entry for Available MT Hardware (linux only).\n===============================================================================\n\nThanks to Marc Tardif for the probing code, taken from scan-for-mt-device.\n\nThe device discovery is done by this provider. However, the reading of\ninput can be performed by other providers like: hidinput, mtdev and\nlinuxwacom. mtdev is used prior to other providers. For more\ninformation about mtdev, check :py:class:`~kivy.input.providers.mtdev`.\n\nHere is an example of auto creation::\n\n    [input]\n    # using mtdev\n    device_%(name)s = probesysfs,provider=mtdev\n    # using hidinput\n    device_%(name)s = probesysfs,provider=hidinput\n    # using mtdev with a match on name\n    device_%(name)s = probesysfs,provider=mtdev,match=acer\n\n    # using hidinput with custom parameters to hidinput (all on one line)\n    %(name)s = probesysfs,\n        provider=hidinput,param=min_pressure=1,param=max_pressure=99\n\n    # you can also match your wacom touchscreen\n    touch = probesysfs,match=E3 Finger,provider=linuxwacom,\n        select_all=1,param=mode=touch\n    # and your wacom pen\n    pen = probesysfs,match=E3 Pen,provider=linuxwacom,\n        select_all=1,param=mode=pen\n\nBy default, ProbeSysfs module will enumerate hardware from the /sys/class/input\ndevice, and configure hardware with ABS_MT_POSITION_X capability. But for\nexample, the wacom screen doesn't support this capability. You can prevent this\nbehavior by putting select_all=1 in your config line. Add use_mouse=1 to also\ninclude touchscreen hardware that offers core pointer functionality.\n'''\n\n__all__ = ('ProbeSysfsHardwareProbe', )\n\nimport os\nfrom os.path import sep\n\nif 'KIVY_DOC' in os.environ:\n\n    ProbeSysfsHardwareProbe = None\n\nelse:\n    from re import match, IGNORECASE\n    from glob import glob\n    from subprocess import Popen, PIPE\n    from kivy.logger import Logger\n    from kivy.input.provider import MotionEventProvider\n    from kivy.input.providers.mouse import MouseMotionEventProvider\n    from kivy.input.factory import MotionEventFactory\n    from kivy.config import _is_rpi\n\n    EventLoop = None\n\n    # See linux/input.h\n    ABS_MT_POSITION_X = 0x35\n\n    _cache_input = None\n    _cache_xinput = None\n\n    class Input(object):\n\n        def __init__(self, path):\n            query_xinput()\n            self.path = path\n\n        @property\n        def device(self):\n            base = os.path.basename(self.path)\n            return os.path.join(\"/dev\", \"input\", base)\n\n        @property\n        def name(self):\n            path = os.path.join(self.path, \"device\", \"name\")\n            return read_line(path)\n\n        def get_capabilities(self):\n            path = os.path.join(self.path, \"device\", \"capabilities\", \"abs\")\n            line = \"0\"\n            try:\n                line = read_line(path)\n            except OSError:\n                return []\n\n            capabilities = []\n            long_bit = getconf(\"LONG_BIT\")\n            for i, word in enumerate(line.split(\" \")):\n                word = int(word, 16)\n                subcapabilities = [bool(word & 1 << i)\n                                   for i in range(long_bit)]\n                capabilities[:0] = subcapabilities\n\n            return capabilities\n\n        def has_capability(self, capability):\n            capabilities = self.get_capabilities()\n            return len(capabilities) > capability and capabilities[capability]\n\n        @property\n        def is_mouse(self):\n            return self.device in _cache_xinput\n\n    def getout(*args):\n        try:\n            return Popen(args, stdout=PIPE).communicate()[0]\n        except OSError:\n            return ''\n\n    def getconf(var):\n        output = getout(\"getconf\", var)\n        return int(output)\n\n    def query_xinput():\n        global _cache_xinput\n        if _cache_xinput is None:\n            _cache_xinput = []\n            devids = getout('xinput', '--list', '--id-only')\n            for did in devids.splitlines():\n                devprops = getout('xinput', '--list-props', did)\n                evpath = None\n                for prop in devprops.splitlines():\n                    prop = prop.strip()\n                    if (prop.startswith(b'Device Enabled') and\n                            prop.endswith(b'0')):\n                        evpath = None\n                        break\n                    if prop.startswith(b'Device Node'):\n                        try:\n                            evpath = prop.split('\"')[1]\n                        except Exception:\n                            evpath = None\n                if evpath:\n                    _cache_xinput.append(evpath)\n\n    def get_inputs(path):\n        global _cache_input\n        if _cache_input is None:\n            event_glob = os.path.join(path, \"event*\")\n            _cache_input = [Input(x) for x in glob(event_glob)]\n        return _cache_input\n\n    def read_line(path):\n        f = open(path)\n        try:\n            return f.readline().strip()\n        finally:\n            f.close()\n\n    class ProbeSysfsHardwareProbe(MotionEventProvider):\n\n        def __new__(self, device, args):\n            # hack to not return an instance of this provider.\n            # :)\n            instance = super(ProbeSysfsHardwareProbe, self).__new__(self)\n            instance.__init__(device, args)\n\n        def __init__(self, device, args):\n            super(ProbeSysfsHardwareProbe, self).__init__(device, args)\n            self.provider = 'mtdev'\n            self.match = None\n            self.input_path = '/sys/class/input'\n            self.select_all = True if _is_rpi else False\n            self.use_mouse = False\n            self.use_regex = False\n            self.args = []\n\n            args = args.split(',')\n            for arg in args:\n                if arg == '':\n                    continue\n                arg = arg.split('=', 1)\n                # ensure it's a key = value\n                if len(arg) != 2:\n                    Logger.error('ProbeSysfs: invalid parameters %s, not'\n                                 ' key=value format' % arg)\n                    continue\n\n                key, value = arg\n                if key == 'match':\n                    self.match = value\n                elif key == 'provider':\n                    self.provider = value\n                elif key == 'use_regex':\n                    self.use_regex = bool(int(value))\n                elif key == 'select_all':\n                    self.select_all = bool(int(value))\n                elif key == 'use_mouse':\n                    self.use_mouse = bool(int(value))\n                elif key == 'param':\n                    self.args.append(value)\n                else:\n                    Logger.error('ProbeSysfs: unknown %s option' % key)\n                    continue\n\n            self.probe()\n\n        def should_use_mouse(self):\n            return (self.use_mouse or\n                    not any(p for p in EventLoop.input_providers\n                            if isinstance(p, MouseMotionEventProvider)))\n\n        def probe(self):\n            global EventLoop\n            from kivy.base import EventLoop\n\n            inputs = get_inputs(self.input_path)\n            Logger.debug('ProbeSysfs: using probesysfs!')\n\n            use_mouse = self.should_use_mouse()\n\n            if not self.select_all:\n                inputs = [x for x in inputs if\n                          x.has_capability(ABS_MT_POSITION_X) and\n                          (use_mouse or not x.is_mouse)]\n            for device in inputs:\n                Logger.debug('ProbeSysfs: found device: %s at %s' % (\n                    device.name, device.device))\n\n                # must ignore ?\n                if self.match:\n                    if self.use_regex:\n                        if not match(self.match, device.name, IGNORECASE):\n                            Logger.debug('ProbeSysfs: device not match the'\n                                         ' rule in config, ignoring.')\n                            continue\n                    else:\n                        if self.match not in device.name:\n                            continue\n\n                Logger.info('ProbeSysfs: device match: %s' % device.device)\n\n                d = device.device\n                devicename = self.device % dict(name=d.split(sep)[-1])\n\n                provider = MotionEventFactory.get(self.provider)\n                if provider is None:\n                    Logger.info('ProbeSysfs: unable to found provider %s' %\n                                self.provider)\n                    Logger.info('ProbeSysfs: fallback on hidinput')\n                    provider = MotionEventFactory.get('hidinput')\n                if provider is None:\n                    Logger.critical('ProbeSysfs: no input provider found'\n                                    ' to handle this device !')\n                    continue\n\n                instance = provider(devicename, '%s,%s' % (\n                    device.device, ','.join(self.args)))\n                if instance:\n                    EventLoop.add_input_provider(instance)\n\n    MotionEventFactory.register('probesysfs', ProbeSysfsHardwareProbe)\n", "path": "kivy/input/providers/probesysfs.py"}], "after_files": [{"content": "'''\nAuto Create Input Provider Config Entry for Available MT Hardware (linux only).\n===============================================================================\n\nThanks to Marc Tardif for the probing code, taken from scan-for-mt-device.\n\nThe device discovery is done by this provider. However, the reading of\ninput can be performed by other providers like: hidinput, mtdev and\nlinuxwacom. mtdev is used prior to other providers. For more\ninformation about mtdev, check :py:class:`~kivy.input.providers.mtdev`.\n\nHere is an example of auto creation::\n\n    [input]\n    # using mtdev\n    device_%(name)s = probesysfs,provider=mtdev\n    # using hidinput\n    device_%(name)s = probesysfs,provider=hidinput\n    # using mtdev with a match on name\n    device_%(name)s = probesysfs,provider=mtdev,match=acer\n\n    # using hidinput with custom parameters to hidinput (all on one line)\n    %(name)s = probesysfs,\n        provider=hidinput,param=min_pressure=1,param=max_pressure=99\n\n    # you can also match your wacom touchscreen\n    touch = probesysfs,match=E3 Finger,provider=linuxwacom,\n        select_all=1,param=mode=touch\n    # and your wacom pen\n    pen = probesysfs,match=E3 Pen,provider=linuxwacom,\n        select_all=1,param=mode=pen\n\nBy default, ProbeSysfs module will enumerate hardware from the /sys/class/input\ndevice, and configure hardware with ABS_MT_POSITION_X capability. But for\nexample, the wacom screen doesn't support this capability. You can prevent this\nbehavior by putting select_all=1 in your config line. Add use_mouse=1 to also\ninclude touchscreen hardware that offers core pointer functionality.\n'''\n\n__all__ = ('ProbeSysfsHardwareProbe', )\n\nimport os\nfrom os.path import sep\n\nif 'KIVY_DOC' in os.environ:\n\n    ProbeSysfsHardwareProbe = None\n\nelse:\n    import ctypes\n    from re import match, IGNORECASE\n    from glob import glob\n    from subprocess import Popen, PIPE\n    from kivy.logger import Logger\n    from kivy.input.provider import MotionEventProvider\n    from kivy.input.providers.mouse import MouseMotionEventProvider\n    from kivy.input.factory import MotionEventFactory\n    from kivy.config import _is_rpi\n\n    EventLoop = None\n\n    # See linux/input.h\n    ABS_MT_POSITION_X = 0x35\n\n    _cache_input = None\n    _cache_xinput = None\n\n    class Input(object):\n\n        def __init__(self, path):\n            query_xinput()\n            self.path = path\n\n        @property\n        def device(self):\n            base = os.path.basename(self.path)\n            return os.path.join(\"/dev\", \"input\", base)\n\n        @property\n        def name(self):\n            path = os.path.join(self.path, \"device\", \"name\")\n            return read_line(path)\n\n        def get_capabilities(self):\n            path = os.path.join(self.path, \"device\", \"capabilities\", \"abs\")\n            line = \"0\"\n            try:\n                line = read_line(path)\n            except OSError:\n                return []\n\n            capabilities = []\n            long_bit = ctypes.sizeof(ctypes.c_long) * 8\n            for i, word in enumerate(line.split(\" \")):\n                word = int(word, 16)\n                subcapabilities = [bool(word & 1 << i)\n                                   for i in range(long_bit)]\n                capabilities[:0] = subcapabilities\n\n            return capabilities\n\n        def has_capability(self, capability):\n            capabilities = self.get_capabilities()\n            return len(capabilities) > capability and capabilities[capability]\n\n        @property\n        def is_mouse(self):\n            return self.device in _cache_xinput\n\n    def getout(*args):\n        try:\n            return Popen(args, stdout=PIPE).communicate()[0]\n        except OSError:\n            return ''\n\n    def query_xinput():\n        global _cache_xinput\n        if _cache_xinput is None:\n            _cache_xinput = []\n            devids = getout('xinput', '--list', '--id-only')\n            for did in devids.splitlines():\n                devprops = getout('xinput', '--list-props', did)\n                evpath = None\n                for prop in devprops.splitlines():\n                    prop = prop.strip()\n                    if (prop.startswith(b'Device Enabled') and\n                            prop.endswith(b'0')):\n                        evpath = None\n                        break\n                    if prop.startswith(b'Device Node'):\n                        try:\n                            evpath = prop.split('\"')[1]\n                        except Exception:\n                            evpath = None\n                if evpath:\n                    _cache_xinput.append(evpath)\n\n    def get_inputs(path):\n        global _cache_input\n        if _cache_input is None:\n            event_glob = os.path.join(path, \"event*\")\n            _cache_input = [Input(x) for x in glob(event_glob)]\n        return _cache_input\n\n    def read_line(path):\n        f = open(path)\n        try:\n            return f.readline().strip()\n        finally:\n            f.close()\n\n    class ProbeSysfsHardwareProbe(MotionEventProvider):\n\n        def __new__(self, device, args):\n            # hack to not return an instance of this provider.\n            # :)\n            instance = super(ProbeSysfsHardwareProbe, self).__new__(self)\n            instance.__init__(device, args)\n\n        def __init__(self, device, args):\n            super(ProbeSysfsHardwareProbe, self).__init__(device, args)\n            self.provider = 'mtdev'\n            self.match = None\n            self.input_path = '/sys/class/input'\n            self.select_all = True if _is_rpi else False\n            self.use_mouse = False\n            self.use_regex = False\n            self.args = []\n\n            args = args.split(',')\n            for arg in args:\n                if arg == '':\n                    continue\n                arg = arg.split('=', 1)\n                # ensure it's a key = value\n                if len(arg) != 2:\n                    Logger.error('ProbeSysfs: invalid parameters %s, not'\n                                 ' key=value format' % arg)\n                    continue\n\n                key, value = arg\n                if key == 'match':\n                    self.match = value\n                elif key == 'provider':\n                    self.provider = value\n                elif key == 'use_regex':\n                    self.use_regex = bool(int(value))\n                elif key == 'select_all':\n                    self.select_all = bool(int(value))\n                elif key == 'use_mouse':\n                    self.use_mouse = bool(int(value))\n                elif key == 'param':\n                    self.args.append(value)\n                else:\n                    Logger.error('ProbeSysfs: unknown %s option' % key)\n                    continue\n\n            self.probe()\n\n        def should_use_mouse(self):\n            return (self.use_mouse or\n                    not any(p for p in EventLoop.input_providers\n                            if isinstance(p, MouseMotionEventProvider)))\n\n        def probe(self):\n            global EventLoop\n            from kivy.base import EventLoop\n\n            inputs = get_inputs(self.input_path)\n            Logger.debug('ProbeSysfs: using probesysfs!')\n\n            use_mouse = self.should_use_mouse()\n\n            if not self.select_all:\n                inputs = [x for x in inputs if\n                          x.has_capability(ABS_MT_POSITION_X) and\n                          (use_mouse or not x.is_mouse)]\n            for device in inputs:\n                Logger.debug('ProbeSysfs: found device: %s at %s' % (\n                    device.name, device.device))\n\n                # must ignore ?\n                if self.match:\n                    if self.use_regex:\n                        if not match(self.match, device.name, IGNORECASE):\n                            Logger.debug('ProbeSysfs: device not match the'\n                                         ' rule in config, ignoring.')\n                            continue\n                    else:\n                        if self.match not in device.name:\n                            continue\n\n                Logger.info('ProbeSysfs: device match: %s' % device.device)\n\n                d = device.device\n                devicename = self.device % dict(name=d.split(sep)[-1])\n\n                provider = MotionEventFactory.get(self.provider)\n                if provider is None:\n                    Logger.info('ProbeSysfs: unable to found provider %s' %\n                                self.provider)\n                    Logger.info('ProbeSysfs: fallback on hidinput')\n                    provider = MotionEventFactory.get('hidinput')\n                if provider is None:\n                    Logger.critical('ProbeSysfs: no input provider found'\n                                    ' to handle this device !')\n                    continue\n\n                instance = provider(devicename, '%s,%s' % (\n                    device.device, ','.join(self.args)))\n                if instance:\n                    EventLoop.add_input_provider(instance)\n\n    MotionEventFactory.register('probesysfs', ProbeSysfsHardwareProbe)\n", "path": "kivy/input/providers/probesysfs.py"}]}