"""\r
\r
import weakref\r
-from keyUtils import key\r
+import inputCore\r
from logHandler import log\r
\r
class Getter(object):\r
func = getattr(self, "script_%s" % scriptName, None)\r
if not func:\r
raise LookupError("No such script: %s" % func)\r
- self._gestureMap[gestureIdentifier.lower()] = func\r
+ self._gestureMap[inputCore.normalizeGestureIdentifier(gestureIdentifier)] = func\r
\r
def bindGestures(self, gestureMap):\r
"""Bind multiple input gestures to scripts.\r
#See the file COPYING for more details.\r
#Copyright (C) 2010 James Teh <jamie@jantrid.net>\r
\r
+import itertools\r
import baseObject\r
import scriptHandler\r
import queueHandler\r
#: The singleton input manager instance.\r
#: @type: L{InputManager}\r
manager = InputManager()\r
+\r
+def normalizeGestureIdentifier(identifier):\r
+ """Normalize a gesture identifier so that it matches other identifiers for the same gesture.\r
+ """\r
+ prefix, main = identifier.split(":", 1)\r
+ main = main.split("+")\r
+ # The order of all parts except the last doesn't matter as far as the user is concerned,\r
+ # but we need them to be in a determinate order so they will match other gesture identifiers.\r
+ # Rather than sorting, just use Python's set ordering.\r
+ main = "+".join(itertools.chain(frozenset(main[:-1]), main[-1:]))\r
+ return "{1}:{2}".format(prefix, main).lower()\r