]> gitweb.factorcode.org Git - factor.git/commitdiff
rename game.input.linux to game.input.x11, make x>hid-bit-order a hook on system
authorJoe Groff <arcata@gmail.com>
Sat, 27 Feb 2010 02:30:51 +0000 (18:30 -0800)
committerJoe Groff <arcata@gmail.com>
Sat, 27 Feb 2010 02:30:51 +0000 (18:30 -0800)
basis/game/input/input.factor
basis/game/input/linux/authors.txt [deleted file]
basis/game/input/linux/linux.factor [deleted file]
basis/game/input/linux/platforms.txt [deleted file]
basis/game/input/linux/summary.txt [deleted file]
basis/game/input/linux/tags.txt [deleted file]
basis/game/input/x11/authors.txt [new file with mode: 0644]
basis/game/input/x11/platforms.txt [new file with mode: 0644]
basis/game/input/x11/summary.txt [new file with mode: 0644]
basis/game/input/x11/tags.txt [new file with mode: 0644]
basis/game/input/x11/x11.factor [new file with mode: 0644]

index f27e1f36d12122c80367aabaa08383caf0bc3ba7..9b514e77e0c853632791354438738343093a971e 100644 (file)
@@ -108,6 +108,6 @@ SYMBOLS: pressed released ;
 {
     { [ os windows? ] [ "game.input.xinput" require ] }
     { [ os macosx? ] [ "game.input.iokit" require ] }
-    { [ os linux? ] [ "game.input.linux" require ] }
+    { [ os linux? ] [ "game.input.x11" require ] }
     [ ]
 } cond
diff --git a/basis/game/input/linux/authors.txt b/basis/game/input/linux/authors.txt
deleted file mode 100644 (file)
index d73be90..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Erik Charlebois
-William Schlieper
diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor
deleted file mode 100644 (file)
index cd482ae..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-! Copyright (C) 2010 Erik Charlebois, William Schlieper.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax arrays kernel game.input namespaces
-classes bit-arrays sequences vectors x11 x11.xlib ;
-IN: game.input.linux
-
-LIBRARY: xlib
-FUNCTION: int XQueryKeymap ( Display* display, char[32] keys_return ) ;
-
-SINGLETON: linux-game-input-backend
-
-linux-game-input-backend game-input-backend set-global
-
-M: linux-game-input-backend (open-game-input)
-    ;
-
-M: linux-game-input-backend (close-game-input)
-    ;
-
-M: linux-game-input-backend (reset-game-input)
-    ;
-
-M: linux-game-input-backend get-controllers
-    { } ;
-
-M: linux-game-input-backend product-string
-    drop "" ;
-     
-M: linux-game-input-backend product-id
-    drop f ;
-     
-M: linux-game-input-backend instance-id
-    drop f ;
-     
-M: linux-game-input-backend read-controller
-    drop controller-state new ;
-     
-M: linux-game-input-backend calibrate-controller
-    drop ;
-     
-M: linux-game-input-backend vibrate-controller
-    3drop ;
-
-CONSTANT: x>hid-bit-order {
-    0 0 0 0 0 0 0 0 
-    0 41 30 31 32 33 34 35 
-    36 37 38 39 45 46 42 43 
-    20 26 8 21 23 28 24 12 
-    18 19 47 48 40 224 4 22 
-    7 9 10 11 13 14 15 51 
-    52 53 225 49 29 27 6 25 
-    5 17 16 54 55 56 229 85 
-    226 44 57 58 59 60 61 62 
-    63 64 65 66 67 83 71 95 
-    96 97 86 92 93 94 87 91 
-    90 89 98 99 0 0 0 68 
-    69 0 0 0 0 0 0 0 
-    88 228 84 70 0 0 74 82 
-    75 80 79 77 81 78 73 76 
-    127 129 128 102 103 0 72 0 
-    0 0 0 227 231 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-    0 0 0 0 0 0 0 0 
-}
-     
-: x-bits>hid-bits ( bit-array -- bit-array )
-    256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map
-    x>hid-bit-order [ nth ] curry map
-    256 <bit-array> swap [ t swap pick set-nth ] each ;
-        
-M: linux-game-input-backend read-keyboard
-    dpy get 256 <bit-array> [ XQueryKeymap drop ] keep
-    x-bits>hid-bits keyboard-state boa ;
-     
-M: linux-game-input-backend read-mouse
-    0 0 0 0 2 <vector> mouse-state boa ;
-     
-M: linux-game-input-backend reset-mouse
-    ;
diff --git a/basis/game/input/linux/platforms.txt b/basis/game/input/linux/platforms.txt
deleted file mode 100644 (file)
index a08e1f3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-linux
diff --git a/basis/game/input/linux/summary.txt b/basis/game/input/linux/summary.txt
deleted file mode 100644 (file)
index 5c88274..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Linux backend for game input.
diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/linux/tags.txt
deleted file mode 100644 (file)
index 84d4140..0000000
+++ /dev/null
@@ -1 +0,0 @@
-games
diff --git a/basis/game/input/x11/authors.txt b/basis/game/input/x11/authors.txt
new file mode 100644 (file)
index 0000000..d73be90
--- /dev/null
@@ -0,0 +1,2 @@
+Erik Charlebois
+William Schlieper
diff --git a/basis/game/input/x11/platforms.txt b/basis/game/input/x11/platforms.txt
new file mode 100644 (file)
index 0000000..a08e1f3
--- /dev/null
@@ -0,0 +1 @@
+linux
diff --git a/basis/game/input/x11/summary.txt b/basis/game/input/x11/summary.txt
new file mode 100644 (file)
index 0000000..5c88274
--- /dev/null
@@ -0,0 +1 @@
+Linux backend for game input.
diff --git a/basis/game/input/x11/tags.txt b/basis/game/input/x11/tags.txt
new file mode 100644 (file)
index 0000000..84d4140
--- /dev/null
@@ -0,0 +1 @@
+games
diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor
new file mode 100644 (file)
index 0000000..4e6f610
--- /dev/null
@@ -0,0 +1,92 @@
+! Copyright (C) 2010 Erik Charlebois, William Schlieper.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays kernel game.input namespaces
+classes bit-arrays system sequences vectors x11 x11.xlib ;
+IN: game.input.x11
+
+SINGLETON: x11-game-input-backend
+
+x11-game-input-backend game-input-backend set-global
+
+M: x11-game-input-backend (open-game-input)
+    ;
+
+M: x11-game-input-backend (close-game-input)
+    ;
+
+M: x11-game-input-backend (reset-game-input)
+    ;
+
+M: x11-game-input-backend get-controllers
+    { } ;
+
+M: x11-game-input-backend product-string
+    drop "" ;
+     
+M: x11-game-input-backend product-id
+    drop f ;
+     
+M: x11-game-input-backend instance-id
+    drop f ;
+     
+M: x11-game-input-backend read-controller
+    drop controller-state new ;
+     
+M: x11-game-input-backend calibrate-controller
+    drop ;
+     
+M: x11-game-input-backend vibrate-controller
+    3drop ;
+
+HOOK: x>hid-bit-order os ( -- x )
+
+M: linux x>hid-bit-order
+    {
+        0 0 0 0 0 0 0 0 
+        0 41 30 31 32 33 34 35 
+        36 37 38 39 45 46 42 43 
+        20 26 8 21 23 28 24 12 
+        18 19 47 48 40 224 4 22 
+        7 9 10 11 13 14 15 51 
+        52 53 225 49 29 27 6 25 
+        5 17 16 54 55 56 229 85 
+        226 44 57 58 59 60 61 62 
+        63 64 65 66 67 83 71 95 
+        96 97 86 92 93 94 87 91 
+        90 89 98 99 0 0 0 68 
+        69 0 0 0 0 0 0 0 
+        88 228 84 70 0 0 74 82 
+        75 80 79 77 81 78 73 76 
+        127 129 128 102 103 0 72 0 
+        0 0 0 227 231 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+        0 0 0 0 0 0 0 0 
+    } ; inline
+     
+: x-bits>hid-bits ( bit-array -- bit-array )
+    256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map
+    x>hid-bit-order [ nth ] curry map
+    256 <bit-array> swap [ t swap pick set-nth ] each ;
+        
+M: x11-game-input-backend read-keyboard
+    dpy get 256 <bit-array> [ XQueryKeymap drop ] keep
+    x-bits>hid-bits keyboard-state boa ;
+     
+M: x11-game-input-backend read-mouse
+    0 0 0 0 2 <vector> mouse-state boa ;
+     
+M: x11-game-input-backend reset-mouse
+    ;