2013-12-10 4 views
2

xbox 360 컨트롤러가 울리기 (진동)하기 시작하는 스크립트를 발견했지만 그 기능을 끌 수는 없습니다. 5 초 후에 럼블이 멈추도록 설정할 수 있습니까? 당신이 바로이 스크립트와 당신의 앞에 필요한 모든 것을 가지고 같은Xbox 360이 윙윙 거리며 진동합니까?

import ctypes 

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

xinput = ctypes.windll.xinput1_1 # 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 

# Now we're ready to call it. Set left motor to 100%, right motor to 50% 
# for controller 0 
vibration = XINPUT_VIBRATION(65535, 32768) 
XInputSetState(0, ctypes.byref(vibration)) 

# You can also create a helper function like this: 
def set_vibration(controller, left_motor, right_motor): 
    vibration = XINPUT_VIBRATION(int(left_motor * 65535), int(right_motor * 65535)) 
    XInputSetState(controller, ctypes.byref(vibration)) 

# ... and use it like so 
set_vibration(0, 0.5, 0.5,) 

감사

+2

'set_vibration (0, 0, 0)'을 시도해 보셨습니까? – Tyler

답변

1

는 것 같습니다. (에 전체) 1.0 (당신의 상황 0)

  • 컨트롤러 ID 0 (해제)에서 조정
  • 왼쪽 모터 진동 - 당신이 50로 설정있어 다음 set_vibration 도우미 기능은 3 개 입력 인수를 0.5
  • 오른쪽 모터 진동을 이용하여 % - 그래서을 설정 (또는 0 1.0)

는 5 초 동안 50 % 전력에서 진동과 같은 시도 :

import time 
set_vibration(0, 0.5, 0.5) 
time.sleep(5) 
set_vibration(0, 0, 0) 

이 스크립트를 검사 한 결과 뿐이며, 테스트를 거치지 않았습니다.

+0

안녕하세요, 고마워요. 지금은 더 복잡한 일이 될 것이라고 생각했습니다. 나는 지금 이벤트 트리거에 럼블 (이 스크립트)을 할당하려고합니다. 왼쪽 조이스틱이 xbox 360 컨트롤러에서 눌려지면 패드가이 스크립트를 재생하고 덜컹 거리는 소리를냅니다. – RKEONECS