侠客英雄传3吧 关注:76贴子:211
  • 8回复贴,共1

游戏手柄游玩侠客英雄传

只看楼主收藏回复

俺的键盘方向键坏了一个,查找各种资料,终于抄袭来怎么用游戏手柄映射键盘按键,特把方法分享出来。使用AutoHotkey,脚本如下:
#Persistent ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
SetTimer, WatchPOV, 5
return
;------------------------------------------------------
;1-4 ABXY
;5 LB
;6 RB
;7 back
;8 start
;9 L3
;10 R3
;JoyX JoyY ×óÒ¡¸Ë
;JoyZ LT RT¹²ÓÃ
;JoyR JoyU ÓÒÒ¡¸Ë
;JoyPOV Ê®×Ö¼ü
;------------------------------------------------------
;1-4 ABXY
;------------------------------------------------------
Joy1::
Send {Esc down}
SetTimer, WaitForButtonUp1, 10
return
WaitForButtonUp1:
if GetKeyState("Joy1") ; The button is still, down, so keep waiting.
return
Send {Esc up}
SetTimer, WaitForButtonUp1, off
return
;------------------------------------------------------
Joy2::
Send {Enter down} ; Hold down the left mouse button.
SetTimer, WaitForButtonUp2, 10
return
WaitForButtonUp2:
if GetKeyState("Joy2") ; The button is still, down, so keep waiting.
return
Send {Enter up} ; Release the left mouse button.
SetTimer, WaitForButtonUp2, off
return
;------------------------------------------------------
Joy3::
Send {Space down} ; Hold down the left mouse button.
SetTimer, WaitForButtonUp3, 10
return
WaitForButtonUp3:
if GetKeyState("Joy3") ; The button is still, down, so keep waiting.
return
Send {Space up} ; Release the left mouse button.
SetTimer, WaitForButtonUp3, off
return
;------------------------------------------------------
;Ë«Ò¡¸Ë£¬LT£¬RT
;------------------------------------------------------
WatchAxis:
GetKeyState, JoyX, JoyX
GetKeyState, JoyY, JoyY
GetKeyState, JoyZ, JoyZ
GetKeyState, JoyR, JoyR
GetKeyState, JoyU, JoyU
GetKeyState, POV, JoyPOV
;-------------------×óÒ¡¸ËXY¶ÔÓ¦ºáÊú-------------------
if JoyX > 70
{
if Key_Right = 0
Send,{right Down}
Key_Right = 1
}
else if Key_Right
{
Send,{right Up}
Key_Right = 0
}
if JoyX < 30
{
if Key_Left = 0
Send,{left Down}
Key_Left = 1
}
else if Key_Left
{
Send,{left Up}
Key_Left = 0
}
;----------------------------------
if JoyY > 70
{
if Key_Down = 0
Send,{down Down}
Key_Down = 1
}
else if Key_Down
{
Send,{down Up}
Key_Down = 0
}
if JoyY < 30
{
if Key_Up = 0
Send,{up Down}
Key_Up = 1
}
else if Key_Up
{
Send,{up Up}
Key_Up = 0
}
;-----------------ÓÒÒ¡¸ËÒ¡¸ËRU¶ÔÓ¦ºáÊú-----------------
if JoyU > 70
{
if Key2_Right = 0
Send,{L Down}
Key2_Right = 1
}
else if Key2_Right
{
Send,{L Up}
Key2_Right = 0
}
if JoyU < 30
{
if Key2_Left = 0
Send,{J Down}
Key2_Left = 1
}
else if Key2_Left
{
Send,{J Up}
Key2_Left = 0
}
;----------------------------------
if JoyR > 70
{
if Key2_Down = 0
Send,{K Down}
Key2_Down = 1
}
else if Key2_Down
{
Send,{K Up}
Key2_Down = 0
}
if JoyR < 30
{
if Key2_Up = 0
Send,{I Down}
Key2_Up = 1
}
else if Key2_Up
{
Send,{I Up}
Key2_Up = 0
}
;-----------------LT RT ¼ü-----------------
if JoyZ > 70
{
if Key3_Right = 0
Send,{G Down}
Key3_Right = 1
}
else if Key3_Right
{
Send,{G Up}
Key3_Right = 0
}
if JoyZ < 30
{
if Key3_Left = 0
Send,{Q Down}
Key3_Left = 1
}
else if Key3_Left
{
Send,{Q Up}
Key3_Left = 0
}
;----------------------------------
return
;----------------------------------
;Ê®×Ö¼ü
;----------------------------------
WatchPOV:
GetKeyState, POV, JoyPOV ; Get position of the POV control.
KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if POV < 0 ; No angle to report
KeyToHoldDown =
else if POV > 31500 ; 315 to 360 degrees: Forward
KeyToHoldDown = Up
else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
KeyToHoldDown = Up
else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
KeyToHoldDown = Right
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
KeyToHoldDown = Down
else ; 225 to 315 degrees: Left
KeyToHoldDown = Left
if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
return ; Do nothing.
; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPrev% up} ; Release it.
if KeyToHoldDown ; There is a key to press down.
Send, {%KeyToHoldDown% down} ; Press it down.
return


IP属地:广东1楼2021-10-04 22:14回复
      你这太复杂了吧,直接用(JoyToKey_汉化版)这个软件,想怎么映射就怎么映射,可以把键盘上的任意键映射给手柄,还可以把鼠标左右键,滚轮,鼠标移动……等等都映射给手柄,并且所有映射的键还能勾选连发,以及连发速度。关键是,它的设置是图形化的,一看就懂。
      我玩侠客英雄传,金庸群侠传,仙剑奇侠传,个别手柄无法响应的模拟器……都是通过这款软件用手柄玩的。所以强力推荐大家试试看。


    IP属地:四川2楼2022-03-01 09:08
    收起回复
      都是大神啊,谢了脚本,支持一下


      IP属地:辽宁3楼2023-11-24 21:33
      回复
        厉害


        IP属地:山东4楼2024-08-16 22:59
        回复