sdl_mouse.odin 2.4 KB

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