Read InputPrefs DoubleClick
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    beworld
    Posts: 598 from 2010/2/10
    From: FRANCE
    hi

    I search to have interval of double click mouse of system/preferences with SDL2 (C).

    I want implement this (SDL2 OS4 version) :

    Code:

    static Uint32
    OS4_GetDoubleClickTimeInMillis(_THIS)
    {
    struct Preferences preferences;
    Uint32 interval;

    IIntuition->GetPrefs(&preferences, sizeof(preferences));

    interval = preferences.DoubleClick.Seconds * 1000 +
    preferences.DoubleClick.Microseconds / 1000;

    dprintf("Doubleclick time %d msn", interval);

    return interval;
    }


    If you have a little code for MorphOS to help me.

    thanks you
    IMac G5 2.1,PowerBook G4 1.5,MacMini 1.5, PowerMac G5 2.7 died !!!
    My MOS ports
  • »29.04.20 - 21:46
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 3092 from 2003/3/5
    From: Canada
    You'd have to parse sys/mouse.conf with ReadArgs(). There's DoubleClickS and DoubleClickM there. When missing/empty file, the default is 0.5s.
  • »30.04.20 - 00:44
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    beworld
    Posts: 598 from 2010/2/10
    From: FRANCE
    Ok thanks,

    We try it, but ReadArgs have not effet here, if you can help us ? thanks

    Here example :

    Code:

    static Uint32
    AMIGA_GetDoubleClickTimeInMillis(_THIS)
    {
    Uint32 interval = 500;

    struct RDArgs rda;
    SDL_memset(&rda, 0, sizeof(rda));
    rda.RDA_Source.CS_Buffer = (STRPTR)SDL_LoadFile("ENV:sys/mouse.conf", &rda.RDA_Source.CS_Length);
    if (rda.RDA_Source.CS_Buffer) {
    LONG array[2] = {0, 0};
    if (ReadArgs("DoubleClickS/K/N/A,DoubleClickM/K/N/A", array, &rda)) {
    interval = array[0] * 1000 + array[1] / 1000;
    FreeArgs(&rda);
    }
    SDL_free(rda.RDA_Source.CS_Buffer);
    }
    return interval;
    }


    Source from BSzili :
    https://pastebin.com/rMdiJGEm?fbclid=IwAR21iA56dbA5HTtkXCf9FUHDm_ZeKQAizzF2WLA6kClz4f8a3bj0cX6pDTI


    [ Edité par beworld 01.05.2020 - 12:01 ]
    IMac G5 2.1,PowerBook G4 1.5,MacMini 1.5, PowerMac G5 2.7 died !!!
    My MOS ports
  • »01.05.20 - 10:55
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 3092 from 2003/3/5
    From: Canada
    https://pastebin.com/1HMHnYgd

    (you don't need that but you should get the idea, this is how Mouse.mprefs loads the file)

    [ Edited by jacadcaps 01.05.2020 - 13:36 ]
  • »01.05.20 - 12:36
    Profile Visit Website
  • MorphOS Developer
    Piru
    Posts: 587 from 2003/2/24
    From: finland, the l...
    Quote:

    beworld wrote:
    Code:

    static Uint32
    AMIGA_GetDoubleClickTimeInMillis(_THIS)
    {
    Uint32 interval = 500;

    struct RDArgs rda;
    SDL_memset(&rda, 0, sizeof(rda));
    rda.RDA_Source.CS_Buffer = (STRPTR)SDL_LoadFile("ENV:sys/mouse.conf", &rda.RDA_Source.CS_Length);
    if (rda.RDA_Source.CS_Buffer) {
    LONG array[2] = {0, 0};
    if (ReadArgs("DoubleClickS/K/N/A,DoubleClickM/K/N/A", array, &rda)) {
    interval = array[0] * 1000 + array[1] / 1000;
    FreeArgs(&rda);
    }
    SDL_free(rda.RDA_Source.CS_Buffer);
    }
    return interval;
    }


    Source from BSzili :
    https://pastebin.com/rMdiJGEm?fbclid=IwAR21iA56dbA5HTtkXCf9FUHDm_ZeKQAizzF2WLA6kClz4f8a3bj0cX6pDTI



    I'd just like to point out the problems in the code in case anyone wants to know why it doesn't work right:

    1. rda.RDA_Source.CS_Length is not set. This should be set to the size of the buffer.
    2. There can be more than DoubleClick ad DoubleClickM parameters in the string. The code will only handle those two and fail if there are other options available. This could be fixed by adding ",OTHERSTUFF/F" to template and 3rd array element.
    3. /N will result in *pointer* to LONG being placed to array index, not the integer itself. So LONG *ARRAY[3] would be more correct and then using *array[0] and *array[1].

    Bonus:
    4. Some version of ReadArgs() won't work right unless if the input string is terminated by a linefeed. If the code needs to be portable it should be ensured that linefeed is there. This is not necessary for MorphOS however.
  • »01.05.20 - 13:38
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    BSzili
    Posts: 559 from 2012/6/8
    From: Hungary
    Thanks for the help. CS_Length is set here by SDL_LoadFile:
    Code:
    rda.RDA_Source.CS_Buffer = (STRPTR)SDL_LoadFile("ENV:sys/mouse.conf", &rda.RDA_Source.CS_Length)

    I'll fix the rest. Here's the the working version.

    [ Edited by BSzili 01.05.2020 - 18:10 ]
    This is just like television, only you can see much further.
  • »01.05.20 - 15:34
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    beworld
    Posts: 598 from 2010/2/10
    From: FRANCE
    Thanks for the help.
    IMac G5 2.1,PowerBook G4 1.5,MacMini 1.5, PowerMac G5 2.7 died !!!
    My MOS ports
  • »01.05.20 - 18:42
    Profile Visit Website