Friday, October 24, 2008

Creative Computing – Week 10 – Semester 2, 2008: “Human Interface Device”

Another masterwork of Photoshop glory...

There was a relatively short space of time between plugging in the game controller, registering it in SC, and integrating the code into my week 6 patch (not my most exciting effort, but one suited to the exercise). Then an epic battle between man and machine ensued as I struggled to work out why the machine would not allow GUI manipulation code to be directly executed from the HIDDevice.action. The reason is due to priority being given to audio synthesis tasks it seems. If you’re going to insert code into your HID action that will update GUI objects with method calls like “slider1.valueAction(someValue)” for instance, then you must ‘wrap’ the code in a function and call .defer on the function like so:

{slider1.valueAction(someValue)}.defer;

This way the machine will do its audio synthesis thing, followed by updating any GUI elements that are involved. I guess this functionality is built into the GUI object classes themselves, negating the need to do the same when working with them directly.

Anyhow, I’ve finally succeeded in mapping the game controller to the four sliders in this patch. The 8 main buttons control slider one, giving obviously crude resolution. The 8-way directional pad does the same for the next one, and the analogue sticks do the next two with much sharper resolution of course.

Click here to link to online folder containing this week's code and a short MP3.


Reference:

Haines, Christian. “Creative Computing – Week 10 – Semester 2, 2008: Human Interface Device.”

Labels:

1 Comments:

At 6:46 AM, Blogger weimer said...

{slider1.valueAction(someValue)}.defer;

well said.

 

Post a Comment

<< Home