WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-26-2014, 12:38 PM
Kevin Chiu Kevin Chiu is offline
WorldViz Team Member
 
Join Date: Feb 2012
Posts: 26
Hi John,

Here is a work around for having the vibration working in Vizard via the Python ctypes library.
Please be aware about the XInput versions which you have and change the line accordingly when loading the Xinput.dll.
For example, if the XInput versions is 9.1.0 then it will become
Code:
ctypes.windll.xinput9_1_0
Here is some information for your reference too.
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Hope this helps.

Best,
Kevin

Code:
import ctypes

# Define necessary structures
class XINPUT_VIBRATION(ctypes.Structure):
    _fields_ = [("wLeftMotorSpeed", ctypes.c_ushort),
                ("wRightMotorSpeed", ctypes.c_ushort)]

xinput = ctypes.windll.xinput1_4  # Load Xinput.dll

# Set up function argument types and return type
XInputSetState = xinput.XInputSetState
XInputSetState.argtypes = [ctypes.c_uint, ctypes.POINTER(XINPUT_VIBRATION)]
XInputSetState.restype = ctypes.c_uint

# The helper function with 3 input arguments:
#   controller id ( 0 for the first controller )
#   left motor vibration scaled from 0 (off) to 1.0 (full on)
#   right motor vibration (also 0 - 1.0)
def set_vibration(controller, left_motor, right_motor):
    vibration = XINPUT_VIBRATION(int(left_motor * 65535), int(right_motor * 65535))
    XInputSetState(controller, ctypes.byref(vibration))


## Example usage
import time
set_vibration(0, 0.5, 0.5)
time.sleep(1)
set_vibration(0, 0, 0)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XBOX One Wireless Controller JB_HP_Viz Vizard 1 07-08-2014 06:45 AM
Rumble on Xbox 360 controller on PC pcatalano Vizard 1 03-11-2012 05:36 PM
Wii Kama Wireless controller ??? djdesmangles Vizard 2 02-11-2009 06:58 PM


All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC