Kevin Vance - Reality is something walking heavily up your spine.

Entries | Archive | Friends | Friends' Friends | User Info

12:00 am

Reality is something walking heavily up your spine.

Monday, July 2nd, 2007
Previous Entry Share Next Entry
I'm still alive. And still coding. And I'll be staying an extra week to continue crossing stuff off the big TKDWC whiteboard.

I have to write about a very cool hack I did for work this weekend. We wanted some controller rumble in the game, which one should be able to add with a few DirectInput calls. But the game engine abstracts the input process enough that I can't access the DirectInput devices directly.

The solution: use a windows API hook to replace the DirectInput initialization function, and then replace a few values in the function pointer table that it returns. It's simply a matter of
  1. Making a copy of the pointer to each gamepad device when it's created, and
  2. Altering the flags to get an exclusive lock when the input device is acquired.
No modifications to the game engine are necessary. It calls the DirectInput functions, which appear to behave normally. Oh, and I found out about this API hook technique *accidentally* when I was google searching for something else. Good weekend :D
Link )Reply )