The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (Linux)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
 
Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Mouse axis movement as Analog Stick
06-18-2013, 07:21 PM
Post: #1
Using Mouse axis movement as Analog Stick
Basically can we have this feature to control arrow/leftstick/rightstick via mouse gestures?
I know you can do it in PCSX2 with Lilypad plugin, so I think there should be a way to implement in here too?
I already tried Autohotkey script such as the one below.

The results were so-so with hover-mode, however stick-mode was frustrating,
I tried adjusting and concluded I best ask here if it can be done, I could use my gamepad,
however I find a lot of games are better with mouse for camera control, especially first person shooters. Smile

Code:
;==========================================================================
;
;                 MouseSendZones
;
; Author:        Pulover [Rodolfo U. Batista]
;                [email protected]
;
; HoverMode:    The script sends user-defined keys when the mouse is
;                over an area of the screen by creating a rectangle at
;                the center to be the Dead Zone and 8 other rectangles
;                around it, each one will send and hold the configured
;                keys when the mouse hovers over it.
;
; StickMode:    When the mouse is moved in one direction the script
;                sends the corresponding keys and releases them when
;                it stops moving. This is more specific for using a
;                joystick to control mouse movements.
;
;==========================================================================

; ########## Configurations: ##########

; Select Hotkey to active HoverMode:
Hover = F1

; Select Hotkey to active StickMode:
Stick = F2

; Select Hotkey show Zones Guidelcines:
ShowZones = CapsLock

; Select optional Hotkey reset mouse to Center:
Center = MButton

; Set Horizontal & Vertical Dead Zone Ranges in pixels:
DeadZoneRangeX := 200
DeadZoneRangeY := 150

KeySet =
( ; Set the keys that will be sent for each of the eight zones of the screen:
Up = up
Down = down
Left = left
Right = right
UpLeft = up & left
UpRight = up & right
DownLeft = down & left
DownRight = down & right
)

; ########## End of configurations! ##########

; Parse KeySet and assign variables to the keys:
Loop, Parse, KeySet, `n
{
    Loop, Parse, A_LoopField, =, %A_Space%
        If Mod(A_Index, 2)
            Key := A_LoopField
        Else
        {
            %Key% := A_LoopField
            StringSplit, %Key%, A_LoopField, &, %A_Space%
        }
}

#SingleInstance, Force
SendMode, Input
SetKeyDelay, -1
SetMouseDelay, -1
SetBatchLines, -1
CoordMode, Mouse, Screen

; Get coordinates for the center of the screen to create a Dead Zone:
DeadZoneX := A_ScreenWidth / 2
DeadZoneY := A_ScreenHeight / 2

; Activate Hotkeys:
Hotkey, %Hover%, Hover, On
Hotkey, %Stick%, Stick, On
Hotkey, %ShowZones%, ShowZones, On
Try Hotkey, %Center%, CenterMouse, On

; Create a rectangle to show Dead Zone:
A := DeadZoneRangeX*2, B := DeadZoneRangeY*2, C := A-2, D := B-2

Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop
Gui, Color, Red
Gui, +LastFound
WinSet, Region, 0-0 %A%-0 %A%-%B% 0-%B% 0-0  2-2 %C%-2 %C%-%D% 2-%D% 2-2
GoSub, ShowZones
Display := !Display
SetTimer, RemoveTip, -1500
return

Hover:
StickMode := False
SetTimer, WatchMouse, % (HoverMode := !HoverMode) ? 0 : "Off"
Loop, % %hKeys%0
    Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
TrayTip,, % (HoverMode) ? "HoverMode On" : "HoverMode Off"
return

Stick:
HoverMode := False
SetTimer, WatchMouse, % (StickMode := !StickMode) ? 0 : "Off"
Loop, % %hKeys%0
    Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
TrayTip,, % (StickMode) ? "StickMode On" : "StickMode Off"
return

ShowZones:
If (Display := !Display)
{
    Gui, Show, % "NA x" DeadZoneX - DeadZoneRangeX "y" DeadZoneY - DeadZoneRangeY "w" DeadZoneRangeX * 2 "h" DeadZoneRangeY * 2
    Tooltip, Dead Zone, % DeadZoneX-25, % DeadZoneY-25, 1
    Tooltip, % Up, % DeadZoneX-25, % 0, 2
    Tooltip, % Down, % DeadZoneX-25, % A_ScreenHeight, 3
    Tooltip, % Left, % 0, % DeadZoneY-25, 4
    Tooltip, % Right, % A_ScreenWidth, % DeadZoneY-25, 5
    Tooltip, % UpLeft, % 0, % 0, 6
    Tooltip, % UpRight, % A_ScreenWidth, % 0, 7
    Tooltip, % DownLeft, % 0, % A_ScreenHeight, 8
    Tooltip, % DownRight, % A_ScreenWidth, % A_ScreenHeight, 9
}
Else
    GoSub, RemoveTip
return

RemoveTip:
Gui, Cancel
Tooltip,,,,1
Tooltip,,,,2
Tooltip,,,,3
Tooltip,,,,4
Tooltip,,,,5
Tooltip,,,,6
Tooltip,,,,7
Tooltip,,,,8
Tooltip,,,,9
return

CenterMouse:
Click, %DeadZoneX%, %DeadZoneY%, 0
return

WatchMouse:
MouseGetPos, pX, pY
If StickMode
{
    If ((pX = 0) || (pX = A_ScreenWidth-1))
        || ((pY = 0) || (pY = A_ScreenHeight-1))
        GoSub, CenterMouse
    Sleep, 150
    MouseGetPos, cX, cY
    zKeys := MoveZone(pX, pY, cX, cY)
}
Else
    zKeys := GetZone(pX, pY, DeadZoneX, DeadZoneY, DeadZoneRangeX, DeadZoneRangeY)
If (hKeys <> zKeys)
{
    Loop, % %hKeys%0
        Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
    Loop, % %zKeys%0
        Send, % (zKeys = "DeadZone") ? "" : "{" %zKeys%%A_Index% "  down}"
    hKeys := zKeys
}
return

GetZone(X, Y, DX, DY, RX, RY)
{
    If (Y < (DY - RY))
        Zone .= "Up"
    If (Y > (DY + RY))
        Zone .= "Down"
    If (X < (DX - RX))
        Zone .= "Left"
    If (X > (DX + RX))
        Zone .= "Right"
    return Zone = "" ? "DeadZone" : Zone
}

MoveZone(pX, pY, cX, cY)
{
    If (cY < pY)
        Zone .= "Up"
    If (cY > pY)
        Zone .= "Down"
    If (cX < pX)
        Zone .= "Left"
    If (cX > pX)
        Zone .= "Right"
    return Zone = "" ? "DeadZone" : Zone
}
p::ExitApp

Laptop:________________________Desktop:
Windows 10 64-bit, 8GB DDR4 RAM | Windows 10 64-bit, 8GB DDR3 RAM
Intel® Core™i5-7300HQ 2,5/3.5ghz | Intel® Core™i5-4440 3,10ghz
NVIDIA GTX 1050 Ti_____________| NVIDIA GTX 1060 3GB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Using Mouse axis movement as Analog Stick - FinalBlast - 06-18-2013 07:21 PM

Forum Jump: