Sunday, February 22, 2009

libusb FTW!

After dealing with this library back and forth, having issues making it work properly, I managed to solve it at last. Thanks goes to a French guy named Clement, who helped me!

The HID driver Windows thinks is the best driver to use, is now disabled, and I use LibUSB-Win32 instead!

Now, the main issue about games receiving mouse events from the mouse used with the treadmill is solved. HID driver is disabled, and I speak with the mouse through libusb - which is the only application that will receive the events!

Typically, I will get some raw data like this:

8: 00 00 28 00 00 00 d8 ff
8: 00 00 1e 00 00 00 e2 ff
8: 00 00 2a 00 00 00 d6 ff
8: 00 00 1f 00 00 00 e1 ff
8: 00 00 2a 00 00 00 d6 ff
8: 00 00 22 00 00 00 de ff
8: 00 00 2b 00 00 00 d5 ff
8: 00 00 20 00 00 00 e0 ff
8: 00 00 28 00 00 00 d8 ff
8: 00 00 20 00 00 00 e0 ff
8: 00 ff 29 00 ff ff d7 ff
8: 00 00 24 00 00 00 dc ff
8: 00 00 28 00 00 00 d8 ff
8: 00 00 22 00 00 00 de ff
8: 00 00 27 00 00 00 d9 ff
8: 00 00 21 00 00 00 df ff
8: 00 00 27 00 00 00 d9 ff
8: 00 00 1d 00 00 00 e3 ff


And, if it goes slowly this is what I get:

8: 00 00 04 00 00 00 fc ff
8: 00 00 03 00 00 00 fd ff
8: 00 00 03 00 00 00 fd ff
8: 00 00 03 00 00 00 fd ff
8: 00 00 04 00 00 00 fc ff
8: 00 00 03 00 00 00 fd ff
8: 00 00 02 00 00 00 fe ff
8: 00 00 04 00 00 00 fc ff
8: 00 00 02 00 00 00 fe ff
8: 00 00 03 00 00 00 fd ff

I basically have two options from here:
  1. Try to send mouse events to GlovePIE (only), and use that normally.
  2. Send keystrokes from my application. This is the last resort, if I can't make above work. For basic simple keystrokes this is manageable from my application, but if I want to go crazy, it would be best to use GlovePIE, so that is why I will try to solve sending mouse events from my application to GlovePIE first.

Wednesday, February 18, 2009

After Some More Research...

Seems like I may solve the issue by doing a filter driver. This is really hardcore stuff.

OR

I want to give heads up to Phidgets! This may very well be a solution. Waiting for response to see if they may be able to help out with a hardware phidget which can help me out... If this can be solved with Phidgets, there are some other cool phidgets which can be used to trigger other things in the game...


Current issue is as follows:

Detailed (Technical)

The RegisterRawInputDevices function will only work on the thread that called it, aka, the application. With this I can identify which mouse send the event, but it will not intercept messages going to other processes (other threads) since each process (in user mode) thinks it's the only process running in the system. When the input focus is moved to a different application window, those WM_INPUT messages only go to that window. They don't propagate system-wide.

The only way to see mouse messages system-wide is to implement a LowLevelMouseProc and use the Windows Hooks functions (SetWindowsHookEx). But, in doing so, I also lose the ability to get the Raw Input data since raw isn't supported by the hook messages. And, with the Global Hooks, I'm not able to identify the mouse, which led me to using RawInput, which doesn't work globally, which...


In short

Microsoft sucks.

Thursday, February 12, 2009

Where it all began...

So, I thought... how to make this gaming thing more real, fun and at the same time - exercise? Or, how can I exercise and have fun at the same time? Really, I want to bring as realistic experience to gaming as possible and more than just pressing buttons and moving one arm. Not just PLAYING the game - Be IN the game.

A few months ago, I bought a USB bike, and been using it a lot. So, one can say this is the next step. Pun intended. :)

The main goal is to let my treadmill work with... say FPS games. So I can walk/run on the treadmill and that will move the character in the game. Then we'll see what could be next.

As you can see in the header image, I'm using a Saitek Pro Gamer Command Unit and under the treadmill, I have taped a Razer Deathadder mouse. I'm using this 1800 DPI mouse, since it really has to have high DPI to be able to catch the fast speed going when running on the treadmill. This has been tested, and works really well. I tried a mouse with less than 1000 DPI, and that one couldn't handle running speeds.

The Pro Gamer Command Unit is for all commands one can do in a game. So I can e.g. open doors... The mouse is connected to the computer and I was testing around with GlovePIE. Worked perfectly. This in front of my projected screen, it will surely feel like walking in the game. :)

However...

If it wasn't for games seemingly just grabbing input from every mouse connected to the computer, I would be all set by now. So, this will be the adventure of figuring out a way to make it work walking/running on the treadmill and let the character only walk/run in the game...

I welcome any help I can get!

Enjoy!