# File /home/oliver/dev/powermate/PowerMate.rb, line 343 def each_event( &block ) super{|event| case event.type ## key pressed when EV_KEY if event.code == BTN_0 or event.code == BTN_MOUSE then if event.value == 1 and @btn_press_handler then @btn_pressed = true @btn_press_handler.call( event ) elsif @btn_release_handler @btn_pressed = false @btn_release_handler.call (event ) end end ## dial rotated when EV_REL if event.code == REL_DIAL or event.code == REL_X then @rotate_handler.call( event ) if @rotate_handler end ## LED status change when EV_MSC ## decode status flag # bits 0- 7: 8 bits: LED brightness # bits 8-16: 9 bits: pulsing speed modifier # bits 17-18: 2 bits: pulse table # bit 19: 1 bit : pulse whilst asleep? # bit 20: 1 bit : pulse constantly? @status.brightness = event.value & 0xff @status.speed = (event.value >> 8) & 0x1FF @status.mode = (event.value >> 17) & 0x3 @status.pulse_asleep = (event.value >> 19) & 0x1 if @status.pulse_asleep == 1 then @status.pulse_asleep = true else @status.pulse_asleep = false end @status.pulse_awake = (event.value >> 20) & 0x1 if @status.pulse_awake == 1 then @status.pulse_awake = true else @status.pulse_awake = false end @led_handler.call( @status ) if @led_handler end # when ## handle generic event handler block.call( event ) if block } end