Friday, October 17, 2014

Hack a USB game controller for browser reading

This is another example of a minor annoyance that snowballed into a time-consuming yet satisfying and elegant solution, all thanks to AutoHotkey (see Better Transcription... and Color Coding...).

I end up reading quite a lot of articles and documents in my web browser as I'm sure you do too. However, I find that I usually end up hunched over with my eyes too close to the screen. My index finger also gets tired from the repetitive scrolling on the mouse wheel. I thought to myself that it would be nice to just have a single button that I could press to scroll the page down while I sat back from the screen a bit. My mouse is wireless but it's awkward to hold it in my lap. I remembered that there are USB foot pedal peripherals that one can buy and program. But then the lightbulb went on!



In my backpack was a knockoff super nintendo USB controller (don't ask me why that was in my backpack, it just was). If I could use the gamepad controller to control my browser, I could sit back and read documents with ease.

A bit of research later, I came across this AutoHotkey script that helped me identify the parameters of the controller to use, such as button numbers. I then modified the script, and with the help of some other useful pages, like this one, I managed to achieve what I was looking for.


Because the default mouse speed was too fast to accurately click buttons on screen, I gave my Right Alt and Right Ctrl keys the function of decreasing and increasing, respectively, the mouse pointer speed. I don't really use those keys for anything else, and they don't execute any other commands when pressed solo, so I thought it made sense. The other thing I didn't show in the video was I mapped the X key to the browser's back button.

You can download the script here and make your own changes however you like.
It isn't totally refined or robust (might take some tweaking to make it work with your own controller), but in its current state, it works how I want it to. One thing I don't like is that pressing the right bumper once is essentially translated into pressing the down arrow key twice. I'd prefer a one-to-one translation for more control and to use with other applications (e.g. did you know using the arrow keys on a google search result page moves between search results?).

Again, the script download link is: http://goo.gl/zGawnD

Later,
Stuart

7 comments:

  1. These posts are totally awesome. Your writing makes me laugh. It seems the link to you script is broken??

    ReplyDelete
  2. The link should start the ahk file downloading, alternately try right click > save link as... keeping in mind you'll also have to have AutoHotkey installed to use it.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. On the Internet, I'm searching this types post and finally I found it from your blog...

    ReplyDelete