rhansby/leap-gamepad

Mac Mouse move

Closed this issue · 4 comments

Cool project guys.

I am working on something similar, and was wondering if you ever got mouse movement to work prober on a Mac? I seem to never be able to control in-game mouse movements with robotjs.

It could very well depend on how your game interacts with intercepting mouse events. When we started working on this the original idea was to get it working with Receiver (a game with hyper-realistic gun control actions which we think would have been cool to play with hand gestures) but we couldn't get the camera to move. IIRC Receiver would lock the mouse to the center of the screen and listen for mouse events relative to the current position (e.g. deltaX = 1, deltaY = -3) but robotjs would simply set the mouse's absolute position, which Receiver would then snap back to the center and nothing would move.

When we tried this with Counter Strike, it had no problems with the absolute mouse position moving and happily accepted the input. Given that we were doing this at a hackathon we simply changed our target game since we didn't have enough time to patch robotjs or implement our own OS interface layer.

What sort of games (or game engines) are you trying?

I've tried Portal, Minecraft and a few browser games so far. Currently I am thinking wheter I can move away from robotjs and find a way to simulate a HID driver, to get a true input.

Thanks for sharing your experience! If you have any suggestions on how to do DIY controllers for games (in software, not hacking hardware), then please let me know. I'd like to make some JS controllers that can simulate mouse, joystick etc..

Don't really have much experience in creating controller drivers myself, this project was my first interaction with that!

My advice would probably be to look into how to emulate a mouse/joystick driver itself since that would probably work in any game or environment, but if that scope is too large you can always look into creating a mod for a specific game.

As for emulating controllers with JS: you'll probably need to drop down to a level low enough to interop with the OS. If you're using node you can compile C++ components and call that from regular JS code (the windows version of this project does that!) or find a library that exposes a JS interface for you (we were originally trying to use NodObjC to dispatch mouse events on OS X, but we just couldn't get it working and robotjs seemed to work well enough for our use case).

Best of luck!

Thanks a lot!