def __init__(self, device):
        def add_button(control):
            setattr(self, control.name + '_control', control)
            @control.event
            def on_press():
                self.dispatch_event('on_button_press', control.name)

            @control.event
            def on_release():
                self.dispatch_event('on_button_release', control.name)
            
        self.device = device
        for control in device.get_controls():
            if control.name in ('left', 'left_hold', 'right', 'right_hold', 'up', 'down', 
                                'menu', 'select', 'menu_hold', 'select_hold'):
                add_button(control)
dataset/ETHPy150Open ardekantur/pyglet/pyglet/input/base.py/AppleRemote.__init__/original