@@ -32,10 +32,12 @@ module SDL.Input.Mouse
3232
3333 -- * Cursor Shape
3434 , Cursor
35+ , SystemCursor (.. )
3536 , activeCursor
3637 , createCursor
3738 , freeCursor
3839 , createColorCursor
40+ , createSystemCursor
3941 ) where
4042
4143import Control.Monad (void )
@@ -159,6 +161,9 @@ data WarpMouseOrigin
159161 -- ^ Move the mouse pointer in global screen space.
160162 deriving (Data , Eq , Generic , Ord , Show , Typeable )
161163
164+
165+
166+
162167-- | Move the current location of a mouse pointer. The 'WarpMouseOrigin' specifies the origin for the given warp coordinates.
163168warpMouse :: MonadIO m => WarpMouseOrigin -> Point V2 CInt -> m ()
164169warpMouse (WarpInWindow (Window w)) (P (V2 x y)) = Raw. warpMouseInWindow w x y
@@ -209,6 +214,35 @@ getMouseButtons = liftIO $
209214newtype Cursor = Cursor { unwrapCursor :: Raw. Cursor }
210215 deriving (Eq , Typeable )
211216
217+ data SystemCursor
218+ = SystemCursorArrow
219+ | SystemCursorIBeam
220+ | SystemCursorWait
221+ | SystemCursorCrossHair
222+ | SystemCursorWaitArrow
223+ | SystemCursorSizeNWSE
224+ | SystemCursorSizeNESW
225+ | SystemCursorSizeWE
226+ | SystemCursorSizeNS
227+ | SystemCursorSizeAll
228+ | SystemCursorNo
229+ | SystemCursorHand
230+
231+
232+ instance ToNumber SystemCursor Word32 where
233+ toNumber SystemCursorArrow = Raw. SDL_SYSTEM_CURSOR_ARROW
234+ toNumber SystemCursorIBeam = Raw. SDL_SYSTEM_CURSOR_IBEAM
235+ toNumber SystemCursorWait = Raw. SDL_SYSTEM_CURSOR_WAIT
236+ toNumber SystemCursorCrossHair = Raw. SDL_SYSTEM_CURSOR_CROSSHAIR
237+ toNumber SystemCursorWaitArrow = Raw. SDL_SYSTEM_CURSOR_WAITARROW
238+ toNumber SystemCursorSizeNWSE = Raw. SDL_SYSTEM_CURSOR_SIZENWSE
239+ toNumber SystemCursorSizeNESW = Raw. SDL_SYSTEM_CURSOR_SIZENESW
240+ toNumber SystemCursorSizeWE = Raw. SDL_SYSTEM_CURSOR_SIZEWE
241+ toNumber SystemCursorSizeNS = Raw. SDL_SYSTEM_CURSOR_SIZENS
242+ toNumber SystemCursorSizeAll = Raw. SDL_SYSTEM_CURSOR_SIZEALL
243+ toNumber SystemCursorNo = Raw. SDL_SYSTEM_CURSOR_NO
244+ toNumber SystemCursorHand = Raw. SDL_SYSTEM_CURSOR_HAND
245+
212246-- | Get or set the currently active cursor. You can create new 'Cursor's with 'createCursor'.
213247--
214248-- This 'StateVar' can be modified using '$=' and the current value retrieved with 'get'.
@@ -241,7 +275,8 @@ createCursor dta msk (V2 w h) (P (V2 hx hy)) =
241275 V. unsafeWith (V. map (bool 0 1 ) msk) $ \ unsafeMsk ->
242276 Raw. createCursor unsafeDta unsafeMsk w h hx hy
243277
244- -- | Free a cursor created with 'createCursor' and 'createColorCusor'.
278+
279+ -- | Free a cursor created with 'createCursor', 'createColorCusor' and 'createSystemCursor'.
245280--
246281-- See @<https://wiki.libsdl.org/SDL_FreeCursor SDL_FreeCursor>@ for C documentation.
247282freeCursor :: MonadIO m => Cursor -> m ()
@@ -258,3 +293,12 @@ createColorCursor (Surface surfPtr _) (P (V2 hx hy)) =
258293 liftIO . fmap Cursor $
259294 throwIfNull " SDL.Input.Mouse.createColorCursor" " SDL_createColorCursor" $
260295 Raw. createColorCursor surfPtr hx hy
296+
297+ -- | Create system cursor.
298+ --
299+ -- See @<https://wiki.libsdl.org/SDL_CreateSystemCursor SDL_CreateSystemCursor>@ for C documentation.
300+ createSystemCursor :: MonadIO m => SystemCursor -> m Cursor
301+ createSystemCursor sc =
302+ liftIO . fmap Cursor $
303+ throwIfNull " SDL.Input.Mouse.createSystemCursor" " SDL_CreateSystemCursor" $
304+ Raw. createSystemCursor (toNumber sc)
0 commit comments