code: def __get_button_events(self, state, timeval=None):
          
          changed_buttons = self.__detect_button_events(state)
          events = self.__emulate_buttons(changed_buttons, timeval)
          return events
docs: Get the button events from xinput.