joypad_button_textures.gd 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright (C) 2022-2023 John Pennycook
  2. # SPDX-License-Identifier: MIT
  3. @tool
  4. class_name JoypadButtonTextures
  5. extends Resource
  6. ## Textures used by a [JoypadButtonPrompt] or [ActionPrompt].
  7. ##
  8. ## Textures used by a [JoypadButtonPrompt] or [ActionPrompt]. Stores a texture
  9. ## for each joypad button index.
  10. ## Texture for Joypad Button 0 (Bottom Action, Sony Cross, Xbox A, Nintendo B)
  11. @export var button_0: Texture2D = null
  12. ## Texture for Joypad Button 1 (Right Action, Sony Circle, Xbox B, Nintendo A)
  13. @export var button_1: Texture2D = null
  14. ## Texture for Joypad Button 2 (Left Action, Sony Square, Xbox X, Nintendo Y)
  15. @export var button_2: Texture2D = null
  16. ## Texture for Joypad Button 3 (Top Action, Sony Triangle, Xbox Y, Nintendo X)
  17. @export var button_3: Texture2D = null
  18. ## Texture for Joypad Button 4 (Back, Sony Select, Xbox Back, Nintendo -)
  19. @export var button_4: Texture2D = null
  20. ## Texture for Joypad Button 5 (Guide, Sony PS, Xbox Home)
  21. @export var button_5: Texture2D = null
  22. ## Texture for Joypad Button 6 (Start, Nintendo +)
  23. @export var button_6: Texture2D = null
  24. ## Texture for Joypad Button 7 (Left Stick, Sony L3, Xbox L/LS)
  25. @export var button_7: Texture2D = null
  26. ## Texture for Joypad Button 8 (Right Stick, Sony R3, Xbox R/RS)
  27. @export var button_8: Texture2D = null
  28. ## Texture for Joypad Button 8 (Left Shoulder, Sony L1, Xbox LB)
  29. @export var button_9: Texture2D = null
  30. ## Texture for Joypad Button 9 (Right Shoulder, Sony R1, Xbox RB)
  31. @export var button_10: Texture2D = null
  32. ## Texture for Joypad Button 11 (D-pad Up)
  33. @export var button_11: Texture2D = null
  34. ## Texture for Joypad Button 12 (D-pad Down)
  35. @export var button_12: Texture2D = null
  36. ## Texture for Joypad Button 13 (D-pad Left)
  37. @export var button_13: Texture2D = null
  38. ## Texture for Joypad Button 14 (D-pad Right)
  39. @export var button_14: Texture2D = null
  40. ## Texture for Joypad Button 15 (Xbox Share, PS5 Microphone, Nintendo Capture)
  41. @export var button_15: Texture2D = null
  42. ## Texture for Joypad Button 16 (Xbox Paddle 1)
  43. @export var button_16: Texture2D = null
  44. ## Texture for Joypad Button 17 (Xbox Paddle 2)
  45. @export var button_17: Texture2D = null
  46. ## Texture for Joypad Button 18 (Xbox Paddle 3)
  47. @export var button_18: Texture2D = null
  48. ## Texture for Joypad Button 10 (Xbox Paddle 4)
  49. @export var button_19: Texture2D = null
  50. ## Texture for Joypad Button 20 (Xbox Paddle 2)
  51. @export var button_20: Texture2D = null
  52. ## Return the [Texture2D] associated with the specified [InputEvent], or null.
  53. func get_texture(event: InputEvent) -> Texture2D:
  54. if not event is InputEventJoypadButton:
  55. return null
  56. var joypad_event := event as InputEventJoypadButton
  57. var button := joypad_event.button_index
  58. return get("button_" + str(button))