• Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    beworld
    Posts: 590 from 2010/2/10
    From: FRANCE
    In SDL2, there is an function to Init Joystick, this fonction just store device in list. (and return number of deveice)

    In my first version, i dont have any problem because i dont use notification support (no hotplug).
    But if i want to support it, i need to rewrite all with notification support.

    Actualy Sources: https://github.com/BSzili/SDL/blob/mos-sdl2/src/joystick/morphos/SDL_sysjoystick.c
    Code:
    static int
    SDL_SYS_JoystickInit(void)
    {
    int rc = -1;

    APTR sensor = NULL;
    ULONG count = 0;

    D("[%s] Obtain sensor list...n", __FUNCTION__);
    sensorlist = ObtainSensorsListTags(SENSORS_Class, SensorClass_HID, /*SENSORS_Type, SensorType_HID_Gamepad,*/ TAG_DONE);
    while ((sensor = NextSensor(sensor, sensorlist, NULL)) && count < MAX_JOYSTICKS)
    {
    JoySensor[count++] = sensor;
    }

    D("[%s] Found %ld joysticks...n", __FUNCTION__, count);
    joystick_count = count;
    rc = count;
    return rc;
    }



    If i have an ID unique for it, i could store just this ID on my joystick list, no need to store Sensor or SensorNotify on my list and no need to start Notify on joystick (maybe just need StartSensorNotify to detect new device)

    When i open Joystick, i could start all notifications on device and close it when i close my joystick.

    And with that i can identify easily witch device plug or unplug and find it in my first list..
    IMac G5 2.1,PowerBook G4 1.5,MacMini 1.5, PowerMac G5 2.7 died !!!
    My MOS ports
  • »09.05.20 - 14:57
    Profile Visit Website