sdl_mouse.odin 2.3 KB

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