return command, arg\r
\r
def _handleResponse(self, command, arg):\r
- updateKeys = False\r
- executeKeys = False\r
-\r
if command == BAUM_CELL_COUNT:\r
self.numCells = ord(arg)\r
elif command == BAUM_DEVICE_ID:\r
self._deviceID = arg\r
\r
elif command in KEY_NAMES:\r
- updateKeys = True\r
arg = sum(ord(byte) << offset * 8 for offset, byte in enumerate(arg))\r
if arg < self._keysDown.get(command, 0):\r
# Release.\r
if not self._ignoreKeyReleases:\r
# The first key released executes the key combination.\r
- executeKeys = True\r
+ try:\r
+ inputCore.manager.executeGesture(InputGesture(self._keysDown))\r
+ except inputCore.NoInputGestureAction:\r
+ pass\r
+ # Any further releases are just the rest of the keys in the combination being released,\r
+ # so they should be ignored.\r
+ self._ignoreKeyReleases = True\r
else:\r
# Press.\r
# This begins a new key combination.\r
self._ignoreKeyReleases = False\r
+ self._keysDown[command] = arg\r
\r
elif command == BAUM_POWERDOWN:\r
log.debug("Power down")\r
else:\r
log.debugWarning("Unknown command {command!r}, arg {arg!r}".format(command=command, arg=arg))\r
\r
- if executeKeys:\r
- try:\r
- inputCore.manager.executeGesture(InputGesture(self._keysDown))\r
- except inputCore.NoInputGestureAction:\r
- pass\r
- # Any further releases are just the rest of the keys in the combination being released,\r
- # so they should be ignored.\r
- self._ignoreKeyReleases = True\r
- if updateKeys:\r
- # We must update key state after execution instead of before because\r
- # execution needs to include the key that was just released.\r
- self._keysDown[command] = arg\r
-\r
def display(self, cells):\r
# cells will already be padded up to numCells.\r
self._sendRequest(BAUM_DISPLAY_DATA, "".join(chr(cell) for cell in cells))\r