; Orbitouch-like joystick input AHK (Autohotkey) Script ; http://www.autohotkey.com ; Written with hooves in mine, could potentially be really used for those with limited ; mobility, all keyboard and mouse input is replicated with just two joy sticks, the only ; button presses are to use the mouse, pushing in the left stick is a left click, pushing ; in the right stick is a right-click ; USE IN TANDEM WITH JoystickMouse.ahk SCRIPT FOR MOUSE SUPPORT: https://pastebin.com/HaR1YFPx   ; This was designed to imitate the orbitouch (see orbitouch.com), a $400 a keyless keyboard replacement for limited mobility, with any ; old gamepad with two analog sticks, See https://www.youtube.com/watch?v=byYs1AScbkg to get an idea (How to type using the Orbitouch)   ; To use the mouse you move the right analog stick, the d-pad can act as a mouse wheel, clicking the left analog stick is a left click, clicking the right analog stick is a right click.   ; To input a key, you hold the left analog stick in one of the eight directions, then move the right analog stick in one of eight directions, the corresponding key will be pressed, (a is left-left, e is right-left, etc), ; to shift you move the left analog stick up twice, all characters in the tooltip will be capitalized to show when this occurs. ; When the left analog stick is moved from its center, the mouse will not move ; A cheat sheet to see all key commands at once (the tooltips will help you): https://claytonmayo.files.wordpress.com/2010/05/orbitouch-slide-guide-desktop-alphabetic-design-sliding-final.png ;  The F1-F12 keys and a few miscellaneous keys are not implemented yet   ; Under the Down key list is Tab, Backspace, Enter and Space in the cardinal directions, shift to have arrow keys here ; Under DownLeft key list, AltTab is assigned to UpRight and ShiftAltTab is assigned to UpLeft, CtrlTab and ShiftCtrlTab are in the same menu under Left and Right respectively.   ; IS THIS SLOWER THAN A KEYBOARD? Yes. I'm up to probably 7-8 wpm with only familiarity. 20wpm might be realistic. Ideally this is paired with software that autocompletes text, it could then make typing faster and painless.  The key order is relatively intuitive, although diagonals can be tricky. Keys would be hard to press with hooves, so could gamepad buttons. The ideal is a fight stick gamepad with arcade buttons and a similar AHK script, but if you find yourself unexpectedly a pony and can't order a custom fight stick right now, this could help you in a jam.   ; 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.   DetectHiddenWindows On  ; Allows a script's hidden main window to be detected. SetTitleMatchMode 2  ; Avoids the need to specify the full path of the file below.   IsShift = false toolTip1 = "" toolTip2 = "" toolTip3 = ""     ; Auto-detect the joystick number if called for: if JoystickNumber <= 0 {     Loop 16  ; Query each joystick number to find out which ones exist.     {         GetKeyState, JoyName, %A_Index%JoyName         if JoyName <>         {             JoystickNumber = %A_Index%             break         }     }     if JoystickNumber <= 0     {         MsgBox The system does not appear to have any joysticks.         ExitApp     } }   Space := "_" Tab := "   " InputMode := MouseMode LeftStick := Unset RightStick := Unset IsRightStickUsed := false UpCounter := 0   #SingleInstance SetFormat, float, 03  ; Omit decimal point from axis position percentages. GetKeyState, joy_buttons, %JoystickNumber%JoyButtons GetKeyState, joy_name, %JoystickNumber%JoyName GetKeyState, joy_info, %JoystickNumber%JoyInfo Loop {       ; UDLR     GetKeyState, joyy, %JoystickNumber%JoyY     if  (joyy < 30) {         LeftStick = Up     }     else     {         if (joyy > 70) {             LeftStick = Down         }         else         {         LeftStick = Unset         }     }         GetKeyState, joyx, %JoystickNumber%JoyX     if (joyx < 20) {         if(LeftStick = "Unset") {             LeftStick = Left         }         else {             LeftStick = %LeftStick% Left         }     }     else {         if (joyx > 80) {             if(LeftStick = "Unset") {                 LeftStick = Right             }             else {                 LeftStick = %LeftStick% Right             }         }     }         if(LeftStick = "Unset"){         if( InputMode = "KeyboardMode"){             PostMessage, 0x111, 65306,,, JoystickMouse.ahk - AutoHotkey  ; Pause.             if(UpCounter = 1){                 UpCounter = 2             }         }         InputMode = MouseMode     }     else {         if( InputMode = "MouseMode"){             PostMessage, 0x111, 65306,,, JoystickMouse.ahk - AutoHotkey  ; Pause.         }         InputMode = KeyboardMode             }             ;Now for the right analog stick     if( InStr(joy_info, U) and InStr(joy_info, V) ){           GetKeyState, joyr, %JoystickNumber%JoyR         if (joyr < 30) {             RightStick = Up         }         else {             if (joyr > 70) {                 RightStick = Down             }             else             {                 RightStick = Unset             }         }                 GetKeyState, joyu, %JoystickNumber%JoyU         if (joyu < 20) {             if(RightStick = "Unset") {                 RightStick = Left             }             else {                 RightStick = %RightStick% Left             }         }         else {             if (joyu > 80) {                 if(RightStick = "Unset") {                     RightStick = Right                 }                 else {                     RightStick = %RightStick% Right                 }             }         }                         if(IsRightStickUsed AND RightStick <> "Unset"){             RightStick = Used         }         else {             if(IsRightStickUsed AND RightStick = "Unset")             IsRightStickUsed := false         }       }         if( InputMode = "KeyboardMode" AND NOT(IsRightStickUsed)){         if(LeftStick <> "Unset" AND RightStick <> "Unset"){             UseKeyboard(LeftStick, RightStick)             UpCounter = 0             IsRightStickUsed := true         }     }         if(LeftStick = "Up" and RightStick = "Unset")     {         if(UpCounter = 0){             UpCounter = 1         }         if(UpCounter = 2){             UpCounter = 3             global IsShift = true         }     }         if(LeftStick = "Unset"){         toolTip1 := "     "         toolTip2 := "  +  "         toolTip3 := "     "     }     else if(LeftStick = "Left" && global IsShift = true){         toolTip1 := "F K P"         toolTip2 := "A + U"         toolTip3 := "% ) Z"     }     else if(LeftStick = "Left"){         toolTip1 := "f k p"         toolTip2 := "a + u"         toolTip3 := "5 0 z"     }     else if(LeftStick = "Up Left" && global IsShift = true){         toolTip1 := "G L Q"         toolTip2 := "B + V"         toolTip3 := "$ ( ?"     }     else if(LeftStick = "Up Left"){         toolTip1 := "g l q"         toolTip2 := "b + v"         toolTip3 := "4 9 /"     }     else if(LeftStick = "Up" && global IsShift = true){         toolTip1 := "H M R"         toolTip2 := "C + W"         toolTip3 := "# * """     }     else if(LeftStick = "Up"){         toolTip1 := "h m r"         toolTip2 := "c + w"         toolTip3 := "3 8 '"     }     else if(LeftStick = "Up Right" && global IsShift = true){         toolTip1 := "I N S"         toolTip2 := "D + X"         toolTip3 := "@ & >"     }     else if(LeftStick = "Up Right"){         toolTip1 := "i n s"         toolTip2 := "d + x"         toolTip3 := "2 7 ."     }     else if(LeftStick = "Right" && global IsShift = true){         toolTip1 := "J O T"         toolTip2 := "E + Y"         toolTip3 := "! ^ <"     }     else if(LeftStick = "Right"){         toolTip1 := "j o t"         toolTip2 := "e + y"         toolTip3 := "1 6 ,"     }     else if(LeftStick = "Down Right" && global IsShift = true){         toolTip1 := "| { """         toolTip2 := ": + _"         toolTip3 := "  }  "     }     else if(LeftStick = "Down Right"){         toolTip1 := "\ [ '"         toolTip2 := "; + -"         toolTip3 := "+ ] ="     }     else if(LeftStick = "Down Left"){         toolTip1 := ""         toolTip2 := ""         toolTip3 := "         "     }     else if(LeftStick = "Down" && global IsShift = true){         toolTip1 := "  ^  "         toolTip2 := "< + >"         toolTip3 := "  v  "     }     else if(LeftStick = "Down"){         toolTip1 := " Tab "         toolTip2 := "BS SPCE"         toolTip3 := "ENTER"       }         joystick_info := "L:" LeftStick "  R:" RightStick     ToolTip, %InputMode% %UpCounter%`n%joystick_info%`n%toolTip1%`n%toolTip2%`n%toolTip3%     Sleep, 100       } return   UseKeyboard( LeftStick, RightStick) {     key = 0         if(LeftStick = "Left" AND RightStick = "Left"){         key = 97            ;a     }     else if(LeftStick = "Up Left" AND RightStick = "Left"){         key = 98        ;b     }     else if(LeftStick = "Up" AND RightStick = "Left"){         key = 99            ;c     }     else if(LeftStick = "Up Right" AND RightStick = "Left"){         key = 100   ;d     }     else if(LeftStick = "Right" AND RightStick = "Left"){         key = 101       ;e     }     else if(LeftStick = "Left" AND RightStick = "Up Left"){         key = 102       ;f     }     else if(LeftStick = "Up Left" AND RightStick = "Up Left"){         key = 103       ;g     }     else if(LeftStick = "Up" AND RightStick = "Up Left"){         key = 104       ;h     }     else if(LeftStick = "Up Right" AND RightStick = "Up Left"){         key = 105       ;i     }     else if(LeftStick = "Right" AND RightStick = "Up Left"){         key = 106       ;j     }     else if(LeftStick = "Left" AND RightStick = "Up"){         key = 107       ;k     }     else if(LeftStick = "Up Left" AND RightStick = "Up"){         key = 108       ;l     }     else if(LeftStick = "Up" AND RightStick = "Up"){         key = 109       ;m     }     else if(LeftStick = "Up Right" AND RightStick = "Up"){         key = 110       ;n     }     else if(LeftStick = "Right" AND RightStick = "Up"){         key = 111       ;o     }     else if(LeftStick = "Left" AND RightStick = "Up Right"){         key = 112       ;p     }     else if(LeftStick = "Up Left" AND RightStick = "Up Right"){         key = 113       ;q     }       else if(LeftStick = "Up" AND RightStick = "Up Right"){         key = 114       ;r     }     else if(LeftStick = "Up Right" AND RightStick = "Up Right"){         key = 115       ;s     }     else if(LeftStick = "Right" AND RightStick = "Up Right"){         key = 116       ;t     }     else if(LeftStick = "Left" AND RightStick = "Right"){         key = 117       ;u     }     else if(LeftStick = "Up Left" AND RightStick = "Right"){         key = 118       ;v     }     else if(LeftStick = "Up" AND RightStick = "Right"){         key = 119       ;w     }     else if(LeftStick = "Up Right" AND RightStick = "Right"){         key = 120       ;x     }     else if(LeftStick = "Right" AND RightStick = "Right"){         key = 121       ;y     }     else if(LeftStick = "Left" AND RightStick = "Down Right"){         key = 122       ;z     }         else if(LeftStick = "Right" AND RightStick = "Down Right"){         if(IsShift = true){             Send, <             IsShift := false         }         else Send, ,     }         else if(LeftStick = "Up Right" AND RightStick = "Down Right"){         if(IsShift = true){             Send, >             IsShift := false         }         else SendInput {Raw}.     }         else if(LeftStick = "Down Right" AND RightStick = "Left"){         if(IsShift = true){             SendInput {:}             IsShift := false         }         else SendInput {;}     }     else if(LeftStick = "Up" AND RightStick = "Down Right"){         if(IsShift = true){             SendRaw "             IsShift := false         }         else SendRaw '     }         if(AND LeftStick = "Down Right" AND RightStick = "Up"){         if(IsShift = true){             SendRaw {             IsShift := false         }         else SendRaw [     }     if(LeftStick = "Down Right" AND RightStick = "Down"){         if(IsShift = true){             SendRaw }             IsShift := false         }         else SendRaw ]     }     if(LeftStick = "Down Right" AND RightStick = "Right"){         if(IsShift = true){             SendRaw _             IsShift := false         }         else SendRaw -     }     if(LeftStick = "Down Right" AND RightStick = "Up Right"){         if(IsShift = true){             SendRaw "             IsShift := false         }         else SendInput {Raw}'     }     if(LeftStick = "Down Right" AND RightStick = "Up Left"){         if(IsShift = true){             SendRaw |             IsShift := false         }         else SendRaw \     }           if(LeftStick = "Down Right" AND RightStick = "Down Left"){         if(IsShift = true){             IsShift := false         }         SendRaw, +     }     if(LeftStick = "Down Right" AND RightStick = "Down Right"){         if(IsShift = true){             IsShift := false         }         SendRaw, =     }                   if(LeftStick = "Up Left" AND RightStick = "Down Right"){         if(IsShift = true){             SendRaw ?             IsShift := false         }         else SendRaw /     }               if(LeftStick = "Down" AND RightStick = "Right"){         if(IsShift = true){             Send {Right}             IsShift := false         }         else Send {space}     }         if(LeftStick = "Down" AND RightStick = "Left"){         if(IsShift = true){             Send {Left}             IsShift := false         }         else Send {BS}     }         if(LeftStick = "Down" AND RightStick = "Down"){         if(IsShift = true){             Send {Down}             IsShift := false         }         else Send {Enter}     }         if(LeftStick = "Down" AND RightStick = "Up"){         if(IsShift = true){             Send {Up}             IsShift := false         }         else Send {Tab}     }         ;tab and window controls     if(LeftStick = "Down Left" AND RightStick = "Up Right")     {         Send, {ALT DOWN}{TAB}{ALT UP}     }     if(LeftStick = "Down Left" AND RightStick = "Up Left")     {         Send, {SHIFT DOWN}{ALT DOWN}{TAB}{ALT UP}{SHIFT UP}     }     if(LeftStick = "Down Left" AND RightStick = "Right")     {         Send, {CTRL DOWN}{TAB}{CTRL UP}     }     if(LeftStick = "Down Left" AND RightStick = "Left")     {         Send, {SHIFT DOWN}{CTRL DOWN}{TAB}{CTRL UP}{SHIFT UP}     }         ;numbers     if(LeftStick = "Right" AND RightStick = "Down Left"){         if(IsShift = true){             SendInput )             IsShift := false         }         else SendInput 1     }     else if(LeftStick = "Up Right" AND RightStick = "Down Left"){         if(IsShift = true){             SendInput @             IsShift := false         }         else SendInput 2     }     else if(LeftStick = "Up" AND RightStick = "Down Left"){         if(IsShift = true){             SendInput, #             IsShift := false         }         else SendInput 3     }     else if(LeftStick = "Up Left" AND RightStick = "Down Left"){         if(IsShift = true){             SendInput, $             IsShift := false         }         else SendInput 4     }     else if(LeftStick = "Left" AND RightStick = "Down Left"){         if(IsShift = true){             Send, {`%}             IsShift := false         }         else SendInput 5     }     else if(LeftStick = "Right" AND RightStick = "Down"){         if(IsShift = true){             SendInput, ^             IsShift := false         }         else SendInput 6     }     else if(LeftStick = "Up Right" AND RightStick = "Down"){         if(IsShift = true){             SendInput, &             IsShift := false         }         else SendInput 7     }     else if(LeftStick = "Up" AND RightStick = "Down"){         if(IsShift = true){             SendInput *             IsShift := false         }         else SendInput 8     }     else if(LeftStick = "Up Left" AND RightStick = "Down"){         if(IsShift = true){             SendInput (             IsShift := false         }         else SendInput 9     }     else if(LeftStick = "Left" AND RightStick = "Down"){         if(IsShift = true){             SendInput )             IsShift := false         }         else SendInput 0     }                 if(key){             if(global IsShift = true){                 key -= 32                 IsShift = false             }         SendInput % Chr(key)     }   }