示例#1
0
    def _syncDeviceState(self):
        """
        An optimized iohub server request that receives all device state and
        event information in one response.

        :return: None
        """
        kb_state = self.getCurrentDeviceState()
        self._reporting = kb_state.get('reporting_events')
        self._modifiers = KeyboardConstants._modifierCodes2Labels(
            kb_state.get('modifiers', 0))

        pressed_keys = kb_state.get('pressed_keys')
        self._pressed_keys.clear()
        for keyid, (key_array, repeatcount) in pressed_keys.items():
            self._pressed_keys[key_array[KeyboardEvent._attrib_index['key']]]\
                = \
                key_array[DeviceEvent.EVENT_HUB_TIME_INDEX]

        for etype, event_arrays in kb_state.get('events').items():
            self._events.setdefault(etype, deque(
                maxlen=self._event_buffer_length)).extend(
                [self._type2class[etype](e) for e in event_arrays])
示例#2
0
 def __init__(self, ioe_array):
     super(KeyboardEvent, self).__init__(ioe_array)
     self._key = ioe_array[KeyboardEvent._attrib_index['key']]
     self._char = ioe_array[KeyboardEvent._attrib_index['char']]
     self._modifiers = KeyboardConstants._modifierCodes2Labels(
         ioe_array[KeyboardEvent._attrib_index['modifiers']])
示例#3
0
 def __init__(self, ioe_array):
     super(KeyboardEvent, self).__init__(ioe_array)
     self._key = ioe_array[KeyboardEvent._attrib_index['key']]
     self._char = ioe_array[KeyboardEvent._attrib_index['char']]
     self._modifiers = KeyboardConstants._modifierCodes2Labels(
         ioe_array[KeyboardEvent._attrib_index['modifiers']])