Module: SDL2::Hints

Defined in:
hint.c,
hint.c

Overview

This module enables you to get and set configuration hints.

Constant Summary

DEFAULT =

low priority, used fro default values

INT2NUM(SDL_HINT_DEFAULT)
NORMAL =

medium priority, overrided by an environment variable

INT2NUM(SDL_HINT_NORMAL)
OVERRIDE =

high priority, this priority overrides the value by environment variables

INT2NUM(SDL_HINT_OVERRIDE)

Class Method Summary collapse

Class Method Details

.[]=(hint, value) ⇒ Boolean .[]=(hint, priority: , value) ⇒ Boolean

Set the value of a hint.

Examples:

SDL2::Hints["SDL_HINT_XINPUT_ENABLED", priority: SDL2::Hints::OVERRIDE] = "0"

Overloads:

  • .[]=(hint, value) ⇒ Boolean

    Set a hint with normal priority.

    Parameters:

    • hint (String)

      the name of the hint to query

    • value (String)

      the value of the hint varaible

  • .[]=(hint, priority: , value) ⇒ Boolean

    Set a hint with given priority.

    Parameters:

    • hint (String)

      the name of the hint to query

    • priority (Integer)

      the priority, one of the DEFAULT, NORMAL, or OVERRIDE.

    • value (String)

      the value of the hint varaible

Returns:

  • (Boolean)

    return true if the hint was set



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'hint.c', line 65

static VALUE Hints_s_aset(int argc, VALUE* argv, VALUE self)
{
    VALUE name, pri, value;
    rb_scan_args(argc, argv, "21", &name, &pri, &value);
    
    if (argc == 2) {
        value = pri;
        return INT2BOOL(SDL_SetHint(StringValueCStr(name), StringValueCStr(value)));
    } else {
        Check_Type(pri, T_HASH);
        return INT2BOOL(SDL_SetHintWithPriority(StringValueCStr(name),
                                                StringValueCStr(value),
                                                NUM2INT(rb_hash_aref(pri, sym_priority))));
    }
        
    return Qnil;
}

.clearnil

Clear all hints set by []=.

Returns:

  • (nil)


18
19
20
21
22
# File 'hint.c', line 18

static VALUE Hints_s_clear(VALUE self)
{
    SDL_ClearHints();
    return Qnil;
}

.[](hint) ⇒ String?

Get the value of a hint.

Parameters:

  • hint (String)

    the name of the hint to query

Returns:

  • (String)

    the string value of a hint

  • (nil)

    if the hint isn’t set



33
34
35
36
37
38
39
40
# File 'hint.c', line 33

static VALUE Hints_s_aref(VALUE self, VALUE name)
{
    const char* value = SDL_GetHint(StringValueCStr(name));
    if (value)
        return utf8str_new_cstr(value);
    else
        return Qnil;
}