Check for currenly pressed buttons. If the new state differs from the
        old state, call the appropriate button event handlers.

        To use the on_channel1_top_left, etc handlers your program would do something like:
        
        .. code:: python

            def top_left_channel_1_action(state):
                print("top left on channel 1: %s" % state)

            def bottom_right_channel_4_action(state):
                print("bottom right on channel 4: %s" % state)

            ir = InfraredSensor()
            ir.on_channel1_top_left = top_left_channel_1_action
            ir.on_channel4_bottom_right = bottom_right_channel_4_action

            while True:
                ir.process()
                time.sleep(0.01)

def process(self):
        """
        Check for currenly pressed buttons. If the new state differs from the
        old state, call the appropriate button event handlers.

        To use the on_channel1_top_left, etc handlers your program would do something like:
        
        .. code:: python

            def top_left_channel_1_action(state):
                print("top left on channel 1: %s" % state)

            def bottom_right_channel_4_action(state):
                print("bottom right on channel 4: %s" % state)

            ir = InfraredSensor()
            ir.on_channel1_top_left = top_left_channel_1_action
            ir.on_channel4_bottom_right = bottom_right_channel_4_action

            while True:
                ir.process()
                time.sleep(0.01)
        
        """
        new_state = []
        state_diff = []

        for channel in range(1,5):

            for button in self.buttons_pressed(channel):
                new_state.append((button, channel))

                # Key was not pressed before but now is pressed
                if (button, channel) not in self._state:
                    state_diff.append((button, channel))

            # Key was pressed but is no longer pressed
            for button in self._BUTTONS:
                if (button, channel) not in new_state and (button, channel) in self._state:
                    state_diff.append((button, channel))

        old_state = self._state
        self._state = new_state

        for (button, channel) in state_diff:
            handler = getattr(self, 'on_channel' + str(channel) + '_' + button )

            if handler is not None:
                handler((button, channel) in new_state)

        if self.on_change is not None and state_diff:
            self.on_change([(button, channel, button in new_state) for (button, channel) in state_diff])