]> gitweb.factorcode.org Git - factor.git/commitdiff
event fixes
authorSlava Pestov <slava@factorcode.org>
Thu, 21 Oct 2004 01:49:10 +0000 (01:49 +0000)
committerSlava Pestov <slava@factorcode.org>
Thu, 21 Oct 2004 01:49:10 +0000 (01:49 +0000)
library/platform/native/math.factor
library/sdl/sdl-event.factor
library/sdl/sdl-utils.factor
library/sdl/sdl-video.factor

index 48246fe19c65816425fc1fab5ebea0a69f5d60cc..b53c8e56e036a78eafc9dee3242f6f02961323bb 100644 (file)
@@ -60,6 +60,7 @@ USE: words
 : 2>rect ( x y -- x:re x:im y:re y:im ) >r >rect r> >rect ;
 
 : complex= ( x y -- ? ) 2>rect 2= ;
+
 : complex+ ( x y -- x+y ) 2>rect swapd + >r + r> rect> ;
 : complex- ( x y -- x-y ) 2>rect swapd - >r - r> rect> ;
 : complex*re ( x y -- zx:re * y:re x:im * r:im )
index 98fe9dfd62a02dba41f7174572eec1e108028338..9bbb7359c1f5710b9d1d52f883ba06a495b64de9 100644 (file)
@@ -89,6 +89,10 @@ BEGIN-STRUCT: keyboard-event
     FIELD: uchar type  ! SDL_KEYDOWN or SDL_KEYUP
     FIELD: uchar which ! The keyboard device index
     FIELD: uchar state ! SDL_PRESSED or SDL_RELEASED
+    ! YUCK!
+    FIELD: uchar pad
+    FIELD: uchar pad
+    FIELD: uchar pad
     ! Later: inline structs
     FIELD: uchar scancode
     FIELD: int sym
@@ -109,8 +113,8 @@ END-STRUCT
 BEGIN-STRUCT: button-event
        FIELD: uchar type    ! SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
        FIELD: uchar which   ! The mouse device index
-       FIELD: uchar button; ! The mouse button index
-       FIELD: uchar state;  ! SDL_PRESSED or SDL_RELEASED
+       FIELD: uchar button  ! The mouse button index
+       FIELD: uchar state   ! SDL_PRESSED or SDL_RELEASED
        FIELD: ushort x
     FIELD: ushort y      ! The X/Y coordinates of the mouse at press time
 END-STRUCT
index 3f48c7a49e2a0f8bae6857bede5f741b879ba3d3..b9844756d9919ae94f1427b58404896b738cae87 100644 (file)
@@ -11,6 +11,7 @@ USE: errors
 USE: combinators
 USE: lists
 USE: logic
+USE: prettyprint
 
 SYMBOL: surface
 SYMBOL: width
@@ -44,13 +45,13 @@ SYMBOL: height
         ] ifte SDL_Flip
     ] with-scope ;
 
-: event-loop ( event -- )
-    dup SDL_WaitEvent 1 = [
-        dup event-type SDL_QUIT = [
-            drop
-        ] [
-            event-loop
-        ] ifte
-    ] [
-        drop
-    ] ifte ;
+: event-loop ( event -- )
+    dup SDL_WaitEvent 1 = [
+        dup event-type SDL_QUIT = [
+            drop
+        ] [
+            event-loop
+        ] ifte
+    ] [
+        drop
+    ] ifte ;
index e2ba6c08475c83329b586566efe174974ae1f431..21de4e2b76682fc17a6ec530562f4a4e8aba0d9b 100644 (file)
@@ -83,6 +83,13 @@ BEGIN-STRUCT: format
     FIELD: uchar  alpha
 END-STRUCT
 
+BEGIN-STRUCT: rect
+    FIELD: short   clip-x
+    FIELD: short   clip-y
+    FIELD: ushort   clip-w
+    FIELD: ushort   clip-h
+END-STRUCT
+
 BEGIN-STRUCT: surface
     FIELD: uint    flags
     FIELD: format* format
@@ -94,8 +101,8 @@ BEGIN-STRUCT: surface
     FIELD: void*   hwdata
     FIELD: short   clip-x
     FIELD: short   clip-y
-    FIELD: short   clip-w
-    FIELD: short   clip-h
+    FIELD: ushort   clip-w
+    FIELD: ushort   clip-h
     FIELD: uint    unused1
     FIELD: uint    locked
     FIELD: int     map
@@ -144,6 +151,10 @@ END-STRUCT
 
 ! SDL_SetGamma: float types
 
+: SDL_FillRect ( surface rect color -- n )
+    "int" "sdl" "SDL_FillRect"
+    [ "surface*" "rect*" "unint" ] alien-call ;
+
 : SDL_LockSurface ( surface -- )
     "int" "sdl" "SDL_LockSurface" [ "surface*" ] alien-call ;