• Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    beworld
    Posts: 590 from 2010/2/10
    From: FRANCE
    @Jaca : thanks.

    Other question.

    When new Sensor is detected by SensorsNotificationMessage,
    how to put it in exist sensorlist (opened before) ?

    I dint want use ReleaseSensorsList and ObtainSensorsList again because
    i lost all child sensor on other joystick after that.

    Code is an example incomplete : Init call first, and Update is call non-stop (SDL2)

    Code:

    APTR sensorlist;
    APTR sensorchild_list[32];
    struct MsgPort *notifyPort
    APTR sensorsNotify;
    ULONG joystick_count;

    static void Init() {
    APTR sensor = NULL;
    ULONG count = 0;
    sensorlist = ObtainSensorsListTags(SENSOR_Class, SensorClass_HID, TAG_DONE);
    while (sensor = NextSensor(sensor, sensorlist, NULL)) {
    sensorchild_list[count++] = sensor;
    }
    joystick_count = count;
    if (notifyPort = CreateMsgPort()) {
    sensorsNotify = StartSensorNotifyTags(NULL,
    SENSORS_Notification_Destination, (IPTR)notifyPort,
    SENSORS_Class, SensorClass_HID,
    SENSORS_Notification_ClassListChanged, TRUE,
    SENSORS_Notification_Removed, FALSE,
    TAG_DONE);
    }

    }

    static void update()
    {
    if (notifyPort) {
    struct SensorsNotificationMessage *notifyMsg;
    while ((notifyMsg = (struct SensorsNotificationMessage *)GetMsg(notifyPort))) {
    sensorchild_list[joystick_count] = notifyMsg->Sensor;
    joystick_count++;
    ReplyMsg(notifyMsg);
    }

    }



    in Update, notifyMsg->Sensor give a new Sensor, but i can read it after because not present in sensoslist...
    Any little help, thanks, I hope it's understandable...

    BeWorld


    [ Edité par beworld 04.05.2020 - 16:36 ]
    IMac G5 2.1,PowerBook G4 1.5,MacMini 1.5, PowerMac G5 2.7 died !!!
    My MOS ports
  • »04.05.20 - 15:25
    Profile Visit Website