• MorphOS Developer
    Piru
    Posts: 580 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