Advertisement
Guest User

Cemu Mouse

a guest
Mar 15th, 2017
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5. #SingleInstance Force
  6. #MaxHotkeysPerInterval 140
  7.  
  8. ; Note the Right stick must be mapped to Up Down Left Right Currently. and check the long comments below for mouse button Mapping
  9.  
  10. CoordMode, Mouse, Window
  11. SystemCursor("I")
  12.  
  13. OnExit, ShowCursor  ; Ensure the cursor is made visible when the script exits.
  14. Toggle := False
  15. Return
  16. ChangeMouse:
  17. MouseGetPos, CurX, CurY
  18.     DifX:=Floor(winW/2 - CurX), DifY:=Floor(winH/2 - CurY)
  19.     Send, % "{" . (DifX > 4 ? "Left Down" : "Left Up") . "}"
  20.     Send, % "{" . (DifX < -4 ? "Right Down" : "Right Up") . "}"
  21.     Send, % "{" . (DifY > 4 ? "Up Down" : "Up Up") . "}"
  22.     Send, % "{" . (DifY < -4 ? "Down Down" : "Down Up") . "}"
  23. MouseMove, % winW/2,  % winH/2
  24. Return
  25.  
  26. #IF Toggle
  27. LButton::Numpad5  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Change here what you want Left mouse button to map to ( Numpad5 is where i have 'Y' mapped in CEMU )
  28. RButton::NumpadMult  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Same for Right mouse button ( NumpadMult is where I have 'ZR' or whatever the Bow aim in BotW is
  29. MButton::MButton     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Middle Button
  30. XButton1::XButton1   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Button 4
  31. XButton2::XButton2   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Button 5
  32.  
  33. WheelUp::WheelUp     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wheel Up
  34. WheelDown::WheelDown ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wheel Down
  35. WheelLeft::WheelLeft ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wheel Left
  36. WheelRight::WheelRight ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wheel Right
  37.  
  38.  
  39. ;; IF you haven't changed the camera from the arrow keys leave this next section alone, as it makes using the keys while active smoother.
  40. $Down::
  41. Thread, NoTimers
  42. Send {Down Down}
  43. While (GetKeyState("Down", "P"))
  44.     Continue
  45. Send {Down Up}
  46. Return
  47. $Up::
  48. Thread, NoTimers
  49. Send {Up Down}
  50. While (GetKeyState("Up", "P"))
  51.     Continue
  52. Send {Up Up}
  53. Return
  54. $Left::
  55. Thread, NoTimers
  56. Send {Left Down}
  57. While (GetKeyState("Left", "P"))
  58.     Continue
  59. Send {Left Up}
  60. Return
  61. $Right::
  62. Thread, NoTimers
  63. Send {Right Down}
  64. While (GetKeyState("Right", "P"))
  65.     Continue
  66. Send {Right Up}
  67. Return
  68. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  69. #IFWinActive Cemu
  70. F1::
  71.     WinGetPos, winX, winY, winW, winH, A
  72.     SetTimer, ChangeMouse, % (Toggle:=!Toggle) ? 15 : "Off"
  73.     SetTimer, WinFocusLoop, % (Toggle) ? 100 : "Off"
  74.     SystemCursor("T")
  75.     Send {Right Up}
  76.     Send {Left Up}
  77.     Send {Up Up}
  78.     Send {Down Up}
  79. Return
  80. #IFWinActive
  81. ~F1::
  82. Critical
  83. SetTimer, WinFocusLoop, Off
  84. SetTimer, ChangeMouse, Off
  85. Toggle := False
  86. SystemCursor("On")
  87. Send {Right Up}
  88. Send {Left Up}
  89. Send {Up Up}
  90. Send {Down Up}
  91. Return
  92.  
  93. ShowCursor:
  94. SystemCursor("On")
  95. ExitApp
  96.  
  97. WinFocusLoop()
  98. {
  99.     Static S_LastProcess := ""
  100.     WinGet, CurProc, ProcessName, A
  101.     If (CurProc != S_LastProcess)
  102.     {
  103.         ;Handle Losing Focus
  104.         Focus_Func := "OnLoseFocus_" . RegExReplace(S_LastProcess,A_Space,"_")
  105.         If (IsLabel(Focus_Func))
  106.             GoSub, %Focus_Func%
  107.  
  108.         ; Handle Gaining Focus.
  109.         Focus_Func := "OnGainFocus_" . RegExReplace(CurProc,A_Space,"_")
  110.         If (IsLabel(Focus_Func))
  111.             GoSub, %Focus_Func%
  112.  
  113.         ; Reset the last process to the current one.
  114.         S_LastProcess := CurProc
  115.     }
  116. Return
  117. }
  118. OnLoseFocus_Cemu.exe:
  119.     Critical
  120.     SetTimer, WinFocusLoop, Off
  121.     SetTimer, ChangeMouse, Off
  122.     Toggle := False
  123.     SystemCursor("On")
  124.     Send {Right Up}
  125.     Send {Left Up}
  126.     Send {Up Up}
  127.     Send {Down Up}
  128. Return
  129.  
  130. SystemCursor(OnOff=0)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
  131. {
  132.     static AndMask, XorMask, $, h_cursor
  133.         ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
  134.         , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
  135.         , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
  136.     if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
  137.     {
  138.         $ = h                                          ; active default cursors
  139.         VarSetCapacity( h_cursor,4444, 1 )
  140.         VarSetCapacity( AndMask, 32*4, 0xFF )
  141.         VarSetCapacity( XorMask, 32*4, 0 )
  142.         system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
  143.         StringSplit c, system_cursors, `,
  144.         Loop %c0%
  145.         {
  146.             h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
  147.             h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
  148.             b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
  149.                 , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
  150.         }
  151.     }
  152.     if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
  153.         $ = b  ; use blank cursors
  154.     else
  155.         $ = h  ; use the saved cursors
  156.  
  157.     Loop %c0%
  158.     {
  159.         h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
  160.         DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement