--[[ @title USB-Fernbedieung V1.01 ]] STATE_IDLE = 0 STATE_IN_STEP = 1 STATE_IN_CONT = 2 STATE_OUT_STEP = 3 STATE_OUT_CONT = 4 STATE_SHOOT_HALF = 5 KEY_NOKEY = 0 KEY_LEFT = 9 KEY_RIGHT = 17 KEY_UP = 25 KEY_DOWN = 33 KEY_PLAY = 41 KEY_MENU = 49 KEY_TIMEOUT = 750 countIn = 0 countOut = 0 state = STATE_SLEEP function zoomIn() if state == STATE_OUT_CONT then release "zoom_out" state = STATE_IDLE elseif state == STATE_IN_CONT then release "zoom_in" state = STATE_IDLE else if state == STATE_SHOOT_HALF then release "shoot_half" end if state == STATE_IN_STEP then if get_tick_count()-countIn > KEY_TIMEOUT then zoomInStep() else zoomInContinue() end else zoomInStep() end end end function zoomInStep() press "zoom_in" sleep(5) release "zoom_in" state = STATE_IN_STEP countIn = get_tick_count() end function zoomInContinue() state = STATE_IN_CONT press "zoom_in" end function zoomOut() if state == STATE_IN_CONT then release "zoom_in" state = STATE_IDLE elseif state == STATE_OUT_CONT then release "zoom_out" state = STATE_IDLE else if state == STATE_SHOOT_HALF then release "shoot_half" end if state == STATE_OUT_STEP then if get_tick_count()-countOut > KEY_TIMEOUT then zoomOutStep() else zoomOutContinue() end else zoomOutStep() end end end function zoomOutStep() press "zoom_out" sleep(5) release "zoom_out" state = STATE_OUT_STEP countOut = get_tick_count() end function zoomOutContinue() state = STATE_OUT_CONT press "zoom_out" end function shootHalf() if state == STATE_OUT_CONT then release "zoom_out" state = STATE_IDLE elseif state == STATE_IN_CONT then release "zoom_in" state = STATE_IDLE elseif state == STATE_SHOOT_HALF then release "shoot_half" state = STATE_IDLE end state = STATE_SHOOT_HALF press "shoot_half" end function shootFull() if state == STATE_OUT_CONT then release "zoom_out" elseif state == STATE_IN_CONT then release "zoom_in" elseif state == STATE_SHOOT_HALF then release "shoot_half" end press "shoot_full" release "shoot_full" state = STATE_IDLE end while true do repeat a = get_usb_power() until a > KEY_NOKEY if a <= KEY_LEFT then zoomIn() elseif a <= KEY_RIGHT then zoomOut() elseif a <= KEY_UP then print("up") elseif a <= KEY_DOWN then shootHalf() elseif a <= KEY_PLAY then shootFull() elseif a <= KEY_MENU then print("menu") else print("other") end end