Changeset 52:50bbffd99071 in xplra
- Timestamp:
- 02/16/13 13:44:12 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/python/xplra.py
r40 r52 34 34 COMMAND_SHOW_MESSAGE = 0x41 35 35 36 COMMAND_REGISTER_HOTKEYS = 0x51 37 38 COMMAND_QUERY_HOTKEYS = 0x52 39 40 COMMAND_UNREGISTER_HOTKEYS = 0x53 41 36 42 TYPE_INT = 0x01 37 43 … … 65 71 66 72 RESULT_OTHER_ERROR = 0xff 73 74 HOTKEY_MODIFIER_SHIFT = 0x0100 75 76 HOTKEY_MODIFIER_CONTROL = 0x0200 67 77 68 78 #------------------------------------------------------------------------------- … … 239 249 self._writeString(message) 240 250 self._writeFloat(duration) 251 self._flush() 252 self._checkResult() 253 254 def registerHotkeys(self, hotkeyCodes): 255 """Register the given hotkey codes for watching.""" 256 self._writeU8(COMMAND_REGISTER_HOTKEYS) 257 self._writeU32(len(hotkeyCodes)) 258 for hotkeyCode in hotkeyCodes: 259 self._writeU16(hotkeyCode) 260 self._flush() 261 self._checkResult() 262 263 def queryHotkeys(self): 264 """Query the state of the hotkeys registered previously""" 265 self._writeU8(COMMAND_QUERY_HOTKEYS) 266 self._flush() 267 self._checkResult() 268 269 length = self._readU32() 270 states = [] 271 for i in range(0, length): 272 states.append(self._readU8()) 273 274 return states 275 276 def unregisterHotkeys(self): 277 """Unregister the previously registered hotkeys.""" 278 self._writeU8(COMMAND_UNREGISTER_HOTKEYS) 241 279 self._flush() 242 280 self._checkResult() … … 334 372 """Write the given value as an unsigned, 8-bit value.""" 335 373 self._stream.write(struct.pack("B", x)) 374 375 def _writeU16(self, x): 376 """Write the given value as an unsigned, 16-bit value.""" 377 self._stream.write(struct.pack("H", x)) 336 378 337 379 def _writeS32(self, x):
Note:
See TracChangeset
for help on using the changeset viewer.