Permalink
Browse files

Delete content and redirec to new home.

  • Loading branch information...
1 parent f5f85ec commit d60b4d789c6205c3a3235732cf0ea983a0bbbe80 @candera committed Jun 14, 2012
View
@@ -1,10 +0,0 @@
-*.suo
-*~
-/obj
-/bin
-*.user
-/.lein-deps-sum
-/.lein-failures
-/lib
-/classes
-/target
View
@@ -0,0 +1,3 @@
+# This project has moved
+
+New home: https://github.com/candera/khordr
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
123 notes.org
@@ -1,123 +0,0 @@
-* Notes
-** What I should work on next
-- Make the existing tests pass
-** What I should work on after that
-- Make sure we're handling the case of two equivalent modifier aliases
- being pressed at the same time
-- Get the main loop of the app working
-** Thoughts on how to implement
-Right now, the app is written to have a giant switch statement, in the
-form of a core.match expression. But I think I might be able to clean
-it up a lot. The key observation is that for modifier aliases, you
-don't actually have to wait until all of the modifiers have been
-pressed. When a modifier alias goes down, it is undecided, but it can
-be decided as a modifier at the very next key press, even if the next
-press is a different modifier alias. And you can even send the aliased
-modifier down event right away.
-
-So instead of the current behavior, which is this:
-
-[:j :dn] => []
-[:j :dn :k :dn] => []
-[:j :dn :k :dn :x :dn] => [:rshift :dn :rcontrol :dn :x :dn]
-
-You'd get this:
-
-[:j :dn] => []
-[:j :dn :k :dn] => [:rshift :dn]
-[:j :dn :k :dn :x :dn] => [:rshift :dn :rcontrol :dn :x :dn]
-
-Further, I think you might be able to structure the code much better.
-I think you could define an IKeyHandler protocol that consists of
-self-down, self-up, other-down, and other-up functions. An instance of
-a record would be kept in an ordered list for every key that was down,
-in the order they were pressed. Every key pressed would be passed to
-all the handlers, in order, either to the self methods (if the handler
-was associated with the key that was pressed) or to the other methods
-(if not).
-
-So initially we'd have two implementations of the protocol:
-RegularKeyHandler and ModifierAliasKeyHandler. RegularKeyHandler would
-have a pretty simple implementation, as it would simply pass through
-self events, and do nothing at all with other events.
-ModifierAliasKeyHandler would, at self-down, go into an undecided
-state. If an other-down happened before a self-up, then it could
-transition to a decided state, and send its aliased down event.
-
-And after further thought, I wonder whether there might not be a
-better way. The responsibilities would be split between the app and
-key handlers. The app would be responsible for knowing which keys are
-down and which are up. These would be maintained in an ordered list,
-with the keys that went down first being first. Each key would have an
-associated handler (perhaps an implementation of the IKeyHandler
-protocol), a new instance of which would be created for each key that
-goes down. IKeyHandler/process would be called for each key press,
-including the one that corresponds to the creation of the handler. The
-method would accept the key event and would return a map. The map
-would have the following keys:
-
-| :handler | a new handler object to represent the updated state of this handler. Returning nil would remove the handler from the handler list. |
-| :continue | false if no further handlers should be called; true to continue processing. |
-| :events | a vector of key events to generate. Events from all handlers will be concatenated. |
-
-So the application's job would be to watch for key events. When a key
-goes from up to down, a new handler would be instantiated and added to
-the handler list. For all key events, process would be called and the
-result examined. The handler would be updated based on the value
-of :handler, events from :events would be accumulated, and processing
-would continue or not based on the value of :continue.
-
-There are at least three implementations of IKeyHandler: one for
-regular keys, one for modifiers alias, and one for special action
-keys.
-
-The regular key handler would be very simple. It would return a map
-whose :handler was itself unless the key was going up, in which
-case :handler would be nil. :continue would always be true. :events
-would simply be whatever event was being handled if it was for the
-self key, and nil otherwise.
-
-The modifier alias handler would initially send no keys and continue
-processing. On the next non-self key down event it saw, it would send
-the modifier and enter a decided state, unless the next event was self
-up, in which case it would send self down, self up and remove itself
-from the handler list. Once decided, it would always send the modifier
-for self down events and remove itself on self up.
-
-The special action handler would be for things like quitting the
-application or suspending key processing. For this we'd probably need
-to modify :events to be something more like :commands. Then it could
-be a sequence of tuples like [:keys [:a :dn :a :up] :suspend
-true :mouse [:left 200]].
-
-How do we leverage multimethods or protocols to make all this work? It
-seems like we ought to be able to dispatch off of the key to look up
-the key handler, although perhaps all we need there is a record class,
-so we can call new on it, passing the key as an argument.
-
-Maybe what we have is a map, like this:
-
-#+begin_src clojure
- {:j [->ModifierAliasHandler :rshift]
- :q [->SpecialActionHandler]}
-#+end_src
-
-That is, a map that associates keys with a tuple whose first element
-is a function that returns an implementation of IKeyHandler given a
-key and any other elements of the tuple. Failing an entry, an instance
-of DefaultHandler is used.
-
-*** Questions
-**** How to send events?
-Maybe we'd pass a function to self/other-up/down that could be called
-to transmit events.
-**** Do we need the ability to suppress further processing?
-For example, if I add macros, I might need a way to prevent
-[:q :dn :z :dn] from having the :z event transmit anything. Or maybe
-this implies that the handler associated with a key can be changed as
-a result of some other key going down, so that holding down :q results
-in no other key transmitting itself.
-**** Do we really need to have the self/other and up/down split?
-Would it make more sense to just have one method on the protocol that
-handles everything? Or would we wind up doing having a bunch of
-conditional processing in every implementation?
View
@@ -1,17 +0,0 @@
-(defproject kchordr "1.0.0-SNAPSHOT"
- :description "FIXME: write description"
- :dependencies [[org.clojure/clojure "1.4.0"]
- [org.clojure/core.match "0.2.0-alpha9"]
- [net.java.dev.jna/jna "3.4.0"]
- [com.nativelibs4java/jnaerator-runtime "0.9.10-SNAPSHOT"]
- ;;[kchordr/interception "1.0.0"]
- ]
- :plugins [[lein-swank "1.4.4"]]
- :source-paths ["src/clj"]
- ;; Use one of the two following, depending on whether you want
- ;; source or jar dependency
- :java-source-paths ["src/java"]
- :repositories {"local" "file:repo"
- "sonatype" "http://oss.sonatype.org/content/repositories/releases"
- "nativelibs4java-repo" "http://nativelibs4java.sourceforge.net/maven"}
- :jvm-opts ["-Djna.library.path=ext"])
Binary file not shown.
@@ -1 +0,0 @@
-9721d5ceefde06076a74cd563eac06b6f0bfdf02 *interception-1.0.0.jar
View
@@ -1,199 +0,0 @@
-;; IntPtr context;
-
-;; int device;
-;; Interception.Stroke stroke = new Interception.Stroke();
-
-;; context = Interception.CreateContext();
-(System/setProperty "jna.library.path" "ext")
-(import 'interception.InterceptionLibrary)
-(let [ctx (.interception_create_context InterceptionLibrary/INSTANCE)]
- (try
- (.interception_set_filter
- InterceptionLibrary/INSTANCE
- ctx
- (reify interception.InterceptionLibrary$InterceptionPredicate
- (apply [_ device]
- (.interception_is_keyboard InterceptionLibrary/INSTANCE device)))
- (short -1))
-
- (dotimes [n 50]
- (let [device (.interception_wait InterceptionLibrary/INSTANCE ctx)
- stroke (interception.InterceptionKeyStroke$ByReference.)
- received (.interception_receive
- InterceptionLibrary/INSTANCE
- ctx
- device
- stroke
- 1)]
-
- (when (< 0 received)
- (println "received:" received (.code stroke) (.state stroke))
- ;; (when (= 0x15 (.code stroke))
- ;; (set! (.code stroke) 0x2d))
- (.interception_send InterceptionLibrary/INSTANCE ctx device stroke 1)
- ;; If it's a y, send an additional x
- (when (= 0x15 (.code stroke))
- (set! (.code stroke) 0x2d)
- (.interception_send InterceptionLibrary/INSTANCE ctx device stroke 1))
- ;; // Hitting escape terminates the program
- ;; if (stroke.key.code == ScanCode.Escape)
- (if (= 0x01 (.code stroke))
- (println "quitting")
- ;(recur)
- ))))
- (finally
- (.interception_destroy_context InterceptionLibrary/INSTANCE ctx))))
-
-
-;; {
-;; break;
-;; }
-;; }
-
-;; Interception.DestroyContext(context);
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(System/setProperty "jna.library.path" "ext")
-
-(interception.TestLibrary/INSTANCE)
-(import interception.TestLibrary)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(require :reload 'kchordr.core)
-(in-ns 'kchordr.core)
-
-(process (state default-key-behaviors) (->event :q :dn))
-
-(def jdn (process (state default-key-behaviors) (->event :j :dn)))
-
-(handle-deciding-regular-press jdn :q)
-
-(process jdn (->event :j :up))
-(process jdn (->event :q :dn))
-jdn
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(map #(apply ->event %) [[:b :dn] [:b :up]])
-
-(->event :b :dn)
-
-(update-in {:to-send []} [:to-send] append (->event :x :up))
-
-(append [(->event :x :up)] (->event :x :dn))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-evt: {:key :j :direction :dn}
-
-state:
-{:to-send [evt evt evt]
- :keystate {:j :undecided, :k :right-control}}
-
-process: state, evt -> state
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(undecided-modifier-downs jdn)
-
-(get-in jdn [:behaviors :q])
-(modifier-alias? nil)
-
-(undecided-modifier? (:keystate jdn))
-
-(regular-key? jdn :j)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(require :reload 'kchordr.core)
-(decide-modifiers jdn)
-(clojure.repl/doc decide-modifier)
-
-(decide-modifier jdn [:j :undecided])
-
-(reduce println jdn (:keystate state))
-
-(concat (:to-send jdn) (undecided-modifier-downs jdn) [(->event :q :dn)])
-
-(clojure.pprint/pprint (process jdn (->event :q :dn)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; Working! The only weirdness is around printscreen and pause, which
-;; both generate multiple keypresses. Since I don't care about those
-;; at the moment, I'm not going to bother with them.
-(defn handle-event [event]
- (let [{:keys [key direction]} event]
- (println "received" key direction)
- (not (or (= key 1) (= key :esc)))))
-
-(System/setProperty "jna.library.path" "ext")
-(require :reload-all 'kchordr.core)
-(kchordr.core/intercept #'handle-event)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(handle-keys (base-state {}) {:key :a :direction :dn})
-
-(def state (base-state {}))
-(def state (update-key-positions state :a :dn))
-(def state (maybe-add-handler (base-state {}) :a :dn))
-(process (first (:handlers state)) :a :dn)
-(def results (map #(process % :a :dn) (:handlers state)))
-(def results (take-while :continue results))
-(filter identity (map :handler results))
-(mapcat :effects results)
-state
-
-handle-keys
-
-(let [_ (println "--------------------")
- state (base-state {})
- event {:key :a :direction :dn}
- {:keys [key direction]} event
- _ (println "With update-key-positions: " state)
- state (maybe-add-handler state key direction)
- _ (println "Key direction: " key direction)
- state (update-key-positions state key direction)
- _ (println "With maybe-add-handler state:" state)
- ;; Walk the handler chain, dealing with the results at each step
- results (map #(process % key direction) (:handlers state))
- results (take-while :continue results)]
- (assoc state
- :handlers (filter identity (map :handler results))
- :effects (mapcat :effects results)))
-
-(maybe-add-handler {:handlers [] :positions {:a :dn}} :a :dn)
-
-(is-down? (base-state {}) :a)
-
-(update-in {:handlers [] :positions {:a :dn}} [:handlers] concat [:foo])
-
-(class (update-key-positions (base-state {}) :a :dn))
-(class (base-state {}))
-
-default-key-behaviors
-
-(base-state default-key-behaviors)
-
-(map (juxt :key :direction)) (:effects (handle-keys (base-state default-key-behaviors) {:key :b :direction :dn}))
-
-;; [[:j :dn] [:x :dn] [:x :up] [:j :up]]
-
-(-> (base-state default-key-behaviors)
- (handle-keys (->event :j :dn))
- (handle-keys (->event :x :dn))
- (handle-keys (->event :x :up))
- #_(handle-keys (->event :j :up)))
-
-(def state (-> (base-state default-key-behaviors)
- (handle-keys (->event :j :dn))))
-
-state
-(def h (first (:handlers state)))
-h
-(def results (map #(process % :j :up) [h]))
-results
-(satisfies? IKeyHandler h)
Oops, something went wrong.

0 comments on commit d60b4d7

Please sign in to comment.