SemlerPDX

AVCS Ready or Not Key Bindings File Parser v4

Jan 16th, 2022 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.82 KB | None | 0 0
  1. ' Ready Or Not - Key Binds File Parsing System v4
  2. '  by SemlerPDX Dec2021
  3. '  VETERANS-GAMING.COM
  4. ' --Loads Keys from user input game settings file into VoiceAttack Global Keypress Variables
  5.  
  6.  
  7. Imports Microsoft.VisualBasic
  8. Imports System
  9. Imports System.Linq
  10. Imports System.Collections
  11. Imports System.Collections.Generic
  12.  
  13. Public Class VAInline
  14.    
  15.     dim NumbersArray() as string = {
  16.         "Zero",
  17.         "One",
  18.         "Two",
  19.         "Three",
  20.         "Four",
  21.         "Five",
  22.         "Six",
  23.         "Seven",
  24.         "Eight",
  25.         "Nine"
  26.     }
  27.     dim NumPadArray() as string = {
  28.         "NumPadZero",
  29.         "NumPadOne",
  30.         "NumPadTwo",
  31.         "NumPadThree",
  32.         "NumPadFour",
  33.         "NumPadFive",
  34.         "NumPadSix",
  35.         "NumPadSeven",
  36.         "NumPadEight",
  37.         "NumPadNine"
  38.     }
  39.     dim FunctionKeysArray() as string = {
  40.         "F1",
  41.         "F2",
  42.         "F3",
  43.         "F4",
  44.         "F5",
  45.         "F6",
  46.         "F7",
  47.         "F8",
  48.         "F9",
  49.         "F10",
  50.         "F11",
  51.         "F12"
  52.     }
  53.     dim keyID as string = ""
  54.     dim keyLabel as string = ""
  55.     dim keyData() as string
  56.     dim contents() as string
  57.     dim actionMapping() as string
  58.     dim setMouse as boolean = false
  59.     dim labelsFinal as new list(of string) ()
  60.    
  61.     Private Function ProcessKeyboardKey(ByVal thisKey as string, ByVal thisLabel as string)
  62.         if not(thisKey.Contains("Gamepad"))
  63.             select case thisKey
  64.                 case "SpaceBar"
  65.                     thisKey = "[SPACE]"
  66.                 case "Decimal"
  67.                     thisKey = "[NUM.]"
  68.                 case "Subtract"
  69.                     thisKey = "[NUM-]"
  70.                 case "Add"
  71.                     thisKey = "[NUM+]"
  72.                 case "Multiply"
  73.                     thisKey = "[NUM*]"
  74.                 case "Divide"
  75.                     thisKey = "[NUM/]"
  76.                 case "Up"
  77.                     thisKey = "[ARROWU]"
  78.                 case "Down"
  79.                     thisKey = "[ARROWD]"
  80.                 case "Left"
  81.                     thisKey = "[ARROWL]"
  82.                 case "Right"
  83.                     thisKey = "[ARROWR]"
  84.                 case "LeftShift"
  85.                     thisKey = "[LSHIFT]"
  86.                 case "RightShift"
  87.                     thisKey = "[RSHIFT]"
  88.                 case "LeftControl"
  89.                     thisKey = "[LCTRL]"
  90.                 case "RightControl"
  91.                     thisKey = "[RCTRL]"
  92.                 case "LeftCommand"
  93.                     thisKey = "[LWIN]"
  94.                 case "RightCommand"
  95.                     thisKey = "[RWIN]"
  96.                 case "Tilde"
  97.                     thisKey = "`"
  98.                 case "Comma"
  99.                     thisKey = ","
  100.                 case "Period"
  101.                     thisKey = "."
  102.                 case "Slash"
  103.                     thisKey = "/"
  104.                 case "Semicolon"
  105.                     thisKey = ";"
  106.                 case "Apostrophe"
  107.                     thisKey = "'"
  108.                 case "Backslash"
  109.                     thisKey = "\"
  110.                 case "Pause"
  111.                     thisKey = "[BREAK]"
  112.                 case else
  113.                     if (NumbersArray.Contains(thisKey))
  114.                         for i as integer = 0 to 9
  115.                             if (NumbersArray(i) = thisKey)
  116.                                 thisKey = i.ToString()
  117.                             end if
  118.                         next
  119.                     else if (NumPadArray.Contains(thisKey))
  120.                         for i as integer = 0 to 9
  121.                             if (NumPadArray(i) = thisKey)
  122.                                 thisKey = "[NUM" + i.ToString() + "]"
  123.                             end if
  124.                         next
  125.                     else if (FunctionKeysArray.Contains(thisKey))
  126.                         for i as integer = 0 to 11
  127.                             if (FunctionKeysArray(i) = thisKey)
  128.                                 thisKey = "[" + FunctionKeysArray(i) + "]"
  129.                             end if
  130.                         next
  131.                     else if (thisKey.Contains("Mouse"))
  132.                         setMouse = false
  133.                         select case thisLabel
  134.                             case "Fire"
  135.                                 if (thisKey = "LeftMouseButton")
  136.                                     setMouse = true
  137.                                 end if
  138.                             case "ToggleADS"
  139.                                 if (thisKey = "RightMouseButton")
  140.                                     setMouse = true
  141.                                 end if
  142.                             case "OpenSwatCommand"
  143.                                 if (thisKey = "MiddleMouseButton")
  144.                                     setMouse = true
  145.                                 end if
  146.                             case "CycleSwatElementNext"
  147.                                 if (thisKey = "MouseScrollUp")
  148.                                     setMouse = true
  149.                                 end if
  150.                             case "CycleSwatElementPrevious"
  151.                                 if (thisKey = "MouseScrollDown")
  152.                                     setMouse = true
  153.                                 end if
  154.                             case else
  155.                                 setMouse = false
  156.                         end select
  157.                         thisKey = "NONE"
  158.                         if (setMouse)
  159.                             VA.SetBoolean("AVCS_RON_Mouse_" + thisLabel, true)
  160.                         end if
  161.                     else
  162.                         thisKey = "[" + thisKey.ToUpper() + "]"
  163.                     end if
  164.             end select
  165.         else
  166.             thisKey = "NONE"
  167.         end if
  168.         return thisKey
  169.     end function
  170.    
  171.     Public Sub Main()
  172.        
  173.         if (VA.GetText("~key_file") isNot nothing)
  174.             contents = VA.GetText("~key_file").Split(new string() {Environment.NewLine},StringSplitOptions.None)
  175.             for each line as string in contents
  176.                 if (line <> "")
  177.                     'Example:
  178.                     'ActionMappings=(ActionName="DrawSting",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=NumPadZero)
  179.                     if (line.StartsWith("ActionMappings"))
  180.                         actionMapping = line.Split("(")
  181.                         keyData = actionMapping(1).Split(",")
  182.                         keyLabel = keyData(0).Substring(12).TrimEnd("""")
  183.                         keyID = keyData(5).Substring(4).TrimEnd(")")
  184.                         if not((keyLabel = "") or (labelsFinal.Contains(keyLabel)))
  185.                             keyID = ProcessKeyboardKey(keyID, keyLabel)
  186.                             if (keyID <> "NONE")
  187.                                 labelsFinal.Add(keyLabel)
  188.                                 VA.SetText("AVCS_RON_KEY_" + keyLabel, keyID)
  189.                             end if
  190.                         end if
  191.                     end if
  192.                 end if
  193.             next
  194.             VA.WriteToLog("AVCS4 RoN - Keyboard Settings File loaded into Keypress Variables", "gray")
  195.         end if
  196.        
  197.     End Sub
  198. End Class
Add Comment
Please, Sign In to add comment