Tag Archives: Cursor Lock

Using Cursor Lock with Steam Games

See updated instructions for 2021.

I often notice people coming to my site from search queries asking how to use my program Cursor Lock. Of course, Cursor Lock comes with plenty of documentation for most users’ needs. I think most of those people are either noobs that can’t find the documentation, or they want Cursor Lock to do something it doesn’t actually do.

Anyways, there is one circumstance where I haven’t documented how to use Cursor Lock, mostly because I only just realized it myself. However, it can be rather tricky, so here’s how to lock games that must be launched with Steam. These instruction will work for the new version that just came out on April 26 and the previous version.

  1. Open Steam and go to your list of games.
  2. Right-click on the game in question and select “Create Desktop Shortcut”.
  3. Find the shortcut on the desktop and right-click to examine its “Properties”.
  4. For the new version of Steam, look at the “Web Document” tab and then the “URL” box. For the old version, look at the “Shortcut” tab and then the “Target” box. Copy the 5 digit number you see there.
  5. Open Cursor Lock Setup.
  6. Select “Open Program” and then find the path to the Steam executable, usually it will be something like C:\Program Files\Valve\Steam\Steam.exe
  7. Select “Open Program Args” and put in -applaunch xxxxx where xxxxx is the 5-digit number you copied earlier.
  8. Select “Lock Program” and then find the path to the game’s main executable–this would be what one would usually set as the “Open Program” when Steam isn’t involved. If you don’t know where it is, you should start looking under C:\Program Files\Valve\Steam\SteamApps\. You can also use Task Manager to help you find the executable name when the game is running.
  9. You’re done! Hit the “Create Shortcut” button to create a permanent shortcut to the game with Cursor Lock.
news300

Using Cursor Lock with Steam Games

Posted in Gaming | Tagged , | 51 Comments

SnakeByte Studios Endorses Obama-Biden

The election will surely be a landslide for the Democrats with this crucial endorsement!

But seriously, I’ve been behind Obama since the primaries. My decision is based on his keen intellect, technological prowess, and inspirational charisma (and you know, the fact that I’m a Democrat). I often wonder how anyone in my field can even support McCain, who can barely use a computer, versus the young, ambitious, and intellectual spirit of most programmers that is embodied in Barack Obama.

I normally wouldn’t discuss politics on my website and have continually shaken off the urge to do so recently, but the fast yet seemingly endless approach of the presidential election has gotten me so excited that I’ve turned into a political junkie over the past few months. Every morning, I scour the web for hot political news; every evening, I’m fixed to MSNBC’s line-up; and every waking hour, I’m watching for new poll data. It’s gotten so bad, that I’m starting to do programs and spreadsheets with election data.

Friday, I randomly decided to start crunching numbers on the differences in spread between the 2004 election and 2008 election predictions. I grabbed the predictions with a Regex on Pollster.com‘s fine poll trend data and the results from the Federal Election Commission for 2004 and mashed them together in Excel to get the spreads. Then, I got the crazy idea of seeing the data visually. So from there, I made a VB.Net script to take the data and decide what color to make a state (with the typical Blue equals more Democratic and Red equals more Republican) by adjusting hue, saturation, and luminance. Unfortunately, the linear hue equation made the map mostly purple, which didn’t convey the key point that the country is turning Democratic this cycle. So I switched to a logarithmic hue equation that would keep the purples towards the very center. For any interested, here’s the code I used to find the colors. (Where “x” is positive for more Democratic and negative for more Republican.)

Dim MaxDemHue As Integer = 147 'hue when input is MaxShift in the democratic direction
Dim MaxRepHue As Integer = 255 'hue when input is MaxShift in the republican direction
Dim MaxSat As Integer = 255 'saturation when input is MaxShift
Dim MinSat As Integer = 160 'saturation when input is 0
Dim MaxLum As Integer = 92 'luminance when input is MaxShift
Dim MinLum As Integer = 207 'luminance when input is 0
Dim CenterHue As Integer = ((MaxRepHue - MaxDemHue) / 2) + MaxDemHue 'hue when input is 0
Dim MaxShift As Integer = 40 'the max spread in either direction

Dim HueShift As Double = ((MaxShift * 0.262) * Math.Log(Math.Abs(x))) + 3.9138
If HueShift > 0 Then HueShift = 0 'possible that it could go negative with log
hsl.H = CenterHue - (Math.Sign(x) * HueShift)
hsl.S = ((Math.Abs(x) / MaxShift) * (MaxSat - MinSat)) + MinSat
hsl.L = ((Math.Abs(x) / MaxShift) * (MaxLum - MinLum)) + MinLum

Initially, I manually put the state colors into an image. This proved to be a bit time-consuming, so I moved to a vector art format called SVG that, because it’s merely XML, can be changed programmatically. With each state shape having a unique ID, I can just XPath to it in code and Regex change the color. Now the results.

Looking at the map, it seems quite clear that indeed the majority of the country is trending Democratic this year. Most of the states are 5 to 10% more for Obama than they were for Kerry. There are some notable exceptions, though. The northeastern states are surprisingly not much more Democratic (or even more Republican in the case of Massachusetts and Rhode Island); I’m guessing this is because they already turned out very strongly for Kerry last election. Similar to Mass. is Arizona, where McCain has the home-team advantage. That leaves Tennessee and Arkansas as the only other states not trending more Democratic, which may be explained by racial factors and population demographics.

Just for the hell of it, I also plugged the raw prediction data into my script to produce a map with a bit more information than the standard electoral ones you see floating around.

news273I’ve worked on the new version of Cursor Lock recently and a release is eminent (hope I didn’t say that last time I mentioned Cursor Lock). A new installer is already made and all the known bugs are fixed, so there’s just the matter of documentation left. If I can peel myself away from the polls, I’ll hopefully have the new release done before November 4th.

Posted in Programming | Tagged , , , | Leave a comment

The Monolithic Procrastination Post

Yes, I’m aware that I’m a bastard for not posting for a whole two months despite not having any work obligations. I was honestly going to post last month following the release of the new Cursor Lock version, but got sidetracked with other projects. The story of my life really–project ADD.

news270

Cursor Lock 2.5 alpha

However, for anyone yearning for a new version of Cursor Lock, I can assure you that I will finish it soon as it’s practically complete already (as the screenshot at right will show). I’ve already completed a majority of the testing and just have a few more issues to resolve and documentation to update. I’ve also found a game that puts the new features to use: DX-Ball 2. The new window locking mode works perfectly in the game’s windowed mode to keep the paddle’s responsiveness from drifting out of the window with the mouse.

Another project that I wanted to post about alongside Cursor Lock last month is my newest Age of Empires 3 mod, Banner Army Reforms. It’s a relatively simple tweak that makes a big difference to the manageability of the Chinese civilization. It allows the player to train units individually instead of in unique groupings (Banner Armies). While a key facet of the Chinese, Banner Armies were just a strategic annoyance to me. Too bad the Chinese still suck.

Last post, I mentioned a PHP script that used PEAR’s Text_Highlighter package, but which I had some concerns about and thus wasn’t ready to go live with. Since then, I’ve been racking my brains trying to come up with a way to securely show external source code files (that have been parsed with Text_Highlighter) embedded inside a formatted page. My second implementation idea was to use my inflatable wrapper technique that places a formatting script inside the target source code file; however, that would force me to make the source code files have .php extensions. I also considered a database of IDs and associated code files, which would be secure but also a hassle and it would obfuscate the underlying source code files.

After much googling and frustration, I finally found a way to make certain file extensions be passed to a handler script. This obscure Apache manual page shows how to add an action to extension handlers. If the target of the action is a script, it will receive the originally called file as some sort of CGI parameter; in PHP, it’s placed in the ENV variable $PHP_SELF (don’t use $PATH_INFO, it can be spoofed).

Once I had all that snazzy handler business figured out and implemented in the script, I noticed a glaring oversight in the Text_Highlighter package. Since they place all the source code in a <pre> tag, no word-wrapping is done. Quite frankly, I never care enough to bother with manually line-breaking code and just let it run off as far as I need. However, on a webpage, horizontal scrolling is a cardinal sin. So, I spent more time than I’d like to admit rewriting the output module of Text_Highlighter to put the source code in a table which would allow it to wrap effectively while preserving line numbering and line indentations. I ended up actually having to put the indentation whitespace in a cell by itself. The script still needs a bit more polish, but can be seen in action on the files in this parallel program directory.

Those source code files are actually part of a column I’ve been working on lately to show off the parallel program I wrote for my final college project. Besides having beautified code, the column is also to have a web-based version of the Powerpoint slideshow I gave during my results presentation. I had originally made a simple PHP script that took a page number as a parameter and showed the appropriate slide image with all the formatting and such. I had two problems with this, however: there was no ability to copy the slide’s text and it was a bit underwhelming in this Web 2.0-hyped world. So, on a whim, I decided to have a go at making a Flash movie with all the typical play controls as well as Fullscreen and Copy Text buttons, which could load in an external SWF file with one slide per frame. Of course, it has all sorts of delicious alpha effects, too. The parallel presentation slideshow isn’t quite live yet, but you can see the new Flash in action on the lovable old Tony the Worm column. It still needs a smidgen of work yet, though, such as tooltips. I find Flash a decidedly quirky and frustrating format; finishing one button is enough for celebration.

Posted in Modding, Programming, Website | Tagged , , | Leave a comment

A Full Month of Doings

I’ve been working on so much stuff lately that it’s hard to decide what to devote each day to. Of course, practically everyone I know doesn’t give a shit about the awesome stuff I do and rather I just jump into the rat race. But anyways, here’s an overview of what I’ve been working on…

Not long after my last post, I updated my mod for the Age of Empires 3 expansion The Asian Dynasties called Gatling Guns for All!. Previously, you could only use the mod with a specific unmodified version of TAD, but I wanted the mod to be usable by all versions of both The Asian Dynasties and The Warchiefs expansions even if they’ve been previously modded. Thus, I had to create an installer (similar to the one I did for Stalker) that would modify only the aspects of the game that I changed. Originally (as I did in the Stalker mod installer), I tried to use regular expressions to find the appropriate setting to change. However, being that the game data is stored as XML, Regex had problems matching certain XML formatting quirks. So, I moved to a query language that I’d never used before called XPath, which is basically XML hierarchy-aware Regex. Though getting some of the nodes in AOE3’s settings files to match was still tricky, XPath in .Net did the job perfectly.

When I went to package the new version of the mod, I actually found out that I had incorrectly archived an essential file in the wrong path in the first versions of the mod. Thus, nobody that downloaded it would have gotten the mod to work as intended :( . And only one person called me on it, though I thought he was a noob at first. But all has been rectified now.

Next, I started working on a script for this site that would color-code programming language syntax and elements so I can attach beautified code to some columns. The script uses a PEAR PHP library called Text_Highlighter to do the color-coding on the fly. However, at the moment, my part of the script still presents certain security risks that I will have to mitigate before it goes live.

news269

Lego Indiana Jones

That project was interrupted by a visit from Kaylen that turned into non-stop gaming in the form of Lego Indiana Jones 😉 . Although the game was littered with some annoying little bugs (having just been released), we did manage to get 100% completion. As most reviews have said, it wasn’t really as fun as Lego Star Wars–how can you beat lightsabers and the force? Though bazookas and bushes you can jump into come close.

The next week, following a concern from a user, I began working on a major new feature for Cursor Lock. Though not really having anything to do with multimonitor gaming, the feature is a natural progression of the existing code. It allows the user to select whether to lock the cursor into the current screen (what it did originally), the selected window, or the selected window interior (client area). Locking the cursor into the window interior is particularly useful for playing windowed 3D games. While I was at it, I decided to completely overhaul the setup GUI to be much more intuitive, separating the selection of the different modes with pretty, graphical buttons. It’s looking rather nice already and should only take a few more days of testing and fixing bugs until public release.

Last week, I got distracted when randomly deciding to replay Deus Ex: Invisible War and then subsequently desiring to mod out some of the major flaws in the game. Only a few changes would make the game much more palatable to the PC fanbase. One of the mod ideas I had was to combine the various proximity and thrown variants of grenades (EMP, scrambler, gas, and concussion), which would return the grenades to their vanilla Deus Ex functionality and give the player a lot more inventory space. So apparently, the developer of Deus Ex, Ion Storm, only decided to release the Thief: Deadly Shadows editor and not the Invisible War one, even though the games were made concurrently on the same engine (Unreal Warfare). I tried for days to get the Thief editor to work for Invisible War, but I don’t see it ever working out easily; there are far too many hardcoded elements of the games in both the editor and the game executables. The best I could do was to get the DX2 packages to load in the Thief editor after it had loaded the core Thief packages first. Then, I could get the DX2 packages to save after some simple modifications, but that made it so there were both Thief and DX2 classes mixed together, making a good number of DX2 objects break ingame (e.g. inventory, particle emitters). In other words: Epic Fail. 😕

However, while I was poking around in Invisible War’s resources, I found the plaintext files containing the secret area’s developer quotes. I decided it’d make a good contribution to my Deus Ex column, despite not being from vanilla Deus Ex. Then, whilst I was formatting the quotes for HTML, I got the crazy notion of using the game’s font for the text. Unfortunately, the font was not in a TrueType or comparable format, but rather it was merely a texture and an accompanying text file (DX2_FONT.cel) of comma-delimited texture character widths (in pixels) that were ordered corresponding to their ASCII value. The texture character height was understood to be 23 pixels, so that a width of -1 in the text file meant to go to the next row. Using a quickly thrown together program, I turned the width values into a Paint Shop Pro script (macro) that would cut out all the characters into individual bitmaps. Finally, I manually pasted them into a font editor to complete the conversion. The font can be downloaded here, and then can be tested on the aforementioned DX2 quotes page.

Posted in Modding, Programming, Website | Tagged , , , , | Leave a comment

A Special Happy, Fun-Time Holiday Post

As is customary for an after semester post, I will say how the semester was a bitch and report my grades. Well, it was a bitch, and I didn’t get anything below a C, so woot. The biggest bitch part was a recommendation report for an BS required English course; unfortunately, it was a group project and I chose a topic that my group was completely incapable of working on: parallel computing. Although a couple sections are missing, the paper is in a refined enough state that I’ve decided to post it here. I’m now a self-taught expert on parallelism, at least.

On my final exam day, CNET Download.com finally got around to approving my submission of Cursor Lock 2.0. It got a couple hundred downloads in the first few days alone, but has since slowed down to about 20 downloads a day. Of course, I never really expected it to be a hot, must-have app; it’s more of an awesome, there when you need it app.

For my next programming project, I’m looking into finally doing a Trillian log converter, which I first mentioned this time last year. Trillian’s native bastardized XML format does not scale well (the more you chat with someone, the longer it takes to access their log) and can only be read with the built-in log viewer. I think that any features which necessitated the use of a proprietary log format over HTML format are of questionable value. I’m sure I can replicate all of the most important features in simple, universal HTML format: bookmarks, search (via Google Desktop Search or something similar), calendar (from splitting into different files by date), and masking different message types (through some delicious CSS and JS). It has the added benefit of extensibility, too; I plan on giving all the page elements their own class, so users can change log formatting to suit their preferences.

news247

Duber the pet monkey from Siberia says hello.

I’ve only written a specification outline for the program so far. Mostly, I’ve just been relaxing to some gaming. The AOE3 expansion, Asian Dynasties, has renewed my interest in Age of Empires. I skipped the War Chief expansion because, frankly, I’m tired of fucking Indians. But the added map locations, high-level home city cards, and civs of Asian Dynasties is just what the game needed. Although China’s unit training differences are too odd for me to handle, Japan has really killer unit upgrade cards plus powerful units already that compliment my turtling style.

Of course, I had to play Portal and Half-Life 2: Episode 2 also. Portal was so fun that I finished it in one sitting 😕 –it was a truimph. Episode 2 was also pretty good; there are some really intense firefights and well-crafted environments. However, as with Fortress Forever, locking issues started creeping up again. Lowering the sound acceleration in dxdiag seemed to make some difference in the time it took to lock, but ultimately they were still completely random. Monitoring component temperatures showed that the CPU temperature was a little high (but still nowhere near the 140F I reached over summer), so I cleaned the HSF out again. That further decreased the frequency of locks, but alas the problem remained with Source Engine games. My latest hunch is that the CPU is just getting tired of the overclock of 100Mhz (2.15 to 2.25Ghz) I imposed years ago. So I’ve been lowering that by half with nVidia’s old nForce2 system utility before playing. So far, results have been promising.

As for games that don’t lock my system up, Kaylen and I finally reached 100% completion in both Lego Star Wars games during her recent visit. It’s clear that the second game is by far superior, but going back and playing the first game from the newer trilogy was still kickass lego fun. Next year: Lego Indiana Jones. Oh, hell yes.

news246

Lego Star Wars

news245

Stud fountain with 3840x score multiplier and Santa disguises.

Posted in Gaming | Tagged , , , , , | Leave a comment

Cursor Lock Optimizations

My recent major version of Multimon Cursor Lock was pretty CPU efficient, using around .15 to .3 seconds of CPU time after two minutes with a poll rate of 20ms. Still, I was noticing a large number of page faults while the program was polling–about 100 for each poll. Page faults occur when a needed “page” of memory is not currently in physical memory and thus needs to be loaded back in from the page file (swap space on a hard drive). Of course, page faults are not fatal, but they do lower performance.

Tonight, I finally decided to investigate the page faults and see if there was any fix. It was really as simple as watching Process Explorer’s process performance tab while stepping through the code. It didn’t take long until I found the culprits: CreateToolhelp32Snapshot() and Process32Next(). (I use these functions to enumerate the processes on a system. Of course, using EnumProcesses() would have been a better way, but that API function is only available on 2000/XP+ and I wanted to support as far back as 98.) Creating the snapshot requires at least 20 page faults, and looping through each process is a few more. Since I saw no memory actually being swapped, I figure the system module that contains this legacy function must be at fault (pun intended).

Seeing that my process enumeration code was causing 100 faults every time it ran (give or take, depending on how many processes are running), I came up with a simple optimization to cause it not to be needed as much. It was basically just to allow the program to remember the ID of the process it locked to last and check if its window still had focus on the next poll. Thus, while the program (typically a game) is locked, it doesn’t need to enumerate processes and creates no page faults. When I went to look at the performance for my optimized code, I actually had trouble seeing if it used any CPU at all. Apparently, the usage is so much smaller than the performance counter’s resolution, that after five minutes of locked polling, I couldn’t see any increase in CPU time usage. Because the usage is so immeasurably small, it was amusingly difficult to say how much the performance increased for the changelog.

Also, I’ve written a new column recently; it’s in the guides section, but it really doesn’t fit that category. I’d love to rearrange my column categories to include a software one, but unfortunately the URLs for columns are based on their category. Anyways, if you enjoyed this post, you’ll probably enjoy this column as well. It’s the same kind of reverse engineering goodness that gets us geeks all hot.

Posted in Programming | Tagged , | Leave a comment