utility.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. function getButtonBitmap(%device, %button)
  2. {
  3. if(%device $= "gamepad")
  4. {
  5. //In the event we passed in a generic gamepad device name, we'll try fetching the actual device here
  6. %device = SDLInputManager::JoystickNameForIndex(0);
  7. //If we couldn't figure out what it was, just use the generic Xbox images
  8. if(%device $= "")
  9. %device = "Xbox";
  10. }
  11. %path = "";
  12. if(%device $= "PS4")
  13. {
  14. %path = "data/ui/images/inputs/PS4/PS4_";
  15. if(%button $= "A" || %button $= "btn_a")
  16. %path = %path @ "Cross";
  17. else if(%button $= "B" || %button $= "btn_b")
  18. %path = %path @ "Circle";
  19. else if(%button $= "X" || %button $= "btn_x")
  20. %path = %path @ "Square";
  21. else if(%button $= "Y" || %button $= "btn_y")
  22. %path = %path @ "Triangle";
  23. else if(%button $= "LB")
  24. %path = %path @ "L1";
  25. else if(%button $= "LT")
  26. %path = %path @ "L2";
  27. else if(%button $= "RB")
  28. %path = %path @ "R1";
  29. else if(%button $= "RT")
  30. %path = %path @ "R2";
  31. else if(%button $= "thumbrx" || %button $= "thumbry")
  32. %path = %path @ "Right_Stick";
  33. else if(%button $= "thumblx" || %button $= "thumbly")
  34. %path = %path @ "Left_Stick";
  35. else if(%button $= "start")
  36. %path = %path @ "Options";
  37. else if(%button $= "back")
  38. %path = %path @ "Share";
  39. else if(%button $= "dpadu")
  40. %path = %path @ "Dpad_Up";
  41. else if(%button $= "dpadd")
  42. %path = %path @ "Dpad_Down";
  43. else if(%button $= "dpadl")
  44. %path = %path @ "Dpad_Left";
  45. else if(%button $= "dpadr")
  46. %path = %path @ "Dpad_Right";
  47. }
  48. else if(%device $= "Switch")
  49. {
  50. %path = "data/ui/images/inputs/Switch/Switch_";
  51. if(%button $= "A" || %button $= "btn_a")
  52. %path = %path @ "B";
  53. else if(%button $= "B" || %button $= "btn_b")
  54. %path = %path @ "A";
  55. else if(%button $= "X" || %button $= "btn_x")
  56. %path = %path @ "Y";
  57. else if(%button $= "Y" || %button $= "btn_y")
  58. %path = %path @ "X";
  59. else if(%button $= "LB")
  60. %path = %path @ "LB";
  61. else if(%button $= "LT")
  62. %path = %path @ "LT";
  63. else if(%button $= "RB")
  64. %path = %path @ "RB";
  65. else if(%button $= "RT")
  66. %path = %path @ "RT";
  67. else if(%button $= "thumbrx" || %button $= "thumbry")
  68. %path = %path @ "Right_Stick";
  69. else if(%button $= "thumblx" || %button $= "thumbly")
  70. %path = %path @ "Left_Stick";
  71. else if(%button $= "start")
  72. %path = %path @ "Plus";
  73. else if(%button $= "back")
  74. %path = %path @ "Minus";
  75. else if(%button $= "dpadu")
  76. %path = %path @ "Dpad_Up";
  77. else if(%button $= "dpadd")
  78. %path = %path @ "Dpad_Down";
  79. else if(%button $= "dpadl")
  80. %path = %path @ "Dpad_Left";
  81. else if(%button $= "dpadr")
  82. %path = %path @ "Dpad_Right";
  83. }
  84. else if(%device $= "Keyboard" || %device $= "Mouse")
  85. {
  86. %pathBase = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_";
  87. %path = %pathBase @ %button @ ".png";
  88. if(!isFile(%path))
  89. %path = %pathBase @ "Blank";
  90. }
  91. else if(%device !$= "")
  92. {
  93. %path = "data/ui/images/inputs/Xbox/Xbox_";
  94. if(%button $= "btn_a")
  95. %path = %path @ "B";
  96. else if(%button $= "btn_b")
  97. %path = %path @ "A";
  98. else if(%button $= "btn_x")
  99. %path = %path @ "Y";
  100. else if(%button $= "btn_y")
  101. %path = %path @ "X";
  102. else if(%button $= "thumbrx" || %button $= "thumbry")
  103. %path = %path @ "Right_Stick";
  104. else if(%button $= "thumblx" || %button $= "thumbly")
  105. %path = %path @ "Left_Stick";
  106. else if(%button $= "start")
  107. %path = %path @ "Menu";
  108. else if(%button $= "back")
  109. %path = %path @ "Windows";
  110. else if(%button $= "dpadu")
  111. %path = %path @ "Dpad_Up";
  112. else if(%button $= "dpadd")
  113. %path = %path @ "Dpad_Down";
  114. else if(%button $= "dpadl")
  115. %path = %path @ "Dpad_Left";
  116. else if(%button $= "dpadr")
  117. %path = %path @ "Dpad_Right";
  118. }
  119. return %path;
  120. }