Archive for July, 2013

ProMouse – Control your mouse position from Unity.

July 9 | 13

Continuing with my small utility scripts for Unity, I’m releasing ProMouse for Unity, its a set of libraries that lets you control the mouse position within Unity, as Input.mousePosition in the docs is read only. This package works seamlessly across Windows, OSX and linux operating systems.

In order to modify the mouse position I  exposed a simple and small API to move your mouse locally or globally in the Screen.

NOTE: All the global coordinates for this package are relative to the main screen.

For more detailed info on how to use this package, you can also check:

If you are still interested you can also get the package at:


The only class you should access when using this package is the ProMouse


The ProMouse.cs class is a singleton that you can call from anywhere in your
code and exposes the following functions:


// Sets the cursor position to (xPos, yPos) pixel coordinates relative to
// Unity's window.
// The bottom-left of the window/screen(in full screen mode)
// is at (0, 0). the top-right of the window/screen(in full screen mode)
// is at (Screen.width, Screen.height)
public void SetCursorPosition(int xPos, int yPos);

// Sets the cursor position to (xPos, yPos) pixel coordinates relative to
// the main display
// The bottom-left of the main display is at (0, 0) and the top-right of the main display
// is at (ProMouse.Instance.GetMainScreenSize().x, ProMouse.Instance.GetMainScreenSize().y)
// which is your current main display resolution.
public void SetGlobalCursorPosition(int xPos, int yPos);

// Returns the value of the global mouse position relative to the main
// display going from 0,0 on the bottom-left corner of your main display to
// (ProMouse.Instance.GetMainScreenSize().x, ProMouse.Instance.GetMainScreenSize().y)
// on the top-right corner of your main display.
public Vector2 GetGlobalMousePosition();

// Returns the value fo the local mouse position relative to Unity's
// window, this is the same as Input.mousePosition
public Vector2 GetLocalMousePosition();

// returns your main screen resolution, this is the same as calling
// (Screen.currentResolution.width, Screen.currentResolution.height)
public Vector2 GetMainScreenSize();


Example usage. 

In order to access any function of the ProMouse class you just need to type

“ProMouse.Instance.” + the name of the function you want to call.

In example for setting the mouse position at 0,0:

void Start() {

For checking all the functions of the ProMouse class working just refer to
the Example.cs class that comes with the project.


For Advanced users:

ProCursor.cs is a singleton class that creates a hidden GameObject to act as a way
to call a coroutine for moving our mouse as we need to wait one frame in
order to get the updated mouse position.

This coroutine is needed in order to update the mouse position and get the
correct values but you dont need to worry about that, you just need to call:

ProMouse.Instance.SetCursorPosition(pixels on x, pixels on y) or
ProMouse.Instance.SetGlobalCursorPosition(Pixels on x, pixels on y)

Depending on your needs.

In case you need to do an operation between when the mouse gets updated to
the new position after moving the mouse (which only takes one frame), there
is a flag that lets you know if there is an operation being performed on the
mouse and can be accesed like this:

(bool) ProMouse.Instance.MouseBusy; (read-only)

*** *** *** *** *** *** *** ***

The ProMouse package will work straight on any platform natively, but if you are
testing your projects in a virtual machine the mouse position gets internally
updated but you will not see your cursor moved; This is caused because the
virtual machine installs mouse drivers in order to seamlessly go from the
Host OS to the virtualized OS.

So basically what you need to do is to disable the mouse integration with the
virtual machine.

Here are some links you can check regarding vmware but they are not
assured to work: (VMware specific)

Maybe this will work on other virtual machines maybe not, if it
happens to work out of the box in other virtualizing software just share it
in the comments so people can know where it works.

Creating a self-containing Nginx executable.

July 3 | 13

So I was wondering how MAMP / XAMP made the self-contained executables work so I wanted to create my own self-contained binary of nginx and it turned to be quite easy to create it.

Download the sourcefiles from

Navigate to the downloaded source file and call the configure exec with this params:
$ ./configure --prefix="" --error-log-path=""

Then run:

If everything goes well until here, you are much pretty done. After the make command finishes an ‘objs’ file gets created, there is where our self contained nginx install will be.

Go to the objs file and do this:
1. Copy mime.types (that resides inside the conf folder) to the ‘objs’ folder.
2. Create a ‘logs’ folder inside the ‘objs’ folder.
3. Create an empty ‘error.log’ and ‘access.log’ files inside the ‘logs’ folder created on step 2.
4. Copy your nginx.conf inside the ‘objs’ folder. (you can find a conf file inside the ‘conf’ folder

And you are done!.

To start the engine just type this:

$: ./nginx -c nginx.conf

And to stop it:

$: ./nginx -c nginx.conf -s stop