From 894907d84dd4b964972e590879bf41686246ebdc Mon Sep 17 00:00:00 2001
From: "U-VICTORIA\\Administrator" <Administrator@victoria.(none)>
Date: Fri, 11 Jul 2008 21:18:32 -0700
Subject: [PATCH 01/35] GUID: literals for COM

---
 extra/windows/com/com-tests.factor          |  8 +--
 extra/windows/com/syntax/syntax-docs.factor | 56 +++++++++++----------
 extra/windows/com/syntax/syntax.factor      |  1 +
 3 files changed, 35 insertions(+), 30 deletions(-)
 mode change 100644 => 100755 extra/windows/com/syntax/syntax-docs.factor

diff --git a/extra/windows/com/com-tests.factor b/extra/windows/com/com-tests.factor
index 394bec2dfb..cd67fd19d2 100755
--- a/extra/windows/com/com-tests.factor
+++ b/extra/windows/com/com-tests.factor
@@ -16,10 +16,10 @@ COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
     int xPlus ( int y )
     int xMulAdd ( int mul, int add ) ;
 
-"{216fb341-0eb2-44b1-8edb-60b76e353abc}" string>guid 1array [ ISimple-iid ] unit-test
-"{9620ecec-8438-423b-bb14-86f835aa40dd}" string>guid 1array [ IInherited-iid ] unit-test
-"{00000000-0000-0000-C000-000000000046}" string>guid 1array [ IUnknown-iid ] unit-test
-"{b06ac3f4-30e4-406b-a7cd-c29cead4552c}" string>guid 1array [ IUnrelated-iid ] unit-test
+{ GUID: {216fb341-0eb2-44b1-8edb-60b76e353abc} } [ ISimple-iid ] unit-test
+{ GUID: {9620ecec-8438-423b-bb14-86f835aa40dd} } [ IInherited-iid ] unit-test
+{ GUID: {00000000-0000-0000-C000-000000000046} } [ IUnknown-iid ] unit-test
+{ GUID: {b06ac3f4-30e4-406b-a7cd-c29cead4552c} } [ IUnrelated-iid ] unit-test
 
 { (( -- iid )) } [ \ ISimple-iid stack-effect ] unit-test
 { (( this -- HRESULT )) } [ \ ISimple::returnOK stack-effect ] unit-test
diff --git a/extra/windows/com/syntax/syntax-docs.factor b/extra/windows/com/syntax/syntax-docs.factor
old mode 100644
new mode 100755
index fa06d5e4e7..62a3c6eaa0
--- a/extra/windows/com/syntax/syntax-docs.factor
+++ b/extra/windows/com/syntax/syntax-docs.factor
@@ -1,26 +1,30 @@
-USING: help.markup help.syntax io kernel math quotations
-multiline ;
-IN: windows.com.syntax
-
-HELP: COM-INTERFACE:
-{ $syntax <"
-COM-INTERFACE: <interface> <parent> <iid>
-    <function-1> ( <params1> )
-    <function-2> ( <params2> )
-    ... ;
-"> }
-{ $description "\nFor the interface " { $snippet "<interface>" } ", a word " { $snippet "<interface>-iid ( -- iid )" } " is defined to push the interface GUID (IID) onto the stack. Words of the form " { $snippet "<interface>::<function>" } " are also defined to invoke each method, as well as the methods inherited from " { $snippet "<parent>" } ". A " { $snippet "<parent>" } " of " { $snippet "f" } " indicates that the interface is a root interface. (Note that COM conventions demand that all interfaces at least inherit from " { $snippet "IUnknown" } ".)\n\nExample:" }
-{ $code <"
-COM-INTERFACE: IUnknown f {00000000-0000-0000-C000-000000000046}
-    HRESULT QueryInterface ( REFGUID iid, void** ppvObject )
-    ULONG AddRef ( )
-    ULONG Release ( ) ;
-
-COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
-    HRESULT returnOK ( )
-    HRESULT returnError ( ) ;
-
-COM-INTERFACE: IInherited ISimple {9620ecec-8438-423b-bb14-86f835aa40dd}
-    int getX ( )
-    void setX ( int newX ) ;
-"> } ;
+USING: help.markup help.syntax io kernel math quotations
+multiline ;
+IN: windows.com.syntax
+
+HELP: GUID:
+{ $syntax "GUID: {01234567-89ab-cdef-0123-456789abcdef}" }
+{ $description "\nCreate a COM globally-unique identifier (GUID) literal at parse time, and push it onto the data stack." } ;
+
+HELP: COM-INTERFACE:
+{ $syntax <"
+COM-INTERFACE: <interface> <parent> <iid>
+    <function-1> ( <params1> )
+    <function-2> ( <params2> )
+    ... ;
+"> }
+{ $description "\nFor the interface " { $snippet "<interface>" } ", a word " { $snippet "<interface>-iid ( -- iid )" } " is defined to push the interface GUID (IID) onto the stack. Words of the form " { $snippet "<interface>::<function>" } " are also defined to invoke each method, as well as the methods inherited from " { $snippet "<parent>" } ". A " { $snippet "<parent>" } " of " { $snippet "f" } " indicates that the interface is a root interface. (Note that COM conventions demand that all interfaces at least inherit from " { $snippet "IUnknown" } ".)\n\nExample:" }
+{ $code <"
+COM-INTERFACE: IUnknown f {00000000-0000-0000-C000-000000000046}
+    HRESULT QueryInterface ( REFGUID iid, void** ppvObject )
+    ULONG AddRef ( )
+    ULONG Release ( ) ;
+
+COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
+    HRESULT returnOK ( )
+    HRESULT returnError ( ) ;
+
+COM-INTERFACE: IInherited ISimple {9620ecec-8438-423b-bb14-86f835aa40dd}
+    int getX ( )
+    void setX ( int newX ) ;
+"> } ;
diff --git a/extra/windows/com/syntax/syntax.factor b/extra/windows/com/syntax/syntax.factor
index dd7d058a77..b607027332 100755
--- a/extra/windows/com/syntax/syntax.factor
+++ b/extra/windows/com/syntax/syntax.factor
@@ -100,3 +100,4 @@ PRIVATE>
     define-words-for-com-interface
     ; parsing
 
+: GUID: scan string>guid parsed ; parsing

From ba120427cdde648f7bf59c3f7ac25bc47efed111 Mon Sep 17 00:00:00 2001
From: "U-VICTORIA\\Administrator" <Administrator@victoria.(none)>
Date: Sat, 12 Jul 2008 11:08:47 -0700
Subject: [PATCH 02/35] DirectInput bindings

---
 extra/windows/dinput/authors.txt              |   1 +
 .../windows/dinput/constants/constants.factor | 563 ++++++++++++++++++
 extra/windows/dinput/dinput.factor            | 382 ++++++++++++
 extra/windows/dinput/summary.txt              |   1 +
 extra/windows/dinput/tags.txt                 |   2 +
 5 files changed, 949 insertions(+)
 create mode 100755 extra/windows/dinput/authors.txt
 create mode 100755 extra/windows/dinput/constants/constants.factor
 create mode 100755 extra/windows/dinput/dinput.factor
 create mode 100755 extra/windows/dinput/summary.txt
 create mode 100755 extra/windows/dinput/tags.txt

diff --git a/extra/windows/dinput/authors.txt b/extra/windows/dinput/authors.txt
new file mode 100755
index 0000000000..f13c9c1e77
--- /dev/null
+++ b/extra/windows/dinput/authors.txt
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/windows/dinput/constants/constants.factor b/extra/windows/dinput/constants/constants.factor
new file mode 100755
index 0000000000..2a5432a9d7
--- /dev/null
+++ b/extra/windows/dinput/constants/constants.factor
@@ -0,0 +1,563 @@
+USING: windows.dinput windows.kernel32 windows.ole32 windows.com
+windows.com.syntax alien alien.c-types alien.syntax kernel system namespaces
+combinators sequences symbols fry math accessors macros words quotations
+libc continuations generalizations splitting locals assocs ;
+IN: windows.dinput.constants
+
+! Some global variables aren't provided by the DirectInput DLL (they're in the
+! dinput8.lib import library), so we lovingly hand-craft equivalent values here
+
+: (field-spec-of) ( field struct -- field-spec )
+    c-type fields>> [ name>> = ] with find nip ;
+: (offsetof) ( field struct -- offset )
+    [ (field-spec-of) offset>> ] [ drop 0 ] if* ;
+: (sizeof) ( field struct -- size )
+    [ (field-spec-of) class>> "[" split1 drop heap-size ] [ drop 1 ] if* ;
+
+MACRO: (flags) ( array -- )
+    0 [ {
+        { [ dup word? ] [ execute ] }
+        { [ dup callable? ] [ call ] }
+        [ ]
+    } cond bitor ] reduce 1quotation ;
+
+: (DIOBJECTDATAFORMAT) ( pguid dwOfs dwType dwFlags alien -- alien )
+    [ {
+        [ set-DIOBJECTDATAFORMAT-dwFlags ]
+        [ set-DIOBJECTDATAFORMAT-dwType ]
+        [ set-DIOBJECTDATAFORMAT-dwOfs ]
+        [ set-DIOBJECTDATAFORMAT-pguid ]
+    } cleave ] keep ;
+
+: <DIOBJECTDATAFORMAT> ( struct {pguid-var,field,index,dwType-flags,dwFlags} -- alien )
+    {
+        [ first dup word? [ get ] when ]
+        [ second rot [ (offsetof) ] [ (sizeof) ] 2bi ]
+        [ third * + ]
+        [ fourth (flags) ]
+        [ 4 swap nth ]
+    } cleave
+    "DIOBJECTDATAFORMAT" <c-object> (DIOBJECTDATAFORMAT) ;
+
+: malloc-DIOBJECTDATAFORMAT-array ( struct array -- alien )
+    [ nip length "DIOBJECTDATAFORMAT" malloc-array dup ]
+    [
+        -rot [| args i alien struct |
+            struct args <DIOBJECTDATAFORMAT>
+            i alien set-DIOBJECTDATAFORMAT-nth
+        ] 2curry each-index
+    ] 2bi ;
+
+: (DIDATAFORMAT) ( dwSize dwObjSize dwFlags dwDataSize dwNumObjs rgodf alien -- alien )
+    [ {
+        [ set-DIDATAFORMAT-rgodf ]
+        [ set-DIDATAFORMAT-dwNumObjs ]
+        [ set-DIDATAFORMAT-dwDataSize ]
+        [ set-DIDATAFORMAT-dwFlags ]
+        [ set-DIDATAFORMAT-dwObjSize ]
+        [ set-DIDATAFORMAT-dwSize ]
+    } cleave ] keep ;
+
+: <DIDATAFORMAT> ( dwFlags dwDataSize struct rgodf-array -- alien )
+    [ "DIDATAFORMAT" heap-size "DIOBJECTDATAFORMAT" heap-size ] 4 ndip
+    [ nip length ] [ malloc-DIOBJECTDATAFORMAT-array ] 2bi
+    "DIDATAFORMAT" <c-object> (DIDATAFORMAT) ;
+
+SYMBOLS:
+    GUID_XAxis GUID_YAxis GUID_ZAxis
+    GUID_RxAxis GUID_RyAxis GUID_RzAxis
+    GUID_Slider GUID_Button GUID_Key GUID_POV GUID_Unknown
+    GUID_SysMouse GUID_SysKeyboard GUID_Joystick GUID_SysMouseEm
+    GUID_SysMouseEm2 GUID_SysKeyboardEm GUID_SysKeyboardEm2 ;
+
+: (malloc-guid-symbol) ( symbol guid -- )
+    global swap '[ [
+        , [ byte-length malloc ] [ over byte-array>memory ] bi
+    ] unless* ] change-at ;
+
+{
+    { GUID_XAxis          GUID: {A36D02E0-C9F3-11CF-BFC7-444553540000} }
+    { GUID_YAxis          GUID: {A36D02E1-C9F3-11CF-BFC7-444553540000} }
+    { GUID_ZAxis          GUID: {A36D02E2-C9F3-11CF-BFC7-444553540000} }
+    { GUID_RxAxis         GUID: {A36D02F4-C9F3-11CF-BFC7-444553540000} }
+    { GUID_RyAxis         GUID: {A36D02F5-C9F3-11CF-BFC7-444553540000} }
+    { GUID_RzAxis         GUID: {A36D02E3-C9F3-11CF-BFC7-444553540000} }
+    { GUID_Slider         GUID: {A36D02E4-C9F3-11CF-BFC7-444553540000} }
+    { GUID_Button         GUID: {A36D02F0-C9F3-11CF-BFC7-444553540000} }
+    { GUID_Key            GUID: {55728220-D33C-11CF-BFC7-444553540000} }
+    { GUID_POV            GUID: {A36D02F2-C9F3-11CF-BFC7-444553540000} }
+    { GUID_Unknown        GUID: {A36D02F3-C9F3-11CF-BFC7-444553540000} }
+    { GUID_SysMouse       GUID: {6F1D2B60-D5A0-11CF-BFC7-444553540000} }
+    { GUID_SysKeyboard    GUID: {6F1D2B61-D5A0-11CF-BFC7-444553540000} }
+    { GUID_Joystick       GUID: {6F1D2B70-D5A0-11CF-BFC7-444553540000} }
+    { GUID_SysMouseEm     GUID: {6F1D2B80-D5A0-11CF-BFC7-444553540000} }
+    { GUID_SysMouseEm2    GUID: {6F1D2B81-D5A0-11CF-BFC7-444553540000} }
+    { GUID_SysKeyboardEm  GUID: {6F1D2B82-D5A0-11CF-BFC7-444553540000} }
+    { GUID_SysKeyboardEm2 GUID: {6F1D2B83-D5A0-11CF-BFC7-444553540000} }
+} [ first2 (malloc-guid-symbol) ] each
+
+SYMBOLS: c_dfDIKeyboard c_dfDIMouse2 c_dfDIJoystick2 ;
+
+c_dfDIJoystick2 global [ [
+    DIDF_ABSAXIS
+    "DIJOYSTATE2" heap-size
+    "DIJOYSTATE2" {
+        { GUID_XAxis  "lX"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_YAxis  "lY"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_ZAxis  "lZ"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RxAxis "lRx"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RyAxis "lRy"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RzAxis "lRz"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglSlider"    0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglSlider"    1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_POV    "rgdwPOV"      0 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+        { GUID_POV    "rgdwPOV"      1 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+        { GUID_POV    "rgdwPOV"      2 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+        { GUID_POV    "rgdwPOV"      3 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   0 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   1 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   2 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   3 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   4 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   5 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   6 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   7 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   8 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"   9 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  10 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  11 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  12 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  13 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  14 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  15 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  16 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  17 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  18 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  19 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  20 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  21 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  22 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  23 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  24 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  25 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  26 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  27 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  28 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  29 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  30 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  31 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  32 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  33 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  34 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  35 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  36 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  37 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  38 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  39 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  40 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  41 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  42 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  43 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  44 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  45 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  46 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  47 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  48 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  49 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  50 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  51 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  52 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  53 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  54 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  55 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  56 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  57 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  58 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  59 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  60 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  61 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  62 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  63 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  64 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  65 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  66 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  67 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  68 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  69 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  70 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  71 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  72 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  73 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  74 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  75 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  76 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  77 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  78 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  79 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  80 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  81 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  82 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  83 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  84 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  85 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  86 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  87 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  88 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  89 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  90 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  91 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  92 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  93 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  94 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  95 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  96 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  97 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  98 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons"  99 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 100 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 101 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 102 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 103 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 104 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 105 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 106 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 107 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 108 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 109 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 110 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 111 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 112 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 113 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 114 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 115 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 116 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 117 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 118 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 119 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 120 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 121 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 122 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 123 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 124 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 125 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 126 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { f           "rgbButtons" 127 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+        { GUID_XAxis  "lVX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_YAxis  "lVY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_ZAxis  "lVZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RxAxis "lVRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RyAxis "lVRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RzAxis "lVRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglVSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglVSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_XAxis  "lAX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_YAxis  "lAY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_ZAxis  "lAZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RxAxis "lARx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RyAxis "lARy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RzAxis "lARz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglASlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglASlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_XAxis  "lFX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_YAxis  "lFY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_ZAxis  "lFZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RxAxis "lFRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RyAxis "lFRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_RzAxis "lFRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglFSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        { GUID_Slider "rglFSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+    } <DIDATAFORMAT>
+] unless* ] change-at
+
+c_dfDIMouse2 global [ [
+    DIDF_RELAXIS
+    "DIMOUSESTATE2" heap-size
+    "DIMOUSESTATE2" {
+        { GUID_XAxis  "lX"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+        { GUID_YAxis  "lY"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+        { GUID_ZAxis  "lZ"         0 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+        { GUID_Button "rgbButtons" 0 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 1 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 2 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 3 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 4 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 5 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 6 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        { GUID_Button "rgbButtons" 7 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+    } <DIDATAFORMAT>
+] unless* ] change-at
+
+c_dfDIKeyboard global [ [
+    DIDF_RELAXIS
+    256
+    f {
+        { GUID_Key f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [   0 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [   1 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [   2 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [   3 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [   4 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [   5 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [   6 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [   7 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [   8 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [   9 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [  10 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [  11 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [  12 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [  13 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [  14 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [  15 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [  16 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [  17 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [  18 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [  19 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [  20 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [  21 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [  22 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [  23 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [  24 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [  25 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [  26 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [  27 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [  28 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [  29 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [  30 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [  31 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [  32 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [  33 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [  34 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [  35 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [  36 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [  37 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [  38 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [  39 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [  40 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [  41 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [  42 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [  43 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [  44 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [  45 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [  46 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [  47 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [  48 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [  49 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [  50 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [  51 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [  52 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [  53 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [  54 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [  55 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [  56 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [  57 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [  58 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [  59 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [  60 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [  61 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [  62 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [  63 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [  64 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [  65 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [  66 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [  67 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [  68 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [  69 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [  70 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [  71 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [  72 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [  73 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [  74 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [  75 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [  76 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [  77 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [  78 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [  79 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [  80 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [  81 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [  82 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [  83 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [  84 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [  85 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [  86 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [  87 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [  88 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [  89 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [  90 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [  91 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [  92 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [  93 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [  94 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [  95 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [  96 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [  97 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [  98 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [  99 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ 100 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ 101 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ 102 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ 103 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ 104 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ 105 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ 106 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 107 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 108 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 109 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 110 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 111 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 112 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 113 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 114 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 115 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 116 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 117 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 118 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 119 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 120 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 121 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 122 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 123 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 124 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 125 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 126 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ 127 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ 128 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ 129 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 130 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 131 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 132 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ 133 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 134 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ 135 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ 136 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ 137 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ 138 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ 139 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 140 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 141 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 142 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 143 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 144 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 145 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 146 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 147 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 148 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 149 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 150 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 151 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 152 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 153 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 154 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 155 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 156 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 157 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 158 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 159 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 160 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 161 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 162 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 163 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 164 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 165 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 166 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 167 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 168 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 169 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 170 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 171 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 172 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 173 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 174 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 175 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 176 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 177 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 178 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 179 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 180 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 181 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 182 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 183 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 184 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 185 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 186 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 187 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 188 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 189 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 190 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 191 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 192 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 193 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 194 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 195 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 196 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 197 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 198 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 199 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 200 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 201 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 202 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 203 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 204 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 205 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 206 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 207 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 208 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 209 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 210 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 211 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 212 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 213 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 214 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 215 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 216 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 217 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 218 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 219 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 220 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 221 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 222 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 223 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ 224 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ 225 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ 226 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ 227 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ 228 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ 229 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ 230 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ 231 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 232 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 233 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 234 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 235 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 236 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 237 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 238 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 239 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 240 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 241 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 242 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 243 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 244 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 245 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 246 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 247 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 248 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 249 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 250 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 251 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 252 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 253 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 254 DIDFT_MAKEINSTANCE ] } 0 }
+        { GUID_Key f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 255 DIDFT_MAKEINSTANCE ] } 0 }
+    } <DIDATAFORMAT>
+] unless* ] change-at
+
+: free-dinput-constants ( -- )
+    {
+        GUID_XAxis GUID_YAxis GUID_ZAxis
+        GUID_RxAxis GUID_RyAxis GUID_RzAxis
+        GUID_Slider GUID_Button GUID_Key GUID_POV GUID_Unknown
+        GUID_SysMouse GUID_SysKeyboard GUID_Joystick GUID_SysMouseEm
+        GUID_SysMouseEm2 GUID_SysKeyboardEm GUID_SysKeyboardEm2
+    } [ global [ [ free ] when* f ] change-at ] each
+    {
+        c_dfDIKeyboard c_dfDIMouse2 c_dfDIJoystick2
+    } [
diff --git a/extra/windows/dinput/dinput.factor b/extra/windows/dinput/dinput.factor
new file mode 100755
index 0000000000..6dec0aed1a
--- /dev/null
+++ b/extra/windows/dinput/dinput.factor
@@ -0,0 +1,382 @@
+USING: windows.kernel32 windows.ole32 windows.com windows.com.syntax
+alien alien.c-types alien.syntax kernel system namespaces math ;
+IN: windows.dinput
+
+<< os windows?
+    [ "dinput" "dinput8.dll" "stdcall" add-library ]
+    [ "DirectInput only supported on Windows" throw ] if
+>>
+
+LIBRARY: dinput
+
+! callback signature: BOOL DIEnumDevicesCallbackW(LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMDEVICESCALLBACKW
+! Callback signature: BOOL DIEnumDevicesBySemanticsCallbackW(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W* lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMDEVICESBYSEMANTICSCBW
+! Callback signature: BOOL DIConfigureDevicesCallback(IUnknown* lpDDSTarget, LPVOID pvRef);
+TYPEDEF: void* LPDICONFIGUREDEVICESCALLBACK
+! Callback signature: BOOL DIEnumEffectsCallbackW(LPCDIEFFECTINFOW pdei, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMEFFECTSCALLBACKW
+! Callback signature: BOOL DIEnumCreatedEffectObjectsCallback(LPDIRECTINPUTEFFECT peff, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMCREATEDEFFECTOBJECTSCALLBACK
+! Callback signature: BOOL DIEnumEffectsInFileCallback(LPCDIFILEEFFECT lpDiFileEf, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMEFFECTSINFILECALLBACK
+! Callback signaature: BOOL DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
+TYPEDEF: void* LPDIENUMDEVICEOBJECTSCALLBACKW
+
+TYPEDEF: DWORD D3DCOLOR
+
+C-STRUCT: DIDEVICEINSTANCEW
+    { "DWORD"      "dwSize" }
+    { "GUID"       "guidInstance" }
+    { "GUID"       "guidProduct" }
+    { "DWORD"      "dwDevType" }
+    { "WCHAR[260]" "tszInstanceName" }
+    { "WCHAR[260]" "tszProductName" }
+    { "GUID"       "guidFFDriver" }
+    { "WORD"       "wUsagePage" }
+    { "WORD"       "wUsage" } ;
+TYPEDEF: DIDEVICEINSTANCEW* LPDIDEVICEINSTANCEW
+TYPEDEF: DIDEVICEINSTANCEW* LPCDIDEVICEINSTANCEW
+C-UNION: DIACTION-union "LPCWSTR" "UINT" ;
+C-STRUCT: DIACTIONW
+    { "UINT_PTR"       "uAppData" }
+    { "DWORD"          "dwSemantic" }
+    { "DWORD"          "dwFlags" }
+    { "DIACTION-union" "lptszActionName-or-uResIdString" }
+    { "GUID"           "guidInstance" }
+    { "DWORD"          "dwObjID" }
+    { "DWORD"          "dwHow" } ;
+TYPEDEF: DIACTIONW* LPDIACTIONW
+TYPEDEF: DIACTIONW* LPCDIACTIONW
+C-STRUCT: DIACTIONFORMATW
+    { "DWORD"       "dwSize" }
+    { "DWORD"       "dwActionSize" }
+    { "DWORD"       "dwDataSize" }
+    { "DWORD"       "dwNumActions" }
+    { "LPDIACTIONW" "rgoAction" }
+    { "GUID"        "guidActionMap" }
+    { "DWORD"       "dwGenre" }
+    { "DWORD"       "dwBufferSize" }
+    { "LONG"        "lAxisMin" }
+    { "LONG"        "lAxisMax" }
+    { "HINSTANCE"   "hInstString" }
+    { "FILETIME"    "ftTimeStamp" }
+    { "DWORD"       "dwCRC" }
+    { "WCHAR[260]"  "tszActionMap" } ;
+TYPEDEF: DIACTIONFORMATW* LPDIACTIONFORMATW
+TYPEDEF: DIACTIONFORMATW* LPCDIACTIONFORMATW
+C-STRUCT: DICOLORSET
+    { "DWORD"    "dwSize" }
+    { "D3DCOLOR" "cTextFore" }
+    { "D3DCOLOR" "cTextHighlight" }
+    { "D3DCOLOR" "cCalloutLine" }
+    { "D3DCOLOR" "cCalloutHighlight" }
+    { "D3DCOLOR" "cBorder" }
+    { "D3DCOLOR" "cControlFill" }
+    { "D3DCOLOR" "cHighlightFill" }
+    { "D3DCOLOR" "cAreaFill" } ;
+TYPEDEF: DICOLORSET* LPDICOLORSET
+TYPEDEF: DICOLORSET* LPCDICOLORSET
+
+C-STRUCT: DICONFIGUREDEVICESPARAMSW
+    { "DWORD"             "dwSize" }
+    { "DWORD"             "dwcUsers" }
+    { "LPWSTR"            "lptszUserNames" }
+    { "DWORD"             "dwcFormats" }
+    { "LPDIACTIONFORMATW" "lprgFormats" }
+    { "HWND"              "hwnd" }
+    { "DICOLORSET"        "dics" }
+    { "IUnknown*"         "lpUnkDDSTarget" } ;
+TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
+TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
+
+C-STRUCT: DIDEVCAPS
+    { "DWORD" "wSize" }
+    { "DWORD" "wFlags" }
+    { "DWORD" "wDevType" }
+    { "DWORD" "wAxes" }
+    { "DWORD" "wButtons" }
+    { "DWORD" "wPOVs" }
+    { "DWORD" "wFFSamplePeriod" }
+    { "DWORD" "wFFMinTimeResolution" }
+    { "DWORD" "wFirmwareRevision" }
+    { "DWORD" "wHardwareRevision" }
+    { "DWORD" "wFFDriverVersion" } ;
+TYPEDEF: DIDEVCAPS* LPDIDEVCAPS
+TYPEDEF: DIDEVCAPS* LPCDIDEVCAPS
+C-STRUCT: DIDEVICEOBJECTINSTANCEW
+    { "DWORD"      "dwSize" }
+    { "GUID"       "guidInstance" }
+    { "GUID"       "guidProduct" }
+    { "DWORD"      "dwDevType" }
+    { "WCHAR[260]" "tszInstanceName" }
+    { "WCHAR[260]" "tszProductName" }
+    { "GUID"       "guidFFDriver" }
+    { "WORD"       "wUsagePage" }
+    { "WORD"       "wUsage" } ;
+TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPDIDEVICEOBJECTINSTANCEW
+TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPCDIDEVICEOBJECTINSTANCEW
+C-STRUCT: DIDEVICEOBJECTDATA
+    { "DWORD"    "dwOfs" }
+    { "DWORD"    "dwData" }
+    { "DWORD"    "dwTimeStamp" }
+    { "DWORD"    "dwSequence" }
+    { "UINT_PTR" "uAppData" } ;
+TYPEDEF: DIDEVICEOBJECTDATA* LPDIDEVICEOBJECTDATA
+TYPEDEF: DIDEVICEOBJECTDATA* LPCDIDEVICEOBJECTDATA
+C-STRUCT: DIOBJECTDATAFORMAT
+    { "GUID*" "pguid" }
+    { "DWORD" "dwOfs" }
+    { "DWORD" "dwType" }
+    { "DWORD" "dwFlags" } ;
+TYPEDEF: DIOBJECTDATAFORMAT* LPDIOBJECTDATAFORMAT
+TYPEDEF: DIOBJECTDATAFORMAT* LPCDIOBJECTDATAFORMAT
+C-STRUCT: DIDATAFORMAT
+    { "DWORD" "dwSize" }
+    { "DWORD" "dwObjSize" }
+    { "DWORD" "dwFlags" }
+    { "DWORD" "dwDataSize" }
+    { "DWORD" "dwNumObjs" }
+    { "LPDIOBJECTDATAFORMAT" "rgodf" } ;
+TYPEDEF: DIDATAFORMAT* LPDIDATAFORMAT
+TYPEDEF: DIDATAFORMAT* LPCDIDATAFORMAT
+C-STRUCT: DIPROPHEADER
+    { "DWORD" "dwSize" }
+    { "DWORD" "dwHeaderSize" }
+    { "DWORD" "dwObj" }
+    { "DWORD" "dwHow" } ;
+TYPEDEF: DIPROPHEADER* LPDIPROPHEADER
+TYPEDEF: DIPROPHEADER* LPCDIPROPHEADER
+C-STRUCT: DIENVELOPE
+    { "DWORD" "dwSize" }
+    { "DWORD" "dwAttackLevel" }
+    { "DWORD" "dwAttackTime" }
+    { "DWORD" "dwFadeLevel" }
+    { "DWORD" "dwFadeTime" } ;
+TYPEDEF: DIENVELOPE* LPDIENVELOPE
+TYPEDEF: DIENVELOPE* LPCDIENVELOPE
+C-STRUCT: DIEFFECT
+    { "DWORD" "dwSize" }
+    { "DWORD" "dwFlags" }
+    { "DWORD" "dwDuration" }
+    { "DWORD" "dwSamplePeriod" }
+    { "DWORD" "dwGain" }
+    { "DWORD" "dwTriggerButton" }
+    { "DWORD" "dwTriggerRepeatInterval" }
+    { "DWORD" "cAxes" }
+    { "LPDWORD" "rgdwAxes" }
+    { "LPLONG" "rglDirection" }
+    { "LPDIENVELOPE" "lpEnvelope" }
+    { "DWORD" "cbTypeSpecificParams" }
+    { "LPVOID" "lpvTypeSpecificParams" }
+    { "DWORD" "dwStartDelay" } ;
+TYPEDEF: DIEFFECT* LPDIEFFECT
+TYPEDEF: DIEFFECT* LPCDIEFFECT
+C-STRUCT: DIEFFECTINFOW
+    { "DWORD"      "dwSize" }
+    { "GUID"       "guid" }
+    { "DWORD"      "dwEffType" }
+    { "DWORD"      "dwStaticParams" }
+    { "DWORD"      "dwDynamicParams" }
+    { "WCHAR[260]" "tszName" } ;
+TYPEDEF: DIEFFECTINFOW* LPDIEFFECTINFOW
+TYPEDEF: DIEFFECTINFOW* LPCDIEFFECTINFOW
+C-STRUCT: DIEFFESCAPE
+    { "DWORD"  "dwSize" }
+    { "DWORD"  "dwCommand" }
+    { "LPVOID" "lpvInBuffer" }
+    { "DWORD"  "cbInBuffer" }
+    { "LPVOID" "lpvOutBuffer" }
+    { "DWORD"  "cbOutBuffer" } ;
+TYPEDEF: DIEFFESCAPE* LPDIEFFESCAPE
+TYPEDEF: DIEFFESCAPE* LPCDIEFFESCAPE
+C-STRUCT: DIFILEEFFECT
+    { "DWORD"       "dwSize" }
+    { "GUID"        "GuidEffect" }
+    { "LPCDIEFFECT" "lpDiEffect" }
+    { "CHAR[260]"   "szFriendlyName" } ;
+TYPEDEF: DIFILEEFFECT* LPDIFILEEFFECT
+TYPEDEF: DIFILEEFFECT* LPCDIFILEEFFECT
+C-STRUCT: DIDEVICEIMAGEINFOW
+    { "WCHAR[260]" "tszImagePath" }
+    { "DWORD"      "dwFlags" }
+    { "DWORD"      "dwViewID" }
+    { "RECT"       "rcOverlay" }
+    { "DWORD"      "dwObjID" }
+    { "DWORD"      "dwcValidPts" }
+    { "POINT[5]"   "rgptCalloutLine" }
+    { "RECT"       "rcCalloutRect" }
+    { "DWORD"      "dwTextAlign" } ;
+TYPEDEF: DIDEVICEIMAGEINFOW* LPDIDEVICEIMAGEINFOW
+TYPEDEF: DIDEVICEIMAGEINFOW* LPCDIDEVICEIMAGEINFOW
+C-STRUCT: DIDEVICEIMAGEINFOHEADERW
+    { "DWORD" "dwSize" }
+    { "DWORD" "dwSizeImageInfo" }
+    { "DWORD" "dwcViews" }
+    { "DWORD" "dwcButtons" }
+    { "DWORD" "dwcAxes" }
+    { "DWORD" "dwcPOVs" }
+    { "DWORD" "dwBufferSize" }
+    { "DWORD" "dwBufferUsed" }
+    { "DIDEVICEIMAGEINFOW*" "lprgImageInfoArray" } ;
+TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPDIDEVICEIMAGEINFOHEADERW
+TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPCDIDEVICEIMAGEINFOHEADERW
+
+C-STRUCT: DIMOUSESTATE2
+    { "LONG"    "lX" }
+    { "LONG"    "lY" }
+    { "LONG"    "lZ" }
+    { "BYTE[8]" "rgbButtons" } ;
+TYPEDEF: DIMOUSESTATE2* LPDIMOUSESTATE2
+TYPEDEF: DIMOUSESTATE2* LPCDIMOUSESTATE2
+
+C-STRUCT: DIJOYSTATE2
+    { "LONG"      "lX" }
+    { "LONG"      "lY" }
+    { "LONG"      "lZ" }
+    { "LONG"      "lRx" }
+    { "LONG"      "lRy" }
+    { "LONG"      "lRz" }
+    { "LONG[2]"   "rglSlider" }
+    { "DWORD[4]"  "rgdwPOV" }
+    { "BYTE[128]" "rgbButtons" }
+    { "LONG"      "lVX" }
+    { "LONG"      "lVY" }
+    { "LONG"      "lVZ" }
+    { "LONG"      "lVRx" }
+    { "LONG"      "lVRy" }
+    { "LONG"      "lVRz" }
+    { "LONG[2]"   "rglVSlider" }
+    { "LONG"      "lAX" }
+    { "LONG"      "lAY" }
+    { "LONG"      "lAZ" }
+    { "LONG"      "lARx" }
+    { "LONG"      "lARy" }
+    { "LONG"      "lARz" }
+    { "LONG[2]"   "rglASlider" }
+    { "LONG"      "lFX" }
+    { "LONG"      "lFY" }
+    { "LONG"      "lFZ" }
+    { "LONG"      "lFRx" }
+    { "LONG"      "lFRy" }
+    { "LONG"      "lFRz" }
+    { "LONG[2]"   "rglFSlider" } ;
+TYPEDEF: DIJOYSTATE2* LPDIJOYSTATE2
+TYPEDEF: DIJOYSTATE2* LPCDIJOYSTATE2
+
+COM-INTERFACE: IDirectInputEffect IUnknown {E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35}
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
+    HRESULT GetEffectGuid ( LPGUID pguid )
+    HRESULT GetParameters ( LPDIEFFECT peff, DWORD dwFlags )
+    HRESULT SetParameters ( LPCDIEFFECT peff, DWORD dwFlags )
+    HRESULT Start ( DWORD dwIterations, DWORD dwFlags )
+    HRESULT Stop ( )
+    HRESULT GetEffectStatus ( LPDWORD pdwFlags )
+    HRESULT Download ( )
+    HRESULT Unload ( )
+    HRESULT Escape ( LPDIEFFESCAPE pesc ) ;
+
+COM-INTERFACE: IDirectInputDevice8W IUnknown {54D41081-DC15-4833-A41B-748F73A38179}
+    HRESULT GetCapabilities ( LPDIDEVCAPS lpDIDeviceCaps )
+    HRESULT EnumObjects ( LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT GetProperty ( REFGUID rguidProp, LPDIPROPHEADER pdiph )
+    HRESULT SetProperty ( REFGUID rguidProp, LPCDIPROPHEADER pdiph )
+    HRESULT Acquire ( )
+    HRESULT Unacquire ( )
+    HRESULT GetDeviceState ( DWORD cbData, LPVOID lpvData )
+    HRESULT GetDeviceData ( DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags )
+    HRESULT SetDataFormat ( LPCDIDATAFORMAT lpdf )
+    HRESULT SetEventNotification ( HANDLE hEvent )
+    HRESULT SetCooperativeLevel ( HWND hwnd, DWORD dwFlags )
+    HRESULT GetObjectInfo ( LPDIDEVICEOBJECTINSTANCEW rdidoi, DWORD dwObj, DWORD dwHow )
+    HRESULT GetDeviceInfo ( LPDIDEVICEINSTANCEW pdidi )
+    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
+    HRESULT CreateEffect ( REFGUID rguid, LPCDIEFFECT lpeff, IDirectInputEffect** ppdeff, LPUNKNOWN punkOuter )
+    HRESULT EnumEffects ( LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType )
+    HRESULT GetEffectInfo ( LPDIEFFECTINFOW pdei, REFGUID rguid )
+    HRESULT GetForceFeedbackState ( LPDWORD pdwOut )
+    HRESULT SendForceFeedbackCommand ( DWORD dwFlags )
+    HRESULT EnumCreatedEffectObjects ( LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl )
+    HRESULT Escape ( LPDIEFFESCAPE pesc )
+    HRESULT Poll ( )
+    HRESULT SendDeviceData ( DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl )
+    HRESULT EnumEffectsInFile ( LPCWSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT WriteEffectToFile ( LPCWSTR lpszFileName, DWORD dwEntries, LPDIFILEEFFECT rgDiFileEffect, DWORD dwFlags )
+    HRESULT BuildActionMap ( LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags )
+    HRESULT SetActionMap ( LPDIACTIONFORMATW lpdiActionFormat, LPCWSTR lpwszUserName, DWORD dwFlags )
+    HRESULT GetImageInfo ( LPDIDEVICEIMAGEINFOHEADERW lpdiDeviceImageInfoHeader ) ;
+
+COM-INTERFACE: IDirectInput8W IUnknown {BF798031-483A-4DA2-AA99-5D64ED369700}
+    HRESULT CreateDevice ( REFGUID rguid, IDirectInputDevice8W** lplpDevice, LPUNKNOWN pUnkOuter )
+    HRESULT EnumDevices ( DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT GetDeviceStatus ( REFGUID rguidInstance )
+    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion )
+    HRESULT FindDevice ( REFGUID rguidClass, LPCWSTR pwszName, LPGUID pguidInstance )
+    HRESULT EnumDevicesBySemantics ( LPCWSTR pwszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT ConfigureDevices ( LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData ) ;
+
+FUNCTION: HRESULT DirectInput8Create ( HINSTANCE hinst, DWORD dwVersion, REFIID riidtlf, LPVOID* ppvOut, LPUNKNOWN punkOuter ) ;
+
+: DIRECTINPUT_VERSION HEX: 0800 ; inline
+
+: DI8DEVCLASS_ALL             0 ; inline
+: DI8DEVCLASS_DEVICE          1 ; inline
+: DI8DEVCLASS_POINTER         2 ; inline
+: DI8DEVCLASS_KEYBOARD        3 ; inline
+: DI8DEVCLASS_GAMECTRL        4 ; inline
+
+: DIEDFL_ALLDEVICES       HEX: 00000000 ; inline
+: DIEDFL_ATTACHEDONLY     HEX: 00000001 ; inline
+: DIEDFL_FORCEFEEDBACK    HEX: 00000100 ; inline
+: DIEDFL_INCLUDEALIASES   HEX: 00010000 ; inline
+: DIEDFL_INCLUDEPHANTOMS  HEX: 00020000 ; inline
+: DIEDFL_INCLUDEHIDDEN    HEX: 00040000 ; inline
+
+: DIENUM_STOP             0 ; inline
+: DIENUM_CONTINUE         1 ; inline
+
+: DIDF_ABSAXIS            1 ;
+: DIDF_RELAXIS            2 ;
+
+: DIDFT_ALL           HEX: 00000000 ; inline
+
+: DIDFT_RELAXIS       HEX: 00000001 ; inline
+: DIDFT_ABSAXIS       HEX: 00000002 ; inline
+: DIDFT_AXIS          HEX: 00000003 ; inline
+
+: DIDFT_PSHBUTTON     HEX: 00000004 ; inline
+: DIDFT_TGLBUTTON     HEX: 00000008 ; inline
+: DIDFT_BUTTON        HEX: 0000000C ; inline
+
+: DIDFT_POV           HEX: 00000010 ; inline
+: DIDFT_COLLECTION    HEX: 00000040 ; inline
+: DIDFT_NODATA        HEX: 00000080 ; inline
+
+: DIDFT_ANYINSTANCE   HEX: 00FFFF00 ; inline
+: DIDFT_INSTANCEMASK  DIDFT_ANYINSTANCE ; inline
+: DIDFT_MAKEINSTANCE ( n -- instance ) 8 shift                   ; inline
+: DIDFT_GETTYPE      ( n -- type     ) HEX: FF bitand            ; inline
+: DIDFT_GETINSTANCE  ( n -- instance ) -8 shift HEX: FFFF bitand ; inline
+: DIDFT_FFACTUATOR        HEX: 01000000 ; inline
+: DIDFT_FFEFFECTTRIGGER   HEX: 02000000 ; inline
+: DIDFT_OUTPUT            HEX: 10000000 ; inline
+: DIDFT_VENDORDEFINED     HEX: 04000000 ; inline
+: DIDFT_ALIAS             HEX: 08000000 ; inline
+: DIDFT_OPTIONAL          HEX: 80000000 ; inline
+
+: DIDFT_ENUMCOLLECTION ( n -- instance ) 8 shift HEX: FFFF bitand ; inline
+: DIDFT_NOCOLLECTION      HEX: 00FFFF00 ; inline
+
+SYMBOL: +dinput+
+
+: create-dinput ( -- )
+    f GetModuleHandle DIRECTINPUT_VERSION IDirectInput8W-iid
+    f <void*> [ f DirectInput8Create ole32-error ] keep *void*
+    +dinput+ set ;
+
+: delete-dinput ( -- )
+    +dinput+ [ com-release f ] change ;
+
diff --git a/extra/windows/dinput/summary.txt b/extra/windows/dinput/summary.txt
new file mode 100755
index 0000000000..7747560f97
--- /dev/null
+++ b/extra/windows/dinput/summary.txt
@@ -0,0 +1 @@
+DirectInput bindings
diff --git a/extra/windows/dinput/tags.txt b/extra/windows/dinput/tags.txt
new file mode 100755
index 0000000000..5aebfa6848
--- /dev/null
+++ b/extra/windows/dinput/tags.txt
@@ -0,0 +1,2 @@
+windows
+bindings

From 1872a066b9cfd47940da5f442d7216380b29a21b Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sun, 13 Jul 2008 10:42:35 -0700
Subject: [PATCH 03/35] Initial IOKit bindings. NSFastEnumeration interface

---
 extra/cocoa/cocoa.factor                     |   1 +
 extra/cocoa/enumeration/enumeration.factor   |  26 +++
 extra/cocoa/types/types.factor               |   6 +
 extra/core-foundation/core-foundation.factor |   3 +-
 extra/iokit/authors.txt                      |   1 +
 extra/iokit/hid/hid.factor                   | 114 ++++++++++++
 extra/iokit/iokit.factor                     | 178 +++++++++++++++++++
 extra/iokit/summary.txt                      |   1 +
 extra/iokit/tags.txt                         |   3 +
 9 files changed, 332 insertions(+), 1 deletion(-)
 create mode 100644 extra/cocoa/enumeration/enumeration.factor
 create mode 100644 extra/iokit/authors.txt
 create mode 100644 extra/iokit/hid/hid.factor
 create mode 100644 extra/iokit/iokit.factor
 create mode 100644 extra/iokit/summary.txt
 create mode 100644 extra/iokit/tags.txt

diff --git a/extra/cocoa/cocoa.factor b/extra/cocoa/cocoa.factor
index 1dd1e0a264..a3ac3e89ce 100755
--- a/extra/cocoa/cocoa.factor
+++ b/extra/cocoa/cocoa.factor
@@ -62,6 +62,7 @@ SYMBOL: super-sent-messages
         "NSResponder"
         "NSSavePanel"
         "NSScreen"
+        "NSString"
         "NSView"
         "NSWindow"
         "NSWorkspace"
diff --git a/extra/cocoa/enumeration/enumeration.factor b/extra/cocoa/enumeration/enumeration.factor
new file mode 100644
index 0000000000..5e3e9c5e44
--- /dev/null
+++ b/extra/cocoa/enumeration/enumeration.factor
@@ -0,0 +1,26 @@
+USING: kernel cocoa cocoa.types alien.c-types locals math sequences
+vectors fry ;
+IN: cocoa.enumeration
+
+: NS-EACH-BUFFER-SIZE 16 ; inline
+
+: (allocate-enumeration-buffers) ( -- state stackbuf count )
+    "NSFastEnumerationState" <c-object>
+    NS-EACH-BUFFER-SIZE "id" <c-array>
+    NS-EACH-BUFFER-SIZE ;
+
+:: (NSFastEnumeration-each) ( object quot state stackbuf count -- )
+    object state stackbuf count -> countByEnumeratingWithState:objects:count:
+    dup zero? [ drop ] [
+        [ stackbuf void*-nth quot call ] each
+        object quot state stackbuf count (NSFastEnumeration-each)
+    ] if ; inline
+
+: NSFastEnumeration-each ( object quot -- )
+    (allocate-enumeration-buffers) (NSFastEnumeration-each) ; inline
+
+: NSFastEnumeration-map ( object quot -- vector )
+    NS-EACH-BUFFER-SIZE <vector> [ '[ @ , push ] NSFastEnumeration-each ] keep ; inline
+
+: NSFastEnumeration>vector ( object -- vector )
+    [ ] NSFastEnumeration-map ;
diff --git a/extra/cocoa/types/types.factor b/extra/cocoa/types/types.factor
index 7d21687e1b..dbaf311da2 100644
--- a/extra/cocoa/types/types.factor
+++ b/extra/cocoa/types/types.factor
@@ -64,3 +64,9 @@ C-STRUCT: CGAffineTransform
     { "float" "d" }
     { "float" "tx" }
     { "float" "ty" } ;
+
+C-STRUCT: NSFastEnumerationState
+    { "ulong" "state" }
+    { "id*" "itemsPtr" }
+    { "ulong*" "mutationsPtr" }
+    { "ulong[5]" "extra" } ;
diff --git a/extra/core-foundation/core-foundation.factor b/extra/core-foundation/core-foundation.factor
index a4bd24ccca..b91493d2be 100644
--- a/extra/core-foundation/core-foundation.factor
+++ b/extra/core-foundation/core-foundation.factor
@@ -24,7 +24,8 @@ FUNCTION: void CFArraySetValueAtIndex ( CFArrayRef array, CFIndex index, void* v
 
 FUNCTION: CFIndex CFArrayGetCount ( CFArrayRef array ) ;
 
-: kCFURLPOSIXPathStyle 0 ;
+: kCFURLPOSIXPathStyle 0 ; inline
+: kCFAllocatorDefault f ; inline
 
 FUNCTION: CFURLRef CFURLCreateWithFileSystemPath ( CFAllocatorRef allocator, CFStringRef filePath, int pathStyle, Boolean isDirectory ) ;
 
diff --git a/extra/iokit/authors.txt b/extra/iokit/authors.txt
new file mode 100644
index 0000000000..f13c9c1e77
--- /dev/null
+++ b/extra/iokit/authors.txt
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/iokit/hid/hid.factor b/extra/iokit/hid/hid.factor
new file mode 100644
index 0000000000..623a01978e
--- /dev/null
+++ b/extra/iokit/hid/hid.factor
@@ -0,0 +1,114 @@
+USING: iokit alien.syntax alien.c-types kernel system ;
+IN: iokit.hid
+
+: kIOHIDDeviceKey "IOHIDDevice" ; inline
+
+: kIOHIDTransportKey                  "Transport" ; inline
+: kIOHIDVendorIDKey                   "VendorID" ; inline
+: kIOHIDVendorIDSourceKey             "VendorIDSource" ; inline
+: kIOHIDProductIDKey                  "ProductID" ; inline
+: kIOHIDVersionNumberKey              "VersionNumber" ; inline
+: kIOHIDManufacturerKey               "Manufacturer" ; inline
+: kIOHIDProductKey                    "Product" ; inline
+: kIOHIDSerialNumberKey               "SerialNumber" ; inline
+: kIOHIDCountryCodeKey                "CountryCode" ; inline
+: kIOHIDLocationIDKey                 "LocationID" ; inline
+: kIOHIDDeviceUsageKey                "DeviceUsage" ; inline
+: kIOHIDDeviceUsagePageKey            "DeviceUsagePage" ; inline
+: kIOHIDDeviceUsagePairsKey           "DeviceUsagePairs" ; inline
+: kIOHIDPrimaryUsageKey               "PrimaryUsage" ; inline
+: kIOHIDPrimaryUsagePageKey           "PrimaryUsagePage" ; inline
+: kIOHIDMaxInputReportSizeKey         "MaxInputReportSize" ; inline
+: kIOHIDMaxOutputReportSizeKey	      "MaxOutputReportSize" ; inline
+: kIOHIDMaxFeatureReportSizeKey	      "MaxFeatureReportSize" ; inline
+: kIOHIDReportIntervalKey             "ReportInterval" ; inline
+
+: kIOHIDElementKey                    "Elements" ; inline
+
+: kIOHIDElementCookieKey                      "ElementCookie" ; inline
+: kIOHIDElementTypeKey                        "Type" ; inline
+: kIOHIDElementCollectionTypeKey              "CollectionType" ; inline
+: kIOHIDElementUsageKey                       "Usage" ; inline
+: kIOHIDElementUsagePageKey                   "UsagePage" ; inline
+: kIOHIDElementMinKey                         "Min" ; inline
+: kIOHIDElementMaxKey                         "Max" ; inline
+: kIOHIDElementScaledMinKey                   "ScaledMin" ; inline
+: kIOHIDElementScaledMaxKey                   "ScaledMax" ; inline
+: kIOHIDElementSizeKey                        "Size" ; inline
+: kIOHIDElementReportSizeKey                  "ReportSize" ; inline
+: kIOHIDElementReportCountKey                 "ReportCount" ; inline
+: kIOHIDElementReportIDKey                    "ReportID" ; inline
+: kIOHIDElementIsArrayKey                     "IsArray" ; inline
+: kIOHIDElementIsRelativeKey                  "IsRelative" ; inline
+: kIOHIDElementIsWrappingKey                  "IsWrapping" ; inline
+: kIOHIDElementIsNonLinearKey                 "IsNonLinear" ; inline
+: kIOHIDElementHasPreferredStateKey           "HasPreferredState" ; inline
+: kIOHIDElementHasNullStateKey                "HasNullState" ; inline
+: kIOHIDElementFlagsKey                       "Flags" ; inline
+: kIOHIDElementUnitKey                        "Unit" ; inline
+: kIOHIDElementUnitExponentKey                "UnitExponent" ; inline
+: kIOHIDElementNameKey                        "Name" ; inline
+: kIOHIDElementValueLocationKey               "ValueLocation" ; inline
+: kIOHIDElementDuplicateIndexKey              "DuplicateIndex" ; inline
+: kIOHIDElementParentCollectionKey            "ParentCollection" ; inline
+
+: kIOHIDElementVendorSpecificKey
+    cpu ppc? "VendorSpecifc" "VendorSpecific" ? ; inline
+
+: kIOHIDElementCookieMinKey           "ElementCookieMin" ; inline
+: kIOHIDElementCookieMaxKey           "ElementCookieMax" ; inline
+: kIOHIDElementUsageMinKey            "UsageMin" ; inline
+: kIOHIDElementUsageMaxKey            "UsageMax" ; inline
+
+: kIOHIDElementCalibrationMinKey              "CalibrationMin" ; inline
+: kIOHIDElementCalibrationMaxKey              "CalibrationMax" ; inline
+: kIOHIDElementCalibrationSaturationMinKey    "CalibrationSaturationMin" ; inline
+: kIOHIDElementCalibrationSaturationMaxKey    "CalibrationSaturationMax" ; inline
+: kIOHIDElementCalibrationDeadZoneMinKey      "CalibrationDeadZoneMin" ; inline
+: kIOHIDElementCalibrationDeadZoneMaxKey      "CalibrationDeadZoneMax" ; inline
+: kIOHIDElementCalibrationGranularityKey      "CalibrationGranularity" ; inline
+
+TYPEDEF: ptrdiff_t IOHIDElementCookie
+TYPEDEF: int IOHIDElementType
+TYPEDEF: int IOHIDElementCollectionType
+TYPEDEF: int IOHIDReportType
+TYPEDEF: uint IOHIDOptionsType
+TYPEDEF: uint IOHIDQueueOptionsType
+TYPEDEF: uint IOHIDElementFlags
+
+: kIOHIDElementTypeInput_Misc        1 ; inline
+: kIOHIDElementTypeInput_Button      2 ; inline
+: kIOHIDElementTypeInput_Axis        3 ; inline
+: kIOHIDElementTypeInput_ScanCodes   4 ; inline
+: kIOHIDElementTypeOutput            129 ; inline
+: kIOHIDElementTypeFeature           257 ; inline
+: kIOHIDElementTypeCollection        513 ; inline
+
+: kIOHIDElementCollectionTypePhysical	    HEX: 00 ; inline
+: kIOHIDElementCollectionTypeApplication    HEX: 01 ; inline
+: kIOHIDElementCollectionTypeLogical        HEX: 02 ; inline
+: kIOHIDElementCollectionTypeReport         HEX: 03 ; inline
+: kIOHIDElementCollectionTypeNamedArray     HEX: 04 ; inline
+: kIOHIDElementCollectionTypeUsageSwitch    HEX: 05 ; inline
+: kIOHIDElementCollectionTypeUsageModifier  HEX: 06 ; inline
+
+: kIOHIDReportTypeInput    0 ; inline
+: kIOHIDReportTypeOutput   1 ; inline
+: kIOHIDReportTypeFeature  2 ; inline
+: kIOHIDReportTypeCount    3 ; inline
+
+: kIOHIDOptionsTypeNone	       HEX: 00 ; inline
+: kIOHIDOptionsTypeSeizeDevice HEX: 01 ; inline
+
+: kIOHIDQueueOptionsTypeNone	   HEX: 00 ; inline
+: kIOHIDQueueOptionsTypeEnqueueAll HEX: 01 ; inline
+
+: kIOHIDElementFlagsConstantMask        HEX: 0001 ; inline
+: kIOHIDElementFlagsVariableMask        HEX: 0002 ; inline
+: kIOHIDElementFlagsRelativeMask        HEX: 0004 ; inline
+: kIOHIDElementFlagsWrapMask            HEX: 0008 ; inline
+: kIOHIDElementFlagsNonLinearMask       HEX: 0010 ; inline
+: kIOHIDElementFlagsNoPreferredMask     HEX: 0020 ; inline
+: kIOHIDElementFlagsNullStateMask       HEX: 0040 ; inline
+: kIOHIDElementFlagsVolativeMask        HEX: 0080 ; inline
+: kIOHIDElementFlagsBufferedByteMask    HEX: 0100 ; inline
diff --git a/extra/iokit/iokit.factor b/extra/iokit/iokit.factor
new file mode 100644
index 0000000000..a7c898ef6d
--- /dev/null
+++ b/extra/iokit/iokit.factor
@@ -0,0 +1,178 @@
+USING: alien.syntax alien.c-types cocoa core-foundation system
+combinators kernel sequences debugger io accessors ;
+IN: iokit
+
+<< {
+    { [ os macosx? ] [ "/System/Library/Frameworks/IOKit.framework" load-framework ] }
+    [ "IOKit only supported on Mac OS X" ]
+} cond >>
+
+: kIOKitBuildVersionKey   "IOKitBuildVersion" ; inline
+: kIOKitDiagnosticsKey   "IOKitDiagnostics" ; inline
+ 
+: kIORegistryPlanesKey   "IORegistryPlanes" ; inline
+: kIOCatalogueKey    "IOCatalogue" ; inline
+
+: kIOServicePlane    "IOService" ; inline
+: kIOPowerPlane    "IOPower" ; inline
+: kIODeviceTreePlane   "IODeviceTree" ; inline
+: kIOAudioPlane    "IOAudio" ; inline
+: kIOFireWirePlane   "IOFireWire" ; inline
+: kIOUSBPlane    "IOUSB" ; inline
+
+: kIOServiceClass    "IOService" ; inline
+
+: kIOResourcesClass   "IOResources" ; inline
+
+: kIOClassKey    "IOClass" ; inline
+: kIOProbeScoreKey   "IOProbeScore" ; inline
+: kIOKitDebugKey    "IOKitDebug" ; inline
+
+: kIOProviderClassKey   "IOProviderClass" ; inline
+: kIONameMatchKey    "IONameMatch" ; inline
+: kIOPropertyMatchKey   "IOPropertyMatch" ; inline
+: kIOPathMatchKey    "IOPathMatch" ; inline
+: kIOLocationMatchKey   "IOLocationMatch" ; inline
+: kIOParentMatchKey   "IOParentMatch" ; inline
+: kIOResourceMatchKey   "IOResourceMatch" ; inline
+: kIOMatchedServiceCountKey  "IOMatchedServiceCountMatch" ; inline
+
+: kIONameMatchedKey   "IONameMatched" ; inline
+
+: kIOMatchCategoryKey   "IOMatchCategory" ; inline
+: kIODefaultMatchCategoryKey  "IODefaultMatchCategory" ; inline
+
+: kIOUserClientClassKey   "IOUserClientClass" ; inline
+
+: kIOUserClientCrossEndianKey   "IOUserClientCrossEndian" ; inline
+: kIOUserClientCrossEndianCompatibleKey  "IOUserClientCrossEndianCompatible" ; inline
+: kIOUserClientSharedInstanceKey   "IOUserClientSharedInstance" ; inline
+
+: kIOPublishNotification   "IOServicePublish" ; inline
+: kIOFirstPublishNotification  "IOServiceFirstPublish" ; inline
+: kIOMatchedNotification   "IOServiceMatched" ; inline
+: kIOFirstMatchNotification  "IOServiceFirstMatch" ; inline
+: kIOTerminatedNotification  "IOServiceTerminate" ; inline
+
+: kIOGeneralInterest   "IOGeneralInterest" ; inline
+: kIOBusyInterest    "IOBusyInterest" ; inline
+: kIOAppPowerStateInterest  "IOAppPowerStateInterest" ; inline
+: kIOPriorityPowerStateInterest  "IOPriorityPowerStateInterest" ; inline
+
+: kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage" ; inline
+
+: kIOCFPlugInTypesKey   "IOCFPlugInTypes" ; inline
+
+: kIOCommandPoolSizeKey         "IOCommandPoolSize" ; inline
+
+: kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" ; inline
+: kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" ; inline
+: kIOMaximumByteCountReadKey "IOMaximumByteCountRead" ; inline
+: kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" ; inline
+: kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" ; inline
+: kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" ; inline
+: kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" ; inline
+: kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" ; inline
+: kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" ; inline
+: kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" ; inline
+
+: kIOIconKey "IOIcon" ; inline
+: kIOBundleResourceFileKey "IOBundleResourceFile" ; inline
+
+: kIOBusBadgeKey "IOBusBadge" ; inline
+: kIODeviceIconKey "IODeviceIcon" ; inline
+
+: kIOPlatformSerialNumberKey  "IOPlatformSerialNumber"  ; inline
+
+: kIOPlatformUUIDKey  "IOPlatformUUID"  ; inline
+
+: kIONVRAMDeletePropertyKey  "IONVRAM-DELETE-PROPERTY" ; inline
+: kIODTNVRAMPanicInfoKey   "aapl,panic-info" ; inline
+
+: kIOBootDeviceKey "IOBootDevice"   ; inline
+: kIOBootDevicePathKey "IOBootDevicePath"  ; inline
+: kIOBootDeviceSizeKey "IOBootDeviceSize"  ; inline
+
+: kOSBuildVersionKey   "OS Build Version" ; inline
+
+: kNilOptions 0 ; inline
+
+TYPEDEF: uint mach_port_t
+TYPEDEF: int kern_return_t
+TYPEDEF: int boolean_t
+TYPEDEF: mach_port_t io_object_t
+TYPEDEF: io_object_t io_iterator_t
+TYPEDEF: io_object_t io_registry_entry_t
+TYPEDEF: char[128] io_name_t
+TYPEDEF: char[512] io_string_t
+
+TYPEDEF: uint IOOptionBits
+
+: MACH_PORT_NULL 0 ; inline
+: KERN_SUCCESS 0 ; inline
+
+FUNCTION: kern_return_t IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ;
+
+FUNCTION: NSDictionary* IOServiceMatching ( char* name ) ;
+FUNCTION: NSDictionary* IOServiceNameMatching ( char* name ) ;
+FUNCTION: NSDictionary* IOBSDNameMatching ( char* name ) ;
+
+FUNCTION: kern_return_t IOObjectRetain ( io_object_t o ) ;
+FUNCTION: kern_return_t IOObjectRelease ( io_object_t o ) ;
+
+FUNCTION: kern_return_t IOServiceGetMatchingServices ( mach_port_t master, NSDictionary* matchingDict, io_iterator_t* iterator ) ;
+
+FUNCTION: io_object_t IOIteratorNext ( io_iterator_t i ) ;
+FUNCTION: void IOIteratorReset ( io_iterator_t i ) ;
+FUNCTION: boolean_t IOIteratorIsValid ( io_iterator_t i ) ;
+
+FUNCTION: kern_return_t IORegistryEntryGetPath ( io_registry_entry_t entry, io_name_t plane, io_string_t path ) ;
+
+FUNCTION: kern_return_t IORegistryEntryCreateCFProperties ( io_registry_entry_t entry, NSMutableDictionary** properties, CFAllocatorRef allocator, IOOptionBits options ) ;
+
+FUNCTION: char* mach_error_string ( kern_return_t error ) ;
+
+TUPLE: mach-error error-code ;
+C: <mach-error> mach-error
+
+M: mach-error error.
+    "IOKit call failed: " print error-code>> mach_error_string print ;
+
+: mach-error ( return -- )
+    dup KERN_SUCCESS = [ drop ] [ <mach-error> throw ] if ;
+
+: master-port ( -- port )
+    MACH_PORT_NULL 0 <uint> [ IOMasterPort mach-error ] keep *uint ;
+
+: io-services-matching-dictionary ( nsdictionary -- iterator )
+    master-port swap 0 <uint>
+    [ IOServiceGetMatchingServices mach-error ] keep
+    *uint ;
+
+: io-services-matching-service ( service -- iterator )
+    IOServiceMatching io-services-matching-dictionary ;
+: io-services-matching-service-name ( service-name -- iterator )
+    IOServiceNameMatching io-services-matching-dictionary ;
+: io-services-matching-bsd-name ( bsd-name -- iterator )
+    IOBSDNameMatching io-services-matching-dictionary ;
+
+: retain-io-object ( o -- o )
+    [ IOObjectRetain mach-error ] keep ;
+: release-io-object ( o -- )
+    IOObjectRelease mach-error ;
+
+: io-objects-from-iterator* ( i -- i array )
+    [ dup IOIteratorNext dup MACH_PORT_NULL = not ]
+    [ ]
+    [ drop ] produce ;
+
+: io-objects-from-iterator ( i -- array )
+    io-objects-from-iterator* [ release-io-object ] dip ;
+    
+: properties-from-io-object ( o -- o nsdictionary )
+    dup f <void*> [
+        kCFAllocatorDefault kNilOptions
+        IORegistryEntryCreateCFProperties mach-error
+    ]
+    keep *void* ;
+
diff --git a/extra/iokit/summary.txt b/extra/iokit/summary.txt
new file mode 100644
index 0000000000..69e03254bd
--- /dev/null
+++ b/extra/iokit/summary.txt
@@ -0,0 +1 @@
+Bindings to Apple IOKit device interface
diff --git a/extra/iokit/tags.txt b/extra/iokit/tags.txt
new file mode 100644
index 0000000000..c83070b657
--- /dev/null
+++ b/extra/iokit/tags.txt
@@ -0,0 +1,3 @@
+mac
+bindings
+system

From 4a3184f3b95226209869ded5dd27e9ac80010ecd Mon Sep 17 00:00:00 2001
From: "U-VICTORIA\\Administrator" <Administrator@victoria.(none)>
Date: Sun, 13 Jul 2008 10:47:50 -0700
Subject: [PATCH 04/35] More DirectInput constants

---
 extra/windows/dinput/dinput.factor | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/extra/windows/dinput/dinput.factor b/extra/windows/dinput/dinput.factor
index 6dec0aed1a..6e77f16bdf 100755
--- a/extra/windows/dinput/dinput.factor
+++ b/extra/windows/dinput/dinput.factor
@@ -370,6 +370,12 @@ FUNCTION: HRESULT DirectInput8Create ( HINSTANCE hinst, DWORD dwVersion, REFIID
 : DIDFT_ENUMCOLLECTION ( n -- instance ) 8 shift HEX: FFFF bitand ; inline
 : DIDFT_NOCOLLECTION      HEX: 00FFFF00 ; inline
 
+: DISCL_EXCLUSIVE     HEX: 00000001 ; inline
+: DISCL_NONEXCLUSIVE  HEX: 00000002 ; inline
+: DISCL_FOREGROUND    HEX: 00000004 ; inline
+: DISCL_BACKGROUND    HEX: 00000008 ; inline
+: DISCL_NOWINKEY      HEX: 00000010 ; inline
+
 SYMBOL: +dinput+
 
 : create-dinput ( -- )

From 8174a0967c907767d7214225ce892a6f5d14d307 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sun, 13 Jul 2008 12:18:35 -0700
Subject: [PATCH 05/35] handle NSFastEnumeration case when the item pointer is
 returned in the NSFastEnumerationState struct. add words for converting plist
 objects to Factor structures

---
 extra/cocoa/cocoa.factor                   |  2 ++
 extra/cocoa/enumeration/enumeration.factor |  6 ++--
 extra/cocoa/plists/plists.factor           | 33 +++++++++++++++++++++-
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/extra/cocoa/cocoa.factor b/extra/cocoa/cocoa.factor
index a3ac3e89ce..907d75fd84 100755
--- a/extra/cocoa/cocoa.factor
+++ b/extra/cocoa/cocoa.factor
@@ -43,6 +43,7 @@ SYMBOL: super-sent-messages
         "NSArray"
         "NSAutoreleasePool"
         "NSBundle"
+        "NSData"
         "NSDictionary"
         "NSError"
         "NSEvent"
@@ -53,6 +54,7 @@ SYMBOL: super-sent-messages
         "NSNib"
         "NSNotification"
         "NSNotificationCenter"
+        "NSNumber"
         "NSObject"
         "NSOpenGLContext"
         "NSOpenGLPixelFormat"
diff --git a/extra/cocoa/enumeration/enumeration.factor b/extra/cocoa/enumeration/enumeration.factor
index 5e3e9c5e44..ae1766b1a9 100644
--- a/extra/cocoa/enumeration/enumeration.factor
+++ b/extra/cocoa/enumeration/enumeration.factor
@@ -12,8 +12,10 @@ IN: cocoa.enumeration
 :: (NSFastEnumeration-each) ( object quot state stackbuf count -- )
     object state stackbuf count -> countByEnumeratingWithState:objects:count:
     dup zero? [ drop ] [
-        [ stackbuf void*-nth quot call ] each
-        object quot state stackbuf count (NSFastEnumeration-each)
+        [
+            state NSFastEnumerationState-itemsPtr dup stackbuf ?
+            void*-nth quot call
+        ] each object quot state stackbuf count (NSFastEnumeration-each)
     ] if ; inline
 
 : NSFastEnumeration-each ( object quot -- )
diff --git a/extra/cocoa/plists/plists.factor b/extra/cocoa/plists/plists.factor
index 9e05773f53..4ffc1db139 100644
--- a/extra/cocoa/plists/plists.factor
+++ b/extra/cocoa/plists/plists.factor
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: strings arrays hashtables assocs sequences
 cocoa.messages cocoa.classes cocoa.application cocoa kernel
-namespaces io.backend ;
+namespaces io.backend math cocoa.enumeration byte-arrays
+combinators alien.c-types ;
 IN: cocoa.plists
 
 : assoc>NSDictionary ( assoc -- alien )
@@ -17,3 +18,33 @@ IN: cocoa.plists
     >r assoc>NSDictionary
     r> normalize-path <NSString> 0 -> writeToFile:atomically:
     [ "write-plist failed" throw ] unless ;
+
+DEFER: plist>
+
+: (plist-NSString>) ( NSString -- string )
+    -> UTF8String ;
+
+: (plist-NSNumber>) ( NSNumber -- number )
+    dup -> doubleValue dup >integer =
+    [ -> longLongValue ]
+    [ -> doubleValue ] if ;
+
+: (plist-NSData>) ( NSData -- byte-array )
+    dup -> length <byte-array> [ -> getBytes: ] keep ;
+
+: (plist-NSArray>) ( NSArray -- vector )
+    [ plist> ] NSFastEnumeration-map ;    
+
+: (plist-NSDictionary>) ( NSDictionary -- hashtable )
+    dup [ [ -> valueForKey: ] keep swap [ plist> ] bi@ 2array ] with
+    NSFastEnumeration-map >hashtable ;
+
+: plist> ( plist -- value )
+    {
+        { [ dup NSString     -> isKindOfClass: c-bool> ] [ (plist-NSString>)      ] }
+        { [ dup NSNumber     -> isKindOfClass: c-bool> ] [ (plist-NSNumber>)      ] }
+        { [ dup NSData       -> isKindOfClass: c-bool> ] [ (plist-NSData>)        ] }
+        { [ dup NSArray      -> isKindOfClass: c-bool> ] [ (plist-NSArray>)       ] }
+        { [ dup NSDictionary -> isKindOfClass: c-bool> ] [ (plist-NSDictionary>)  ] }
+        [ ]
+    } cond ;

From 310acd52c5d2ee577990423becd63ad682b2157a Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sun, 13 Jul 2008 12:48:59 -0700
Subject: [PATCH 06/35] malloc the NSFastEnumeration buffers because the class
 implementation might store pointers into the buffers in the enumeration state

---
 extra/cocoa/enumeration/enumeration.factor | 24 ++++++++++++----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/extra/cocoa/enumeration/enumeration.factor b/extra/cocoa/enumeration/enumeration.factor
index ae1766b1a9..0cd8e90531 100644
--- a/extra/cocoa/enumeration/enumeration.factor
+++ b/extra/cocoa/enumeration/enumeration.factor
@@ -1,28 +1,30 @@
 USING: kernel cocoa cocoa.types alien.c-types locals math sequences
-vectors fry ;
+vectors fry libc ;
 IN: cocoa.enumeration
 
 : NS-EACH-BUFFER-SIZE 16 ; inline
 
-: (allocate-enumeration-buffers) ( -- state stackbuf count )
-    "NSFastEnumerationState" <c-object>
-    NS-EACH-BUFFER-SIZE "id" <c-array>
-    NS-EACH-BUFFER-SIZE ;
+: (with-enumeration-buffers) ( quot -- )
+    "NSFastEnumerationState" heap-size swap '[
+        NS-EACH-BUFFER-SIZE "id" heap-size * [
+            NS-EACH-BUFFER-SIZE @
+        ] with-malloc
+    ] with-malloc ; inline
 
 :: (NSFastEnumeration-each) ( object quot state stackbuf count -- )
     object state stackbuf count -> countByEnumeratingWithState:objects:count:
     dup zero? [ drop ] [
-        [
-            state NSFastEnumerationState-itemsPtr dup stackbuf ?
-            void*-nth quot call
-        ] each object quot state stackbuf count (NSFastEnumeration-each)
+        state NSFastEnumerationState-itemsPtr [ stackbuf ] unless*
+        '[ , void*-nth quot call ] each
+        object quot state stackbuf count (NSFastEnumeration-each)
     ] if ; inline
 
 : NSFastEnumeration-each ( object quot -- )
-    (allocate-enumeration-buffers) (NSFastEnumeration-each) ; inline
+    [ (NSFastEnumeration-each) ] (with-enumeration-buffers) ; inline
 
 : NSFastEnumeration-map ( object quot -- vector )
-    NS-EACH-BUFFER-SIZE <vector> [ '[ @ , push ] NSFastEnumeration-each ] keep ; inline
+    NS-EACH-BUFFER-SIZE <vector>
+    [ '[ @ , push ] NSFastEnumeration-each ] keep ; inline
 
 : NSFastEnumeration>vector ( object -- vector )
     [ ] NSFastEnumeration-map ;

From f80172e0762717d8520a367026f6c0312bec23b6 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sun, 13 Jul 2008 19:19:16 -0700
Subject: [PATCH 07/35] replace limited assoc>NSDictionary word with a >plist
 word that can convert any structure of numbers, strings, byte-arrays,
 hashtables, and sequences into the equivalent Cocoa objects

---
 extra/cocoa/application/application.factor   | 12 ++++-
 extra/cocoa/plists/plists.factor             | 25 ++++++----
 extra/core-foundation/core-foundation.factor | 50 +++++++++++++++++++-
 3 files changed, 76 insertions(+), 11 deletions(-)

diff --git a/extra/cocoa/application/application.factor b/extra/cocoa/application/application.factor
index 3e6f8c5be7..a28952ea33 100755
--- a/extra/cocoa/application/application.factor
+++ b/extra/cocoa/application/application.factor
@@ -3,12 +3,20 @@
 USING: alien alien.syntax io kernel namespaces core-foundation
 core-foundation.run-loop cocoa.messages cocoa cocoa.classes
 cocoa.runtime sequences threads debugger init summary
-kernel.private ;
+kernel.private assocs ;
 IN: cocoa.application
 
 : <NSString> ( str -- alien ) <CFString> -> autorelease ;
-
 : <NSArray> ( seq -- alien ) <CFArray> -> autorelease ;
+: <NSNumber> ( number -- alien ) <CFNumber> -> autorelease ;
+: <NSData> ( byte-array -- alien ) <CFData> -> autorelease ;
+: <NSDictionary> ( assoc -- alien )
+    NSMutableDictionary over assoc-size -> dictionaryWithCapacity:
+    [
+        [
+            spin -> setObject:forKey:
+        ] curry assoc-each
+    ] keep ;
 
 : NSApplicationDelegateReplySuccess 0 ;
 : NSApplicationDelegateReplyCancel  1 ;
diff --git a/extra/cocoa/plists/plists.factor b/extra/cocoa/plists/plists.factor
index 4ffc1db139..139e0840e1 100644
--- a/extra/cocoa/plists/plists.factor
+++ b/extra/cocoa/plists/plists.factor
@@ -6,16 +6,25 @@ namespaces io.backend math cocoa.enumeration byte-arrays
 combinators alien.c-types ;
 IN: cocoa.plists
 
-: assoc>NSDictionary ( assoc -- alien )
-    NSMutableDictionary over assoc-size -> dictionaryWithCapacity:
-    [
-        [
-            spin [ <NSString> ] bi@ -> setObject:forKey:
-        ] curry assoc-each
-    ] keep ;
+GENERIC: >plist ( value -- plist )
+
+M: number >plist
+    <NSNumber> ;
+M: t >plist
+    <NSNumber> ;
+M: f >plist
+    <NSNumber> ;
+M: string >plist
+    <NSString> ;
+M: byte-array >plist
+    <NSData> ;
+M: hashtable >plist
+    [ [ >plist ] bi@ ] assoc-map <NSDictionary> ;
+M: sequence >plist
+    [ >plist ] map <NSArray> ;
 
 : write-plist ( assoc path -- )
-    >r assoc>NSDictionary
+    >r >plist
     r> normalize-path <NSString> 0 -> writeToFile:atomically:
     [ "write-plist failed" throw ] unless ;
 
diff --git a/extra/core-foundation/core-foundation.factor b/extra/core-foundation/core-foundation.factor
index b91493d2be..e1c2c4c517 100644
--- a/extra/core-foundation/core-foundation.factor
+++ b/extra/core-foundation/core-foundation.factor
@@ -6,16 +6,44 @@ IN: core-foundation
 
 TYPEDEF: void* CFAllocatorRef
 TYPEDEF: void* CFArrayRef
+TYPEDEF: void* CFDataRef
+TYPEDEF: void* CFDictionaryRef
+TYPEDEF: void* CFMutableDictionaryRef
+TYPEDEF: void* CFNumberRef
 TYPEDEF: void* CFBundleRef
+TYPEDEF: void* CFRunLoopRef
+TYPEDEF: void* CFSetRef
 TYPEDEF: void* CFStringRef
 TYPEDEF: void* CFURLRef
 TYPEDEF: void* CFUUIDRef
+TYPEDEF: void* CFTypeRef
 TYPEDEF: bool Boolean
 TYPEDEF: int CFIndex
 TYPEDEF: int SInt32
+TYPEDEF: uint UInt32
+TYPEDEF: uint CFTypeID
 TYPEDEF: double CFTimeInterval
 TYPEDEF: double CFAbsoluteTime
 
+TYPEDEF: int CFNumberType
+: kCFNumberSInt8Type 1 ; inline
+: kCFNumberSInt16Type 2 ; inline
+: kCFNumberSInt32Type 3 ; inline
+: kCFNumberSInt64Type 4 ; inline
+: kCFNumberFloat32Type 5 ; inline
+: kCFNumberFloat64Type 6 ; inline
+: kCFNumberCharType 7 ; inline
+: kCFNumberShortType 8 ; inline
+: kCFNumberIntType 9 ; inline
+: kCFNumberLongType 10 ; inline
+: kCFNumberLongLongType 11 ; inline
+: kCFNumberFloatType 12 ; inline
+: kCFNumberDoubleType 13 ; inline
+: kCFNumberCFIndexType 14 ; inline
+: kCFNumberNSIntegerType 15 ; inline
+: kCFNumberCGFloatType 16 ; inline
+: kCFNumberMaxType 16 ; inline
+
 FUNCTION: CFArrayRef CFArrayCreateMutable ( CFAllocatorRef allocator, CFIndex capacity, void* callbacks ) ;
 
 FUNCTION: void* CFArrayGetValueAtIndex ( CFArrayRef array, CFIndex idx ) ;
@@ -39,11 +67,18 @@ FUNCTION: CFIndex CFStringGetLength ( CFStringRef theString ) ;
 
 FUNCTION: void CFStringGetCharacters ( void* theString, CFIndex start, CFIndex length, void* buffer ) ;
 
+FUNCTION: CFNumberRef CFNumberCreate ( CFAllocatorRef allocator, CFNumberType theType, void* valuePtr ) ;
+
+FUNCTION: CFDataRef CFDataCreate ( CFAllocatorRef allocator, uchar* bytes, CFIndex length ) ;
+
 FUNCTION: CFBundleRef CFBundleCreate ( CFAllocatorRef allocator, CFURLRef bundleURL ) ;
 
 FUNCTION: Boolean CFBundleLoadExecutable ( CFBundleRef bundle ) ;
 
-FUNCTION: void CFRelease ( void* cf ) ;
+FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) ;
+FUNCTION: void CFRelease ( CFTypeRef cf ) ;
+
+FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ;
 
 : CF>array ( alien -- array )
     dup CFArrayGetCount [ CFArrayGetValueAtIndex ] with map ;
@@ -81,6 +116,19 @@ FUNCTION: void CFRelease ( void* cf ) ;
         f swap CFBundleCreate
     ] keep CFRelease ;
 
+GENERIC: <CFNumber> ( number -- alien )
+M: integer <CFNumber>
+    [ f kCFNumberLongLongType ] dip <longlong> CFNumberCreate ;
+M: float <CFNumber>
+    [ f kCFNumberDoubleType ] dip <double> CFNumberCreate ;
+M: t <CFNumber>
+    drop f kCFNumberIntType 1 <int> CFNumberCreate ;
+M: f <CFNumber>
+    drop f kCFNumberIntType 0 <int> CFNumberCreate ;
+
+: <CFData> ( byte-array -- alien )
+    [ f ] dip dup length CFDataCreate ;
+
 : load-framework ( name -- )
     dup <CFBundle> [
         CFBundleLoadExecutable drop

From f1b745d76e82e2814c76060cebdeed0c3a29ca52 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Mon, 14 Jul 2008 18:54:09 -0700
Subject: [PATCH 08/35] Pretty-print methods for BLAS objects

---
 extra/math/blas/syntax/syntax.factor | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/extra/math/blas/syntax/syntax.factor b/extra/math/blas/syntax/syntax.factor
index 895e6f3d99..187d9c3a6c 100644
--- a/extra/math/blas/syntax/syntax.factor
+++ b/extra/math/blas/syntax/syntax.factor
@@ -1,4 +1,5 @@
-USING: kernel math.blas.matrices math.blas.vectors parser ;
+USING: kernel math.blas.matrices math.blas.vectors parser
+arrays prettyprint.backend sequences ;
 IN: math.blas.syntax
 
 : svector{ ( accum -- accum )
@@ -18,3 +19,16 @@ IN: math.blas.syntax
     \ } [ >float-complex-blas-matrix ] parse-literal ; parsing
 : zmatrix{ ( accum -- accum )
     \ } [ >double-complex-blas-matrix ] parse-literal ; parsing
+
+M: float-blas-vector pprint-delims drop \ svector{ \ } ;
+M: double-blas-vector pprint-delims drop \ dvector{ \ } ;
+M: float-complex-blas-vector pprint-delims drop \ cvector{ \ } ;
+M: double-complex-blas-vector pprint-delims drop \ zvector{ \ } ;
+
+M: float-blas-matrix pprint-delims drop \ smatrix{ \ } ;
+M: double-blas-matrix pprint-delims drop \ dmatrix{ \ } ;
+M: float-complex-blas-matrix pprint-delims drop \ cmatrix{ \ } ;
+M: double-complex-blas-matrix pprint-delims drop \ zmatrix{ \ } ;
+
+M: blas-vector-base >pprint-sequence ;
+M: blas-matrix-base >pprint-sequence Mrows [ >array ] map ;

From 136a7a66c3f367d1fa8a87f2fdbb3f45b56e37d4 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Mon, 14 Jul 2008 19:43:39 -0700
Subject: [PATCH 09/35] IOHIDValues, Elements, and Transactions

---
 extra/iokit/hid/hid.factor | 160 ++++++++++++++++++++++++++++++++++---
 extra/iokit/iokit.factor   |  24 +++---
 2 files changed, 164 insertions(+), 20 deletions(-)

diff --git a/extra/iokit/hid/hid.factor b/extra/iokit/hid/hid.factor
index 623a01978e..da8c785791 100644
--- a/extra/iokit/hid/hid.factor
+++ b/extra/iokit/hid/hid.factor
@@ -1,4 +1,4 @@
-USING: iokit alien.syntax alien.c-types kernel system ;
+USING: iokit alien.syntax alien.c-types kernel system core-foundation ;
 IN: iokit.hid
 
 : kIOHIDDeviceKey "IOHIDDevice" ; inline
@@ -68,14 +68,6 @@ IN: iokit.hid
 : kIOHIDElementCalibrationDeadZoneMaxKey      "CalibrationDeadZoneMax" ; inline
 : kIOHIDElementCalibrationGranularityKey      "CalibrationGranularity" ; inline
 
-TYPEDEF: ptrdiff_t IOHIDElementCookie
-TYPEDEF: int IOHIDElementType
-TYPEDEF: int IOHIDElementCollectionType
-TYPEDEF: int IOHIDReportType
-TYPEDEF: uint IOHIDOptionsType
-TYPEDEF: uint IOHIDQueueOptionsType
-TYPEDEF: uint IOHIDElementFlags
-
 : kIOHIDElementTypeInput_Misc        1 ; inline
 : kIOHIDElementTypeInput_Button      2 ; inline
 : kIOHIDElementTypeInput_Axis        3 ; inline
@@ -112,3 +104,153 @@ TYPEDEF: uint IOHIDElementFlags
 : kIOHIDElementFlagsNullStateMask       HEX: 0040 ; inline
 : kIOHIDElementFlagsVolativeMask        HEX: 0080 ; inline
 : kIOHIDElementFlagsBufferedByteMask    HEX: 0100 ; inline
+
+: kIOHIDValueScaleTypeCalibrated 0 ; inline
+: kIOHIDValueScaleTypePhysical   1 ; inline
+
+: kIOHIDTransactionDirectionTypeInput  0 ; inline
+: kIOHIDTransactionDirectionTypeOutput 1 ; inline
+
+: kIOHIDTransactionOptionDefaultOutputValue 1 ; inline
+
+TYPEDEF: ptrdiff_t IOHIDElementCookie
+TYPEDEF: int IOHIDElementType
+TYPEDEF: int IOHIDElementCollectionType
+TYPEDEF: int IOHIDReportType
+TYPEDEF: uint IOHIDOptionsType
+TYPEDEF: uint IOHIDQueueOptionsType
+TYPEDEF: uint IOHIDElementFlags
+TYPEDEF: void* IOHIDDeviceRef
+TYPEDEF: void* IOHIDElementRef
+TYPEDEF: void* IOHIDValueRef
+TYPEDEF: void* IOHIDManagerRef
+TYPEDEF: void* IOHIDTransactionRef
+TYPEDEF: UInt32 IOHIDValueScaleType
+TYPEDEF: UInt32 IOHIDTransactionDirectionType
+
+! Callback signature: void IOHIDCallback(void* context, IOReturn result, void* sender);
+TYPEDEF: void* IOHIDCallback
+! Callback signature: void IOHIDReportCallback(void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, uchar * report, CFIndex reportLength);
+TYPEDEF: void* IOHIDReportCallback
+! Callback signature: void IOHIDValueCallback(void* context, IOReturn result, void* sender, IOHIDValueRef value);
+TYPEDEF: void* IOHIDValueCallback
+! Callback signature: void IOHIDValueMultipleCallback(void* context, IOReturn result, void* sender, CFDictionaryRef multiple);
+TYPEDEF: void* IOHIDValueMultipleCallback
+! Callback signature: void IOHIDDeviceCallback(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
+TYPEDEF: void* IOHIDDeviceCallback
+
+! IOHIDDevice
+
+FUNCTION: CFTypeID IOHIDDeviceGetTypeID ( ) ;
+FUNCTION: IOHIDDeviceRef IOHIDDeviceCreate ( CFAllocatorRef allocator, io_service_t service ) ;
+FUNCTION: IOReturn IOHIDDeviceOpen ( IOHIDDeviceRef device, IOOptionBits options ) ;
+FUNCTION: IOReturn IOHIDDeviceClose ( IOHIDDeviceRef device, IOOptionBits options ) ;
+FUNCTION: Boolean IOHIDDeviceConformsTo ( IOHIDDeviceRef device, UInt32 usagePage, UInt32 usage ) ;
+FUNCTION: CFTypeRef IOHIDDeviceGetProperty ( IOHIDDeviceRef device, CFStringRef key ) ;
+FUNCTION: Boolean IOHIDDeviceSetProperty ( IOHIDDeviceRef device, CFStringRef key, CFTypeRef property ) ;
+FUNCTION: CFArrayRef IOHIDDeviceCopyMatchingElements ( IOHIDDeviceRef device, CFDictionaryRef matching, IOOptionBits options ) ;
+FUNCTION: void IOHIDDeviceScheduleWithRunLoop ( IOHIDDeviceRef device, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDDeviceUnscheduleFromRunLoop ( IOHIDDeviceRef device, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDDeviceRegisterRemovalCallback ( IOHIDDeviceRef device, IOHIDCallback callback, void* context ) ;
+FUNCTION: void IOHIDDeviceRegisterInputValueCallback ( IOHIDDeviceRef device, IOHIDValueCallback callback, void* context ) ;
+FUNCTION: void IOHIDDeviceRegisterInputReportCallback ( IOHIDDeviceRef device, uchar* report, CFIndex reportLength, IOHIDReportCallback callback, void* context ) ;
+FUNCTION: void IOHIDDeviceSetInputValueMatching ( IOHIDDeviceRef device, CFDictionaryRef matching ) ;
+FUNCTION: void IOHIDDeviceSetInputValueMatchingMultiple ( IOHIDDeviceRef device, CFArrayRef multiple ) ;
+FUNCTION: IOReturn IOHIDDeviceSetValue ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef value ) ;
+FUNCTION: IOReturn IOHIDDeviceSetValueMultiple ( IOHIDDeviceRef device, CFDictionaryRef multiple ) ;
+FUNCTION: IOReturn IOHIDDeviceSetValueWithCallback ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef value, CFTimeInterval timeout, IOHIDValueCallback callback, void* context ) ;
+FUNCTION: IOReturn IOHIDDeviceSetValueMultipleWithCallback ( IOHIDDeviceRef device, CFDictionaryRef multiple, CFTimeInterval timeout, IOHIDValueMultipleCallback callback, void* context ) ;
+FUNCTION: IOReturn IOHIDDeviceGetValue ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef* pValue ) ;
+FUNCTION: IOReturn IOHIDDeviceCopyValueMultiple ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple ) ;
+FUNCTION: IOReturn IOHIDDeviceGetValueWithCallback ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef* pValue, CFTimeInterval timeout, IOHIDValueCallback callback, void* context ) ;
+FUNCTION: IOReturn IOHIDDeviceCopyValueMultipleWithCallback ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple, CFTimeInterval timeout, IOHIDValueMultipleCallback callback, void* context ) ;
+FUNCTION: IOReturn IOHIDDeviceSetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex reportLength ) ;
+FUNCTION: IOReturn IOHIDDeviceSetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex reportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ;
+FUNCTION: IOReturn IOHIDDeviceGetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex* pReportLength ) ;
+FUNCTION: IOReturn IOHIDDeviceGetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex* pReportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ;
+
+! IOHIDManager
+
+FUNCTION: CFTypeID IOHIDManagerGetTypeID ( ) ;
+FUNCTION: IOHIDManagerRef IOHIDManagerCreate ( CFAllocatorRef allocator, IOOptionBits options ) ;
+FUNCTION: IOReturn IOHIDManagerOpen ( IOHIDManagerRef manager, IOOptionBits options ) ;
+FUNCTION: IOReturn IOHIDManagerClose ( IOHIDManagerRef manager, IOOptionBits options ) ;
+FUNCTION: CFTypeRef IOHIDManagerGetProperty ( IOHIDManagerRef manager, CFStringRef key ) ;
+FUNCTION: Boolean IOHIDManagerSetProperty ( IOHIDManagerRef manager, CFStringRef key, CFTypeRef value ) ;
+FUNCTION: void IOHIDManagerScheduleWithRunLoop ( IOHIDManagerRef manager, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDManagerUnscheduleFromRunLoop ( IOHIDManagerRef manager, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDManagerSetDeviceMatching ( IOHIDManagerRef manager, CFDictionaryRef matching ) ;
+FUNCTION: void IOHIDManagerSetDeviceMatchingMultiple ( IOHIDManagerRef manager, CFArrayRef multiple ) ;
+FUNCTION: CFSetRef IOHIDManagerCopyDevices ( IOHIDManagerRef manager ) ;
+FUNCTION: void IOHIDManagerRegisterDeviceMatchingCallback ( IOHIDManagerRef manager, IOHIDDeviceCallback callback, void* context ) ;
+FUNCTION: void IOHIDManagerRegisterDeviceRemovalCallback ( IOHIDManagerRef manager, IOHIDDeviceCallback callback, void* context ) ;
+FUNCTION: void IOHIDManagerRegisterInputReportCallback ( IOHIDManagerRef manager, IOHIDReportCallback callback, void* context ) ;
+FUNCTION: void IOHIDManagerRegisterInputValueCallback ( IOHIDManagerRef manager, IOHIDValueCallback callback, void* context ) ;
+FUNCTION: void IOHIDManagerSetInputValueMatching ( IOHIDManagerRef manager, CFDictionaryRef matching ) ;
+FUNCTION: void IOHIDManagerSetInputValueMatchingMultiple ( IOHIDManagerRef manager, CFArrayRef multiple ) ;
+
+! IOHIDElement
+
+FUNCTION: CFTypeID IOHIDElementGetTypeID ( ) ;
+FUNCTION: IOHIDElementRef IOHIDElementCreateWithDictionary ( CFAllocatorRef allocator, CFDictionaryRef dictionary ) ;
+FUNCTION: IOHIDDeviceRef IOHIDElementGetDevice ( IOHIDElementRef element ) ;
+FUNCTION: IOHIDElementRef IOHIDElementGetParent ( IOHIDElementRef element ) ;
+FUNCTION: CFArrayRef IOHIDElementGetChildren ( IOHIDElementRef element ) ;
+FUNCTION: void IOHIDElementAttach ( IOHIDElementRef element, IOHIDElementRef toAttach ) ;
+FUNCTION: void IOHIDElementDetach ( IOHIDElementRef element, IOHIDElementRef toDetach ) ;
+FUNCTION: CFArrayRef IOHIDElementCopyAttached ( IOHIDElementRef element ) ;
+FUNCTION: IOHIDElementCookie IOHIDElementGetCookie ( IOHIDElementRef element ) ;
+FUNCTION: IOHIDElementType IOHIDElementGetType ( IOHIDElementRef element ) ;
+FUNCTION: IOHIDElementCollectionType IOHIDElementGetCollectionType ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetUsagePage ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetUsage ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementIsVirtual ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementIsRelative ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementIsWrapping ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementIsArray ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementIsNonLinear ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementHasPreferredState ( IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDElementHasNullState ( IOHIDElementRef element ) ;
+FUNCTION: CFStringRef IOHIDElementGetName ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetReportID ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetReportSize ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetReportCount ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetUnit ( IOHIDElementRef element ) ;
+FUNCTION: UInt32 IOHIDElementGetUnitExponent ( IOHIDElementRef element ) ;
+FUNCTION: CFIndex IOHIDElementGetLogicalMin ( IOHIDElementRef element ) ;
+FUNCTION: CFIndex IOHIDElementGetLogicalMax ( IOHIDElementRef element ) ;
+FUNCTION: CFIndex IOHIDElementGetPhysicalMin ( IOHIDElementRef element ) ;
+FUNCTION: CFIndex IOHIDElementGetPhysicalMax ( IOHIDElementRef element ) ;
+FUNCTION: CFTypeRef IOHIDElementGetProperty ( IOHIDElementRef element, CFStringRef key ) ;
+FUNCTION: Boolean IOHIDElementSetProperty ( IOHIDElementRef element, CFStringRef key, CFTypeRef property ) ;
+
+! IOHIDValue
+
+FUNCTION: CFTypeID IOHIDValueGetTypeID ( ) ;
+FUNCTION: IOHIDValueRef IOHIDValueCreateWithIntegerValue ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, CFIndex value ) ;
+FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytes ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, uchar* bytes, CFIndex length ) ;
+FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytesNoCopy ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, uchar* bytes, CFIndex length ) ;
+FUNCTION: IOHIDElementRef IOHIDValueGetElement ( IOHIDValueRef value ) ;
+FUNCTION: ulonglong IOHIDValueGetTimeStamp ( IOHIDValueRef value ) ;
+FUNCTION: CFIndex IOHIDValueGetLength ( IOHIDValueRef value ) ;
+FUNCTION: uchar* IOHIDValueGetBytePtr ( IOHIDValueRef value ) ;
+FUNCTION: CFIndex IOHIDValueGetIntegerValue ( IOHIDValueRef value ) ;
+FUNCTION: double IOHIDValueGetScaledValue ( IOHIDValueRef value, IOHIDValueScaleType type ) ;
+
+! IOHIDTransaction
+
+FUNCTION: CFTypeID IOHIDTransactionGetTypeID ( ) ;
+FUNCTION: IOHIDTransactionRef IOHIDTransactionCreate ( CFAllocatorRef allocator, IOHIDDeviceRef device, IOHIDTransactionDirectionType direction, IOOptionBits options ) ;
+FUNCTION: IOHIDDeviceRef IOHIDTransactionGetDevice ( IOHIDTransactionRef transaction ) ;
+FUNCTION: IOHIDTransactionDirectionType IOHIDTransactionGetDirection ( IOHIDTransactionRef transaction ) ;
+FUNCTION: void IOHIDTransactionSetDirection ( IOHIDTransactionRef transaction, IOHIDTransactionDirectionType direction ) ;
+FUNCTION: void IOHIDTransactionAddElement ( IOHIDTransactionRef transaction, IOHIDElementRef element ) ;
+FUNCTION: void IOHIDTransactionRemoveElement ( IOHIDTransactionRef transaction, IOHIDElementRef element ) ;
+FUNCTION: Boolean IOHIDTransactionContainsElement ( IOHIDTransactionRef transaction, IOHIDElementRef element ) ;
+FUNCTION: void IOHIDTransactionScheduleWithRunLoop ( IOHIDTransactionRef transaction, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDTransactionUnscheduleFromRunLoop ( IOHIDTransactionRef transaction, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ;
+FUNCTION: void IOHIDTransactionSetValue ( IOHIDTransactionRef transaction, IOHIDElementRef element, IOHIDValueRef value, IOOptionBits options ) ;
+FUNCTION: IOHIDValueRef IOHIDTransactionGetValue ( IOHIDTransactionRef transaction, IOHIDElementRef element, IOOptionBits options ) ;
+FUNCTION: IOReturn IOHIDTransactionCommit ( IOHIDTransactionRef transaction ) ;
+FUNCTION: IOReturn IOHIDTransactionCommitWithCallback ( IOHIDTransactionRef transaction, CFTimeInterval timeout, IOHIDCallback callback, void* context ) ;
+FUNCTION: void IOHIDTransactionClear ( IOHIDTransactionRef transaction ) ;
diff --git a/extra/iokit/iokit.factor b/extra/iokit/iokit.factor
index a7c898ef6d..1babd697c1 100644
--- a/extra/iokit/iokit.factor
+++ b/extra/iokit/iokit.factor
@@ -1,4 +1,4 @@
-USING: alien.syntax alien.c-types cocoa core-foundation system
+USING: alien.syntax alien.c-types core-foundation system
 combinators kernel sequences debugger io accessors ;
 IN: iokit
 
@@ -103,34 +103,36 @@ TYPEDEF: int boolean_t
 TYPEDEF: mach_port_t io_object_t
 TYPEDEF: io_object_t io_iterator_t
 TYPEDEF: io_object_t io_registry_entry_t
+TYPEDEF: io_object_t io_service_t
 TYPEDEF: char[128] io_name_t
 TYPEDEF: char[512] io_string_t
+TYPEDEF: kern_return_t IOReturn
 
 TYPEDEF: uint IOOptionBits
 
 : MACH_PORT_NULL 0 ; inline
 : KERN_SUCCESS 0 ; inline
 
-FUNCTION: kern_return_t IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ;
+FUNCTION: IOReturn IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ;
 
-FUNCTION: NSDictionary* IOServiceMatching ( char* name ) ;
-FUNCTION: NSDictionary* IOServiceNameMatching ( char* name ) ;
-FUNCTION: NSDictionary* IOBSDNameMatching ( char* name ) ;
+FUNCTION: CFDictionaryRef IOServiceMatching ( char* name ) ;
+FUNCTION: CFDictionaryRef IOServiceNameMatching ( char* name ) ;
+FUNCTION: CFDictionaryRef IOBSDNameMatching ( char* name ) ;
 
-FUNCTION: kern_return_t IOObjectRetain ( io_object_t o ) ;
-FUNCTION: kern_return_t IOObjectRelease ( io_object_t o ) ;
+FUNCTION: IOReturn IOObjectRetain ( io_object_t o ) ;
+FUNCTION: IOReturn IOObjectRelease ( io_object_t o ) ;
 
-FUNCTION: kern_return_t IOServiceGetMatchingServices ( mach_port_t master, NSDictionary* matchingDict, io_iterator_t* iterator ) ;
+FUNCTION: IOReturn IOServiceGetMatchingServices ( mach_port_t master, CFDictionaryRef matchingDict, io_iterator_t* iterator ) ;
 
 FUNCTION: io_object_t IOIteratorNext ( io_iterator_t i ) ;
 FUNCTION: void IOIteratorReset ( io_iterator_t i ) ;
 FUNCTION: boolean_t IOIteratorIsValid ( io_iterator_t i ) ;
 
-FUNCTION: kern_return_t IORegistryEntryGetPath ( io_registry_entry_t entry, io_name_t plane, io_string_t path ) ;
+FUNCTION: IOReturn IORegistryEntryGetPath ( io_registry_entry_t entry, io_name_t plane, io_string_t path ) ;
 
-FUNCTION: kern_return_t IORegistryEntryCreateCFProperties ( io_registry_entry_t entry, NSMutableDictionary** properties, CFAllocatorRef allocator, IOOptionBits options ) ;
+FUNCTION: IOReturn IORegistryEntryCreateCFProperties ( io_registry_entry_t entry, CFMutableDictionaryRef properties, CFAllocatorRef allocator, IOOptionBits options ) ;
 
-FUNCTION: char* mach_error_string ( kern_return_t error ) ;
+FUNCTION: char* mach_error_string ( IOReturn error ) ;
 
 TUPLE: mach-error error-code ;
 C: <mach-error> mach-error

From a0ea30743219bd7c65327ce60c095ef496dc6df1 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Mon, 14 Jul 2008 20:12:06 -0700
Subject: [PATCH 10/35] HID manager callback convenience words. CFRunLoop
 function bindings

---
 extra/core-foundation/core-foundation.factor |  5 ++++
 extra/iokit/hid/hid.factor                   | 27 +++++++++++++++-----
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/extra/core-foundation/core-foundation.factor b/extra/core-foundation/core-foundation.factor
index e1c2c4c517..1dbf295cee 100644
--- a/extra/core-foundation/core-foundation.factor
+++ b/extra/core-foundation/core-foundation.factor
@@ -80,6 +80,9 @@ FUNCTION: void CFRelease ( CFTypeRef cf ) ;
 
 FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ;
 
+FUNCTION: CFRunLoopRef CFRunLoopGetCurrent ( ) ;
+FUNCTION: CFRunLoopRef CFRunLoopGetMain ( ) ;
+
 : CF>array ( alien -- array )
     dup CFArrayGetCount [ CFArrayGetValueAtIndex ] with map ;
 
@@ -135,3 +138,5 @@ M: f <CFNumber>
     ] [
         "Cannot load bundled named " prepend throw
     ] ?if ;
+
+: kCFRunLoopDefaultMode "kCFRunLoopDefaultMode" <CFString> ; inline
diff --git a/extra/iokit/hid/hid.factor b/extra/iokit/hid/hid.factor
index da8c785791..79c3516b4e 100644
--- a/extra/iokit/hid/hid.factor
+++ b/extra/iokit/hid/hid.factor
@@ -1,4 +1,5 @@
-USING: iokit alien.syntax alien.c-types kernel system core-foundation ;
+USING: iokit alien alien.syntax alien.c-types kernel
+system core-foundation ;
 IN: iokit.hid
 
 : kIOHIDDeviceKey "IOHIDDevice" ; inline
@@ -128,16 +129,30 @@ TYPEDEF: void* IOHIDTransactionRef
 TYPEDEF: UInt32 IOHIDValueScaleType
 TYPEDEF: UInt32 IOHIDTransactionDirectionType
 
-! Callback signature: void IOHIDCallback(void* context, IOReturn result, void* sender);
 TYPEDEF: void* IOHIDCallback
-! Callback signature: void IOHIDReportCallback(void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, uchar * report, CFIndex reportLength);
+: IOHIDCallback ( quot -- alien )
+    [ "void" { "void*" "IOReturn" "void*" } "cdecl" ]
+    dip alien-callback ; inline
+
 TYPEDEF: void* IOHIDReportCallback
-! Callback signature: void IOHIDValueCallback(void* context, IOReturn result, void* sender, IOHIDValueRef value);
+: IOHIDReportCallback ( quot -- alien )
+    [ "void" { "void*" "IOReturn" "void*" "IOHIDReportType" "UInt32" "uchar*" "CFIndex" } "cdecl" ]
+    dip alien-callback ; inline
+
 TYPEDEF: void* IOHIDValueCallback
-! Callback signature: void IOHIDValueMultipleCallback(void* context, IOReturn result, void* sender, CFDictionaryRef multiple);
+: IOHIDValueCallback ( quot -- alien )
+    [ "void" { "void*" "IOReturn" "void*" "IOHIDValueRef" } "cdecl" ]
+    dip alien-callback ; inline
+
 TYPEDEF: void* IOHIDValueMultipleCallback
-! Callback signature: void IOHIDDeviceCallback(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
+: IOHIDValueMultipleCallback ( quot -- alien )
+    [ "void" { "void*" "IOReturn" "void*" "CFDictionaryRef" } "cdecl" ]
+    dip alien-callback ; inline
+
 TYPEDEF: void* IOHIDDeviceCallback
+: IOHIDDeviceCallback ( quot -- alien )
+    [ "void" { "void*" "IOReturn" "void*" "IOHIDDeviceRef" } "cdecl" ]
+    dip alien-callback ; inline
 
 ! IOHIDDevice
 

From 55604878aa301dd381c985437b5b5c8b6c7c6b98 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Mon, 14 Jul 2008 20:21:10 -0700
Subject: [PATCH 11/35] whoops... missed core-foundation.run-loop!

---
 extra/core-foundation/core-foundation.factor   | 5 -----
 extra/core-foundation/run-loop/run-loop.factor | 1 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/extra/core-foundation/core-foundation.factor b/extra/core-foundation/core-foundation.factor
index 1dbf295cee..d2376997e5 100644
--- a/extra/core-foundation/core-foundation.factor
+++ b/extra/core-foundation/core-foundation.factor
@@ -11,7 +11,6 @@ TYPEDEF: void* CFDictionaryRef
 TYPEDEF: void* CFMutableDictionaryRef
 TYPEDEF: void* CFNumberRef
 TYPEDEF: void* CFBundleRef
-TYPEDEF: void* CFRunLoopRef
 TYPEDEF: void* CFSetRef
 TYPEDEF: void* CFStringRef
 TYPEDEF: void* CFURLRef
@@ -80,9 +79,6 @@ FUNCTION: void CFRelease ( CFTypeRef cf ) ;
 
 FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ;
 
-FUNCTION: CFRunLoopRef CFRunLoopGetCurrent ( ) ;
-FUNCTION: CFRunLoopRef CFRunLoopGetMain ( ) ;
-
 : CF>array ( alien -- array )
     dup CFArrayGetCount [ CFArrayGetValueAtIndex ] with map ;
 
@@ -139,4 +135,3 @@ M: f <CFNumber>
         "Cannot load bundled named " prepend throw
     ] ?if ;
 
-: kCFRunLoopDefaultMode "kCFRunLoopDefaultMode" <CFString> ; inline
diff --git a/extra/core-foundation/run-loop/run-loop.factor b/extra/core-foundation/run-loop/run-loop.factor
index 7594766635..5ffcafbbaf 100644
--- a/extra/core-foundation/run-loop/run-loop.factor
+++ b/extra/core-foundation/run-loop/run-loop.factor
@@ -12,6 +12,7 @@ IN: core-foundation.run-loop
 TYPEDEF: void* CFRunLoopRef
 
 FUNCTION: CFRunLoopRef CFRunLoopGetMain ( ) ;
+FUNCTION: CFRunLoopRef CFRunLoopGetCurrent ( ) ;
 
 FUNCTION: SInt32 CFRunLoopRunInMode (
    CFStringRef mode,

From 23eb1c5fc3f5e28d6f9627c4d3fb853eca198cc5 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Mon, 14 Jul 2008 20:48:04 -0700
Subject: [PATCH 12/35] make directinput constants image-load-resistant

---
 .../windows/dinput/constants/constants.factor | 976 +++++++++---------
 extra/windows/dinput/dinput.factor            |  25 +-
 2 files changed, 517 insertions(+), 484 deletions(-)

diff --git a/extra/windows/dinput/constants/constants.factor b/extra/windows/dinput/constants/constants.factor
index 2a5432a9d7..f55406395a 100755
--- a/extra/windows/dinput/constants/constants.factor
+++ b/extra/windows/dinput/constants/constants.factor
@@ -7,6 +7,16 @@ IN: windows.dinput.constants
 ! Some global variables aren't provided by the DirectInput DLL (they're in the
 ! dinput8.lib import library), so we lovingly hand-craft equivalent values here
 
+SYMBOLS:
+    GUID_XAxis GUID_YAxis GUID_ZAxis
+    GUID_RxAxis GUID_RyAxis GUID_RzAxis
+    GUID_Slider GUID_Button GUID_Key GUID_POV GUID_Unknown
+    GUID_SysMouse GUID_SysKeyboard GUID_Joystick GUID_SysMouseEm
+    GUID_SysMouseEm2 GUID_SysKeyboardEm GUID_SysKeyboardEm2
+    c_dfDIKeyboard c_dfDIMouse2 c_dfDIJoystick2 ;
+
+<PRIVATE
+
 : (field-spec-of) ( field struct -- field-spec )
     c-type fields>> [ name>> = ] with find nip ;
 : (offsetof) ( field struct -- offset )
@@ -63,492 +73,499 @@ MACRO: (flags) ( array -- )
     [ nip length ] [ malloc-DIOBJECTDATAFORMAT-array ] 2bi
     "DIDATAFORMAT" <c-object> (DIDATAFORMAT) ;
 
-SYMBOLS:
-    GUID_XAxis GUID_YAxis GUID_ZAxis
-    GUID_RxAxis GUID_RyAxis GUID_RzAxis
-    GUID_Slider GUID_Button GUID_Key GUID_POV GUID_Unknown
-    GUID_SysMouse GUID_SysKeyboard GUID_Joystick GUID_SysMouseEm
-    GUID_SysMouseEm2 GUID_SysKeyboardEm GUID_SysKeyboardEm2 ;
-
 : (malloc-guid-symbol) ( symbol guid -- )
     global swap '[ [
         , [ byte-length malloc ] [ over byte-array>memory ] bi
     ] unless* ] change-at ;
 
-{
-    { GUID_XAxis          GUID: {A36D02E0-C9F3-11CF-BFC7-444553540000} }
-    { GUID_YAxis          GUID: {A36D02E1-C9F3-11CF-BFC7-444553540000} }
-    { GUID_ZAxis          GUID: {A36D02E2-C9F3-11CF-BFC7-444553540000} }
-    { GUID_RxAxis         GUID: {A36D02F4-C9F3-11CF-BFC7-444553540000} }
-    { GUID_RyAxis         GUID: {A36D02F5-C9F3-11CF-BFC7-444553540000} }
-    { GUID_RzAxis         GUID: {A36D02E3-C9F3-11CF-BFC7-444553540000} }
-    { GUID_Slider         GUID: {A36D02E4-C9F3-11CF-BFC7-444553540000} }
-    { GUID_Button         GUID: {A36D02F0-C9F3-11CF-BFC7-444553540000} }
-    { GUID_Key            GUID: {55728220-D33C-11CF-BFC7-444553540000} }
-    { GUID_POV            GUID: {A36D02F2-C9F3-11CF-BFC7-444553540000} }
-    { GUID_Unknown        GUID: {A36D02F3-C9F3-11CF-BFC7-444553540000} }
-    { GUID_SysMouse       GUID: {6F1D2B60-D5A0-11CF-BFC7-444553540000} }
-    { GUID_SysKeyboard    GUID: {6F1D2B61-D5A0-11CF-BFC7-444553540000} }
-    { GUID_Joystick       GUID: {6F1D2B70-D5A0-11CF-BFC7-444553540000} }
-    { GUID_SysMouseEm     GUID: {6F1D2B80-D5A0-11CF-BFC7-444553540000} }
-    { GUID_SysMouseEm2    GUID: {6F1D2B81-D5A0-11CF-BFC7-444553540000} }
-    { GUID_SysKeyboardEm  GUID: {6F1D2B82-D5A0-11CF-BFC7-444553540000} }
-    { GUID_SysKeyboardEm2 GUID: {6F1D2B83-D5A0-11CF-BFC7-444553540000} }
-} [ first2 (malloc-guid-symbol) ] each
+: define-guid-constants ( -- )
+    {
+        { GUID_XAxis          GUID: {A36D02E0-C9F3-11CF-BFC7-444553540000} }
+        { GUID_YAxis          GUID: {A36D02E1-C9F3-11CF-BFC7-444553540000} }
+        { GUID_ZAxis          GUID: {A36D02E2-C9F3-11CF-BFC7-444553540000} }
+        { GUID_RxAxis         GUID: {A36D02F4-C9F3-11CF-BFC7-444553540000} }
+        { GUID_RyAxis         GUID: {A36D02F5-C9F3-11CF-BFC7-444553540000} }
+        { GUID_RzAxis         GUID: {A36D02E3-C9F3-11CF-BFC7-444553540000} }
+        { GUID_Slider         GUID: {A36D02E4-C9F3-11CF-BFC7-444553540000} }
+        { GUID_Button         GUID: {A36D02F0-C9F3-11CF-BFC7-444553540000} }
+        { GUID_Key            GUID: {55728220-D33C-11CF-BFC7-444553540000} }
+        { GUID_POV            GUID: {A36D02F2-C9F3-11CF-BFC7-444553540000} }
+        { GUID_Unknown        GUID: {A36D02F3-C9F3-11CF-BFC7-444553540000} }
+        { GUID_SysMouse       GUID: {6F1D2B60-D5A0-11CF-BFC7-444553540000} }
+        { GUID_SysKeyboard    GUID: {6F1D2B61-D5A0-11CF-BFC7-444553540000} }
+        { GUID_Joystick       GUID: {6F1D2B70-D5A0-11CF-BFC7-444553540000} }
+        { GUID_SysMouseEm     GUID: {6F1D2B80-D5A0-11CF-BFC7-444553540000} }
+        { GUID_SysMouseEm2    GUID: {6F1D2B81-D5A0-11CF-BFC7-444553540000} }
+        { GUID_SysKeyboardEm  GUID: {6F1D2B82-D5A0-11CF-BFC7-444553540000} }
+        { GUID_SysKeyboardEm2 GUID: {6F1D2B83-D5A0-11CF-BFC7-444553540000} }
+    } [ first2 (malloc-guid-symbol) ] each ;
 
-SYMBOLS: c_dfDIKeyboard c_dfDIMouse2 c_dfDIJoystick2 ;
+: define-joystick-format-constant ( -- )
+    c_dfDIJoystick2 global [ [
+        DIDF_ABSAXIS
+        "DIJOYSTATE2" heap-size
+        "DIJOYSTATE2" {
+            { GUID_XAxis  "lX"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_YAxis  "lY"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_ZAxis  "lZ"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RxAxis "lRx"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RyAxis "lRy"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RzAxis "lRz"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglSlider"    0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglSlider"    1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV    "rgdwPOV"      0 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV    "rgdwPOV"      1 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV    "rgdwPOV"      2 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV    "rgdwPOV"      3 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   0 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   1 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   2 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   3 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   4 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   5 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   6 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   7 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   8 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   9 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  10 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  11 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  12 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  13 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  14 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  15 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  16 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  17 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  18 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  19 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  20 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  21 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  22 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  23 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  24 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  25 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  26 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  27 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  28 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  29 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  30 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  31 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  32 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  33 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  34 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  35 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  36 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  37 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  38 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  39 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  40 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  41 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  42 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  43 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  44 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  45 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  46 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  47 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  48 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  49 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  50 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  51 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  52 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  53 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  54 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  55 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  56 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  57 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  58 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  59 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  60 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  61 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  62 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  63 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  64 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  65 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  66 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  67 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  68 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  69 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  70 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  71 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  72 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  73 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  74 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  75 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  76 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  77 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  78 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  79 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  80 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  81 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  82 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  83 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  84 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  85 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  86 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  87 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  88 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  89 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  90 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  91 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  92 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  93 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  94 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  95 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  96 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  97 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  98 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  99 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 100 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 101 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 102 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 103 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 104 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 105 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 106 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 107 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 108 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 109 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 110 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 111 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 112 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 113 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 114 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 115 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 116 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 117 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 118 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 119 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 120 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 121 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 122 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 123 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 124 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 125 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 126 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 127 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { GUID_XAxis  "lVX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_YAxis  "lVY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_ZAxis  "lVZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RxAxis "lVRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RyAxis "lVRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RzAxis "lVRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglVSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglVSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_XAxis  "lAX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_YAxis  "lAY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_ZAxis  "lAZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RxAxis "lARx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RyAxis "lARy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RzAxis "lARz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglASlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglASlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_XAxis  "lFX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_YAxis  "lFY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_ZAxis  "lFZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RxAxis "lFRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RyAxis "lFRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RzAxis "lFRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglFSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider "rglFSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+        } <DIDATAFORMAT>
+    ] unless* ] change-at ;
 
-c_dfDIJoystick2 global [ [
-    DIDF_ABSAXIS
-    "DIJOYSTATE2" heap-size
-    "DIJOYSTATE2" {
-        { GUID_XAxis  "lX"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_YAxis  "lY"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_ZAxis  "lZ"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RxAxis "lRx"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RyAxis "lRy"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RzAxis "lRz"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglSlider"    0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglSlider"    1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_POV    "rgdwPOV"      0 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-        { GUID_POV    "rgdwPOV"      1 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-        { GUID_POV    "rgdwPOV"      2 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-        { GUID_POV    "rgdwPOV"      3 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   0 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   1 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   2 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   3 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   4 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   5 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   6 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   7 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   8 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"   9 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  10 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  11 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  12 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  13 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  14 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  15 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  16 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  17 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  18 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  19 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  20 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  21 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  22 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  23 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  24 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  25 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  26 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  27 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  28 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  29 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  30 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  31 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  32 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  33 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  34 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  35 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  36 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  37 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  38 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  39 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  40 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  41 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  42 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  43 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  44 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  45 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  46 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  47 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  48 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  49 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  50 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  51 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  52 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  53 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  54 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  55 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  56 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  57 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  58 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  59 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  60 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  61 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  62 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  63 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  64 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  65 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  66 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  67 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  68 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  69 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  70 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  71 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  72 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  73 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  74 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  75 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  76 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  77 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  78 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  79 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  80 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  81 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  82 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  83 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  84 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  85 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  86 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  87 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  88 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  89 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  90 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  91 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  92 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  93 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  94 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  95 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  96 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  97 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  98 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons"  99 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 100 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 101 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 102 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 103 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 104 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 105 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 106 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 107 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 108 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 109 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 110 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 111 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 112 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 113 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 114 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 115 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 116 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 117 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 118 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 119 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 120 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 121 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 122 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 123 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 124 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 125 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 126 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { f           "rgbButtons" 127 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-        { GUID_XAxis  "lVX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_YAxis  "lVY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_ZAxis  "lVZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RxAxis "lVRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RyAxis "lVRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RzAxis "lVRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglVSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglVSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_XAxis  "lAX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_YAxis  "lAY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_ZAxis  "lAZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RxAxis "lARx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RyAxis "lARy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RzAxis "lARz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglASlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglASlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_XAxis  "lFX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_YAxis  "lFY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_ZAxis  "lFZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RxAxis "lFRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RyAxis "lFRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_RzAxis "lFRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglFSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-        { GUID_Slider "rglFSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-    } <DIDATAFORMAT>
-] unless* ] change-at
+: define-mouse-format-constant ( -- )
+    c_dfDIMouse2 global [ [
+        DIDF_RELAXIS
+        "DIMOUSESTATE2" heap-size
+        "DIMOUSESTATE2" {
+            { GUID_XAxis  "lX"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_YAxis  "lY"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_ZAxis  "lZ"         0 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_Button "rgbButtons" 0 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 1 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 2 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 3 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 4 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 5 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 6 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button "rgbButtons" 7 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        } <DIDATAFORMAT>
+    ] unless* ] change-at ;
 
-c_dfDIMouse2 global [ [
-    DIDF_RELAXIS
-    "DIMOUSESTATE2" heap-size
-    "DIMOUSESTATE2" {
-        { GUID_XAxis  "lX"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-        { GUID_YAxis  "lY"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-        { GUID_ZAxis  "lZ"         0 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-        { GUID_Button "rgbButtons" 0 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 1 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 2 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 3 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 4 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 5 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 6 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        { GUID_Button "rgbButtons" 7 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-    } <DIDATAFORMAT>
-] unless* ] change-at
+: define-keyboard-format-constant ( -- )
+    c_dfDIKeyboard global [ [
+        DIDF_RELAXIS
+        256
+        f {
+            { GUID_Key f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [   0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [   1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [   2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [   3 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [   4 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [   5 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [   6 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [   7 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [   8 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [   9 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [  10 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [  11 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [  12 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [  13 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [  14 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [  15 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [  16 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [  17 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [  18 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [  19 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [  20 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [  21 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [  22 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [  23 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [  24 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [  25 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [  26 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [  27 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [  28 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [  29 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [  30 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [  31 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [  32 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [  33 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [  34 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [  35 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [  36 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [  37 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [  38 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [  39 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [  40 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [  41 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [  42 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [  43 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [  44 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [  45 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [  46 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [  47 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [  48 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [  49 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [  50 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [  51 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [  52 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [  53 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [  54 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [  55 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [  56 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [  57 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [  58 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [  59 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [  60 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [  61 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [  62 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [  63 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [  64 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [  65 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [  66 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [  67 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [  68 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [  69 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [  70 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [  71 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [  72 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [  73 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [  74 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [  75 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [  76 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [  77 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [  78 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [  79 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [  80 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [  81 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [  82 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [  83 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [  84 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [  85 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [  86 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [  87 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [  88 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [  89 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [  90 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [  91 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [  92 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [  93 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [  94 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [  95 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [  96 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [  97 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [  98 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [  99 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ 100 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ 101 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ 102 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ 103 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ 104 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ 105 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ 106 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 107 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 108 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 109 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 110 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 111 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 112 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 113 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 114 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 115 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 116 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 117 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 118 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 119 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 120 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 121 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 122 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 123 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 124 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 125 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 126 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ 127 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ 128 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ 129 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 130 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 131 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 132 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ 133 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 134 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ 135 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ 136 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ 137 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ 138 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ 139 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 140 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 141 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 142 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 143 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 144 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 145 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 146 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 147 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 148 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 149 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 150 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 151 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 152 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 153 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 154 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 155 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 156 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 157 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 158 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 159 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 160 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 161 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 162 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 163 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 164 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 165 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 166 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 167 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 168 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 169 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 170 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 171 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 172 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 173 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 174 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 175 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 176 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 177 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 178 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 179 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 180 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 181 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 182 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 183 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 184 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 185 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 186 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 187 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 188 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 189 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 190 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 191 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 192 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 193 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 194 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 195 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 196 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 197 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 198 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 199 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 200 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 201 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 202 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 203 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 204 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 205 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 206 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 207 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 208 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 209 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 210 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 211 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 212 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 213 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 214 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 215 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 216 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 217 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 218 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 219 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 220 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 221 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 222 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 223 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ 224 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ 225 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ 226 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ 227 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ 228 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ 229 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ 230 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ 231 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 232 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 233 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 234 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 235 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 236 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 237 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 238 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 239 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 240 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 241 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 242 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 243 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 244 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 245 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 246 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 247 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 248 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 249 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 250 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 251 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 252 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 253 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 254 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 255 DIDFT_MAKEINSTANCE ] } 0 }
+        } <DIDATAFORMAT>
+    ] unless* ] change-at ;
 
-c_dfDIKeyboard global [ [
-    DIDF_RELAXIS
-    256
-    f {
-        { GUID_Key f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [   0 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [   1 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [   2 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [   3 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [   4 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [   5 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [   6 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [   7 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [   8 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [   9 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [  10 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [  11 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [  12 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [  13 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [  14 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [  15 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [  16 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [  17 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [  18 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [  19 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [  20 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [  21 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [  22 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [  23 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [  24 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [  25 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [  26 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [  27 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [  28 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [  29 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [  30 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [  31 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [  32 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [  33 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [  34 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [  35 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [  36 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [  37 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [  38 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [  39 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [  40 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [  41 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [  42 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [  43 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [  44 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [  45 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [  46 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [  47 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [  48 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [  49 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [  50 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [  51 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [  52 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [  53 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [  54 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [  55 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [  56 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [  57 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [  58 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [  59 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [  60 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [  61 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [  62 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [  63 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [  64 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [  65 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [  66 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [  67 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [  68 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [  69 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [  70 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [  71 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [  72 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [  73 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [  74 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [  75 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [  76 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [  77 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [  78 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [  79 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [  80 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [  81 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [  82 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [  83 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [  84 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [  85 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [  86 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [  87 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [  88 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [  89 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [  90 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [  91 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [  92 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [  93 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [  94 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [  95 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [  96 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [  97 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [  98 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [  99 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ 100 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ 101 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ 102 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ 103 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ 104 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ 105 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ 106 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 107 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 108 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 109 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 110 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 111 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 112 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 113 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 114 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 115 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 116 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 117 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 118 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 119 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 120 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 121 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 122 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 123 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 124 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 125 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 126 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ 127 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ 128 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ 129 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 130 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 131 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 132 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ 133 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 134 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ 135 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ 136 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ 137 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ 138 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ 139 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 140 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 141 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 142 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 143 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 144 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 145 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 146 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 147 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 148 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 149 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 150 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 151 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 152 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 153 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 154 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 155 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 156 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 157 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 158 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 159 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 160 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 161 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 162 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 163 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 164 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 165 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 166 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 167 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 168 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 169 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 170 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 171 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 172 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 173 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 174 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 175 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 176 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 177 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 178 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 179 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 180 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 181 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 182 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 183 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 184 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 185 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 186 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 187 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 188 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 189 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 190 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 191 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 192 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 193 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 194 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 195 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 196 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 197 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 198 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 199 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 200 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 201 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 202 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 203 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 204 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 205 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 206 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 207 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 208 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 209 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 210 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 211 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 212 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 213 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 214 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 215 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 216 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 217 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 218 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 219 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 220 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 221 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 222 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 223 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ 224 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ 225 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ 226 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ 227 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ 228 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ 229 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ 230 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ 231 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 232 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 233 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 234 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 235 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 236 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 237 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 238 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 239 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 240 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 241 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 242 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 243 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 244 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 245 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 246 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 247 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 248 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 249 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 250 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 251 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 252 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 253 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 254 DIDFT_MAKEINSTANCE ] } 0 }
-        { GUID_Key f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 255 DIDFT_MAKEINSTANCE ] } 0 }
-    } <DIDATAFORMAT>
-] unless* ] change-at
+: define-format-constants ( -- )
+    define-joystick-format-constant
+    define-mouse-format-constant
+    define-keyboard-format-constant ;
+
+: define-constants
+    define-guid-constants
+    define-format-constants ;
+
+[ define-constants ] "windows.dinput.constants" add-init-hook
+define-constants
 
 : free-dinput-constants ( -- )
     {
@@ -560,4 +577,7 @@ c_dfDIKeyboard global [ [
     } [ global [ [ free ] when* f ] change-at ] each
     {
         c_dfDIKeyboard c_dfDIMouse2 c_dfDIJoystick2
-    } [
+    } [ global [ [ DIDATAFORMAT-rgodf free ] when* f ] change-at ] each ;
+
+PRIVATE>
+
diff --git a/extra/windows/dinput/dinput.factor b/extra/windows/dinput/dinput.factor
index 6e77f16bdf..829eb7c4ee 100755
--- a/extra/windows/dinput/dinput.factor
+++ b/extra/windows/dinput/dinput.factor
@@ -9,20 +9,33 @@ IN: windows.dinput
 
 LIBRARY: dinput
 
-! callback signature: BOOL DIEnumDevicesCallbackW(LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef);
 TYPEDEF: void* LPDIENUMDEVICESCALLBACKW
-! Callback signature: BOOL DIEnumDevicesBySemanticsCallbackW(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W* lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef);
+: LPDIENUMDEVICESCALLBACKW ( quot -- alien )
+    [ "BOOL" { "LPCDIDEVICEINSTANCEW" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 TYPEDEF: void* LPDIENUMDEVICESBYSEMANTICSCBW
-! Callback signature: BOOL DIConfigureDevicesCallback(IUnknown* lpDDSTarget, LPVOID pvRef);
+: LPDIENUMDEVICESBYSEMANTICSCBW ( quot -- alien )
+    [ "BOOL" { "LPCDIDEVICEINSTANCEW" "IDirectInputDevice8W*" "DWORD" "DWORD" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 TYPEDEF: void* LPDICONFIGUREDEVICESCALLBACK
-! Callback signature: BOOL DIEnumEffectsCallbackW(LPCDIEFFECTINFOW pdei, LPVOID pvRef);
+: LPDICONFIGUREDEVICESCALLBACK ( quot -- alien )
+    [ "BOOL" { "IUnknown*" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 TYPEDEF: void* LPDIENUMEFFECTSCALLBACKW
-! Callback signature: BOOL DIEnumCreatedEffectObjectsCallback(LPDIRECTINPUTEFFECT peff, LPVOID pvRef);
+: LPDIENUMEFFECTSCALLBACKW ( quot -- alien )
+    [ "BOOL" { "LPCDIEFFECTINFOW" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 TYPEDEF: void* LPDIENUMCREATEDEFFECTOBJECTSCALLBACK
-! Callback signature: BOOL DIEnumEffectsInFileCallback(LPCDIFILEEFFECT lpDiFileEf, LPVOID pvRef);
+: LPDIENUMCREATEDEFFECTOBJECTSCALLBACK
+    [ "BOOL" { "LPDIRECTINPUTEFFECT" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 TYPEDEF: void* LPDIENUMEFFECTSINFILECALLBACK
+    [ "BOOL" { "LPCDIFILEEFFECT" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 ! Callback signaature: BOOL DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
 TYPEDEF: void* LPDIENUMDEVICEOBJECTSCALLBACKW
+    [ "BOOL" { "LPCDIDEVICEOBJECTINSTANCE" "LPVOID" } "stdcall" ]
+    dip alien-callback ; inline
 
 TYPEDEF: DWORD D3DCOLOR
 

From 653dee57d95c78744465c5b20035a0c2548ce992 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 01:58:37 -0500
Subject: [PATCH 13/35] color-picker: rewrite <color-picker>

---
 extra/color-picker/color-picker.factor | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/extra/color-picker/color-picker.factor b/extra/color-picker/color-picker.factor
index c786f77e85..15c4e7c733 100755
--- a/extra/color-picker/color-picker.factor
+++ b/extra/color-picker/color-picker.factor
@@ -3,7 +3,8 @@
 USING: kernel math math.functions math.parser models
        models.filter models.range models.compose sequences ui
        ui.gadgets ui.gadgets.frames ui.gadgets.labels ui.gadgets.packs
-       ui.gadgets.sliders ui.render math.geometry.rect accessors ;
+       ui.gadgets.sliders ui.render math.geometry.rect accessors
+       ui.gadgets.grids ;
 IN: color-picker
 
 ! Simple example demonstrating the use of models.
@@ -33,12 +34,16 @@ M: color-preview model-changed
       [ <color-slider> add-gadget ] each ;
 
 : <color-picker> ( -- gadget )
-    [
-        <color-sliders> @top frame,
-        dup <color-model> <color-preview> @center frame,
-        [ [ truncate number>string ] map " " join ] <filter>
-        <label-control> @bottom frame,
-    ] make-frame ;
+  <frame>
+    <color-sliders>
+      swap dup
+      [                               @top    grid-add* ]
+      [ <color-model> <color-preview> @center grid-add* ]
+      [
+        [ [ truncate number>string ] map " " join ] <filter> <label-control>
+        @bottom grid-add*
+      ]
+      tri* ;
 
 : color-picker-window ( -- )
     [ <color-picker> "Color Picker" open-window ] with-ui ;

From a0d978227f5939da7236d66f0d007f10c97b942e Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:00:05 -0500
Subject: [PATCH 14/35] ui.tools-tests: fix using

---
 extra/ui/tools/tools-tests.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extra/ui/tools/tools-tests.factor b/extra/ui/tools/tools-tests.factor
index 0120ecb92f..e9c907a33f 100755
--- a/extra/ui/tools/tools-tests.factor
+++ b/extra/ui/tools/tools-tests.factor
@@ -2,7 +2,7 @@ USING: ui.tools ui.tools.interactor ui.tools.listener
 ui.tools.search ui.tools.workspace kernel models namespaces
 sequences tools.test ui.gadgets ui.gadgets.buttons
 ui.gadgets.labelled ui.gadgets.presentations
-ui.gadgets.scrollers vocabs tools.test.ui ui ;
+ui.gadgets.scrollers vocabs tools.test.ui ui accessors ;
 IN: ui.tools.tests
 
 [ f ]

From 799d541d92a98085353a4727842fdfc576c179a2 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:04:53 -0500
Subject: [PATCH 15/35] ui.tools.search-tests: add a missing stack effect

---
 extra/ui/tools/search/search-tests.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extra/ui/tools/search/search-tests.factor b/extra/ui/tools/search/search-tests.factor
index 4a75ebfc96..34e1823a42 100755
--- a/extra/ui/tools/search/search-tests.factor
+++ b/extra/ui/tools/search/search-tests.factor
@@ -10,7 +10,7 @@ IN: ui.tools.search.tests
     T{ key-down f { C+ } "x" } swap search-gesture
 ] unit-test
 
-: assert-non-empty empty? f assert= ;
+: assert-non-empty ( obj -- ) empty? f assert= ;
 
 : update-live-search ( search -- seq )
     dup [

From 1a04f30c7ce8187fadbab0aa71cda400ae2df05a Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:17:13 -0500
Subject: [PATCH 16/35] ui.gadgets.tracks: rewrite available-dim

---
 extra/ui/gadgets/tracks/tracks.factor | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index af54b3c47c..9ab3c5200f 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -23,8 +23,7 @@ TUPLE: track < pack sizes ;
     dup gadget-children swap track-sizes { 0 0 }
     [ [ drop { 0 0 } ] [ pref-dim ] if v+ ] 2reduce ;
 
-: available-dim ( track -- dim )
-    dup rect-dim swap alloted-dim v- ;
+: available-dim ( track -- dim ) [ dim>> ] [ alloted-dim ] bi v- ;
 
 : track-layout ( track -- sizes )
     dup available-dim over gadget-children rot normalized-sizes

From 43b20221767dbbcbd171ec824f23a4d57b0f4a66 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:25:37 -0500
Subject: [PATCH 17/35] ui.gadgets.tracks: rewrite pref-dim* method

---
 extra/ui/gadgets/tracks/tracks.factor | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 9ab3c5200f..09e3d5307a 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -16,8 +16,7 @@ TUPLE: track < pack sizes ;
         V{ } clone >>sizes
         1 >>fill ; inline
 
-: <track> ( orientation -- track )
-    track new-track ;
+: <track> ( orientation -- track ) track new-track ;
 
 : alloted-dim ( track -- dim )
     dup gadget-children swap track-sizes { 0 0 }
@@ -29,21 +28,20 @@ TUPLE: track < pack sizes ;
     dup available-dim over gadget-children rot normalized-sizes
     [ [ over n*v ] [ pref-dim ] ?if ] 2map nip ;
 
-M: track layout*
-    dup track-layout pack-layout ;
+M: track layout* ( track -- ) dup track-layout pack-layout ;
 
-: track-pref-dims-1 ( track -- dim )
-    gadget-children pref-dims max-dim ;
+: track-pref-dims-1 ( track -- dim ) children>> pref-dims max-dim ;
 
 : track-pref-dims-2 ( track -- dim )
     dup gadget-children pref-dims swap normalized-sizes
     [ [ v/n ] when* ] 2map max-dim [ >fixnum ] map ;
 
-M: track pref-dim*
-    dup track-pref-dims-1
-    over alloted-dim
-    pick track-pref-dims-2 v+
-    rot gadget-orientation set-axis ;
+M: track pref-dim* ( gadget -- dim )
+   [ track-pref-dims-1                           ]
+   [ [ alloted-dim ] [ track-pref-dims-1 ] bi v+ ]
+   [ orientation>>                               ]
+   tri
+   set-axis ;
 
 : track-add ( gadget track constraint -- )
     over track-sizes push swap add-gadget drop ;

From 27c83d4884b7e2d3470577badc89676773f55924 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:31:04 -0500
Subject: [PATCH 18/35] ui.gadgets.tracks: rewrite alloted-dim

---
 extra/ui/gadgets/tracks/tracks.factor | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 09e3d5307a..755dc341d3 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -11,16 +11,16 @@ TUPLE: track < pack sizes ;
     [ sift sum ] keep [ dup [ over / ] when ] map nip ;
 
 : new-track ( orientation class -- track )
-    new-gadget
-        swap >>orientation
-        V{ } clone >>sizes
-        1 >>fill ; inline
+  new-gadget
+    swap       >>orientation
+    V{ } clone >>sizes
+    1          >>fill ; inline
 
 : <track> ( orientation -- track ) track new-track ;
 
 : alloted-dim ( track -- dim )
-    dup gadget-children swap track-sizes { 0 0 }
-    [ [ drop { 0 0 } ] [ pref-dim ] if v+ ] 2reduce ;
+  [ children>> ] [ sizes>> ] bi { 0 0 }
+  [ [ drop { 0 0 } ] [ pref-dim ] if v+ ] 2reduce ;
 
 : available-dim ( track -- dim ) [ dim>> ] [ alloted-dim ] bi v- ;
 
@@ -47,8 +47,7 @@ M: track pref-dim* ( gadget -- dim )
     over track-sizes push swap add-gadget drop ;
 
 : track-add* ( track gadget constraint -- track )
-    pick sizes>> push
-    add-gadget ;
+  pick sizes>> push add-gadget ;
 
 : track-remove ( gadget track -- )
     over [

From 39ec81361eca214d7673cc77bd4d53c09731cdae Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:33:44 -0500
Subject: [PATCH 19/35] ui.gadgets.tracks: rewrite track-layout

---
 extra/ui/gadgets/tracks/tracks.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 755dc341d3..296385bfb8 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -25,7 +25,7 @@ TUPLE: track < pack sizes ;
 : available-dim ( track -- dim ) [ dim>> ] [ alloted-dim ] bi v- ;
 
 : track-layout ( track -- sizes )
-    dup available-dim over gadget-children rot normalized-sizes
+    [ available-dim ] [ children>> ] [ normalized-sizes ] tri
     [ [ over n*v ] [ pref-dim ] ?if ] 2map nip ;
 
 M: track layout* ( track -- ) dup track-layout pack-layout ;

From 1f422a14127126781fc70ee596f20a1591fdaad1 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:38:04 -0500
Subject: [PATCH 20/35] ui.gadgets.tracks: rewrite track-pref-dims-2

---
 extra/ui/gadgets/tracks/tracks.factor | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 296385bfb8..7f0e38bff7 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -33,8 +33,10 @@ M: track layout* ( track -- ) dup track-layout pack-layout ;
 : track-pref-dims-1 ( track -- dim ) children>> pref-dims max-dim ;
 
 : track-pref-dims-2 ( track -- dim )
-    dup gadget-children pref-dims swap normalized-sizes
-    [ [ v/n ] when* ] 2map max-dim [ >fixnum ] map ;
+  [ children>> pref-dims ] [ normalized-sizes ] bi
+  [ [ v/n ] when* ] 2map
+  max-dim
+  [ >fixnum ] map ;
 
 M: track pref-dim* ( gadget -- dim )
    [ track-pref-dims-1                           ]

From 57dfbf6d10e7021848952a34d2415e8cdb45455a Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 02:45:15 -0500
Subject: [PATCH 21/35] ui.gadgets.tracks: rewrite normalized-sizes

---
 extra/ui/gadgets/tracks/tracks.factor | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 7f0e38bff7..36df45a3b6 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -1,14 +1,15 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors io kernel math namespaces
-sequences words math.vectors ui.gadgets ui.gadgets.packs math.geometry.rect ;
+       sequences words math.vectors ui.gadgets ui.gadgets.packs
+       math.geometry.rect fry ;
+
 IN: ui.gadgets.tracks
 
 TUPLE: track < pack sizes ;
 
 : normalized-sizes ( track -- seq )
-    track-sizes
-    [ sift sum ] keep [ dup [ over / ] when ] map nip ;
+  sizes>> dup sift sum '[ dup [ , / ] when ] map ;
 
 : new-track ( orientation class -- track )
   new-gadget
@@ -59,5 +60,4 @@ M: track pref-dim* ( gadget -- dim )
         2drop
     ] if ;
 
-: clear-track ( track -- )
-    V{ } clone over set-track-sizes clear-gadget ;
+: clear-track ( track -- ) V{ } clone >>sizes clear-gadget ;

From fd7f3423edbe286dc9ce99b77c6231cb282bc67a Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 03:48:48 -0500
Subject: [PATCH 22/35] ui.gadgets.tracks: rewrite track-remove

---
 extra/ui/gadgets/tracks/tracks.factor     | 16 +++++++++-------
 extra/ui/tools/workspace/workspace.factor |  6 +++---
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor
index 36df45a3b6..bf6b02463e 100644
--- a/extra/ui/gadgets/tracks/tracks.factor
+++ b/extra/ui/gadgets/tracks/tracks.factor
@@ -52,12 +52,14 @@ M: track pref-dim* ( gadget -- dim )
 : track-add* ( track gadget constraint -- track )
   pick sizes>> push add-gadget ;
 
-: track-remove ( gadget track -- )
-    over [
-        [ gadget-children index ] 2keep
-        swap unparent track-sizes delete-nth
-    ] [
-        2drop
-    ] if ;
+: track-remove ( track gadget -- track )
+  dupd dup
+    [
+      [ swap children>> index ]
+      [ unparent sizes>>      ] 2bi
+      delete-nth 
+    ]
+    [ 2drop ]
+  if ;
 
 : clear-track ( track -- ) V{ } clone >>sizes clear-gadget ;
diff --git a/extra/ui/tools/workspace/workspace.factor b/extra/ui/tools/workspace/workspace.factor
index c7a13938b1..ee3f24c2cd 100755
--- a/extra/ui/tools/workspace/workspace.factor
+++ b/extra/ui/tools/workspace/workspace.factor
@@ -57,9 +57,9 @@ M: gadget tool-scroller drop f ;
     article-title open-window ;
 
 : hide-popup ( workspace -- )
-    dup workspace-popup over track-remove
-    f over set-workspace-popup
-    request-focus ;
+  dup popup>> track-remove
+  f >>popup
+  request-focus ;
 
 : show-popup ( gadget workspace -- )
     dup hide-popup

From 7c0fe0cf05d998ed02abbed38d9de882a167009a Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 03:54:05 -0500
Subject: [PATCH 23/35] ui.tools.workspace: update find-tool

---
 extra/ui/tools/workspace/workspace.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extra/ui/tools/workspace/workspace.factor b/extra/ui/tools/workspace/workspace.factor
index ee3f24c2cd..2d759ca1d2 100755
--- a/extra/ui/tools/workspace/workspace.factor
+++ b/extra/ui/tools/workspace/workspace.factor
@@ -28,7 +28,7 @@ GENERIC: tool-scroller ( tool -- scroller )
 M: gadget tool-scroller drop f ;
 
 : find-tool ( class workspace -- index tool )
-    workspace-book gadget-children [ class eq? ] with find ;
+  book>> children>> [ class eq? ] with find ;
 
 : show-tool ( class workspace -- tool )
     [ find-tool swap ] keep workspace-book gadget-model

From 2abc7c329b84e867d30de098c9dcc15ba1d7c5fd Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 03:58:01 -0500
Subject: [PATCH 24/35] ui.tools.workspace: minor changes

---
 extra/ui/tools/workspace/workspace.factor | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/extra/ui/tools/workspace/workspace.factor b/extra/ui/tools/workspace/workspace.factor
index 2d759ca1d2..45dfd32609 100755
--- a/extra/ui/tools/workspace/workspace.factor
+++ b/extra/ui/tools/workspace/workspace.factor
@@ -1,25 +1,23 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes continuations help help.topics kernel models
-sequences ui ui.backend ui.tools.debugger ui.gadgets
-ui.gadgets.books ui.gadgets.buttons ui.gadgets.labelled
-ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks
-ui.gadgets.worlds ui.gadgets.presentations ui.gadgets.status-bar
-ui.commands ui.gestures assocs arrays namespaces accessors ;
+       sequences ui ui.backend ui.tools.debugger ui.gadgets
+       ui.gadgets.books ui.gadgets.buttons ui.gadgets.labelled
+       ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks
+       ui.gadgets.worlds ui.gadgets.presentations ui.gadgets.status-bar
+       ui.commands ui.gestures assocs arrays namespaces accessors ;
+
 IN: ui.tools.workspace
 
 TUPLE: workspace < track book listener popup ;
 
-: find-workspace ( gadget -- workspace )
-    [ workspace? ] find-parent ;
+: find-workspace ( gadget -- workspace ) [ workspace? ] find-parent ;
 
 SYMBOL: workspace-window-hook
 
-: workspace-window* ( -- workspace )
-    workspace-window-hook get call ;
+: workspace-window* ( -- workspace ) workspace-window-hook get call ;
 
-: workspace-window ( -- )
-    workspace-window* drop ;
+: workspace-window ( -- ) workspace-window* drop ;
 
 GENERIC: call-tool* ( arg tool -- )
 

From e549806d32a7dfd4029b0e4dacb50de4f530be0c Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Tue, 15 Jul 2008 06:28:10 -0700
Subject: [PATCH 25/35] remove redundant comment line from dinput

---
 extra/windows/dinput/dinput.factor | 1 -
 1 file changed, 1 deletion(-)

diff --git a/extra/windows/dinput/dinput.factor b/extra/windows/dinput/dinput.factor
index 829eb7c4ee..25abbb7534 100755
--- a/extra/windows/dinput/dinput.factor
+++ b/extra/windows/dinput/dinput.factor
@@ -32,7 +32,6 @@ TYPEDEF: void* LPDIENUMCREATEDEFFECTOBJECTSCALLBACK
 TYPEDEF: void* LPDIENUMEFFECTSINFILECALLBACK
     [ "BOOL" { "LPCDIFILEEFFECT" "LPVOID" } "stdcall" ]
     dip alien-callback ; inline
-! Callback signaature: BOOL DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
 TYPEDEF: void* LPDIENUMDEVICEOBJECTSCALLBACKW
     [ "BOOL" { "LPCDIDEVICEOBJECTINSTANCE" "LPVOID" } "stdcall" ]
     dip alien-callback ; inline

From 2b9d2302e679e48d5c4698e43f7c4c587ef2ba29 Mon Sep 17 00:00:00 2001
From: Joe Groff <jcg@dhcp-177-191.(none)>
Date: Tue, 15 Jul 2008 08:57:24 -0700
Subject: [PATCH 26/35] Change math.blas.vectors division tests so that
 everything is powers of two--no floating-point error

---
 extra/math/blas/syntax/syntax.factor         | 2 +-
 extra/math/blas/vectors/vectors-tests.factor | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/extra/math/blas/syntax/syntax.factor b/extra/math/blas/syntax/syntax.factor
index 187d9c3a6c..d6e76ecd85 100644
--- a/extra/math/blas/syntax/syntax.factor
+++ b/extra/math/blas/syntax/syntax.factor
@@ -31,4 +31,4 @@ M: float-complex-blas-matrix pprint-delims drop \ cmatrix{ \ } ;
 M: double-complex-blas-matrix pprint-delims drop \ zmatrix{ \ } ;
 
 M: blas-vector-base >pprint-sequence ;
-M: blas-matrix-base >pprint-sequence Mrows [ >array ] map ;
+M: blas-matrix-base >pprint-sequence Mrows ;
diff --git a/extra/math/blas/vectors/vectors-tests.factor b/extra/math/blas/vectors/vectors-tests.factor
index d4cff82e50..5f9e8fdc42 100644
--- a/extra/math/blas/vectors/vectors-tests.factor
+++ b/extra/math/blas/vectors/vectors-tests.factor
@@ -104,12 +104,12 @@ unit-test
 [ svector{ 1.0 2.0 } ] [ svector{ 4.0 8.0 } 4.0 V/n ] unit-test
 [ dvector{ 1.0 2.0 } ] [ dvector{ 4.0 8.0 } 4.0 V/n ] unit-test
 
-[ cvector{ 2.0 1.0 } ]
-[ cvector{ C{ 16.0 4.0 } C{ 8.0 2.0 } } C{ 8.0 2.0 } V/n ]
+[ cvector{ C{ 0.0 -4.0 } 1.0 } ]
+[ cvector{ C{ 4.0 -4.0 } C{ 1.0 1.0 } } C{ 1.0 1.0 } V/n ]
 unit-test
 
-[ cvector{ 2.0 1.0 } ]
-[ cvector{ C{ 16.0 4.0 } C{ 8.0 2.0 } } C{ 8.0 2.0 } V/n ]
+[ zvector{ C{ 0.0 -4.0 } 1.0 } ]
+[ zvector{ C{ 4.0 -4.0 } C{ 1.0 1.0 } } C{ 1.0 1.0 } V/n ]
 unit-test
 
 ! V.

From c3dd210079bae4fb1374bc22db1042a53116f56a Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 12:07:17 -0500
Subject: [PATCH 27/35] ui.tools.workspace: rewrite show-popup

---
 extra/ui/tools/workspace/workspace.factor | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/extra/ui/tools/workspace/workspace.factor b/extra/ui/tools/workspace/workspace.factor
index 45dfd32609..86cfdb02c7 100755
--- a/extra/ui/tools/workspace/workspace.factor
+++ b/extra/ui/tools/workspace/workspace.factor
@@ -60,10 +60,10 @@ M: gadget tool-scroller drop f ;
   request-focus ;
 
 : show-popup ( gadget workspace -- )
-    dup hide-popup
-    2dup set-workspace-popup
-    dupd f track-add
-    request-focus ;
+  dup hide-popup
+  over >>popup
+  over f track-add* drop
+  request-focus ;
 
 : show-titled-popup ( workspace gadget title -- )
     [ find-workspace hide-popup ] <closable-gadget>

From 9e52e3f90df9ba6352180427eea9207f429e37f6 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 13:50:42 -0500
Subject: [PATCH 28/35] ui.gadgets.books: rewrite a few words

---
 extra/ui/gadgets/books/books.factor | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/extra/ui/gadgets/books/books.factor b/extra/ui/gadgets/books/books.factor
index ce15bd9e6c..9f92266efe 100755
--- a/extra/ui/gadgets/books/books.factor
+++ b/extra/ui/gadgets/books/books.factor
@@ -7,27 +7,24 @@ TUPLE: book < gadget ;
 
 : hide-all ( book -- ) gadget-children [ hide-gadget ] each ;
 
-: current-page ( book -- gadget )
-    [ control-value ] keep nth-gadget ;
+: current-page ( book -- gadget ) [ control-value ] keep nth-gadget ;
 
-M: book model-changed
+M: book model-changed ( model book -- )
     nip
     dup hide-all
     dup current-page show-gadget
     relayout ;
 
 : new-book ( pages model class -- book )
-    new-gadget
-        swap >>model
-        [ swap add-gadgets drop ] keep ; inline
+  new-gadget
+    swap >>model
+    swap add-gadgets ; inline
 
-: <book> ( pages model -- book )
-    book new-book ;
+: <book> ( pages model -- book ) book new-book ;
 
-M: book pref-dim* gadget-children pref-dims max-dim ;
+M: book pref-dim* ( book -- dim ) children>> pref-dims max-dim ;
 
-M: book layout*
-    dup rect-dim swap gadget-children
-    [ set-layout-dim ] with each ;
+M: book layout* ( book -- )
+   [ dim>> ] [ children>> ] bi [ set-layout-dim ] with each ;
 
-M: book focusable-child* current-page ;
+M: book focusable-child* ( book -- child/t ) current-page ;

From d7d896205c067cb3f2b0973150f6cec8cb8ce757 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Tue, 15 Jul 2008 14:12:23 -0500
Subject: [PATCH 29/35] ui.gadgets.sliders: rewrite some words

---
 extra/ui/gadgets/sliders/sliders.factor | 49 ++++++++-----------------
 1 file changed, 15 insertions(+), 34 deletions(-)

diff --git a/extra/ui/gadgets/sliders/sliders.factor b/extra/ui/gadgets/sliders/sliders.factor
index 7904a9ab66..4e081d972f 100755
--- a/extra/ui/gadgets/sliders/sliders.factor
+++ b/extra/ui/gadgets/sliders/sliders.factor
@@ -9,27 +9,21 @@ IN: ui.gadgets.sliders
 
 TUPLE: elevator < gadget direction ;
 
-: find-elevator ( gadget -- elevator/f )
-    [ elevator? ] find-parent ;
+: find-elevator ( gadget -- elevator/f ) [ elevator? ] find-parent ;
 
 TUPLE: slider < frame elevator thumb saved line ;
 
-: find-slider ( gadget -- slider/f )
-    [ slider? ] find-parent ;
+: find-slider ( gadget -- slider/f ) [ slider? ] find-parent ;
 
 : elevator-length ( slider -- n )
-    dup slider-elevator rect-dim
-    swap gadget-orientation v. ;
+  [ elevator>> dim>> ] [ orientation>> ] bi v. ;
 
 : min-thumb-dim 15 ;
 
 : slider-value ( gadget -- n ) gadget-model range-value >fixnum ;
-
-: slider-page ( gadget -- n ) gadget-model range-page-value ;
-
-: slider-max ( gadget -- n ) gadget-model range-max-value ;
-
-: slider-max* ( gadget -- n ) gadget-model range-max-value* ;
+: slider-page  ( gadget -- n ) gadget-model range-page-value    ;
+: slider-max   ( gadget -- n ) gadget-model range-max-value     ;
+: slider-max*  ( gadget -- n ) gadget-model range-max-value*    ;
 
 : thumb-dim ( slider -- h )
     dup slider-page over slider-max 1 max / 1 min
@@ -45,7 +39,6 @@ TUPLE: slider < frame elevator thumb saved line ;
     swap slider-max* 1 max / ;
 
 : slider>screen ( m scale -- n ) slider-scale * ;
-
 : screen>slider ( m scale -- n ) slider-scale / ;
 
 M: slider model-changed nip slider-elevator relayout-1 ;
@@ -76,11 +69,9 @@ thumb H{
         t >>root?
     thumb-theme ;
 
-: slide-by ( amount slider -- )
-    gadget-model move-by ;
+: slide-by ( amount slider -- ) gadget-model move-by ;
 
-: slide-by-page ( amount slider -- )
-    gadget-model move-by-page ;
+: slide-by-page ( amount slider -- ) gadget-model move-by-page ;
 
 : compute-direction ( elevator -- -1/1 )
     dup find-slider swap hand-click-rel
@@ -100,13 +91,10 @@ elevator H{
     { T{ button-down } [ elevator-click ] }
 } set-gestures
 
-: elevator-theme ( elevator -- )
-    lowered-gradient swap set-gadget-interior ;
-
 : <elevator> ( vector -- elevator )
-    elevator new-gadget
-    [ set-gadget-orientation ] keep
-    dup elevator-theme ;
+  elevator new-gadget
+    swap             >>orientation
+    lowered-gradient >>interior ;
 
 : (layout-thumb) ( slider n -- n thumb )
     over gadget-orientation n*v swap slider-thumb ;
@@ -144,17 +132,10 @@ M: elevator layout*
   dup elevator>> over thumb>> add-gadget
   @center grid-add* ;
 
-: <left-button> ( -- button )
-    { 0 1 } arrow-left -1 <slide-button> ;
-
-: <right-button> ( -- button )
-    { 0 1 } arrow-right 1 <slide-button> ;
-
-: <up-button> ( -- button )
-    { 1 0 } arrow-up -1 <slide-button> ;
-
-: <down-button> ( -- button )
-    { 1 0 } arrow-down 1 <slide-button> ;
+: <left-button>  ( -- button ) { 0 1 } arrow-left -1 <slide-button> ;
+: <right-button> ( -- button ) { 0 1 } arrow-right 1 <slide-button> ;
+: <up-button>    ( -- button ) { 1 0 } arrow-up   -1 <slide-button> ;
+: <down-button>  ( -- button ) { 1 0 } arrow-down  1 <slide-button> ;
 
 : <slider> ( range orientation -- slider )
     slider new-frame

From b4fc1e0d5fc71cb12fd4c50c2f09da9f9901acca Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 16:17:13 -0500
Subject: [PATCH 30/35] Make vocab-usage and vocab-uses more useful

---
 extra/help/markup/markup.factor           |  3 +++
 extra/tools/vocabs/browser/browser.factor | 10 +++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/extra/help/markup/markup.factor b/extra/help/markup/markup.factor
index 692255bdd5..0f2de467f9 100755
--- a/extra/help/markup/markup.factor
+++ b/extra/help/markup/markup.factor
@@ -188,6 +188,9 @@ M: f print-element drop ;
 : $links ( topics -- )
     [ [ ($link) ] textual-list ] ($span) ;
 
+: $vocab-links ( vocabs -- )
+    [ vocab ] map $links ;
+
 : $see-also ( topics -- )
     "See also" $heading $links ;
 
diff --git a/extra/tools/vocabs/browser/browser.factor b/extra/tools/vocabs/browser/browser.factor
index afbb936df1..55a96c8b7d 100755
--- a/extra/tools/vocabs/browser/browser.factor
+++ b/extra/tools/vocabs/browser/browser.factor
@@ -3,7 +3,7 @@
 USING: accessors kernel combinators vocabs vocabs.loader
 tools.vocabs io io.files io.styles help.markup help.stylesheet
 sequences assocs help.topics namespaces prettyprint words
-sorting definitions arrays summary sets ;
+sorting definitions arrays summary sets generic ;
 IN: tools.vocabs.browser
 
 : vocab-status-string ( vocab -- string )
@@ -104,9 +104,9 @@ C: <vocab-author> vocab-author
     ] unless drop ;
 
 : vocab-xref ( vocab quot -- vocabs )
-    >r dup vocab-name swap words r> map
+    >r dup vocab-name swap words [ generic? not ] filter r> map
     [ [ word? ] filter [ vocabulary>> ] map ] gather natural-sort
-    remove sift [ vocab ] map ; inline
+    remove sift ; inline
 
 : vocab-uses ( vocab -- vocabs ) [ uses ] vocab-xref ;
 
@@ -115,13 +115,13 @@ C: <vocab-author> vocab-author
 : describe-uses ( vocab -- )
     vocab-uses dup empty? [
         "Uses" $heading
-        dup $links
+        dup $vocab-links
     ] unless drop ;
 
 : describe-usage ( vocab -- )
     vocab-usage dup empty? [
         "Used by" $heading
-        dup $links
+        dup $vocab-links
     ] unless drop ;
 
 : $describe-vocab ( element -- )

From ad87a38ab8e8385c3f5e7024ce0dfd3d156d6fa2 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 17:16:08 -0500
Subject: [PATCH 31/35] Refactor binary search

---
 core/binary-search/binary-search-docs.factor  | 43 +++++++++++++++++
 core/binary-search/binary-search-tests.factor | 17 +++++++
 core/binary-search/binary-search.factor       | 46 +++++++++++++++++++
 core/sequences/sequences-docs.factor          |  3 +-
 core/sorting/sorting-docs.factor              | 29 ++----------
 core/sorting/sorting-tests.factor             | 10 ----
 core/sorting/sorting.factor                   | 24 +---------
 extra/cords/cords.factor                      |  6 +--
 extra/interval-maps/interval-maps.factor      |  8 ++--
 extra/math/primes/primes.factor               | 11 +++--
 extra/ui/gadgets/gadgets.factor               | 17 ++++---
 extra/usa-cities/usa-cities.factor            |  2 +-
 12 files changed, 136 insertions(+), 80 deletions(-)
 create mode 100644 core/binary-search/binary-search-docs.factor
 create mode 100644 core/binary-search/binary-search-tests.factor
 create mode 100644 core/binary-search/binary-search.factor

diff --git a/core/binary-search/binary-search-docs.factor b/core/binary-search/binary-search-docs.factor
new file mode 100644
index 0000000000..db442a9ac8
--- /dev/null
+++ b/core/binary-search/binary-search-docs.factor
@@ -0,0 +1,43 @@
+IN: binary-search
+USING: help.markup help.syntax sequences kernel math.order ;
+
+ARTICLE: "binary-search" "Binary search"
+"The " { $emphasis "binary search" } " algorithm allows elements to be located in sorted sequence in " { $snippet "O(log n)" } " time."
+{ $subsection search }
+"Variants of sequence words optimized for sorted sequences:"
+{ $subsection sorted-index }
+{ $subsection sorted-member? }
+{ $subsection sorted-memq? }
+{ $see-also "order-specifiers" "sequences-sorting" } ;
+
+ABOUT: "binary-search"
+
+HELP: search
+{ $values { "seq" "a sorted sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- <=> )" } } { "i" "an index, or " { $link f } } { "elt" "an element, or " { $link f } } }
+{ $description "Performs a binary search on a sequence, calling the quotation to decide whether to end the search (" { $link +eq+ } "), search lower (" { $link +lt+ } ") or search higher (" { $link +gt+ } ")."
+$nl
+"If the sequence is non-empty, outputs the index and value of the closest match, which is either an element for which the quotation output " { $link +eq+ } ", or failing that, least element for which the quotation output " { $link +lt+ } "."
+$nl
+"If the sequence is empty, outputs " { $link f } " " { $link f } "." }
+{ $notes "If the sequence has at least one element, this word always outputs a valid index, because it finds the closest match, not necessarily an exact one. In this respect its behavior differs from " { $link find } "." } ;
+
+{ find find-from find-last find-last find-last-from search } related-words
+
+HELP: sorted-index
+{ $values { "elt" object } { "seq" "a sorted sequence" } { "i" "an index, or " { $link f } } { "elt" "an element, or " { $link f } } }
+{ $description "Outputs the index and value of the element closest to " { $snippet "elt" } " in the sequence. See " { $link search } " for details." }
+{ $notes "If the sequence has at least one element, this word always outputs a valid index, because it finds the closest match, not necessarily an exact one. In this respect its behavior differs from " { $link index } "." } ;
+
+{ index index-from last-index last-index-from sorted-index } related-words
+
+HELP: sorted-member?
+{ $values { "elt" object } { "seq" "a sorted sequence" } { "?" "a boolean" } }
+{ $description "Tests if the sorted sequence contains " { $snippet "elt" } ". Equality is tested with " { $link = } "." } ;
+
+{ member? sorted-member? } related-words
+
+HELP: sorted-memq?
+{ $values { "elt" object } { "seq" "a sorted sequence" } { "?" "a boolean" } }
+{ $description "Tests if the sorted sequence contains " { $snippet "elt" } ". Equality is tested with " { $link eq? } "." } ;
+
+{ memq? sorted-memq? } related-words
diff --git a/core/binary-search/binary-search-tests.factor b/core/binary-search/binary-search-tests.factor
new file mode 100644
index 0000000000..77b1c16505
--- /dev/null
+++ b/core/binary-search/binary-search-tests.factor
@@ -0,0 +1,17 @@
+IN: binary-search.tests
+USING: binary-search math.order vectors kernel tools.test ;
+
+\ sorted-member? must-infer
+
+[ f ] [ 3 { } [ <=> ] with search drop ] unit-test
+[ 0 ] [ 3 { 3 } [ <=> ] with search drop ] unit-test
+[ 1 ] [ 2 { 1 2 3 } [ <=> ] with search drop ] unit-test
+[ 3 ] [ 4 { 1 2 3 4 5 6 } [ <=> ] with search drop ] unit-test
+[ 2 ] [ 3.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
+[ 4 ] [ 5.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
+[ 10 ] [ 10 20 >vector [ <=> ] with search drop ] unit-test
+
+[ t ] [ "hello" { "alligrator" "cat" "fish" "hello" "ikarus" "java" } sorted-member? ] unit-test
+[ 3 ] [ "hey" { "alligrator" "cat" "fish" "hello" "ikarus" "java" } sorted-index ] unit-test
+[ f ] [ "hello" { "alligrator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
+[ f ] [ "zebra" { "alligrator" "cat" "fish" "ikarus" "java" } sorted-member? ] unit-test
diff --git a/core/binary-search/binary-search.factor b/core/binary-search/binary-search.factor
new file mode 100644
index 0000000000..87a4e0f503
--- /dev/null
+++ b/core/binary-search/binary-search.factor
@@ -0,0 +1,46 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences sequences.private accessors math
+math.order combinators ;
+IN: binary-search
+
+<PRIVATE
+
+: midpoint ( seq -- elt )
+    [ midpoint@ ] keep nth-unsafe ; inline
+
+: decide ( quot seq -- quot seq <=> )
+    [ midpoint swap call ] 2keep rot ; inline
+
+: finish ( quot slice -- i elt )
+    [ [ from>> ] [ midpoint@ ] bi + ] [ seq>> ] bi
+    [ drop ] [ dup ] [ ] tri* nth ; inline
+
+: (search) ( quot seq -- i elt )
+    dup length 1 <= [
+        finish
+    ] [
+        decide {
+            { +eq+ [ finish ] }
+            { +lt+ [ dup midpoint@ head-slice (search) ] }
+            { +gt+ [ dup midpoint@ tail-slice (search) ] }
+        } case
+    ] if ; inline
+
+PRIVATE>
+
+: search ( seq quot -- i elt )
+    over empty? [ 2drop f f ] [ swap <flat-slice> (search) ] if ;
+    inline
+
+: natural-search ( obj seq -- i elt )
+    [ <=> ] with search ;
+
+: sorted-index ( obj seq -- i )
+    natural-search drop ;
+
+: sorted-member? ( obj seq -- ? )
+    dupd natural-search nip = ;
+
+: sorted-memq? ( obj seq -- ? )
+    dupd natural-search nip eq? ;
diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor
index 1bb7666447..8434a99b30 100755
--- a/core/sequences/sequences-docs.factor
+++ b/core/sequences/sequences-docs.factor
@@ -243,6 +243,7 @@ $nl
 { $subsection "sequences-destructive" }
 { $subsection "sequences-stacks" }
 { $subsection "sequences-sorting" }
+{ $subsection "binary-search" }
 { $subsection "sets" }
 "For inner loops:"
 { $subsection "sequences-unsafe" } ;
@@ -585,8 +586,6 @@ HELP: index
 { $values { "obj" object } { "seq" sequence } { "n" "an index" } }
 { $description "Outputs the index of the first element in the sequence equal to " { $snippet "obj" } ". If no element is found, outputs " { $link f } "." } ;
 
-{ index index-from last-index last-index-from member? memq? } related-words
-
 HELP: index-from
 { $values { "obj" object } { "i" "a start index" } { "seq" sequence } { "n" "an index" } }
 { $description "Outputs the index of the first element in the sequence equal to " { $snippet "obj" } ", starting the search from the " { $snippet "i" } "th element. If no element is found, outputs " { $link f } "." } ;
diff --git a/core/sorting/sorting-docs.factor b/core/sorting/sorting-docs.factor
index d52ea5e11f..e55d1eb150 100644
--- a/core/sorting/sorting-docs.factor
+++ b/core/sorting/sorting-docs.factor
@@ -2,18 +2,15 @@ USING: help.markup help.syntax kernel words math
 sequences math.order ;
 IN: sorting
 
-ARTICLE: "sequences-sorting" "Sorting and binary search"
-"Sorting and binary search combinators all take comparator quotations with stack effect " { $snippet "( elt1 elt2 -- <=> )" } ", where the output value is one of the three " { $link "order-specifiers" } "."
+ARTICLE: "sequences-sorting" "Sorting sequences"
+"Sorting combinators all take comparator quotations with stack effect " { $snippet "( elt1 elt2 -- <=> )" } ", where the output value is one of the three " { $link "order-specifiers" } "."
 $nl
 "Sorting a sequence with a custom comparator:"
 { $subsection sort }
 "Sorting a sequence with common comparators:"
 { $subsection natural-sort }
 { $subsection sort-keys }
-{ $subsection sort-values }
-"Binary search:"
-{ $subsection binsearch }
-{ $subsection binsearch* } ;
+{ $subsection sort-values } ;
 
 ABOUT: "sequences-sorting"
 
@@ -41,24 +38,4 @@ HELP: midpoint@
 { $values { "seq" "a sequence" } { "n" integer } }
 { $description "Outputs the index of the midpoint of " { $snippet "seq" } "." } ;
 
-HELP: midpoint
-{ $values { "seq" "a sequence" } { "elt" object } }
-{ $description "Outputs the element at the midpoint of a sequence." } ;
-
-HELP: partition
-{ $values { "seq" "a sequence" } { "n" integer } { "slice" slice } }
-{ $description "Outputs a slice of the first or second half of the sequence, respectively, depending on the integer's sign." } ;
-
-HELP: binsearch
-{ $values { "elt" object } { "seq" "a sorted sequence" } { "quot" "a quotation with stack effect " { $snippet "( obj1 obj2 -- <=> )" } } { "i" "the index of the search result" } }
-{ $description "Given a sequence that is sorted with respect to the " { $snippet "quot" } " comparator, searches for an element equal to " { $snippet "elt" } ", or failing that, the greatest element smaller than " { $snippet "elt" } ". Comparison is performed with " { $snippet "quot" } "."
-$nl
-"Outputs f if the sequence is empty. If the sequence has at least one element, this word always outputs a valid index." } ;
-
-HELP: binsearch*
-{ $values { "elt" object } { "seq" "a sorted sequence" } { "quot" "a quotation with stack effect " { $snippet "( obj1 obj2 -- <=> )" } } { "result" "the search result" } }
-{ $description "Variant of " { $link binsearch } " which outputs the found element rather than its index in the sequence."
-$nl
-"Outputs " { $link f } " if the sequence is empty. If the sequence has at least one element, this word always outputs a sequence element." } ;
-
 { <=> compare natural-sort sort-keys sort-values } related-words
diff --git a/core/sorting/sorting-tests.factor b/core/sorting/sorting-tests.factor
index 17ec2d7cd1..f79800feae 100755
--- a/core/sorting/sorting-tests.factor
+++ b/core/sorting/sorting-tests.factor
@@ -16,13 +16,3 @@ unit-test
 ] unit-test
 
 [ ] [ { 1 2 } [ 2drop 1 ] sort drop ] unit-test
-
-[ 3 ] [ { 1 2 3 4 } midpoint ] unit-test
-
-[ f ] [ 3 { } [ <=> ] binsearch ] unit-test
-[ 0 ] [ 3 { 3 } [ <=> ] binsearch ] unit-test
-[ 1 ] [ 2 { 1 2 3 } [ <=> ] binsearch ] unit-test
-[ 3 ] [ 4 { 1 2 3 4 5 6 } [ <=> ] binsearch ] unit-test
-[ 2 ] [ 3.5 { 1 2 3 4 5 6 7 8 } [ <=> ] binsearch ] unit-test
-[ 4 ] [ 5.5 { 1 2 3 4 5 6 7 8 } [ <=> ] binsearch ] unit-test
-[ 10 ] [ 10 20 >vector [ <=> ] binsearch ] unit-test
diff --git a/core/sorting/sorting.factor b/core/sorting/sorting.factor
index 1a2491328c..0bc09089db 100755
--- a/core/sorting/sorting.factor
+++ b/core/sorting/sorting.factor
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays kernel math sequences vectors math.order
 sequences sequences.private math.order ;
@@ -53,25 +53,3 @@ PRIVATE>
 : sort-values ( seq -- sortedseq ) [ [ second ] compare ] sort ;
 
 : sort-pair ( a b -- c d ) 2dup after? [ swap ] when ;
-
-: midpoint ( seq -- elt )
-    [ midpoint@ ] keep nth-unsafe ; inline
-
-: partition ( seq n -- slice )
-    +gt+ eq? not swap halves ? ; inline
-
-: (binsearch) ( elt quot seq -- i )
-    dup length 1 <= [
-        slice-from 2nip
-    ] [
-        [ midpoint swap call ] 3keep roll dup +eq+ eq?
-        [ drop dup slice-from swap midpoint@ + 2nip ]
-        [ partition (binsearch) ] if
-    ] if ; inline
-
-: binsearch ( elt seq quot -- i )
-    swap dup empty?
-    [ 3drop f ] [ <flat-slice> (binsearch) ] if ; inline
-
-: binsearch* ( elt seq quot -- result )
-    over >r binsearch [ r> ?nth ] [ r> drop f ] if* ; inline
diff --git a/extra/cords/cords.factor b/extra/cords/cords.factor
index a7f4246826..52cb9914b4 100644
--- a/extra/cords/cords.factor
+++ b/extra/cords/cords.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs sequences sorting math math.order
-arrays combinators kernel ;
+USING: accessors assocs sequences sorting binary-search math
+math.order arrays combinators kernel ;
 IN: cords
 
 <PRIVATE
@@ -23,7 +23,7 @@ M: multi-cord length count>> ;
 
 M: multi-cord virtual@
     dupd
-    seqs>> [ first <=> ] binsearch*
+    seqs>> [ first <=> ] with search nip
     [ first - ] [ second ] bi ;
 
 M: multi-cord virtual-seq
diff --git a/extra/interval-maps/interval-maps.factor b/extra/interval-maps/interval-maps.factor
index 95e3794e32..a62855d78f 100755
--- a/extra/interval-maps/interval-maps.factor
+++ b/extra/interval-maps/interval-maps.factor
@@ -1,5 +1,7 @@
-USING: kernel sequences arrays accessors grouping
-math.order sorting math assocs locals namespaces ;
+! Copyright (C) 2008 Daniel Ehrenberg.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences arrays accessors grouping math.order
+sorting binary-search math assocs locals namespaces ;
 IN: interval-maps
 
 TUPLE: interval-map array ;
@@ -7,7 +9,7 @@ TUPLE: interval-map array ;
 <PRIVATE
 
 : find-interval ( key interval-map -- interval-node )
-    [ first <=> ] binsearch* ;
+    [ first <=> ] with search nip ;
 
 : interval-contains? ( key interval-node -- ? )
     first2 between? ;
diff --git a/extra/math/primes/primes.factor b/extra/math/primes/primes.factor
index 59aebbf0dd..f3a515e72b 100644
--- a/extra/math/primes/primes.factor
+++ b/extra/math/primes/primes.factor
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators kernel lists.lazy math math.functions math.miller-rabin
-       math.order math.primes.list math.ranges sequences sorting ;
+       math.order math.primes.list math.ranges sequences sorting
+       binary-search ;
 IN: math.primes
 
 <PRIVATE
@@ -13,14 +14,14 @@ PRIVATE>
 
 : next-prime ( n -- p )
   dup 999983 < [
-    primes-under-million [ [ <=> ] binsearch 1+ ] keep nth
+    primes-under-million [ natural-search drop 1+ ] keep nth
   ] [
     next-odd find-prime-miller-rabin
   ] if ; foldable
 
 : prime? ( n -- ? )
   dup 1000000 < [
-    dup primes-under-million [ <=> ] binsearch* =
+    dup primes-under-million natural-search nip =
   ] [
     miller-rabin
   ] if ; foldable
@@ -37,7 +38,7 @@ PRIVATE>
   {
     { [ dup 2 < ] [ drop { } ] }
     { [ dup 1000003 < ]
-      [ primes-under-million [ [ <=> ] binsearch 1+ 0 swap ] keep <slice> ] }
+      [ primes-under-million [ natural-search drop 1+ 0 swap ] keep <slice> ] }
     [ primes-under-million 1000003 lprimes-from
         rot [ <= ] curry lwhile list>array append ]
   } cond ; foldable
@@ -45,6 +46,6 @@ PRIVATE>
 : primes-between ( low high -- seq )
   primes-upto
   [ 1- next-prime ] dip
-  [ [ <=> ] binsearch ] keep [ length ] keep <slice> ; foldable
+  [ natural-search drop ] keep [ length ] keep <slice> ; foldable
 
 : coprime? ( a b -- ? ) gcd nip 1 = ; foldable
diff --git a/extra/ui/gadgets/gadgets.factor b/extra/ui/gadgets/gadgets.factor
index 19593d2f22..ea51847ba7 100755
--- a/extra/ui/gadgets/gadgets.factor
+++ b/extra/ui/gadgets/gadgets.factor
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays hashtables kernel models math namespaces
-       sequences quotations math.vectors combinators sorting vectors
-       dlists dequeues models threads concurrency.flags
-       math.order math.geometry.rect ;
+       sequences quotations math.vectors combinators sorting
+       binary-search vectors dlists dequeues models threads
+       concurrency.flags math.order math.geometry.rect ;
 
 IN: ui.gadgets
 
@@ -70,12 +70,15 @@ GENERIC: children-on ( rect/point gadget -- seq )
 
 M: gadget children-on nip children>> ;
 
-: (fast-children-on) ( dim axis gadgets -- i )
-    swapd [ rect-loc v- over v. 0 <=> ] binsearch nip ;
+: ((fast-children-on)) ( gadget dim axis -- <=> )
+    [ swap loc>> v- ] dip v. 0 <=> ;
+
+: (fast-children-on) ( dim axis children -- i )
+    -rot [ ((fast-children-on)) ] 2curry search drop ;
 
 : fast-children-on ( rect axis children -- from to )
-    [ >r >r rect-loc r> r> (fast-children-on) 0 or ]
-    [ >r >r dup rect-loc swap rect-dim v+ r> r> (fast-children-on) ?1+ ]
+    [ [ rect-loc ] 2dip (fast-children-on) 0 or ]
+    [ [ rect-bounds v+ ] 2dip (fast-children-on) ?1+ ]
     3bi ;
 
 : inside? ( bounds gadget -- ? )
diff --git a/extra/usa-cities/usa-cities.factor b/extra/usa-cities/usa-cities.factor
index 968bf9d053..a5abb53c62 100644
--- a/extra/usa-cities/usa-cities.factor
+++ b/extra/usa-cities/usa-cities.factor
@@ -50,4 +50,4 @@ MEMO: cities-named-in ( name state -- cities )
     ] with with filter ;
 
 : find-zip-code ( code -- city )
-    cities [ first-zip>> <=> ] binsearch* ;
+    cities [ first-zip>> <=> ] with search nip ;

From 2a1f6885fbb992df08f4b1c27612048b6fe2394e Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 20:48:25 -0500
Subject: [PATCH 32/35] Faster mergesort conses less and no longer does slice
 fiddling

---
 core/optimizer/known-words/known-words.factor |   8 ++
 core/sorting/sorting-tests.factor             |   8 +-
 core/sorting/sorting.factor                   | 135 ++++++++++++++----
 3 files changed, 121 insertions(+), 30 deletions(-)

diff --git a/core/optimizer/known-words/known-words.factor b/core/optimizer/known-words/known-words.factor
index cd5ec7fda2..af35607ce9 100755
--- a/core/optimizer/known-words/known-words.factor
+++ b/core/optimizer/known-words/known-words.factor
@@ -143,6 +143,14 @@ IN: optimizer.known-words
     { [ dup optimize-instance? ] [ optimize-instance ] }
 } define-optimizers
 
+! This is a special-case hack
+: redundant-array-capacity-check? ( #call -- ? )
+    dup in-d>> first node-literal [ 0 = ] [ fixnum? ] bi and ;
+
+\ array-capacity? {
+    { [ dup redundant-array-capacity-check? ] [ [ drop t ] f splice-quot ] }
+} define-optimizers
+
 ! eq? on the same object is always t
 { eq? = } {
     { { @ @ } [ 2drop t ] }
diff --git a/core/sorting/sorting-tests.factor b/core/sorting/sorting-tests.factor
index f79800feae..5f3dab14bc 100755
--- a/core/sorting/sorting-tests.factor
+++ b/core/sorting/sorting-tests.factor
@@ -1,8 +1,8 @@
 USING: sorting sequences kernel math math.order random
-tools.test vectors ;
+tools.test vectors sets ;
 IN: sorting.tests
 
-[ [ ] ] [ [ ] natural-sort ] unit-test
+[ { } ] [ { } natural-sort ] unit-test
 
 [ { 270000000 270000001 } ]
 [ T{ slice f 270000000 270000002 270000002 } natural-sort ]
@@ -11,7 +11,9 @@ unit-test
 [ t ] [
     100 [
         drop
-        100 [ 20 random [ 1000 random ] replicate ] replicate natural-sort [ before=? ] monotonic?
+        100 [ 20 random [ 1000 random ] replicate ] replicate
+        dup natural-sort
+        [ set= ] [ nip [ before=? ] monotonic? ] 2bi and
     ] all?
 ] unit-test
 
diff --git a/core/sorting/sorting.factor b/core/sorting/sorting.factor
index 0bc09089db..a6bcf92651 100755
--- a/core/sorting/sorting.factor
+++ b/core/sorting/sorting.factor
@@ -4,46 +4,127 @@ USING: accessors arrays kernel math sequences vectors math.order
 sequences sequences.private math.order ;
 IN: sorting
 
-DEFER: sort
+! Optimized merge-sort:
+!
+! 1) only allocates 2 temporary arrays
+
+! 2) first phase (interchanging pairs x[i], x[i+1] where
+! x[i] > x[i+1]) is handled specially
 
 <PRIVATE
 
-: <iterator> 0 tail-slice ; inline
+TUPLE: merge
+{ seq    array }
+{ accum  vector }
+{ accum1 vector }
+{ accum2 vector }
+{ from1  array-capacity }
+{ to1    array-capacity }
+{ from2  array-capacity }
+{ to2    array-capacity } ;
 
-: this ( slice -- obj )
-    dup slice-from swap slice-seq nth-unsafe ; inline
+: dump ( from to seq accum -- )
+    #! Optimize common case where to - from = 1.
+    >r >r 2dup swap - 1 =
+    [ drop r> nth-unsafe r> push ]
+    [ r> <slice> r> push-all ]
+    if ; inline
 
-: next ( iterator -- )
-    dup slice-from 1+ swap set-slice-from ; inline
+: l-elt   [ from1>> ] [ seq>> ] bi nth-unsafe ; inline
+: r-elt   [ from2>> ] [ seq>> ] bi nth-unsafe ; inline
+: l-done? [ from1>> ] [ to1>> ] bi number= ; inline
+: r-done? [ from2>> ] [ to2>> ] bi number= ; inline
+: dump-l  [ [ from1>> ] [ to1>> ] [ seq>> ] tri ] [ accum>> ] bi dump ; inline
+: dump-r  [ [ from2>> ] [ to2>> ] [ seq>> ] tri ] [ accum>> ] bi dump ; inline
+: l-next  [ [ l-elt ] [ [ 1+ ] change-from1 drop ] bi ] [ accum>> ] bi push ; inline
+: r-next  [ [ r-elt ] [ [ 1+ ] change-from2 drop ] bi ] [ accum>> ] bi push ; inline
+: decide  [ [ l-elt ] [ r-elt ] bi ] dip call +lt+ eq? ; inline
 
-: smallest ( iter1 iter2 quot -- elt )
-    >r over this over this r> call +lt+ eq?
-    -rot ? [ this ] keep next ; inline
-
-: (merge) ( iter1 iter2 quot accum -- )
-    >r pick empty? [
-        drop nip r> push-all
-    ] [
-        over empty? [
-            2drop r> push-all
-        ] [
-            3dup smallest r> [ push ] keep (merge)
+: (merge) ( merge quot -- )
+    over l-done? [ drop dump-r ] [
+        over r-done? [ drop dump-l ] [
+            2dup decide
+            [ over l-next ] [ over r-next ] if
+            (merge)
         ] if
     ] if ; inline
 
-: merge ( sorted1 sorted2 quot -- result )
-    >r [ [ <iterator> ] bi@ ] 2keep r>
-    rot length rot length + <vector>
-    [ (merge) ] [ underlying>> ] bi ; inline
+: flip-accum ( merge -- )
+    dup [ accum>> ] [ accum1>> ] bi eq? [
+        dup accum1>> underlying>> >>seq
+        dup accum2>> >>accum
+    ] [
+        dup accum1>> >>accum
+        dup accum2>> underlying>> >>seq
+    ] if
+    dup accum>> 0 >>length 2drop ; inline
 
-: conquer ( first second quot -- result )
-    [ tuck >r >r sort r> r> sort ] keep merge ; inline
+: <merge> ( seq -- merge )
+    \ merge new
+        over >vector >>accum1
+        swap length <vector> >>accum2
+        dup accum1>> underlying>> >>seq
+        dup accum2>> >>accum
+        dup accum>> 0 >>length drop ; inline
+
+: compute-midpoint ( merge -- merge )
+    dup [ from1>> ] [ to2>> ] bi + 2/ >>to1 ; inline
+
+: merging ( from to merge -- )
+    swap >>to2
+    swap >>from1
+    compute-midpoint
+    dup [ to1>> ] [ seq>> length ] bi min >>to1
+    dup [ to2>> ] [ seq>> length ] bi min >>to2
+    dup to1>> >>from2
+    drop ; inline
+
+: nth-chunk ( n size -- from to ) [ * dup ] keep + ; inline
+
+: chunks ( length size -- n ) [ align ] keep /i ; inline
+
+: each-chunk ( length size quot -- )
+    [ [ chunks ] keep ] dip
+    [ nth-chunk ] prepose curry
+    each-integer ; inline
+
+: merge ( from to merge quot -- )
+    [ [ merging ] keep ] dip (merge) ; inline
+
+: sort-pass ( merge size quot -- )
+    [
+        over flip-accum
+        over [ seq>> length ] 2dip
+    ] dip
+    [ merge ] 2curry each-chunk ; inline
+
+: sort-loop ( merge quot -- )
+    2 swap
+    [ pick seq>> length pick > ]
+    [ [ dup ] [ 1 shift ] [ ] tri* [ sort-pass ] 2keep ]
+    [ ] while 3drop ; inline
+
+: each-pair ( seq quot -- )
+    [ [ length 1+ 2/ ] keep ] dip
+    [ [ 1 shift dup 1+ ] dip ] prepose curry each-integer ; inline
+
+: (sort-pairs) ( i1 i2 seq quot accum -- )
+    >r >r 2dup length = [
+        nip nth r> drop r> push
+    ] [
+        tuck [ nth-unsafe ] 2bi@ 2dup r> call +gt+ eq?
+        [ swap ] when r> tuck [ push ] 2bi@
+    ] if ; inline
+
+: sort-pairs ( merge quot -- )
+    [ [ seq>> ] [ accum>> ] bi ] dip swap
+    [ (sort-pairs) ] 2curry each-pair ; inline
 
 PRIVATE>
 
-: sort ( seq quot -- sortedseq )
-    over length 1 <=
-    [ drop ] [ over >r >r halves r> conquer r> like ] if ;
+: sort ( seq quot -- seq' )
+    [ <merge> ] dip
+    [ sort-pairs ] [ sort-loop ] [ drop accum>> underlying>> ] 2tri ;
     inline
 
 : natural-sort ( seq -- sortedseq ) [ <=> ] sort ;

From 19919bb1307c11ee63fbd9b461aa1b7297ca2c31 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 20:57:56 -0500
Subject: [PATCH 33/35] Fix soundex

---
 extra/soundex/soundex-tests.factor | 1 +
 extra/soundex/soundex.factor       | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/extra/soundex/soundex-tests.factor b/extra/soundex/soundex-tests.factor
index df6338c4ec..f4bd18e34b 100644
--- a/extra/soundex/soundex-tests.factor
+++ b/extra/soundex/soundex-tests.factor
@@ -2,3 +2,4 @@ IN: soundex.tests
 USING: soundex tools.test ;
 
 [ "S162" ] [ "supercalifrag" soundex ] unit-test
+[ "M000" ] [ "M" soundex ] unit-test
diff --git a/extra/soundex/soundex.factor b/extra/soundex/soundex.factor
index c82825d814..23d5ee4d4c 100644
--- a/extra/soundex/soundex.factor
+++ b/extra/soundex/soundex.factor
@@ -25,8 +25,8 @@ TR: soundex-tr
         [ first>upper ]
         [
             soundex-tr
-            trim-first
-            remove-duplicates
+            [ "" ] [ trim-first ] if-empty
+            [ "" ] [ remove-duplicates ] if-empty
             remove-zeroes
         ] bi
         pad-4

From 696a80367f79682541ded03bacd435446421ec78 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 22:58:45 -0500
Subject: [PATCH 34/35] Ricing

---
 core/sorting/sorting.factor | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/core/sorting/sorting.factor b/core/sorting/sorting.factor
index a6bcf92651..a93a30e7f2 100755
--- a/core/sorting/sorting.factor
+++ b/core/sorting/sorting.factor
@@ -24,11 +24,23 @@ TUPLE: merge
 { to2    array-capacity } ;
 
 : dump ( from to seq accum -- )
-    #! Optimize common case where to - from = 1.
-    >r >r 2dup swap - 1 =
-    [ drop r> nth-unsafe r> push ]
-    [ r> <slice> r> push-all ]
-    if ; inline
+    #! Optimize common case where to - from = 1, 2, or 3.
+    >r >r 2dup swap - dup 1 =
+    [ 2drop r> nth-unsafe r> push ] [
+        dup 2 = [
+            2drop dup 1+
+            r> [ nth-unsafe ] curry bi@
+            r> [ push ] curry bi@
+        ] [
+            dup 3 = [
+                2drop dup 1+ dup 1+
+                r> [ nth-unsafe ] curry tri@
+                r> [ push ] curry tri@
+            ] [
+                drop r> subseq r> push-all
+            ] if
+        ] if
+    ] if ; inline
 
 : l-elt   [ from1>> ] [ seq>> ] bi nth-unsafe ; inline
 : r-elt   [ from2>> ] [ seq>> ] bi nth-unsafe ; inline

From 6577d4e500b01a05d122d618218233159861e87f Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 15 Jul 2008 23:00:40 -0500
Subject: [PATCH 35/35] Fix load error

---
 extra/usa-cities/usa-cities.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extra/usa-cities/usa-cities.factor b/extra/usa-cities/usa-cities.factor
index a5abb53c62..c5e059c519 100644
--- a/extra/usa-cities/usa-cities.factor
+++ b/extra/usa-cities/usa-cities.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files io.encodings.ascii sequences generalizations
 math.parser combinators kernel memoize csv symbols summary
-words accessors math.order sorting ;
+words accessors math.order binary-search ;
 IN: usa-cities
 
 SINGLETONS: AK AL AR AS AZ CA CO CT DC DE FL GA HI IA ID IL IN