]> gitweb.factorcode.org Git - factor.git/commitdiff
usb: add macosx structs
authorchris.double <chris.double@double.co.nz>
Fri, 15 Sep 2006 03:20:26 +0000 (03:20 +0000)
committerchris.double <chris.double@double.co.nz>
Fri, 15 Sep 2006 03:20:26 +0000 (03:20 +0000)
contrib/usb/load.factor
contrib/usb/usb-macosx.factor [new file with mode: 0644]

index 27ea3e4d1973345346c2f6aea4d07365f8557c68..6c0ce06a3acdab69b6e39deae9539af794939bcb 100644 (file)
@@ -6,6 +6,7 @@ PROVIDE: contrib/usb {
        "usb-common.factor" 
        { "usb-unix.factor" [ unix? ] }
        { "usb-win32.factor" [ win32? ] }
+       { "usb-macosx.factor" [ macosx? ] }
        "usb.factor" 
 } { 
 } ;
diff --git a/contrib/usb/usb-macosx.factor b/contrib/usb/usb-macosx.factor
new file mode 100644 (file)
index 0000000..23e8ad7
--- /dev/null
@@ -0,0 +1,66 @@
+! Copyright (C) 2006 Chris Double.
+! See http://factorcode.org/license.txt for BSD license.
+!
+IN: usb
+USING: kernel alien ;
+
+"usb" "libusb.dll" "cdecl" add-library
+
+LIBRARY: usb
+
+BEGIN-STRUCT: usb_bus
+  FIELD: void*      next
+  FIELD: void*      prev       
+  FIELD: char[1025] dirname
+  FIELD: void*      devices
+  FIELD: uint       location
+  FIELD: void*      root_dev
+END-STRUCT
+
+! __attribute__ ((packed))
+BEGIN-STRUCT: usb_device_descriptor
+  PACKED-FIELD: uchar bLength
+  PACKED-FIELD: uchar bDescriptorType
+  PACKED-FIELD: ushort bcdUSB
+  PACKED-FIELD: uchar  bDeviceClass
+  PACKED-FIELD: uchar  bDeviceSubClass
+  PACKED-FIELD: uchar  bDeviceProtocol
+  PACKED-FIELD: uchar  bMaxPacketSize0
+  PACKED-FIELD: ushort idVendor
+  PACKED-FIELD: ushort idProduct
+  PACKED-FIELD: ushort bcdDevice;
+  PACKED-FIELD: uchar  iManufacturer
+  PACKED-FIELD: uchar  iProduct
+  PACKED-FIELD: uchar  iSerialNumber
+  PACKED-FIELD: uchar  bNumConfigurations
+END-STRUCT
+
+BEGIN-STRUCT: usb_config_descriptor
+  PACKED-FIELD: uchar  bLength ! __attribute__ ((packed))
+  PACKED-FIELD: uchar  bDescriptorType ! __attribute__ ((packed))
+  PACKED-FIELD: ushort wTotalLength ! __attribute__ ((packed))
+  PACKED-FIELD: uchar  bNumInterfaces !  __attribute__ ((packed))
+  PACKED-FIELD: uchar  bConfigurationValue ! __attribute__ ((packed))
+  PACKED-FIELD: uchar  iConfiguration ! __attribute__ ((packed))
+  PACKED-FIELD: uchar  bmAttributes ! __attribute__ ((packed))
+  PACKED-FIELD: uchar  MaxPower ! __attribute__ ((packed))
+
+  FIELD: void*  interface
+
+  FIELD: uchar* extra
+  FIELD: int extralen
+END-STRUCT
+
+BEGIN-STRUCT: usb_device
+  FIELD: void* next
+  FIELD: void* prev
+  FIELD: char[1025] filename
+  FIELD: usb_bus* bus
+  FIELD: usb_device_descriptor descriptor
+  FIELD: usb_config_descriptor* config
+  FIELD: void* dev
+  FIELD: uchar devnum
+  FIELD: uchar num_children
+  FIELD: void* children
+END-STRUCT
+