ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pygame-users
pygame-users
[pygame] Force feedback wrapper for Python
by Doug Holton other posts by this author
Jul 11 2003 10:21PM messages near this date
Re: [pygame] Where to next? | [pygame] Newbie - trouble with inheritance in pygame
Hi,
   Apparently some people at the university of North Carolina have 
created a force feedback wrapper for Python using SWIG.  I thought it 
would be of interest to the pygame users.  It wraps the Immersion 
foundation classes (IFC) from Immersion (Windows only).
Unfortunately Immersion recently started charging for their SDK.  But 
you may not need it though to create basic force feedback effects.

pyIFC library (still requires compiling with SWIG and IFC apparently):
http://www.cs.unc.edu/Research/assist/developer.shtml
working demos (try NCDemo):
http://sourceforge.net/projects/uncbats/
map you can open with BATS demo: (don't unzip) 
http://www.cs.unc.edu/Research/assist/bats/maps/nc%20railroads.zip
source for the demos and pyIFC:
http://cvs.sourceforge.net/cvstarballs/uncbats-cvsroot.tar.gz
http://cvs.sourceforge.net/cvstarballs/uncassist-cvsroot.tar.gz

And here are links to the Immersion and Microsoft DirectX SDKs and some 
force feedback tutorials:
http://edtechdev.org/blog/archives/000924.html

Rough code sample adapted from NCDemo, this won't work as is:

from wxPython.wx import *
from pyIFC import *
import win32api
class Frame(wxFrame):
    def __init__(self):
       hinst = win32api.GetModuleHandle(None)
       hwnd = self.GetHandle() # wxFrame window handle
       self.dev = CImmDevice_CreateDevice(hinst, hwnd)
       if self.dev != None:
          self.tact = pyImmProject()
          #This is an example of loading effects from an .ifr file
          #created with IStudio, but you can create effects directly too.
          if self.dev.GetDeviceType() == IMM_DEVICETYPE_DIRECTINPUT:
             self.tact.OpenFile("NCTextureJoy.ifr", self.dev)
    def playeffect(self)
       #play an effect from the .ifr file:
       self.tact.Stop()
       effect = ? # some effect in the .ifr file
       self.tact.Start(effect,IMM_EFFECT_DONT_CHANGE)

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved