Connect Wireless XBox 360 Controller(s) to your Windows PC

To further my quest to get 4 player Castle Crashers up and running on my computer, I needed to make use of both my PS3 and XBox 360 controllers. (Here's the guide to get the PS3 controller working on PC via USB cable or bluetooth)

Rather than using a standard bluetooth dongle, the Xbox 360 controller requires the purchase of a "XBox 360 Wireless Gaming Receiver For Windows" which allows you to connect up to 4 control pads.

The great thing about this is they don't have to cost much if you're ok with getting a cheap knockoff.

Hardware Requirements

  • A USB wireless controller receiver (I got mine for $8 delivered from eBay)
  • A wireless XBox 360 controller from (You can get replicas for cheaper, but legit ones feel better)

The link seems to have died, so here are some alternatives:

Software Requirements


  • First of all, install the drivers. This ensures you've got everything in place ready to go.
  • Then plug in the wireless receiver into a USB port.


  • If Windows automatically detects the drivers for it and gives you the thumbs up then you're good to go!


  • If not, you'll have to manually select the drivers. Don't fret, it's not that hard.
  • Open up the Control Panel
  • Click on Device Manager
  • Expand "Other devices" and right click on "Unknown device"
  • Select "Update driver software"
  • Click "Browse my computer for driver software (advanced)"


  • Select "Let me pick from a list of device drivers on my computer"
  • Select "Microsoft Common Controller for Windows Class" and click Next
  • Select "Xbox 360 Wireless Receiver for Windows" and click Next
  • Click Yes when prompted to confirm
  • It should now be successful.

Pairing the wireless controller with Windows

Surprisingly, this didn't work for me straight off. Not because of hardware or software but because of batteries. Yep, apparently if the batteries are weak it won't pair. The only way you can really know is to try it.

  • First you need to turn on the controller. Hold the big X button in the middle until it flashes


  • Then press the sync button on the receiver.


  • Lastly, press the sync button on the controller


  • After a few seconds it'll connect and stop flashing


An easy way of testing the controller is to just run Steam on Big Picture Mode. If you can navigate the menu using the controller then you're onto a winner!

Yep, it's really working. Try not to look so surprised!


Varnish: Enabling wildcard purging of cache content

Varnish is great for load balancing and reducing load on your servers by caching content, but at the same time it's an absolute pain in the ass to clear the cache for multiple things at once. Fortunately, Varnish 3.0 makes it much easier to do mass purging.

Setup in Varnish 2.x

In 2.x syntax, we'd open up the VCL file and do something like:

sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge_acl) {
error 405 "Not allowed";


# Which also requires
sub vcl_hit {
# Clear the cache if a PURGE has been requested
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";

Setup in Varnish 3.x

In 3.x syntax, purge() and purge_url() has been replaced by ban() and ban_url(). Contrary to the name, it doesn't ban a request but rather refresh it.

sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge_acl) {
error 405 "Not allowed";

ban(" == " + + " && req.url ~ " + req.url + "$");
error 200 "Purged.";

Requesting a PURGE

To clear the URL, we simply make a call using curl.

To clear a specific URL:

curl -X PURGE

To clear any urls which match this pattern:

curl -X PURGE*

Main differences

No more logic in vcl_hit() ! All your cache invalidation is done in the one place.

Another subtle difference is that purge() will clear the contents from memory, opening up your server to the thundering herd problem while ban() simply invalidates it and refreshes it when ready.

One last benefit of going to Varnish 3.0 is the support for GZip on ESI pages!

All great changes in my opinion!


Awww yeahhhhh~!


Django: Adding images to RSS feed items

It was a bit tricky trying to find information on how to do this and StackOverflow seemed to be giving advice of all sorts except for code that actually worked.

StackOverflow in a nutshell. Sometimes it feels like people are just answering for the upvotes and not to actually answer the question...

Below is a working sample which uses Django's syndication framework the way it's meant to be used but also checks out nicely with any well known validator.

We create a class called MediaRssFeed which subclasses a built-in feed generator called Rss201rev2Feed.

MediaRssFeed allows us to declare the namespaces required for the thumbnail markup to be valid, but also allows us to insert additional elements into the item as it is rendered.

In our LatestNewsFeed class, we simply replace feed_type with MediaRssFeed and add a new function item_extra_kwargs() which returns information for the feed generator to use.

from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Rss201rev2Feed

class MediaRssFeed(Rss201rev2Feed):
Implement thumbnails which adhere to Yahoo Media RSS (mrss) feed.

def rss_attributes(self):
attrs = super(MediaRssFeed, self).rss_attributes()
attrs['xmlns:dc'] = ""
attrs['xmlns:media'] = ''
return attrs

def add_item_elements(self, handler, item):
Callback to add thumbnail element to each item (item/entry) element.
super(MediaRssFeed, self).add_item_elements(handler, item)

thumbnail = { 'url': item['thumbnail_url'] }

if 'thumbnail_width' in item:
thumbnail['width'] = str(item['thumbnail_width'])

if 'thumbnail_height' in item:
thumbnail['height'] = str(item['thumbnail_height'])

handler.addQuickElement(u"media:thumbnail", '', thumbnail)

class LatestNewsFeed(Feed):
feed_type = MediaRssFeed

def item_extra_kwargs(self, article):
Return a dictionary to the feedgenerator for each item to be added to the feed.
If the object is a Gallery, uses a random sample image for use as the feed Item
image = article.get_main_image()

item = {
'thumbnail_url': generate_image_url(image, 300, 150, absolute = True),

# Optional
'thumbnail_width': 300,
'thumbnail_height': 150,

return item

# The rest of your feed class here as usual


How to use your PS3 Controller (DS3 / Dual Shock 3) on a Windows 7 x64 PC

For the longest time I've been looking for a way to use my PS3 controller on PC for Castle Crashers so I could get the 4th player in on the action, but most of the time the instructions were to use MotionInJoy (which is a complete piece of steaming shit). (Here's the guide to get a wireless XBox 360 controller working on PC)

Eventually I stumbled upon something by Scarlet.Crush on the PCSX2 forums called "XInput Wrapper for DS3 and USB Dual DS2 Controller", or better known as "SCP DS3" which lets you do just that.

This post covers the PS3 controller information, but the steps are the same for the PS4 controller (Dual Shock 4)

How it works

Scarlet.Crush wrote drivers for the Dual Shock pads and interfaced them with the XInput API, which allows games or programs to interact with the XBox Controller.

No more arcane hacks to get it working. If anything, this is actually pretty clever.

Hardware Requirement

  • PS3 or PS4 controller
  • USB cable
  • (optional) One USB bluetooth dongle / adapter for up to 4 controllers if you want wireless connectivity

(The dongle I bought also works for Wii remotes)

Software Requirements


  • Install .NET 4 package (if necessary)
  • Install the XBox 360 controller driver package (Windows XP/Vista users should install this AFTER installing the SCP drivers)
  • Restart if asked to.
  • Important: Connect your bluetooth dongle and let Windows do it's thing.
  • Important: Connect your PS3/PS4 controller and let Windows install the default drivers.
  • Extract the contents of "ScpServer\bin" from "SCP-DS-Driver-Package-" to where you want to put it. Personally I put it into "C:\Games\Utils\SCP-DS3\"
  • Run "ScpDriver.exe"



  • Click "Install" to install the SCP driver, bluetooth driver and SCP service (maps controller input to XInput).
  • Once it's done, you can exit.

Testing it

  • Run "ScpServer.exe" to take a look at how things are running.
  • Your controller should automatically pair (check for 1 LED lit up instead of 4 flashing lights)
  • Go to "Devices & Printers" in your control panel and you should see a "PLAYSTATION(R)3 Controller" AND an "Xbox 360 Controller for Windows".
  • Right click the Xbox controller icon and select "Game Controller Settings" > Properties.
  • From there you can try out all the buttons



  • Unplug it from USB to check if bluetooth is working. It should stay paired with the computer but remove the DS3 controller icon.

If bluetooth is not working


If this happens...

  • Unplug everything
  • Start up "ScpDriver.exe"
  • Click uninstall
  • And start again. Except this time, select "Force install" when installing the drivers with "ScpDriver.exe".

This happened because my USB Bluetooth dongle wasn't on the supported list, but forcing the install MAY work for you. <insert usual "your milage may vary" disclaimer here>


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog