 (def ^:const snes-product-id 0xd015)
 
 
+(def ^:private snes-buttons
+  {:X      [3 0]
+   :A      [3 1]
+   :B      [3 2]
+   :Y      [3 3]
+   :L      [3 4]
+   :R      [3 5]
+   :select [4 0]
+   :start  [4 1]})
+
+
 (defn- snes-read-state
   "SNES controller state is read 8 bytes at a time:
     byte 0: x-axis [00 7F FF] (FF is right)

      :else (inc value))
    (/ 128.0)
    (- 1.0)))


(defn- button-events

  (if (< len 8)
    (println "Incomplete data read from SNES controller:"
             (apply str (map (partial format "%02X") (take len buffer))))
    (assoc
      (read-buttons snes-buttons buffer)
      :x-axis (byte-axis (aget buffer 0))
      :y-axis (- (byte-axis (aget buffer 1))))))


(defn- snes-state-events
