@@ -585,6 +585,131 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void);
585
585
*/
586
586
extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme (void );
587
587
588
+ /**
589
+ * An enumeration of various boolean system preferences.
590
+ *
591
+ * Some systems provide a variety of accessibility options that allow users to
592
+ * adapt their environment to various conditions.
593
+ *
594
+ * The preference names have been chosen so that `true` indicate a positive
595
+ * preference, whereas `false` indicate no preference. Some systems describe
596
+ * their preferences negatively, like "Enable animations" on Windows, which is
597
+ * `true` by default (no preference) and `false` when the user wants to disable
598
+ * animations. In these situations, SDL inverts the preferences so that `false`
599
+ * correspond to the situation where no particular change is needed.
600
+ *
601
+ * \since This enum is available since SDL 3.4.0.
602
+ *
603
+ * \sa SDL_GetSystemPreference
604
+ */
605
+ typedef enum SDL_SystemPreference
606
+ {
607
+ SDL_SYSTEM_PREFERENCE_REDUCED_MOTION , /**< Disable smooth graphical transitions */
608
+ SDL_SYSTEM_PREFERENCE_REDUCED_TRANSPARENCY , /**< Reduce usage of semi-transparent objects */
609
+ SDL_SYSTEM_PREFERENCE_HIGH_CONTRAST , /**< Use extreme color differences between different elements of the interface */
610
+ SDL_SYSTEM_PREFERENCE_COLORBLIND , /**< Add shape-based distinction between color-coded elements, for example "0" and "1" on switches */
611
+ SDL_SYSTEM_PREFERENCE_PERSIST_SCROLLBARS , /**< Always show scrollbars, don't hide them after a few seconds of inactivity */
612
+ SDL_SYSTEM_PREFERENCE_SCREEN_READER , /**< A screen reader (text-to-speech OR braille) is currently active */
613
+ } SDL_SystemPreference ;
614
+
615
+ /**
616
+ * Get whether or not a certain system preference was enabled by the user.
617
+ *
618
+ * Some preferences may not be supported on some platforms; this function will
619
+ * return false by default in this case. The preference names have been chosen
620
+ * so that `true` indicate a positive preference, whereas `false` indicate no
621
+ * preference.
622
+ *
623
+ * This setting will emit a `SDL_EVENT_SYSTEM_PREFERENCE_CHANGED` when the user
624
+ * updates the corresponding preference in their settings or accessibility app.
625
+ * Note that some platforms may provide certain settings, but not allow
626
+ * listening to changes; as such, there may be certain preferences that can be
627
+ * fetched but that won't produce events when they are changed.
628
+ *
629
+ * \param preference the preference to be fetched.
630
+ * \returns true if the user enabled the system preference; false if the user
631
+ * did not activate the setting, or the setting doesn't exist on the
632
+ * current platform, or an error occured.
633
+ *
634
+ * \threadsafety This function should only be called on the main thread.
635
+ *
636
+ * \since This function is available since SDL 3.4.0.
637
+ *
638
+ * \sa SDL_SystemPreference
639
+ * \sa SDL_PreferenceEvent
640
+ */
641
+ extern SDL_DECLSPEC bool SDLCALL SDL_GetSystemPreference (SDL_SystemPreference preference );
642
+
643
+ /**
644
+ * Get the system's accent color, as chosen by the user.
645
+ *
646
+ * If the current system does not have an accent color, false is returned and
647
+ * the struct is unaffected.
648
+ *
649
+ * This setting will emit a `SDL_EVENT_SYSTEM_ACCENT_COLOR_CHANGED` when the
650
+ * user updates the corresponding preference in their settings or accessibility
651
+ * app. Note that some platforms may provide certain settings, but not allow
652
+ * listening to changes; as such, there may be certain preferences that can be
653
+ * fetched but that won't produce events when they are changed.
654
+ *
655
+ * \param color a pointer to a struct to be filled with the color info. The
656
+ * alpha channel corresponds to the value returned by operating
657
+ * system, which is not necessarily equivalent to SDL_ALPHA_OPAQUE.
658
+ * \returns true on success or false on failure; call SDL_GetError() for more
659
+ * information.
660
+ *
661
+ * \threadsafety This function should only be called on the main thread.
662
+ *
663
+ * \since This function is available since SDL 3.4.0.
664
+ */
665
+ extern SDL_DECLSPEC bool SDLCALL SDL_GetSystemAccentColor (SDL_Color * color );
666
+
667
+ /**
668
+ * Get the scale factor for text, as set by the user for their system.
669
+ *
670
+ * Some systems do not have a notion of text scale factor, but instead provide
671
+ * a base font size. In this case, SDL calculates a scaling factor by dividing
672
+ * the given font size by 16 pixels.
673
+ *
674
+ * If the system does not have a setting to scale the font, 1 is returned.
675
+ *
676
+ * This setting will emit a `SDL_EVENT_SYSTEM_TEXT_SCALE_CHANGED` when the user
677
+ * updates the corresponding preference in their settings or accessibility app.
678
+ * Note that some platforms may provide certain settings, but not allow
679
+ * listening to changes; as such, there may be certain preferences that can be
680
+ * fetched but that won't produce events when they are changed.
681
+ *
682
+ * \returns the preferred scale for text; a scale of 1 means no scaling.
683
+ *
684
+ * \threadsafety This function should only be called on the main thread.
685
+ *
686
+ * \since This function is available since SDL 3.4.0.
687
+ */
688
+ extern SDL_DECLSPEC float SDLCALL SDL_GetSystemTextScale (void );
689
+
690
+ /**
691
+ * Get the scale factor for the cursor, as set by the user for their system.
692
+ *
693
+ * Some systems do not have a notion of cursor scale factor, but instead provide
694
+ * a base cursor size. In this case, SDL calculates a scaling factor by dividing
695
+ * the given cursor lateral size by 32 pixels.
696
+ *
697
+ * If the system does not have a setting to scale the cursor, 1 is returned.
698
+ *
699
+ * This setting will emit a `SDL_EVENT_SYSTEM_CURSOR_SCALE_CHANGED` when the
700
+ * user updates the corresponding preference in their settings or accessibility
701
+ * app. Note that some platforms may provide certain settings, but not allow
702
+ * listening to changes; as such, there may be certain preferences that can be
703
+ * fetched but that won't produce events when they are changed.
704
+ *
705
+ * \returns the preferred scale for the cursor; a scale of 1 means no scaling.
706
+ *
707
+ * \threadsafety This function should only be called on the main thread.
708
+ *
709
+ * \since This function is available since SDL 3.4.0.
710
+ */
711
+ extern SDL_DECLSPEC float SDLCALL SDL_GetSystemCursorScale (void );
712
+
588
713
/**
589
714
* Get a list of currently connected displays.
590
715
*
0 commit comments