sdl_mouse.odin 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == "windows" { foreign import lib "SDL2.lib" }
  4. when ODIN_OS == "linux" { foreign import lib "system:SDL2" }
  5. when ODIN_OS == "darwin" { foreign import lib "system:SDL2" }
  6. when ODIN_OS == "freebsd" { foreign import lib "system:SDL2" }
  7. Cursor :: struct {}
  8. BUTTON :: #force_inline proc "c" (X: c.int) -> c.int { return 1 << u32(X-1) }
  9. BUTTON_LEFT :: 1
  10. BUTTON_MIDDLE :: 2
  11. BUTTON_RIGHT :: 3
  12. BUTTON_X1 :: 4
  13. BUTTON_X2 :: 5
  14. BUTTON_LMASK :: 1<<(BUTTON_LEFT-1)
  15. BUTTON_MMASK :: 1<<(BUTTON_MIDDLE-1)
  16. BUTTON_RMASK :: 1<<(BUTTON_RIGHT-1)
  17. BUTTON_X1MASK :: 1<<(BUTTON_X1-1)
  18. BUTTON_X2MASK :: 1<<(BUTTON_X2-1)
  19. SystemCursor :: enum c.int {
  20. ARROW, /**< Arrow */
  21. IBEAM, /**< I-beam */
  22. WAIT, /**< Wait */
  23. CROSSHAIR, /**< Crosshair */
  24. WAITARROW, /**< Small wait cursor (or Wait if not available) */
  25. SIZENWSE, /**< Double arrow pointing northwest and southeast */
  26. SIZENESW, /**< Double arrow pointing northeast and southwest */
  27. SIZEWE, /**< Double arrow pointing west and east */
  28. SIZENS, /**< Double arrow pointing north and south */
  29. SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */
  30. NO, /**< Slashed circle or crossbones */
  31. HAND, /**< Hand */
  32. NUM_SYSTEM_CURSORS,
  33. }
  34. SDL_MouseWheelDirection :: enum c.int {
  35. NORMAL, /**< The scroll direction is normal */
  36. FLIPPED, /**< The scroll direction is flipped / natural */
  37. }
  38. @(default_calling_convention="c", link_prefix="SDL_")
  39. foreign lib {
  40. GetMouseFocus :: proc() -> ^Window ---
  41. GetMouseState :: proc(x, y: ^c.int) -> u32 ---
  42. GetGlobalMouseState :: proc(x, y: ^c.int) -> u32 ---
  43. GetRelativeMouseState :: proc(x, y: ^c.int) -> u32 ---
  44. WarpMouseInWindow :: proc(window: ^Window, x, y: c.int) ---
  45. WarpMouseGlobal :: proc(x, y: c.int) -> c.int ---
  46. SetRelativeMouseMode :: proc(enabled: bool) -> c.int ---
  47. CaptureMouse :: proc(enabled: bool) -> c.int ---
  48. GetRelativeMouseMode :: proc() -> bool ---
  49. CreateCursor :: proc(data: [^]u8, mask: [^]u8, w, h, hot_x, hot_y: c.int) -> ^Cursor ---
  50. CreateColorCursor :: proc(surface: ^Surface, hot_x, hot_y: c.int) -> ^Cursor ---
  51. CreateSystemCursor :: proc(id: SystemCursor) -> ^Cursor ---
  52. SetCursor :: proc(cursor: ^Cursor) ---
  53. GetCursor :: proc() -> ^Cursor ---
  54. GetDefaultCursor :: proc() -> ^Cursor ---
  55. FreeCursor :: proc(cursor: ^Cursor) ---
  56. ShowCursor :: proc(toggle: c.int) -> c.int ---
  57. }