Code Monkey home page Code Monkey logo

lovr-mouse's Introduction

lovr-mouse

A mouse module for LÖVR.

Usage

Copy lovr-mouse.lua to your project and require it. I like to put it on the lovr global like this:

lovr.mouse = require 'lovr-mouse'

function lovr.update(dt)
  print(lovr.mouse.getPosition())
end

lovr-mouse can only run on systems where LÖVR uses both LuaJIT and GLFW. If your project needs to be compatible with Android or WebVR, you can optionally include lovr-keyboard with:

if type(jit) == 'table' and lovr.getOS() ~= 'Android' and lovr.getOS() ~= 'Web' then
	lovr.keyboard = require 'lovr-mouse'
end

API

  • mouse.getX() Returns the x position of the cursor.
  • mouse.getY() Returns the y position of the cursor.
  • mouse.getPosition() Returns the x and y position of the cursor.
  • mouse.setX(x) Sets the x position of the cursor.
  • mouse.getY(y) Sets the y position of the cursor.
  • mouse.setPosition(x, y) Sets the position of the cursor.
  • mouse.isDown(button, ...) Returns whether any of the specified buttons are currently pressed. Available buttons:
    • 1 the left mouse button.
    • 2 the right mouse button.
    • 3 the middle mouse button.
    • Other higher numbers may be supported for fancier mice.
  • mouse.setRelativeMode(enable) Sets or disables relative mode. In relative mode the cursor is hidden and it can move infinitely (you can use the dx and dy parameters of mousemoved to get the movement amounts).
  • mouse.getRelativeMode() Returns whether relative mode is currently enabled.
  • lovr.mousepressed(x, y, button) Called when a mouse button is pressed.
  • lovr.mousereleased(x, y, button) Called when a mouse button is released.
  • lovr.mousemoved(x, y, dx, dy) Called when the mouse is moved. The arguments represent the new cursor position as well as the delta from the previous position, in window coordinates.
  • lovr.wheelmoved(dx, dy) Called when the mouse is scrolled.

License

MIT

lovr-mouse's People

Contributors

bjornbytes avatar mcclure avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.