diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index a2afbe92a3..7543a05c60 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -93,5 +93,5 @@ M: mouse-state clone { { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } - { [ t ] [ ] } + { [ os linux? ] [ "game.input.linux" require ] } } cond diff --git a/basis/game/input/linux/authors.txt b/basis/game/input/linux/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/basis/game/input/linux/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor new file mode 100644 index 0000000000..465cefa84b --- /dev/null +++ b/basis/game/input/linux/linux.factor @@ -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 keyboard-state boa ; + +M: linux-game-input-backend read-mouse + 0 0 0 0 2 mouse-state boa ; + +M: linux-game-input-backend reset-mouse + ; diff --git a/basis/game/input/linux/summary.txt b/basis/game/input/linux/summary.txt new file mode 100644 index 0000000000..5c88274722 --- /dev/null +++ b/basis/game/input/linux/summary.txt @@ -0,0 +1 @@ +Linux backend for game input. diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/linux/tags.txt new file mode 100644 index 0000000000..84d4140a70 --- /dev/null +++ b/basis/game/input/linux/tags.txt @@ -0,0 +1 @@ +games diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 4c977f17a4..673dd8e9c3 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -1,14 +1,13 @@ ! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays ascii assocs colors -classes.struct combinators io.encodings.ascii -io.encodings.string io.encodings.utf8 kernel literals math -namespaces sequences strings ui ui.backend ui.clipboards -ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds -ui.gestures ui.pixel-formats ui.pixel-formats.private -ui.private x11 x11.clipboard x11.constants x11.events x11.glx -x11.io x11.windows x11.xim x11.xlib environment command-line -combinators.short-circuit ; +USING: accessors alien.c-types ascii assocs classes.struct combinators +combinators.short-circuit command-line environment io.encodings.ascii +io.encodings.string io.encodings.utf8 kernel literals locals math +namespaces sequences specialized-arrays.instances.alien.c-types.uchar +strings ui ui.backend ui.clipboards ui.event-loop ui.gadgets +ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats +ui.pixel-formats.private ui.private x11 x11.clipboard x11.constants +x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ; IN: ui.backend.x11 SINGLETON: x11-ui-backend @@ -328,6 +327,22 @@ M: x11-ui-backend (with-ui) ( quot -- ) M: x11-ui-backend beep ( -- ) dpy get 100 XBell drop ; +: black ( -- xcolor ) 0 0 0 0 0 0 XColor ; 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 [ "DISPLAY" os-env "ui.tools" "listener" ? ] diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index a6097c9dad..7235aaf679 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -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: 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 @@ -1096,6 +1101,7 @@ X-FUNCTION: int XGrabPointer ( X-FUNCTION: Status XUngrabPointer ( Display* display, 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: 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 XGetInputFocus ( Display* display, @@ -1210,6 +1216,14 @@ STRUCT: XVisualInfo { colormap_size 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 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!