Merge branch 'master' of git://github.com/erikcharlebois/factor
commit
b59da05347
|
@ -267,7 +267,7 @@ T{ book
|
||||||
{ $list
|
{ $list
|
||||||
"Make a new tuple to represent your data"
|
"Make a new tuple to represent your data"
|
||||||
{ "Map the Factor types to the database types with " { $link define-persistent } }
|
{ "Map the Factor types to the database types with " { $link define-persistent } }
|
||||||
{ "Make a custom database combinator (see" { $link "db-custom-database-combinators" } ") to open your database and run a " { $link quotation } }
|
{ "Make a custom database combinator (see " { $link "db-custom-database-combinators" } ") to open your database and run a " { $link quotation } }
|
||||||
{ "Create a table with " { $link create-table } ", " { $link ensure-table } ", or " { $link recreate-table } }
|
{ "Create a table with " { $link create-table } ", " { $link ensure-table } ", or " { $link recreate-table } }
|
||||||
{ "Start making and storing objects with " { $link insert-tuple } ", " { $link update-tuple } ", " { $link delete-tuples } ", and " { $link select-tuples } }
|
{ "Start making and storing objects with " { $link insert-tuple } ", " { $link update-tuple } ", " { $link delete-tuples } ", and " { $link select-tuples } }
|
||||||
} ;
|
} ;
|
||||||
|
|
|
@ -93,5 +93,5 @@ M: mouse-state clone
|
||||||
{
|
{
|
||||||
{ [ os windows? ] [ "game.input.xinput" require ] }
|
{ [ os windows? ] [ "game.input.xinput" require ] }
|
||||||
{ [ os macosx? ] [ "game.input.iokit" require ] }
|
{ [ os macosx? ] [ "game.input.iokit" require ] }
|
||||||
{ [ t ] [ ] }
|
{ [ os linux? ] [ "game.input.linux" require ] }
|
||||||
} cond
|
} cond
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -0,0 +1,49 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: kernel game.input namespaces classes windows.com.syntax
|
||||||
|
bit-arrays
|
||||||
|
vectors ;
|
||||||
|
IN: game.input.linux
|
||||||
|
|
||||||
|
SINGLETON: linux-game-input-backend
|
||||||
|
|
||||||
|
linux-game-input-backend game-input-backend set-global
|
||||||
|
|
||||||
|
M: linux-game-input-backend (open-game-input)
|
||||||
|
;
|
||||||
|
|
||||||
|
M: linux-game-input-backend (close-game-input)
|
||||||
|
;
|
||||||
|
|
||||||
|
M: linux-game-input-backend (reset-game-input)
|
||||||
|
;
|
||||||
|
|
||||||
|
M: linux-game-input-backend get-controllers
|
||||||
|
{ } ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend product-string
|
||||||
|
drop "" ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend product-id
|
||||||
|
drop GUID: {00000000-0000-0000-0000-000000000000} ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend instance-id
|
||||||
|
drop GUID: {00000000-0000-0000-0000-000000000000} ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend read-controller
|
||||||
|
drop controller-state new ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend calibrate-controller
|
||||||
|
drop ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend vibrate-controller
|
||||||
|
3drop ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend read-keyboard
|
||||||
|
256 <bit-array> keyboard-state boa ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend read-mouse
|
||||||
|
0 0 0 0 2 <vector> mouse-state boa ;
|
||||||
|
|
||||||
|
M: linux-game-input-backend reset-mouse
|
||||||
|
;
|
|
@ -0,0 +1 @@
|
||||||
|
Linux backend for game input.
|
|
@ -0,0 +1 @@
|
||||||
|
games
|
|
@ -1,14 +1,13 @@
|
||||||
! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov
|
! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types arrays ascii assocs colors
|
USING: accessors alien.c-types ascii assocs classes.struct combinators
|
||||||
classes.struct combinators io.encodings.ascii
|
combinators.short-circuit command-line environment io.encodings.ascii
|
||||||
io.encodings.string io.encodings.utf8 kernel literals math
|
io.encodings.string io.encodings.utf8 kernel literals locals math
|
||||||
namespaces sequences strings ui ui.backend ui.clipboards
|
namespaces sequences specialized-arrays.instances.alien.c-types.uchar
|
||||||
ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds
|
strings ui ui.backend ui.clipboards ui.event-loop ui.gadgets
|
||||||
ui.gestures ui.pixel-formats ui.pixel-formats.private
|
ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats
|
||||||
ui.private x11 x11.clipboard x11.constants x11.events x11.glx
|
ui.pixel-formats.private ui.private x11 x11.clipboard x11.constants
|
||||||
x11.io x11.windows x11.xim x11.xlib environment command-line
|
x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ;
|
||||||
combinators.short-circuit ;
|
|
||||||
IN: ui.backend.x11
|
IN: ui.backend.x11
|
||||||
|
|
||||||
SINGLETON: x11-ui-backend
|
SINGLETON: x11-ui-backend
|
||||||
|
@ -328,6 +327,22 @@ M: x11-ui-backend (with-ui) ( quot -- )
|
||||||
M: x11-ui-backend beep ( -- )
|
M: x11-ui-backend beep ( -- )
|
||||||
dpy get 100 XBell drop ;
|
dpy get 100 XBell drop ;
|
||||||
|
|
||||||
|
: black ( -- xcolor ) 0 0 0 0 0 0 XColor <struct-boa> ; inline
|
||||||
|
|
||||||
|
M:: x11-ui-backend (grab-input) ( handle -- )
|
||||||
|
handle window>> :> wnd
|
||||||
|
dpy get :> dpy
|
||||||
|
dpy wnd uchar-array{ 0 0 0 0 0 0 0 0 } 8 8 XCreateBitmapFromData :> pixmap
|
||||||
|
dpy pixmap dup black dup 0 0 XCreatePixmapCursor :> cursor
|
||||||
|
|
||||||
|
dpy wnd 1 NoEventMask GrabModeAsync dup wnd cursor CurrentTime XGrabPointer drop
|
||||||
|
|
||||||
|
dpy cursor XFreeCursor drop
|
||||||
|
dpy pixmap XFreePixmap drop ;
|
||||||
|
|
||||||
|
M: x11-ui-backend (ungrab-input)
|
||||||
|
drop dpy get CurrentTime XUngrabPointer drop ;
|
||||||
|
|
||||||
x11-ui-backend ui-backend set-global
|
x11-ui-backend ui-backend set-global
|
||||||
|
|
||||||
[ "DISPLAY" os-env "ui.tools" "listener" ? ]
|
[ "DISPLAY" os-env "ui.tools" "listener" ? ]
|
||||||
|
|
|
@ -901,12 +901,6 @@ CONSTANT: D3DMULTISAMPLE_15_SAMPLES 15
|
||||||
CONSTANT: D3DMULTISAMPLE_16_SAMPLES 16
|
CONSTANT: D3DMULTISAMPLE_16_SAMPLES 16
|
||||||
CONSTANT: D3DMULTISAMPLE_FORCE_DWORD HEX: 7fffffff
|
CONSTANT: D3DMULTISAMPLE_FORCE_DWORD HEX: 7fffffff
|
||||||
|
|
||||||
:: MAKEFOURCC ( ch0 ch1 ch2 ch3 -- n )
|
|
||||||
ch3 HEX: ff bitand 24 shift
|
|
||||||
ch2 HEX: ff bitand 16 shift
|
|
||||||
ch1 HEX: ff bitand 8 shift
|
|
||||||
ch0 HEX: ff bitand bitor bitor bitor ; inline
|
|
||||||
|
|
||||||
TYPEDEF: int D3DFORMAT
|
TYPEDEF: int D3DFORMAT
|
||||||
CONSTANT: D3DFMT_UNKNOWN 0
|
CONSTANT: D3DFMT_UNKNOWN 0
|
||||||
CONSTANT: D3DFMT_R8G8B8 20
|
CONSTANT: D3DFMT_R8G8B8 20
|
||||||
|
@ -937,15 +931,15 @@ CONSTANT: D3DFMT_X8L8V8U8 62
|
||||||
CONSTANT: D3DFMT_Q8W8V8U8 63
|
CONSTANT: D3DFMT_Q8W8V8U8 63
|
||||||
CONSTANT: D3DFMT_V16U16 64
|
CONSTANT: D3DFMT_V16U16 64
|
||||||
CONSTANT: D3DFMT_A2W10V10U10 67
|
CONSTANT: D3DFMT_A2W10V10U10 67
|
||||||
#! : D3DFMT_UYVY ( -- n ) 'U' 'Y' 'V' 'Y' MAKEFOURCC
|
CONSTANT: D3DFMT_UYVY HEX: 55595659
|
||||||
#! D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
|
CONSTANT: D3DFMT_R8G8_B8G8 HEX: 52474247
|
||||||
#! D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
|
CONSTANT: D3DFMT_YUY2 HEX: 59555932
|
||||||
#! D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
|
CONSTANT: D3DFMT_G8R8_G8B8 HEX: 47524742
|
||||||
#! D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
|
CONSTANT: D3DFMT_DXT1 HEX: 44585431
|
||||||
#! D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
|
CONSTANT: D3DFMT_DXT2 HEX: 44585432
|
||||||
#! D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
|
CONSTANT: D3DFMT_DXT3 HEX: 44585433
|
||||||
#! D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
|
CONSTANT: D3DFMT_DXT4 HEX: 44585434
|
||||||
#! D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
|
CONSTANT: D3DFMT_DXT5 HEX: 44585435
|
||||||
CONSTANT: D3DFMT_D16_LOCKABLE 70
|
CONSTANT: D3DFMT_D16_LOCKABLE 70
|
||||||
CONSTANT: D3DFMT_D32 71
|
CONSTANT: D3DFMT_D32 71
|
||||||
CONSTANT: D3DFMT_D15S1 73
|
CONSTANT: D3DFMT_D15S1 73
|
||||||
|
@ -962,7 +956,7 @@ CONSTANT: D3DFMT_VERTEXDATA 100
|
||||||
CONSTANT: D3DFMT_INDEX16 101
|
CONSTANT: D3DFMT_INDEX16 101
|
||||||
CONSTANT: D3DFMT_INDEX32 102
|
CONSTANT: D3DFMT_INDEX32 102
|
||||||
CONSTANT: D3DFMT_Q16W16V16U16 110
|
CONSTANT: D3DFMT_Q16W16V16U16 110
|
||||||
#! D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M', 'E', 'T', '1'),
|
CONSTANT: D3DFMT_MULTI2_ARGB8 HEX: 4d455431
|
||||||
CONSTANT: D3DFMT_R16F 111
|
CONSTANT: D3DFMT_R16F 111
|
||||||
CONSTANT: D3DFMT_G16R16F 112
|
CONSTANT: D3DFMT_G16R16F 112
|
||||||
CONSTANT: D3DFMT_A16B16G16R16F 113
|
CONSTANT: D3DFMT_A16B16G16R16F 113
|
||||||
|
|
|
@ -284,6 +284,11 @@ X-FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom targe
|
||||||
X-FUNCTION: Pixmap XCreatePixmap ( Display* display, Drawable d, uint width, uint height, uint depth ) ;
|
X-FUNCTION: Pixmap XCreatePixmap ( Display* display, Drawable d, uint width, uint height, uint depth ) ;
|
||||||
X-FUNCTION: int XFreePixmap ( Display* display, Pixmap pixmap ) ;
|
X-FUNCTION: int XFreePixmap ( Display* display, Pixmap pixmap ) ;
|
||||||
|
|
||||||
|
! 5.2 - Creating, Recoloring, and Freeing Cursors
|
||||||
|
|
||||||
|
C-TYPE: XColor
|
||||||
|
X-FUNCTION: Cursor XCreatePixmapCursor ( Display* display, Pixmap source, Pixmap mask, XColor* foreground_color, XColor* background_color, uint x, uint y ) ;
|
||||||
|
X-FUNCTION: int XFreeCursor ( Display* display, Cursor cursor ) ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
! 6 - Color Management Functions
|
! 6 - Color Management Functions
|
||||||
|
@ -1096,6 +1101,7 @@ X-FUNCTION: int XGrabPointer (
|
||||||
X-FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ;
|
X-FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ;
|
||||||
X-FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ;
|
X-FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ;
|
||||||
X-FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ;
|
X-FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ;
|
||||||
|
X-FUNCTION: int XGrabKeyboard ( Display* display, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode, Time time ) ;
|
||||||
X-FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ;
|
X-FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ;
|
||||||
|
|
||||||
X-FUNCTION: Status XGetInputFocus ( Display* display,
|
X-FUNCTION: Status XGetInputFocus ( Display* display,
|
||||||
|
@ -1210,6 +1216,14 @@ STRUCT: XVisualInfo
|
||||||
{ colormap_size int }
|
{ colormap_size int }
|
||||||
{ bits_per_rgb int } ;
|
{ bits_per_rgb int } ;
|
||||||
|
|
||||||
|
! 16.9 Manipulating Bitmaps
|
||||||
|
X-FUNCTION: Pixmap XCreateBitmapFromData (
|
||||||
|
Display* display,
|
||||||
|
Drawable d,
|
||||||
|
char* data,
|
||||||
|
uint width,
|
||||||
|
uint height ) ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
! Appendix D - Compatibility Functions
|
! Appendix D - Compatibility Functions
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
! Copyright (C) 2010 Erik Charlebois
|
! Copyright (C) 2010 Erik Charlebois
|
||||||
! See http:// factorcode.org/license.txt for BSD license.
|
! See http:// factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors chipmunk classes.struct game.loop game.worlds gpu
|
USING: accessors chipmunk classes.struct game.worlds kernel locals
|
||||||
gpu.util.wasd kernel literals locals math method-chains opengl.gl
|
math method-chains opengl.gl random sequences specialized-arrays
|
||||||
random sequences specialized-arrays
|
specialized-arrays.instances.alien.c-types.void* ui ui.gadgets.worlds
|
||||||
specialized-arrays.instances.alien.c-types.void* ui.gadgets.worlds
|
|
||||||
ui.pixel-formats ;
|
ui.pixel-formats ;
|
||||||
IN: chipmunk.demo
|
IN: chipmunk.demo
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ CONSTANT: image-bitmap B{
|
||||||
cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit cpCircleShape memory>struct
|
cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit cpCircleShape memory>struct
|
||||||
[ shape>> 0 >>e ] [ shape>> 0 >>u ] bi drop ;
|
[ shape>> 0 >>e ] [ shape>> 0 >>u ] bi drop ;
|
||||||
|
|
||||||
TUPLE: chipmunk-world < wasd-world
|
TUPLE: chipmunk-world < game-world
|
||||||
space ;
|
space ;
|
||||||
|
|
||||||
AFTER: chipmunk-world tick-game-world
|
AFTER: chipmunk-world tick-game-world
|
||||||
|
@ -97,8 +96,6 @@ M:: chipmunk-world draw-world* ( world -- )
|
||||||
|
|
||||||
M:: chipmunk-world begin-game-world ( world -- )
|
M:: chipmunk-world begin-game-world ( world -- )
|
||||||
cpInitChipmunk
|
cpInitChipmunk
|
||||||
init-gpu
|
|
||||||
world { -0.2 0.13 0.1 } 1.1 0.2 set-wasd-view drop
|
|
||||||
|
|
||||||
cpSpaceAlloc cpSpaceInit cpSpace memory>struct :> space
|
cpSpaceAlloc cpSpaceInit cpSpace memory>struct :> space
|
||||||
|
|
||||||
|
@ -132,20 +129,19 @@ M: chipmunk-world end-game-world
|
||||||
[ cpSpaceFreeChildren ]
|
[ cpSpaceFreeChildren ]
|
||||||
[ cpSpaceFree ] bi ;
|
[ cpSpaceFree ] bi ;
|
||||||
|
|
||||||
M: chipmunk-world wasd-movement-speed drop 1/160. ;
|
: chipmunk-demo ( -- )
|
||||||
M: chipmunk-world wasd-near-plane drop 1/32. ;
|
[
|
||||||
M: chipmunk-world wasd-far-plane drop 256.0 ;
|
f
|
||||||
|
T{ game-attributes
|
||||||
GAME: chipmunk-demo {
|
|
||||||
{ world-class chipmunk-world }
|
{ world-class chipmunk-world }
|
||||||
{ title "Chipmunk Physics Demo" }
|
{ title "Chipmunk Physics Demo" }
|
||||||
{ pixel-format-attributes {
|
{ pixel-format-attributes
|
||||||
windowed
|
{ windowed double-buffered }
|
||||||
double-buffered
|
}
|
||||||
T{ depth-bits { value 24 } }
|
|
||||||
} }
|
|
||||||
{ grab-input? t }
|
|
||||||
{ use-game-input? t }
|
|
||||||
{ pref-dim { 640 480 } }
|
{ pref-dim { 640 480 } }
|
||||||
{ tick-interval-micros $[ 60 fps ] }
|
{ tick-interval-micros 16666 }
|
||||||
} ;
|
}
|
||||||
|
clone
|
||||||
|
open-window
|
||||||
|
] with-ui ;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
FFI bindings to the Chipmunk 2D physics library.
|
Chipmunk 2D physics library binding
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
bindings
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -0,0 +1,422 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: accessors alien alien.c-types alien.libraries
|
||||||
|
alien.syntax classes.struct combinators endian io.binary
|
||||||
|
kernel locals math sequences specialized-arrays
|
||||||
|
system unix.time unix.types ;
|
||||||
|
FROM: alien.c-types => short ;
|
||||||
|
IN: libusb
|
||||||
|
|
||||||
|
<< "libusb" {
|
||||||
|
{ [ os windows? ] [ "libusb-1.0.dll" ] }
|
||||||
|
{ [ os macosx? ] [ "libusb-1.0.dylib" ] }
|
||||||
|
{ [ os unix? ] [ "libusb-1.0.so" ] }
|
||||||
|
} cond "cdecl" add-library >>
|
||||||
|
LIBRARY: libusb
|
||||||
|
|
||||||
|
: libusb_cpu_to_le16 ( x -- y )
|
||||||
|
2 >native-endian le> ; inline
|
||||||
|
|
||||||
|
ALIAS: libusb_le16_to_cpu libusb_cpu_to_le16
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_CLASS_PER_INTERFACE 0
|
||||||
|
CONSTANT: LIBUSB_CLASS_AUDIO 1
|
||||||
|
CONSTANT: LIBUSB_CLASS_COMM 2
|
||||||
|
CONSTANT: LIBUSB_CLASS_HID 3
|
||||||
|
CONSTANT: LIBUSB_CLASS_PRINTER 7
|
||||||
|
CONSTANT: LIBUSB_CLASS_PTP 6
|
||||||
|
CONSTANT: LIBUSB_CLASS_MASS_STORAGE 8
|
||||||
|
CONSTANT: LIBUSB_CLASS_HUB 9
|
||||||
|
CONSTANT: LIBUSB_CLASS_DATA 10
|
||||||
|
CONSTANT: LIBUSB_CLASS_VENDOR_SPEC HEX: ff
|
||||||
|
TYPEDEF: int libusb_class_code
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_DT_DEVICE HEX: 01
|
||||||
|
CONSTANT: LIBUSB_DT_CONFIG HEX: 02
|
||||||
|
CONSTANT: LIBUSB_DT_STRING HEX: 03
|
||||||
|
CONSTANT: LIBUSB_DT_INTERFACE HEX: 04
|
||||||
|
CONSTANT: LIBUSB_DT_ENDPOINT HEX: 05
|
||||||
|
CONSTANT: LIBUSB_DT_HID HEX: 21
|
||||||
|
CONSTANT: LIBUSB_DT_REPORT HEX: 22
|
||||||
|
CONSTANT: LIBUSB_DT_PHYSICAL HEX: 23
|
||||||
|
CONSTANT: LIBUSB_DT_HUB HEX: 29
|
||||||
|
TYPEDEF: int libusb_descriptor_type
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_DT_DEVICE_SIZE 18
|
||||||
|
CONSTANT: LIBUSB_DT_CONFIG_SIZE 9
|
||||||
|
CONSTANT: LIBUSB_DT_INTERFACE_SIZE 9
|
||||||
|
CONSTANT: LIBUSB_DT_ENDPOINT_SIZE 7
|
||||||
|
CONSTANT: LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9
|
||||||
|
CONSTANT: LIBUSB_DT_HUB_NONVAR_SIZE 7
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ENDPOINT_ADDRESS_MASK HEX: 0f
|
||||||
|
CONSTANT: LIBUSB_ENDPOINT_DIR_MASK HEX: 80
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ENDPOINT_IN HEX: 80
|
||||||
|
CONSTANT: LIBUSB_ENDPOINT_OUT HEX: 00
|
||||||
|
TYPEDEF: int libusb_endpoint_direction
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_TYPE_MASK HEX: 03
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_TYPE_CONTROL 0
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_TYPE_ISOCHRONOUS 1
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_TYPE_BULK 2
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_TYPE_INTERRUPT 3
|
||||||
|
TYPEDEF: int libusb_transfer_type
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_REQUEST_GET_STATUS HEX: 00
|
||||||
|
CONSTANT: LIBUSB_REQUEST_CLEAR_FEATURE HEX: 01
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SET_FEATURE HEX: 03
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SET_ADDRESS HEX: 05
|
||||||
|
CONSTANT: LIBUSB_REQUEST_GET_DESCRIPTOR HEX: 06
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SET_DESCRIPTOR HEX: 07
|
||||||
|
CONSTANT: LIBUSB_REQUEST_GET_CONFIGURATION HEX: 08
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SET_CONFIGURATION HEX: 09
|
||||||
|
CONSTANT: LIBUSB_REQUEST_GET_INTERFACE HEX: 0A
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SET_INTERFACE HEX: 0B
|
||||||
|
CONSTANT: LIBUSB_REQUEST_SYNCH_FRAME HEX: 0C
|
||||||
|
TYPEDEF: int libusb_standard_request
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_REQUEST_TYPE_STANDARD HEX: 00
|
||||||
|
CONSTANT: LIBUSB_REQUEST_TYPE_CLASS HEX: 20
|
||||||
|
CONSTANT: LIBUSB_REQUEST_TYPE_VENDOR HEX: 40
|
||||||
|
CONSTANT: LIBUSB_REQUEST_TYPE_RESERVED HEX: 60
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_RECIPIENT_DEVICE HEX: 00
|
||||||
|
CONSTANT: LIBUSB_RECIPIENT_INTERFACE HEX: 01
|
||||||
|
CONSTANT: LIBUSB_RECIPIENT_ENDPOINT HEX: 02
|
||||||
|
CONSTANT: LIBUSB_RECIPIENT_OTHER HEX: 03
|
||||||
|
TYPEDEF: int libusb_request_recipient
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ISO_SYNC_TYPE_MASK HEX: 0C
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ISO_SYNC_TYPE_NONE 0
|
||||||
|
CONSTANT: LIBUSB_ISO_SYNC_TYPE_ASYNC 1
|
||||||
|
CONSTANT: LIBUSB_ISO_SYNC_TYPE_ADAPTIVE 2
|
||||||
|
CONSTANT: LIBUSB_ISO_SYNC_TYPE_SYNC 3
|
||||||
|
TYPEDEF: int libusb_iso_sync_type
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ISO_USAGE_TYPE_MASK HEX: 30
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_ISO_USAGE_TYPE_DATA 0
|
||||||
|
CONSTANT: LIBUSB_ISO_USAGE_TYPE_FEEDBACK 1
|
||||||
|
CONSTANT: LIBUSB_ISO_USAGE_TYPE_IMPLICIT 2
|
||||||
|
TYPEDEF: int libusb_iso_usage_type
|
||||||
|
|
||||||
|
STRUCT: libusb_device_descriptor
|
||||||
|
{ bLength uint8_t }
|
||||||
|
{ bDescriptorType uint8_t }
|
||||||
|
{ bcdUSB uint16_t }
|
||||||
|
{ bDeviceClass uint8_t }
|
||||||
|
{ bDeviceSubClass uint8_t }
|
||||||
|
{ bDeviceProtocol uint8_t }
|
||||||
|
{ bMaxPacketSize0 uint8_t }
|
||||||
|
{ idVendor uint16_t }
|
||||||
|
{ idProduct uint16_t }
|
||||||
|
{ bcdDevice uint16_t }
|
||||||
|
{ iManufacturer uint8_t }
|
||||||
|
{ iProduct uint8_t }
|
||||||
|
{ iSerialNumber uint8_t }
|
||||||
|
{ bNumConfigurations uint8_t } ;
|
||||||
|
|
||||||
|
STRUCT: libusb_endpoint_descriptor
|
||||||
|
{ bLength uint8_t }
|
||||||
|
{ bDescriptorType uint8_t }
|
||||||
|
{ bEndpointAddress uint8_t }
|
||||||
|
{ bmAttributes uint8_t }
|
||||||
|
{ wMaxPacketSize uint16_t }
|
||||||
|
{ bInterval uint8_t }
|
||||||
|
{ bRefresh uint8_t }
|
||||||
|
{ bSynchAddress uint8_t }
|
||||||
|
{ extra uchar* }
|
||||||
|
{ extra_length int } ;
|
||||||
|
|
||||||
|
STRUCT: libusb_interface_descriptor
|
||||||
|
{ bLength uint8_t }
|
||||||
|
{ bDescriptorType uint8_t }
|
||||||
|
{ bInterfaceNumber uint8_t }
|
||||||
|
{ bAlternateSetting uint8_t }
|
||||||
|
{ bNumEndpoints uint8_t }
|
||||||
|
{ bInterfaceClass uint8_t }
|
||||||
|
{ bInterfaceSubClass uint8_t }
|
||||||
|
{ bInterfaceProtocol uint8_t }
|
||||||
|
{ iInterface uint8_t }
|
||||||
|
{ endpoint libusb_endpoint_descriptor* }
|
||||||
|
{ extra uchar* }
|
||||||
|
{ extra_length int } ;
|
||||||
|
|
||||||
|
STRUCT: libusb_interface
|
||||||
|
{ altsetting libusb_interface_descriptor* }
|
||||||
|
{ num_altsetting int } ;
|
||||||
|
|
||||||
|
STRUCT: libusb_config_descriptor
|
||||||
|
{ bLength uint8_t }
|
||||||
|
{ bDescriptorType uint8_t }
|
||||||
|
{ wTotalLength uint16_t }
|
||||||
|
{ bNumInterfaces uint8_t }
|
||||||
|
{ bConfigurationValue uint8_t }
|
||||||
|
{ iConfiguration uint8_t }
|
||||||
|
{ bmAttributes uint8_t }
|
||||||
|
{ MaxPower uint8_t }
|
||||||
|
{ interface libusb_interface* }
|
||||||
|
{ extra uchar* }
|
||||||
|
{ extra_length int } ;
|
||||||
|
|
||||||
|
STRUCT: libusb_control_setup
|
||||||
|
{ bmRequestType uint8_t }
|
||||||
|
{ bRequest uint8_t }
|
||||||
|
{ wValue uint16_t }
|
||||||
|
{ wIndex uint16_t }
|
||||||
|
{ wLength uint16_t } ;
|
||||||
|
|
||||||
|
: LIBUSB_CONTROL_SETUP_SIZE ( -- x ) libusb_control_setup heap-size ; inline
|
||||||
|
|
||||||
|
C-TYPE: libusb_context
|
||||||
|
C-TYPE: libusb_device
|
||||||
|
C-TYPE: libusb_device_handle
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_SUCCESS 0
|
||||||
|
CONSTANT: LIBUSB_ERROR_IO -1
|
||||||
|
CONSTANT: LIBUSB_ERROR_INVALID_PARAM -2
|
||||||
|
CONSTANT: LIBUSB_ERROR_ACCESS -3
|
||||||
|
CONSTANT: LIBUSB_ERROR_NO_DEVICE -4
|
||||||
|
CONSTANT: LIBUSB_ERROR_NOT_FOUND -5
|
||||||
|
CONSTANT: LIBUSB_ERROR_BUSY -6
|
||||||
|
CONSTANT: LIBUSB_ERROR_TIMEOUT -7
|
||||||
|
CONSTANT: LIBUSB_ERROR_OVERFLOW -8
|
||||||
|
CONSTANT: LIBUSB_ERROR_PIPE -9
|
||||||
|
CONSTANT: LIBUSB_ERROR_INTERRUPTED -10
|
||||||
|
CONSTANT: LIBUSB_ERROR_NO_MEM -11
|
||||||
|
CONSTANT: LIBUSB_ERROR_NOT_SUPPORTED -12
|
||||||
|
CONSTANT: LIBUSB_ERROR_OTHER -99
|
||||||
|
TYPEDEF: int libusb_error
|
||||||
|
|
||||||
|
C-ENUM:
|
||||||
|
LIBUSB_TRANSFER_COMPLETED
|
||||||
|
LIBUSB_TRANSFER_ERROR
|
||||||
|
LIBUSB_TRANSFER_TIMED_OUT
|
||||||
|
LIBUSB_TRANSFER_CANCELLED
|
||||||
|
LIBUSB_TRANSFER_STALL
|
||||||
|
LIBUSB_TRANSFER_NO_DEVICE
|
||||||
|
LIBUSB_TRANSFER_OVERFLOW ;
|
||||||
|
TYPEDEF: int libusb_transfer_status
|
||||||
|
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_SHORT_NOT_OK 1
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_FREE_BUFFER 2
|
||||||
|
CONSTANT: LIBUSB_TRANSFER_FREE_TRANSFER 4
|
||||||
|
TYPEDEF: int libusb_transfer_flags
|
||||||
|
|
||||||
|
STRUCT: libusb_iso_packet_descriptor
|
||||||
|
{ length uint }
|
||||||
|
{ actual_length uint }
|
||||||
|
{ status libusb_transfer_status } ;
|
||||||
|
SPECIALIZED-ARRAY: libusb_iso_packet_descriptor
|
||||||
|
|
||||||
|
C-TYPE: libusb_transfer
|
||||||
|
|
||||||
|
CALLBACK: void libusb_transfer_cb_fn ( libusb_transfer* transfer ) ;
|
||||||
|
|
||||||
|
STRUCT: libusb_transfer
|
||||||
|
{ dev_handle libusb_device_handle* }
|
||||||
|
{ flags uint8_t }
|
||||||
|
{ endpoint uchar }
|
||||||
|
{ type uchar }
|
||||||
|
{ timeout uint }
|
||||||
|
{ status libusb_transfer_status }
|
||||||
|
{ length int }
|
||||||
|
{ actual_length int }
|
||||||
|
{ callback libusb_transfer_cb_fn }
|
||||||
|
{ user_data void* }
|
||||||
|
{ buffer uchar* }
|
||||||
|
{ num_iso_packets int }
|
||||||
|
{ iso_packet_desc libusb_iso_packet_descriptor[0] } ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_init ( libusb_context** ctx ) ;
|
||||||
|
FUNCTION: void libusb_exit ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_set_debug ( libusb_context* ctx, int level ) ;
|
||||||
|
|
||||||
|
FUNCTION: ssize_t libusb_get_device_list ( libusb_context* ctx, libusb_device*** list ) ;
|
||||||
|
FUNCTION: void libusb_free_device_list ( libusb_device** list, int unref_devices ) ;
|
||||||
|
FUNCTION: libusb_device* libusb_ref_device ( libusb_device* dev ) ;
|
||||||
|
FUNCTION: void libusb_unref_device ( libusb_device* dev ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_get_configuration ( libusb_device_handle* dev, int* config ) ;
|
||||||
|
FUNCTION: int libusb_get_device_descriptor ( libusb_device* dev, libusb_device_descriptor* desc ) ;
|
||||||
|
FUNCTION: int libusb_get_active_config_descriptor ( libusb_device* dev, libusb_config_descriptor** config ) ;
|
||||||
|
FUNCTION: int libusb_get_config_descriptor ( libusb_device* dev, uint8_t config_index, libusb_config_descriptor** config ) ;
|
||||||
|
FUNCTION: int libusb_get_config_descriptor_by_value ( libusb_device* dev, uint8_t bConfigurationValue, libusb_config_descriptor** config ) ;
|
||||||
|
FUNCTION: void libusb_free_config_descriptor ( libusb_config_descriptor* config ) ;
|
||||||
|
FUNCTION: uint8_t libusb_get_bus_number ( libusb_device* dev ) ;
|
||||||
|
FUNCTION: uint8_t libusb_get_device_address ( libusb_device* dev ) ;
|
||||||
|
FUNCTION: int libusb_get_max_packet_size ( libusb_device* dev, uchar endpoint ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_open ( libusb_device* dev, libusb_device_handle** handle ) ;
|
||||||
|
FUNCTION: void libusb_close ( libusb_device_handle* dev_handle ) ;
|
||||||
|
FUNCTION: libusb_device* libusb_get_device ( libusb_device_handle* dev_handle ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_set_configuration ( libusb_device_handle* dev, int configuration ) ;
|
||||||
|
FUNCTION: int libusb_claim_interface ( libusb_device_handle* dev, int iface ) ;
|
||||||
|
FUNCTION: int libusb_release_interface ( libusb_device_handle* dev, int iface ) ;
|
||||||
|
|
||||||
|
FUNCTION: libusb_device_handle* libusb_open_device_with_vid_pid ( libusb_context* ctx, uint16_t vendor_id, uint16_t product_id ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_set_interface_alt_setting ( libusb_device_handle* dev, int interface_number, int alternate_setting ) ;
|
||||||
|
FUNCTION: int libusb_clear_halt ( libusb_device_handle* dev, uchar endpoint ) ;
|
||||||
|
FUNCTION: int libusb_reset_device ( libusb_device_handle* dev ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_kernel_driver_active ( libusb_device_handle* dev, int interface ) ;
|
||||||
|
FUNCTION: int libusb_detach_kernel_driver ( libusb_device_handle* dev, int interface ) ;
|
||||||
|
FUNCTION: int libusb_attach_kernel_driver ( libusb_device_handle* dev, int interface ) ;
|
||||||
|
|
||||||
|
: libusb_control_transfer_get_data ( transfer -- data )
|
||||||
|
buffer>> LIBUSB_CONTROL_SETUP_SIZE swap <displaced-alien> ; inline
|
||||||
|
|
||||||
|
: libusb_control_transfer_get_setup ( transfer -- setup )
|
||||||
|
buffer>> libusb_control_setup memory>struct ; inline
|
||||||
|
|
||||||
|
:: libusb_fill_control_setup ( buffer bmRequestType bRequest wValue wIndex wLength -- )
|
||||||
|
buffer libusb_control_setup memory>struct
|
||||||
|
bmRequestType >>bmRequestType
|
||||||
|
bRequest >>bRequest
|
||||||
|
wValue libusb_cpu_to_le16 >>wValue
|
||||||
|
wIndex libusb_cpu_to_le16 >>wIndex
|
||||||
|
wLength libusb_cpu_to_le16 >>wLength drop ; inline
|
||||||
|
|
||||||
|
FUNCTION: libusb_transfer* libusb_alloc_transfer ( int iso_packets ) ;
|
||||||
|
FUNCTION: int libusb_submit_transfer ( libusb_transfer* transfer ) ;
|
||||||
|
FUNCTION: int libusb_cancel_transfer ( libusb_transfer* transfer ) ;
|
||||||
|
FUNCTION: void libusb_free_transfer ( libusb_transfer* transfer ) ;
|
||||||
|
|
||||||
|
:: libusb_fill_control_transfer ( transfer dev_handle buffer callback user_data timeout -- )
|
||||||
|
transfer
|
||||||
|
dev_handle >>dev_handle
|
||||||
|
0 >>endpoint
|
||||||
|
LIBUSB_TRANSFER_TYPE_CONTROL >>type
|
||||||
|
timeout >>timeout
|
||||||
|
buffer >>buffer
|
||||||
|
user_data >>user_data
|
||||||
|
callback >>callback
|
||||||
|
|
||||||
|
buffer [
|
||||||
|
libusb_control_setup memory>struct wLength>> LIBUSB_CONTROL_SETUP_SIZE +
|
||||||
|
] [ 0 ] if* >>length drop ; inline
|
||||||
|
|
||||||
|
:: libusb_fill_bulk_transfer ( transfer dev_handle endpoint buffer length callback user_data timeout -- )
|
||||||
|
transfer
|
||||||
|
dev_handle >>dev_handle
|
||||||
|
endpoint >>endpoint
|
||||||
|
LIBUSB_TRANSFER_TYPE_BULK >>type
|
||||||
|
timeout >>timeout
|
||||||
|
buffer >>buffer
|
||||||
|
length >>length
|
||||||
|
user_data >>user_data
|
||||||
|
callback >>callback
|
||||||
|
drop ; inline
|
||||||
|
|
||||||
|
:: libusb_fill_interrupt_transfer ( transfer dev_handle endpoint buffer length callback user_data timeout -- )
|
||||||
|
transfer
|
||||||
|
dev_handle >>dev_handle
|
||||||
|
endpoint >>endpoint
|
||||||
|
LIBUSB_TRANSFER_TYPE_INTERRUPT >>type
|
||||||
|
timeout >>timeout
|
||||||
|
buffer >>buffer
|
||||||
|
length >>length
|
||||||
|
user_data >>user_data
|
||||||
|
callback >>callback
|
||||||
|
drop ; inline
|
||||||
|
|
||||||
|
:: libusb_fill_iso_transfer ( transfer dev_handle endpoint buffer length num_iso_packets callback user_data timeout -- )
|
||||||
|
transfer
|
||||||
|
dev_handle >>dev_handle
|
||||||
|
endpoint >>endpoint
|
||||||
|
LIBUSB_TRANSFER_TYPE_ISOCHRONOUS >>type
|
||||||
|
timeout >>timeout
|
||||||
|
buffer >>buffer
|
||||||
|
length >>length
|
||||||
|
num_iso_packets >>num_iso_packets
|
||||||
|
user_data >>user_data
|
||||||
|
callback >>callback
|
||||||
|
drop ; inline
|
||||||
|
|
||||||
|
: libusb_set_iso_packet_lengths ( transfer length -- )
|
||||||
|
[ [ iso_packet_desc>> >c-ptr ]
|
||||||
|
[ num_iso_packets>> ] bi
|
||||||
|
<direct-libusb_iso_packet_descriptor-array>
|
||||||
|
] dip [ >>length drop ] curry each ; inline
|
||||||
|
|
||||||
|
:: libusb_get_iso_packet_buffer ( transfer packet -- data )
|
||||||
|
packet transfer num_iso_packets>> >=
|
||||||
|
[ f ]
|
||||||
|
[
|
||||||
|
transfer
|
||||||
|
[ iso_packet_desc>> >c-ptr ]
|
||||||
|
[ num_iso_packets>> ] bi
|
||||||
|
<direct-libusb_iso_packet_descriptor-array> 0
|
||||||
|
[ length>> + ] reduce
|
||||||
|
transfer buffer>> <displaced-alien>
|
||||||
|
] if ;
|
||||||
|
|
||||||
|
:: libusb_get_iso_packet_buffer_simple ( transfer packet -- data )
|
||||||
|
packet transfer num_iso_packets>> >=
|
||||||
|
[ f ]
|
||||||
|
[
|
||||||
|
0 transfer
|
||||||
|
[ iso_packet_desc>> >c-ptr ]
|
||||||
|
[ num_iso_packets>> ] bi
|
||||||
|
<direct-libusb_iso_packet_descriptor-array> nth
|
||||||
|
length>> packet *
|
||||||
|
transfer buffer>> <displaced-alien>
|
||||||
|
] if ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_control_transfer ( libusb_device_handle* dev_handle,
|
||||||
|
uint8_t request_type, uint8_t request, uint16_t value, uint16_t index,
|
||||||
|
uchar* data, uint16_t length, uint timeout ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_bulk_transfer ( libusb_device_handle* dev_handle,
|
||||||
|
uchar endpoint, uchar* data, int length,
|
||||||
|
int* actual_length, uint timeout ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle,
|
||||||
|
uchar endpoint, uchar* data, int length,
|
||||||
|
int* actual_length, int timeout ) ;
|
||||||
|
|
||||||
|
:: libusb_get_descriptor ( dev desc_type desc_index data length -- int )
|
||||||
|
dev LIBUSB_ENDPOINT_IN LIBUSB_REQUEST_GET_DESCRIPTOR
|
||||||
|
desc_type 8 shift desc_index bitor 0 data
|
||||||
|
length 1000 libusb_control_transfer ; inline
|
||||||
|
|
||||||
|
:: libusb_get_string_descriptor ( dev desc_index langid data length -- int )
|
||||||
|
dev LIBUSB_ENDPOINT_IN LIBUSB_REQUEST_GET_DESCRIPTOR
|
||||||
|
LIBUSB_DT_STRING 8 shift desc_index bitor
|
||||||
|
langid data length 1000 libusb_control_transfer ; inline
|
||||||
|
|
||||||
|
FUNCTION: int libusb_get_string_descriptor_ascii ( libusb_device_handle* dev,
|
||||||
|
uint8_t index,
|
||||||
|
uchar* data,
|
||||||
|
int length ) ;
|
||||||
|
|
||||||
|
FUNCTION: int libusb_try_lock_events ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_lock_events ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_unlock_events ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: int libusb_event_handling_ok ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: int libusb_event_handler_active ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_lock_event_waiters ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_unlock_event_waiters ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: int libusb_wait_for_event ( libusb_context* ctx, timeval* tv ) ;
|
||||||
|
FUNCTION: int libusb_handle_events_timeout ( libusb_context* ctx, timeval* tv ) ;
|
||||||
|
FUNCTION: int libusb_handle_events ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: int libusb_handle_events_locked ( libusb_context* ctx, timeval* tv ) ;
|
||||||
|
FUNCTION: int libusb_get_next_timeout ( libusb_context* ctx, timeval* tv ) ;
|
||||||
|
|
||||||
|
STRUCT: libusb_pollfd
|
||||||
|
{ fd int }
|
||||||
|
{ events short } ;
|
||||||
|
|
||||||
|
CALLBACK: void libusb_pollfd_added_cb ( int fd, short events, void* user_data ) ;
|
||||||
|
CALLBACK: void libusb_pollfd_removed_cb ( int fd, void* user_data ) ;
|
||||||
|
|
||||||
|
FUNCTION: libusb_pollfd** libusb_get_pollfds ( libusb_context* ctx ) ;
|
||||||
|
FUNCTION: void libusb_set_pollfd_notifiers ( libusb_context* ctx,
|
||||||
|
libusb_pollfd_added_cb added_cb,
|
||||||
|
libusb_pollfd_removed_cb removed_cb,
|
||||||
|
void* user_data ) ;
|
|
@ -0,0 +1 @@
|
||||||
|
Bindings to libusb
|
|
@ -0,0 +1 @@
|
||||||
|
bindings
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -0,0 +1,44 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: help.markup help.syntax math ;
|
||||||
|
IN: math.splines
|
||||||
|
|
||||||
|
HELP: <bezier-curve>
|
||||||
|
{ $values
|
||||||
|
{ "control-points" "sequence of control points same dimension" }
|
||||||
|
{ "polynomials" "sequence of polynomials for each dimension" }
|
||||||
|
}
|
||||||
|
{ $description "Creates bezier curve polynomials for the given control points." } ;
|
||||||
|
|
||||||
|
HELP: <catmull-rom-spline>
|
||||||
|
{ $values
|
||||||
|
{ "points" "points on the spline" } { "m0" "initial tangent vector" } { "mn" "final tangent vector" }
|
||||||
|
{ "polynomials-sequence" "sequence of sequences of polynomials" }
|
||||||
|
}
|
||||||
|
{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points and generating tangents for C1 continuity." } ;
|
||||||
|
|
||||||
|
HELP: <cubic-hermite-curve>
|
||||||
|
{ $values
|
||||||
|
{ "p0" "start point" } { "m0" "start tangent" } { "p1" "end point" } { "m1" "end tangent" }
|
||||||
|
{ "polynomials" "sequence of polynomials" }
|
||||||
|
}
|
||||||
|
{ $description "Creates a sequence of polynomials (one per dimension) for the curve passing through " { $emphasis "p0" } " and " { $emphasis "p1" } "." } ;
|
||||||
|
|
||||||
|
HELP: <cubic-hermite-spline>
|
||||||
|
{ $values
|
||||||
|
{ "point-tangent-pairs" "sequence of point and tangent pairs" }
|
||||||
|
{ "polynomials-sequence" "sequence of sequences of polynomials" }
|
||||||
|
}
|
||||||
|
{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points with the given tangents." } ;
|
||||||
|
|
||||||
|
HELP: <kochanek-bartels-curve>
|
||||||
|
{ $values
|
||||||
|
{ "points" "points on the spline" } { "m0" "start tangent" } { "mn" "end tangent" } { "tension" number } { "bias" number } { "continuity" number }
|
||||||
|
{ "polynomials-sequence" "sequence of sequence of polynomials" }
|
||||||
|
}
|
||||||
|
{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points, generating tangents with the given tuning parameters." } ;
|
||||||
|
|
||||||
|
ARTICLE: "math.splines" "Common parametric curves."
|
||||||
|
"The curve creating functions create sequences of polynomials, one for each degree of the input points. The spline creating functions create sequences of these curve polynomial sequences. The " { $vocab-link "math.splines.viewer" } " vocabulary provides a gadget to evaluate the generated polynomials and view the results.";
|
||||||
|
|
||||||
|
ABOUT: "math.splines"
|
|
@ -0,0 +1,84 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: accessors combinators kernel locals math math.combinatorics
|
||||||
|
math.polynomials opengl.gl sequences ui.gadgets ui.gadgets.panes
|
||||||
|
ui.render arrays grouping math.vectors assocs
|
||||||
|
ui.gestures ;
|
||||||
|
IN: math.splines
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
:: bernstein-polynomial-ith ( n i -- p )
|
||||||
|
n i nCk { 0 1 } i p^ { 1 -1 } n i - p^ p* n*p ;
|
||||||
|
|
||||||
|
:: hermite-polynomial ( p0 m0 p1 m1 -- poly )
|
||||||
|
p0
|
||||||
|
m0
|
||||||
|
-3 p0 * -2 m0 * + 3 p1 * + m1 neg +
|
||||||
|
2 p0 * m0 + -2 p1 * + m1 +
|
||||||
|
4array ;
|
||||||
|
|
||||||
|
:: kochanek-bartels-coefficients ( tension bias continuity -- s1 d1 s2 d2 )
|
||||||
|
1 tension -
|
||||||
|
[
|
||||||
|
1 bias +
|
||||||
|
[ 1 continuity + * * 2 / ]
|
||||||
|
[ 1 continuity - * * 2 / ] 2bi
|
||||||
|
]
|
||||||
|
[
|
||||||
|
1 bias -
|
||||||
|
[ 1 continuity - * * 2 / ]
|
||||||
|
[ 1 continuity + * * 2 / ] 2bi
|
||||||
|
] bi ;
|
||||||
|
|
||||||
|
:: kochanek-bartels-tangents ( points m0 mn c1 c2 -- tangents )
|
||||||
|
points 3 clump [
|
||||||
|
first3 :> ( pi-1 pi pi+1 )
|
||||||
|
pi pi-1 v- c1 v*n
|
||||||
|
pi+1 pi v- c2 v*n v+
|
||||||
|
] map
|
||||||
|
m0 prefix
|
||||||
|
mn suffix ;
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
:: <bezier-curve> ( control-points -- polynomials )
|
||||||
|
control-points
|
||||||
|
[ length 1 - ]
|
||||||
|
[ first length [ { 0 } ] replicate ]
|
||||||
|
bi :> ( n acc )
|
||||||
|
|
||||||
|
control-points [| pt i |
|
||||||
|
n i bernstein-polynomial-ith :> poly
|
||||||
|
pt [| v j |
|
||||||
|
j acc [ v poly n*p p+ ] change-nth
|
||||||
|
] each-index
|
||||||
|
] each-index
|
||||||
|
acc ;
|
||||||
|
|
||||||
|
:: <cubic-hermite-curve> ( p0 m0 p1 m1 -- polynomials )
|
||||||
|
p0 length iota [
|
||||||
|
{
|
||||||
|
[ p0 nth ] [ m0 nth ]
|
||||||
|
[ p1 nth ] [ m1 nth ]
|
||||||
|
} cleave
|
||||||
|
hermite-polynomial
|
||||||
|
] map ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
: (cubic-hermite-spline) ( point-in-out-triplets -- polynomials-sequence )
|
||||||
|
2 clump [
|
||||||
|
first2 [ first2 ] [ [ first ] [ third ] bi ] bi* <cubic-hermite-curve>
|
||||||
|
] map ;
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: <cubic-hermite-spline> ( point-tangent-pairs -- polynomials-sequence )
|
||||||
|
2 clump [ first2 [ first2 ] bi@ <cubic-hermite-curve> ] map ;
|
||||||
|
|
||||||
|
:: <kochanek-bartels-curve> ( points m0 mn tension bias continuity -- polynomials-sequence )
|
||||||
|
tension bias continuity kochanek-bartels-coefficients :> ( s1 d1 s2 d2 )
|
||||||
|
points m0 mn
|
||||||
|
[ s1 s2 kochanek-bartels-tangents ]
|
||||||
|
[ d1 d2 kochanek-bartels-tangents ] 3bi :> ( in out )
|
||||||
|
points in out [ 3array ] 3map (cubic-hermite-spline) ;
|
||||||
|
|
||||||
|
: <catmull-rom-spline> ( points m0 mn -- polynomials-sequence )
|
||||||
|
0 0 0 <kochanek-bartels-curve> ;
|
|
@ -0,0 +1 @@
|
||||||
|
Common parametric curves
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -0,0 +1,49 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: locals math.splines math.splines.viewer arrays ;
|
||||||
|
IN: math.splines.testing
|
||||||
|
|
||||||
|
: test1 ( -- )
|
||||||
|
{
|
||||||
|
{ { 0 0 } { 0 200 } }
|
||||||
|
{ { 100 50 } { 0 -200 } }
|
||||||
|
{ { 300 300 } { 500 200 } }
|
||||||
|
{ { 400 400 } { 300 0 } }
|
||||||
|
} <cubic-hermite-spline> { 50 100 } 4 spline. ;
|
||||||
|
|
||||||
|
: test2 ( -- )
|
||||||
|
{
|
||||||
|
{ 50 50 }
|
||||||
|
{ 100 100 }
|
||||||
|
{ 300 200 }
|
||||||
|
{ 350 0 }
|
||||||
|
{ 400 400 }
|
||||||
|
} { 0 100 } { 100 0 } <catmull-rom-spline> { 100 50 } 50 spline. ;
|
||||||
|
|
||||||
|
:: test3 ( x y z -- )
|
||||||
|
{
|
||||||
|
{ 100 50 }
|
||||||
|
{ 200 350 }
|
||||||
|
{ 300 50 }
|
||||||
|
} { 0 100 } { 0 -100 } x y z <kochanek-bartels-curve> { 50 50 } 1000 spline. ;
|
||||||
|
|
||||||
|
: test4 ( -- )
|
||||||
|
{
|
||||||
|
{ 0 5 }
|
||||||
|
{ 0.5 3 }
|
||||||
|
{ 10 10 }
|
||||||
|
{ 12 4 }
|
||||||
|
{ 15 5 }
|
||||||
|
} <bezier-curve> 1array { 100 100 } 100 spline. ;
|
||||||
|
|
||||||
|
: test-splines ( -- )
|
||||||
|
test1 test2
|
||||||
|
1 0 0 test3
|
||||||
|
-1 0 0 test3
|
||||||
|
0 1 0 test3
|
||||||
|
0 -1 0 test3
|
||||||
|
0 0 1 test3
|
||||||
|
0 0 -1 test3
|
||||||
|
test4 ;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -0,0 +1,49 @@
|
||||||
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: accessors kernel locals math math.order math.polynomials
|
||||||
|
math.splines opengl.gl sequences ui.gadgets ui.gadgets.panes ui.render
|
||||||
|
arrays ;
|
||||||
|
IN: math.splines.viewer
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
: eval-polynomials ( polynomials-seq n -- xy-sequence )
|
||||||
|
[
|
||||||
|
[ 1 + iota ] keep [
|
||||||
|
/f swap [ polyval ] with map
|
||||||
|
] curry with map
|
||||||
|
] curry map concat ;
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
TUPLE: spline-gadget < gadget polynomials steps spline-dim ;
|
||||||
|
|
||||||
|
M: spline-gadget pref-dim* spline-dim>> ;
|
||||||
|
|
||||||
|
M:: spline-gadget draw-gadget* ( gadget -- )
|
||||||
|
0 0 0 glColor3f
|
||||||
|
|
||||||
|
gadget [ polynomials>> ] [ steps>> ] bi eval-polynomials :> pts
|
||||||
|
|
||||||
|
pts [ first ] [ max ] map-reduce :> x-max
|
||||||
|
pts [ first ] [ min ] map-reduce :> x-min
|
||||||
|
pts [ second ] [ max ] map-reduce :> y-max
|
||||||
|
pts [ second ] [ min ] map-reduce :> y-min
|
||||||
|
|
||||||
|
pts [
|
||||||
|
[ first x-min - x-max x-min - / gadget spline-dim>> first * ]
|
||||||
|
[ second y-min - y-max y-min - / gadget spline-dim>> second * ] bi 2array
|
||||||
|
] map :> pts
|
||||||
|
|
||||||
|
GL_LINE_STRIP glBegin
|
||||||
|
pts [
|
||||||
|
first2 neg gadget spline-dim>> second + glVertex2f
|
||||||
|
] each
|
||||||
|
glEnd ;
|
||||||
|
|
||||||
|
:: <spline-gadget> ( polynomials dim steps -- gadget )
|
||||||
|
spline-gadget new
|
||||||
|
dim >>spline-dim
|
||||||
|
polynomials >>polynomials
|
||||||
|
steps >>steps ;
|
||||||
|
|
||||||
|
: spline. ( curve dim steps -- )
|
||||||
|
<spline-gadget> gadget. ;
|
Loading…
Reference in New Issue