Unix

C&C Gold on Linux, windowed mode: howto grab mouse to allow scrolling

ForceCore 2010. 10. 13. 22:15
Grabbing macro not needed anymore!
http://hifi.iki.fi/cnc-ddraw/
Use cnc-ddraw instead!

Wine's grab mouse is long broken (for YEARS!) and RTS games with edge scrolling seems unplayable for me. Especially, C&C gold has no other methods to scroll than the edge scrolling, which screws the game play. However, there is a walkaround.

First, we need to get mouse jail: http://www.linuxquestions.org/questions/linux-general-1/confine-mouse-movement-mouse-jail-729654/
For mouse jail to work, we need xdotool installed.

confine.sh (mouse jail script) : Just in case the link gets broken...


Here's the script to start C&C gold in windowed mode.
The idea is to place the game window to some exact position (150,120) and use this information to confine.sh to trap the cursor in the game area. We already "know" that the game has a resolution of 1024x768 (using nyergud's patch), hence we can trap the cursor with ZERO error.

#!/bin/bash
HERE=`pwd`

cd "$HOME/.wine/drive_c/Westwood/C&C95"
taskset 0x00000001 wine explorer /desktop=DAWN,1024x768 C\&C95.exe &
sleep 1

cd $HERE

WIDS=`xdotool search --name "DAWN - Wine"`
echo $WIDS
xdotool windowmove $WIDS 150 120
./confine.sh 150 120 `expr 150 + 1024 - 1` `expr 120 + 768 - 1`

Voila!
For me, it seems that I need taskset to stabilize the game: restrict the game to a single core.