     :size [1280 :by 720])))
 
 
-(def default-speed 0.5)
-
+;; Keys are WASD/QZ, with Shift to "strafe":
+;; W / S  -  Move forward / Move backward
+;; A / D  -  Yaw left / Yaw right
+;; Q / Z  -  Climb / Descend
+;; Shift-A / Shift D  - Move left / Move right.
 
 (def key-actions
+  ;; Checked in order as they appear here, so make sure to put keys
+  ;; with mods first.
   [[{:code KeyEvent/VK_A :mod InputEvent/SHIFT_MASK} ar-drone/left]
    [{:code KeyEvent/VK_D :mod InputEvent/SHIFT_MASK} ar-drone/right]
    [{:code KeyEvent/VK_W} ar-drone/front]


(defn find-key-action [evt actions]
  (if-let [e (some #(if (key-descriptor-matches? (first %) evt) %) actions)]
    e
    nil))


(defn make-key-controller [ui drone]
  (seesaw/listen
   ui
   :key (fn [^KeyEvent e]
          (let [id (.getID e)]
            (cond
              (= id KeyEvent/KEY_PRESSED)
              (if-let [action (find-key-action e key-actions)]
                (println action))
              (= id KeyEvent/KEY_RELEASED)
              (if-let [action (find-key-action e key-actions)]
                (println "STOPPING" action)))))))


(defn make-controller [ui drone]
  (make-key-controller ui drone))


(defn -main [& args]
  (let [ui (make-ui)
        fq (pave/make-frame-queue)
        is (io/input-stream (first args))
        decoder (video/decoder)
        drone (ar-drone/make-drone)]
    (-> ui seesaw/pack! seesaw/show!)
    (let [view (seesaw/select ui [:#video])]
      (make-controller ui drone)
      (doto
          (Thread.
           (fn []
             (loop []
               (let [image (-> fq
                               pave/pull-frame
                               decoder)]
                 (seesaw/invoke-now
                  (.drawImage (.getGraphics view) image 0 0 1280 720 view)))
               (recur))))
        (.start))
      (loop [frame (pave/read-frame is)]
        (when frame
          (pave/queue-frame fq frame)
          (Thread/sleep 30)
          (recur (pave/read-frame is)))))))

   [{:code KeyEvent/VK_A} ar-drone/counter-clockwise]
   [{:code KeyEvent/VK_D} ar-drone/clockwise]
   [{:code KeyEvent/VK_Q} ar-drone/up]
   [{:code KeyEvent/VK_Z} ar-drone/down]
   [{:code KeyEvent/VK_T} ar-drone/takeoff :continuous? false]
   [{:code KeyEvent/VK_L} ar-drone/land :continuous? false]
   [{:code KeyEvent/VK_C} #(ar-drone/command % :switch-camera :forward)
    :continuous? false]
   [{:code KeyEvent/VK_V} #(ar-drone/command % :switch-camera :down)
    :continuous? false]])


(defn key-descriptor-matches? [descriptor ^KeyEvent evt]
