mouse.l 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. (
  2. (def mouse (open "/mouse"))
  3. (def mouse-x 0)
  4. (def mouse-y 0)
  5. (def mouse-oldx 0)
  6. (def mouse-oldy 0)
  7. (def mouse-dx 0)
  8. (def mouse-dy 0)
  9. (def mouse-btn 0)
  10. (def mouse-dragging 0)
  11. (def mouse-func (fn (t task) dummy (do
  12. (blit-char16 fb unifont 32 mouse-x mouse-y)
  13. (let mouse-info (recv mouse))
  14. (def mouse-x (car (car mouse-info)))
  15. (def mouse-y (cdr (car mouse-info)))
  16. (def mouse-dx (- mouse-x mouse-oldx))
  17. (def mouse-dy (- mouse-y mouse-oldy))
  18. (def mouse-oldx (+ mouse-x 0))
  19. (def mouse-oldy (+ mouse-y 0))
  20. ;(def mouse-x (+ mouse-x mouse-dx))
  21. ;(def mouse-y (+ mouse-y mouse-dy))
  22. ;(if (lt mouse-x 0) (def mouse-x 0) 0)
  23. ;(if (lt mouse-y 0) (def mouse-y 0) 0)
  24. ;(if (gt mouse-x (- screen-width 1)) (def mouse-x (- screen-width 1)) 0)
  25. ;(if (gt mouse-y (- screen-height 1)) (def mouse-y (- screen-height 1)) 0)
  26. (def mouse-btn (cdr mouse-info))
  27. (def mouse-dragging mouse-btn)
  28. (if mouse-btn (blit-char16 fb unifont 0x219c mouse-x mouse-y)
  29. (blit-char16 fb unifont 0x2196 mouse-x mouse-y))
  30. )))
  31. )