WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   XBOX 360 wireless controller vibration feedback (https://forum.worldviz.com/showthread.php?t=5143)

JB_HP_Viz 08-19-2014 02:30 PM

XBOX 360 wireless controller vibration feedback
 
In Vizard 5 is there a way to make the vibration feedback work on the XBOX 360 wireless controller. I checked in VizConnect and I don't see any way to control the vibration feedback. I also looked through the documentation and I see .hasForceFeedback() and .setForce(vector). When I print .hasForceFeedback() I get FALSE. But I used another program on my Windows 7 computer to test the vibration feedback on the left side and right side of the controller and it works fine.

Thank you

John

Kevin Chiu 08-25-2014 03:08 PM

Hi John,

Unfortunately, since Vizard accessing data from any DirectInput compatible gamepad and joystick device. Which also means that for the Xbox360 controller, it will need to have the force feedback function provided by DirectInput but currently it seems not.
The reason why you got the vibration feedback works on another program is that it is actually using XInput instead of DirectInput.
Here is some information for your reference.
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
So maybe a logitech rumblepad might be a better choice for you if you want a force feedback fuction that works with Vizard.

Best Regards,
Kevin

Kevin Chiu 08-26-2014 11:38 AM

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)


JB_HP_Viz 08-26-2014 11:45 AM

Thank you for the info. I will try out what you provided.

Since you mentioned Logitech, do you know if Logitech F710 Wireless Gamepad would work without needing to make the changes you mentioned for the XBox 360 Wireless controller?

thank you

John

Kevin Chiu 08-26-2014 12:31 PM

Seems positive though we don't have it to confirm at our end.
But according to their web page, it seems for having the rumble effect will just require a software installation when using DirectInput mode which they already provide at this page.
http://www.logitech.com/en-us/suppor...-f710?crid=411
Hope this still helps.

Best,
Kevin

JB_HP_Viz 08-27-2014 03:27 AM

Thank you for information and your help. I was able to get the code you provided working with my XBox 360 controller. very helpful.

Thank you

John


All times are GMT -7. The time now is 05:41 AM.

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