赞 | 0 |
VIP | 13 |
好人卡 | 0 |
积分 | 129 |
经验 | 77844 |
最后登录 | 2024-11-14 |
在线时间 | 1046 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 12936
- 在线时间
- 1046 小时
- 注册时间
- 2007-12-15
- 帖子
- 188
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
手边找不到手柄来测试…………
理论上应该能用…………
以下是脚本:
- #============================================================================
- # ■ 全手柄脚本
- #----------------------------------------------------------------------------
- # By: 洛克人SZ
- # Date: 2008.06.05
- # Version 1
- #============================================================================
- module Joyall
- #==========================================================================
- # 以下是常量列表
- #--------------------------------------------------------------------------
- JOYSTICKID1 = 0
- JOYSTICKID2 = 1
- JOY_POVCENTERED = -1
- JOY_POVFORWARD = 0
- JOY_POVRIGHT = 9000
- JOY_POVLEFT = 27000
- JOY_RETURNX = 0x0001
- JOY_RETURNY = 0x0002
- JOY_RETURNZ = 0x0004
- JOY_RETURNR = 0x0008
- JOY_RETURNU = 0x0010
- JOY_RETURNV = 0x0020
- JOY_RETURNPOV = 0x0040
- JOY_RETURNBUTTONS = 0x0080
- JOY_RETURNRAWDATA = 0x0100
- JOY_RETURNPOVCTS = 0x0200
- JOY_RETURNCENTERED = 0x0400
- JOY_USEDEADZONE = 0x0800
- JOY_RETURNALL = (JOY_RETURNX + JOY_RETURNY + JOY_RETURNZ + JOY_RETURNR + JOY_RETURNU + JOY_RETURNV + JOY_RETURNPOV + JOY_RETURNBUTTONS)
- JOY_CAL_READALWAYS = 0x10000
- JOY_CAL_READRONLY = 0x2000000
- JOY_CAL_READ3 = 0x40000
- JOY_CAL_READ4 = 0x80000
- JOY_CAL_READXONLY = 0x100000
- JOY_CAL_READYONLY = 0x200000
- JOY_CAL_READ5 = 0x400000
- JOY_CAL_READ6 = 0x800000
- JOY_CAL_READZONLY = 0x1000000
- JOY_CAL_READUONLY = 0x4000000
- JOY_CAL_READVONLY = 0x8000000
-
- JB_1 = 0x0001
- JB_2 = 0x0002
- JB_3 = 0x0004
- JB_4 = 0x0008
- JB_5 = 0x0010
- JB_6 = 0x0020
- JB_7 = 0x0040
- JB_8 = 0x0080
- JB_9 = 0x0100
- JB_10 = 0x0200
- JB_11 = 0x0400
- JB_12 = 0x0800
- JB_13 = 0x1000
- JB_14 = 0x2000
- JB_15 = 0x4000
- JB_16 = 0x8000
- JB_17 = 0x10000
- JB_18 = 0x20000
- JB_19 = 0x40000
- JB_20 = 0x80000
- JB_21 = 0x100000
- JB_22 = 0x200000
- JB_23 = 0x400000
- JB_24 = 0x800000
- JB_25 = 0x1000000
- JB_26 = 0x2000000
- JB_27 = 0x4000000
- JB_28 = 0x8000000
- JB_29 = 0x10000000
- JB_30 = 0x20000000
- JB_31 = 0x40000000
- JB_32 = 0x80000000
- @R_Button_Hash = {}
- @R_Button_Repeat = {}
- #==========================================================================
- # 以下是 API 声明
- #--------------------------------------------------------------------------
- JoyGetPosEx = Win32API.new("winmm.dll", "joyGetPosEx", "lp", "l")
- JoySetCapture = Win32API.new("winmm.dll", "joySetCapture", "llll", "l")
- JoyReleaseCapture = Win32API.new("winmm.dll", "joyReleaseCapture", "l", "l")
- #==========================================================================
- module_function
- #==========================================================================
- # ANALOG 模式下对应方向键(x, y) (数字模式下对应方向键)
- #--------------------------------------------------------------------------
- def direction_a
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("LLLLLLLLLLLLL")
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("LLLLLLLLLLLLL")
- return myjoy[6], myjoy[7]
- end
- #==========================================================================
- # ANALOG 模式下对应左摇杆(x, y) (数字模式下对应方向键)
- #--------------------------------------------------------------------------
- def direction_b
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("LLLLLLLLLLLLL")
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("LLLLLLLLLLLLL")
- return myjoy[3], myjoy[2]
- end
- #==========================================================================
- # ANALOG 模式下对应右摇杆(x, y) (数字模式下对应方向键)
- #--------------------------------------------------------------------------
- def direction_c
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("LLLLLLLLLLLLL")
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("LLLLLLLLLLLLL")
- return myjoy[4], myjoy[5]
- end
- #==========================================================================
- # 按键判断a(按键)
- #--------------------------------------------------------------------------
- def press?(buttons)
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("l*")#("LLLLLLLLLLLLL")
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("l*")#("LLLLLLLLLLLLL")
- if myjoy[8] == buttons
- return true
- else
- return false
- end
- end
- #==========================================================================
- # 按键判断b(按键)
- #--------------------------------------------------------------------------
- def repeat?(buttons)
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("l*")#("LLLLLLLLLLLLL")
- #qqq = JoyGetPosEx.call(JOYSTICKID1, myjoy)
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("l*")#("LLLLLLLLLLLLL")
- if myjoy[8] == buttons
- if @R_Button_Repeat[buttons].nil?
- @R_Button_Repeat[buttons] = 0
- return true
- end
- @R_Button_Repeat[buttons] += 1
- else
- @R_Button_Repeat[buttons] = nil
- @R_Button_Hash[buttons] = 0
- end
- if !@R_Button_Repeat[buttons].nil? and @R_Button_Repeat[buttons] > 4
- @R_Button_Repeat[buttons] = 0
- return true
- else
- return false
- end
- end
- #==========================================================================
- # 按键判断c(按键)
- #--------------------------------------------------------------------------
- def trigger?(buttons)
- myjoy = [64,JOY_RETURNALL,0,0,0,0,0,0,0,0,0,0,0]
- myjoy = myjoy.pack("l*")#("L*")#("LLLLLLLLLLLLL")
- JoyGetPosEx.call(JOYSTICKID1, myjoy)
- myjoy = myjoy.unpack("l*")#("L*")#("LLLLLLLLLLLLL")
- if @R_Button_Hash[buttons] == 1 and myjoy[8] == buttons
- return false
- end
- if myjoy[8] == buttons
- @R_Button_Hash[buttons] = 1
- return true
- else
- @R_Button_Hash[buttons] = 0
- return false
- end
- end
- end
复制代码 |
|