0001-renderers-Do-not-assume-all-keyboards-have-LEDs.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 709f21e80199ee51badff2d9b5dc6bae8af2a1a1 Mon Sep 17 00:00:00 2001
  2. From: n3rdopolis <bluescreen_avenger@verizon.net>
  3. Date: Wed, 31 Jan 2024 08:38:38 -0500
  4. Subject: [PATCH] renderers: Do not assume all keyboards have LEDs
  5. This is an attempt to fix #245
  6. ---
  7. src/plugins/renderers/drm/plugin.c | 22 +++++++++++++++++++--
  8. src/plugins/renderers/frame-buffer/plugin.c | 22 +++++++++++++++++++--
  9. 2 files changed, 40 insertions(+), 4 deletions(-)
  10. diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c
  11. index 54cfe874..2fbb6b85 100644
  12. --- a/src/plugins/renderers/drm/plugin.c
  13. +++ b/src/plugins/renderers/drm/plugin.c
  14. @@ -1972,6 +1972,17 @@ get_panel_properties (ply_renderer_backend_t *backend,
  15. return true;
  16. }
  17. +static ply_input_device_t *
  18. +get_any_input_device (ply_renderer_backend_t *backend)
  19. +{
  20. + ply_list_node_t *node = ply_list_get_first_node (backend->input_source.input_devices);
  21. +
  22. + if (node != NULL)
  23. + return ply_list_node_get_data (node);
  24. +
  25. + return NULL;
  26. +}
  27. +
  28. static ply_input_device_t *
  29. get_any_input_device_with_leds (ply_renderer_backend_t *backend)
  30. {
  31. @@ -1994,6 +2005,9 @@ get_capslock_state (ply_renderer_backend_t *backend)
  32. {
  33. if (using_input_device (&backend->input_source)) {
  34. ply_input_device_t *dev = get_any_input_device_with_leds (backend);
  35. + if (!dev)
  36. + return false;
  37. +
  38. return ply_input_device_get_capslock_state (dev);
  39. }
  40. if (!backend->terminal)
  41. @@ -2006,8 +2020,12 @@ static const char *
  42. get_keymap (ply_renderer_backend_t *backend)
  43. {
  44. if (using_input_device (&backend->input_source)) {
  45. - ply_input_device_t *dev = get_any_input_device_with_leds (backend);
  46. - const char *keymap = ply_input_device_get_keymap (dev);
  47. + const char *keymap;
  48. + ply_input_device_t *dev = get_any_input_device (backend);
  49. + if (!dev)
  50. + return NULL;
  51. +
  52. + keymap = ply_input_device_get_keymap (dev);
  53. if (keymap != NULL) {
  54. return keymap;
  55. }
  56. diff --git a/src/plugins/renderers/frame-buffer/plugin.c b/src/plugins/renderers/frame-buffer/plugin.c
  57. index e57d0437..3d56116e 100644
  58. --- a/src/plugins/renderers/frame-buffer/plugin.c
  59. +++ b/src/plugins/renderers/frame-buffer/plugin.c
  60. @@ -821,6 +821,17 @@ close_input_source (ply_renderer_backend_t *backend,
  61. backend->input_source_is_open = false;
  62. }
  63. +static ply_input_device_t *
  64. +get_any_input_device (ply_renderer_backend_t *backend)
  65. +{
  66. + ply_list_node_t *node = ply_list_get_first_node (backend->input_source.input_devices);
  67. +
  68. + if (node != NULL)
  69. + return ply_list_node_get_data (node);
  70. +
  71. + return NULL;
  72. +}
  73. +
  74. static ply_input_device_t *
  75. get_any_input_device_with_leds (ply_renderer_backend_t *backend)
  76. {
  77. @@ -843,6 +854,9 @@ get_capslock_state (ply_renderer_backend_t *backend)
  78. {
  79. if (using_input_device (&backend->input_source)) {
  80. ply_input_device_t *dev = get_any_input_device_with_leds (backend);
  81. + if (!dev)
  82. + return false;
  83. +
  84. return ply_input_device_get_capslock_state (dev);
  85. }
  86. if (!backend->terminal)
  87. @@ -855,8 +869,12 @@ static const char *
  88. get_keymap (ply_renderer_backend_t *backend)
  89. {
  90. if (using_input_device (&backend->input_source)) {
  91. - ply_input_device_t *dev = get_any_input_device_with_leds (backend);
  92. - const char *keymap = ply_input_device_get_keymap (dev);
  93. + const char *keymap;
  94. + ply_input_device_t *dev = get_any_input_device (backend);
  95. + if (!dev)
  96. + return NULL;
  97. +
  98. + keymap = ply_input_device_get_keymap (dev);
  99. if (keymap != NULL) {
  100. return keymap;
  101. }
  102. --
  103. 2.43.0