From 0ffbe6ca7eb68e78eac417e3ebdc8458cbb6d7fa Mon Sep 17 00:00:00 2001 From: Ragnar-F <1332321+Ragnar-F@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:00:40 +0200 Subject: [PATCH] Remove obsolete files --- target/docs/misc/RemapJoystick.htm | 208 -------------------------- target/docs/scripts/JoystickMouse.ahk | 162 -------------------- target/docs/scripts/JoystickTest.ahk | 77 ---------- 3 files changed, 447 deletions(-) delete mode 100644 target/docs/misc/RemapJoystick.htm delete mode 100644 target/docs/scripts/JoystickMouse.ahk delete mode 100644 target/docs/scripts/JoystickTest.ahk diff --git a/target/docs/misc/RemapJoystick.htm b/target/docs/misc/RemapJoystick.htm deleted file mode 100644 index de8e8de19..000000000 --- a/target/docs/misc/RemapJoystick.htm +++ /dev/null @@ -1,208 +0,0 @@ - - - -Remapping a Joystick to Keyboard or Mouse | AutoHotkey v2 - - - - - - - - - -

Remapping a Joystick to Keyboard or Mouse

- -

目次

- - -

Important Notes

- - -

Making a Joystick Button Send Keystrokes or Mouse Clicks

- -

Different Approaches

-

Below are three approaches, starting at the simplest and ending with the most complex. The most complex method works in the broadest variety of circumstances (such as games that require a key or mouse button to be held down).

- -

Method #1

-

This method sends simple keystrokes and mouse clicks. 事例:

-
Joy1::Send "{Left}"  ; Have button #1 send a left-arrow keystroke.
-Joy2::Click  ; Have button #2 send a click of left mouse button.
-Joy3::Send "a{Esc}{Space}{Enter}"  ; Have button #3 send the letter "a" followed by Escape, Space, and Enter.
-Joy4::Send "Sincerely,{Enter}John Smith"  ; Have button #4 send a two-line signature.
-

To have a button perform more than one function, put the first function beneath the button name and make the last line a return. 事例:

-
Joy5::
-{
-    Run "notepad"
-    WinWait "無題-メモ帳"
-    WinActivate
-    Send "This is the text that will appear in Notepad.{Enter}"
-}
-

See the Key List for the complete list of keys and mouse/joystick buttons.

- -

Method #2

-

This method is necessary in cases where a key or mouse button must be held down for the entire time that you're holding down a joystick button. The following example makes the joystick's second button become the left-arrow key:

-
Joy2::
-{
-    Send "{Left down}"  ; Hold down the left-arrow key.
-    KeyWait "Joy2"  ; Wait for the user to release the joystick button.
-    Send "{Left up}"  ; Release the left-arrow key.
-}
- -

Method #3

-

This method is necessary in cases where you have more than one joystick hotkey of the type described in Method #2, and you sometimes press and release such hotkeys simultaneously. The following example makes the joystick's third button become the left mouse button:

-
Joy3::
-{
-    Send "{LButton down}"   ; Hold down the left mouse button.
-    SetTimer WaitForButtonUp3, 10
-}
-
-WaitForButtonUp3()
-{
-    if GetKeyState("Joy3")  ; The button is still, down, so keep waiting.
-        return
-    ; Otherwise, the button has been released.
-    Send "{LButton up}"  ; Release the left mouse button.
-    SetTimer , 0
-}
-
- -

Auto-repeating a Keystroke

-

Some programs or games might require a key to be sent repeatedly (as though you are holding it down on the keyboard). The following example achieves this by sending spacebar keystrokes repeatedly while you hold down the joystick's second button:

-
Joy2::
-{
-    Send "{Space down}"   ; Press the spacebar down.
-    SetTimer WaitForJoy2, 30  ; Reduce the number 30 to 20 or 10 to send keys faster. Increase it to send slower.
-}
-
-WaitForJoy2()
-{
-    if not GetKeyState("Joy2")  ; The button has been released.
-    {
-        Send "{Space up}"  ; Release the spacebar.
-        SetTimer , 0  ; Stop monitoring the button.
-        return
-    }
-    ; Since above didn't "return", the button is still being held down.
-    Send "{Space down}"  ; Send another Spacebar keystroke.
-}
- -

Context-sensitive Joystick Buttons

-

The #HotIf directive can be used to make selected joystick buttons perform a different action (or none at all) depending on any condition, such as the type of window that is active.

- -

Using a Joystick as a Mouse

-

The Joystick-To-Mouse script converts a joystick into a mouse by remapping its buttons and axis control.

- -

Making Other Joystick Controls Send Keystrokes or Mouse Clicks

-

To have a script respond to movement of a joystick's axis or POV hat, use SetTimer and GetKeyState.

- -

Joystick Axes

-

The following example makes the joystick's X and Y axes behave like the arrow key cluster on a keyboard (left, right, up, and down):

-
SetTimer WatchAxis, 5
-
-WatchAxis()
-{
-    JoyX := GetKeyState("JoyX")  ; Get position of X axis.
-    JoyY := GetKeyState("JoyY")  ; Get position of Y axis.
-    KeyToHoldDownPrev := KeyToHoldDown  ; Prev now holds the key that was down before (if any).
-
-if JoyX > 70
-        KeyToHoldDown := "Right"
-    else if JoyX < 30
-        KeyToHoldDown := "Left"
-    else if JoyY > 70
-        KeyToHoldDown := "Down"
-    else if JoyY < 30
-        KeyToHoldDown := "Up"
-    else
-        KeyToHoldDown := ""
-
-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.
-}
- -

Joystick POV Hat

-

The following example makes the joystick's POV hat behave like the arrow key cluster on a keyboard; that is, the POV hat will send arrow keystrokes (left, right, up, and down):

-
SetTimer WatchPOV, 5
-
-WatchPOV()
-{
-    static KeyToHoldDown := ""
-    POV := GetKeyState("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 >= 0 and POV <= 4500      ; 0 to 45 degrees: Forward
-        KeyToHoldDown := "Up"
-    else if POV >= 4501 and POV <= 13500  ; 45 to 135 degrees: Right
-        KeyToHoldDown := "Right"
-    else if POV >= 13501 and POV <= 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.
-}
- -

Auto-repeating a Keystroke

-

Both examples above can be modified to send the key repeatedly rather than merely holding it down (that is, they can mimic physically holding down a key on the keyboard). To do this, replace the following line:

-
return  ; Do nothing.
-

With the following:

-
{
-    if KeyToHoldDown
-        Send "{" KeyToHoldDown " down}"  ; Auto-repeat the keystroke.
-    return
-}
-

備考

-

A joystick other than first may be used by preceding the button or axis name with the number of the joystick. For example, 2Joy1 would be the second joystick's first button.

-

To find other useful joystick scripts, visit the AutoHotkey forum. A keyword search such as Joystick and GetKeyState and Send is likely to produce topics of interest.

- - - - - diff --git a/target/docs/scripts/JoystickMouse.ahk b/target/docs/scripts/JoystickMouse.ahk deleted file mode 100644 index c42f30e1f..000000000 --- a/target/docs/scripts/JoystickMouse.ahk +++ /dev/null @@ -1,162 +0,0 @@ -; Using a Joystick as a Mouse -; https://www.autohotkey.com -; This script converts a joystick into a three-button mouse. It allows each -; button to drag just like a mouse button and it uses virtually no CPU time. -; Also, it will move the cursor faster depending on how far you push the joystick -; from center. You can personalize various settings at the top of the script. - -; Increase the following value to make the mouse cursor move faster: -JoyMultiplier := 0.30 - -; Decrease the following value to require less joystick displacement-from-center -; to start moving the mouse. However, you may need to calibrate your joystick -; -- ensuring it's properly centered -- to avoid cursor drift. A perfectly tight -; and centered joystick could use a value of 1: -JoyThreshold := 3 - -; Change the following to true to invert the Y-axis, which causes the mouse to -; move vertically in the direction opposite the stick: -InvertYAxis := false - -; Change these values to use joystick button numbers other than 1, 2, and 3 for -; the left, right, and middle mouse buttons. Available numbers are 1 through 32. -; Use the Joystick Test Script to find out your joystick's numbers more easily. -ButtonLeft := 1 -ButtonRight := 2 -ButtonMiddle := 3 - -; If your joystick has a POV control, you can use it as a mouse wheel. The -; following value is the number of milliseconds between turns of the wheel. -; Decrease it to have the wheel turn faster: -WheelDelay := 250 - -; If your system has more than one joystick, increase this value to use a joystick -; other than the first: -JoystickNumber := 1 - -; END OF CONFIG SECTION -- Don't change anything below this point unless you want -; to alter the basic nature of the script. - -#SingleInstance - -JoystickPrefix := JoystickNumber "Joy" -Hotkey JoystickPrefix . ButtonLeft, ClickButtonLeft -Hotkey JoystickPrefix . ButtonRight, ClickButtonRight -Hotkey JoystickPrefix . ButtonMiddle, ClickButtonMiddle - -; Calculate the axis displacements that are needed to start moving the cursor: -JoyThresholdUpper := 50 + JoyThreshold -JoyThresholdLower := 50 - JoyThreshold -if InvertYAxis - YAxisMultiplier := -1 -else - YAxisMultiplier := 1 - -SetTimer WatchJoystick, 10 ; Monitor the movement of the joystick. - -JoyInfo := GetKeyState(JoystickNumber "JoyInfo") -if InStr(JoyInfo, "P") ; Joystick has POV control, so use it as a mouse wheel. - SetTimer MouseWheel, WheelDelay - -; The functions below do not use KeyWait because that would sometimes trap the -; WatchJoystick quasi-thread beneath the wait-for-button-up thread, which would -; effectively prevent mouse-dragging with the joystick. - -ClickButtonLeft(*) -{ - SetMouseDelay -1 ; Makes movement smoother. - MouseClick "Left",,, 1, 0, "D" ; Hold down the left mouse button. - SetTimer WaitForLeftButtonUp, 10 - - WaitForLeftButtonUp() - { - if GetKeyState(A_ThisHotkey) - return ; The button is still, down, so keep waiting. - ; Otherwise, the button has been released. - SetTimer , 0 - SetMouseDelay -1 ; Makes movement smoother. - MouseClick "Left",,, 1, 0, "U" ; Release the mouse button. - } -} - -ClickButtonRight(*) -{ - SetMouseDelay -1 ; Makes movement smoother. - MouseClick "Right",,, 1, 0, "D" ; Hold down the right mouse button. - SetTimer WaitForRightButtonUp, 10 - - WaitForRightButtonUp() - { - if GetKeyState(A_ThisHotkey) - return ; The button is still, down, so keep waiting. - ; Otherwise, the button has been released. - SetTimer , 0 - MouseClick "Right",,, 1, 0, "U" ; Release the mouse button. - } -} - -ClickButtonMiddle(*) -{ - SetMouseDelay -1 ; Makes movement smoother. - MouseClick "Middle",,, 1, 0, "D" ; Hold down the right mouse button. - SetTimer WaitForMiddleButtonUp, 10 - - WaitForMiddleButtonUp() - { - if GetKeyState(A_ThisHotkey) - return ; The button is still, down, so keep waiting. - ; Otherwise, the button has been released. - SetTimer , 0 - MouseClick "Middle",,, 1, 0, "U" ; Release the mouse button. - } - -} - -WatchJoystick() -{ - global - MouseNeedsToBeMoved := false ; Set default. - joyx := GetKeyState(JoystickNumber "JoyX") - joyy := GetKeyState(JoystickNumber "JoyY") - if joyx > JoyThresholdUpper - { - MouseNeedsToBeMoved := true - DeltaX := Round(joyx - JoyThresholdUpper) - } - else if joyx < JoyThresholdLower - { - MouseNeedsToBeMoved := true - DeltaX := Round(joyx - JoyThresholdLower) - } - else - DeltaX := 0 - if joyy > JoyThresholdUpper - { - MouseNeedsToBeMoved := true - DeltaY := Round(joyy - JoyThresholdUpper) - } - else if joyy < JoyThresholdLower - { - MouseNeedsToBeMoved := true - DeltaY := Round(joyy - JoyThresholdLower) - } - else - DeltaY := 0 - if MouseNeedsToBeMoved - { - SetMouseDelay -1 ; Makes movement smoother. - MouseMove DeltaX * JoyMultiplier, DeltaY * JoyMultiplier * YAxisMultiplier, 0, "R" - } -} - -MouseWheel() -{ - global - JoyPOV := GetKeyState(JoystickNumber "JoyPOV") - if JoyPOV = -1 ; No angle. - return - if (JoyPOV > 31500 or JoyPOV < 4500) ; Forward - Send "{WheelUp}" - else if JoyPOV >= 13500 and JoyPOV <= 22500 ; Back - Send "{WheelDown}" -} diff --git a/target/docs/scripts/JoystickTest.ahk b/target/docs/scripts/JoystickTest.ahk deleted file mode 100644 index 495c99b75..000000000 --- a/target/docs/scripts/JoystickTest.ahk +++ /dev/null @@ -1,77 +0,0 @@ -; Joystick Test Script -; https://www.autohotkey.com -; This script helps determine the button numbers and other attributes -; of your joystick. It might also reveal if your joystick is in need -; of calibration; that is, whether the range of motion of each of its -; axes is from 0 to 100 percent as it should be. If calibration is -; needed, use the operating system's control panel or the software -; that came with your joystick. - -; July 16, 2016: Revised code for AHK v2 compatibility -; July 6, 2005 : Added auto-detection of joystick number. -; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of -; detecting whether the joystick is connected. Some joysticks are -; gamepads and don't have even a single axis. - -; If you want to unconditionally use a specific joystick number, change -; the following value from 0 to the number of the joystick (1-16). -; A value of 0 causes the joystick number to be auto-detected: -JoystickNumber := 0 - -; END OF CONFIG SECTION. Do not make changes below this point unless -; you wish to alter the basic functionality of the script. - -; Auto-detect the joystick number if called for: -if JoystickNumber <= 0 -{ - Loop 16 ; Query each joystick number to find out which ones exist. - { - if GetKeyState(A_Index "JoyName") - { - JoystickNumber := A_Index - break - } - } - if JoystickNumber <= 0 - { - MsgBox "The system does not appear to have any joysticks." - ExitApp - } -} - -#SingleInstance -joy_buttons := GetKeyState(JoystickNumber "JoyButtons") -joy_name := GetKeyState(JoystickNumber "JoyName") -joy_info := GetKeyState(JoystickNumber "JoyInfo") -Loop -{ - buttons_down := "" - Loop joy_buttons - { - if GetKeyState(JoystickNumber "Joy" A_Index) - buttons_down .= " " A_Index - } - axis_info := "X" Round(GetKeyState(JoystickNumber "JoyX")) - axis_info .= " Y" Round(GetKeyState(JoystickNumber "JoyY")) - if InStr(joy_info, "Z") - axis_info .= " Z" Round(GetKeyState(JoystickNumber "JoyZ")) - if InStr(joy_info, "R") - axis_info .= " R" Round(GetKeyState(JoystickNumber "JoyR")) - if InStr(joy_info, "U") - axis_info .= " U" Round(GetKeyState(JoystickNumber "JoyU")) - if InStr(joy_info, "V") - axis_info .= " V" Round(GetKeyState(JoystickNumber "JoyV")) - if InStr(joy_info, "P") - axis_info .= " POV" Round(GetKeyState(JoystickNumber "JoyPOV")) - ToolTip - ( - joy_name " (#" JoystickNumber "): - " axis_info " - Buttons Down: - " buttons_down " - - (right-click the tray icon to exit)" - ) - Sleep 100 -} -return