<commit_before>#include <atomic>
#include <iostream>
#include <thread>

#include <libusb-1.0/libusb.h>

#include "common.h"
#include "switch-pro-x.h"

namespace {
    int HotplugCallback(struct libusb_context *ctx, struct libusb_device *dev, libusb_hotplug_event event, void *user_data)
    {
        switch (event)
        {
        case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED:
        {
            AddController(dev);
            break;
        }
        case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT:
        {
            RemoveController(dev);
            break;
        }
        }

        return 0;
    }
}

void SetupDeviceNotifications()
{
    libusb_init(nullptr);

    struct libusb_device **devices;

    libusb_hotplug_callback_handle callback;
    int hotplug_ret = libusb_hotplug_register_callback(
        nullptr,
        static_cast<libusb_hotplug_event>(LIBUSB_HOTPLUG_MATCH_ANY),
        LIBUSB_HOTPLUG_ENUMERATE,
        PRO_CONTROLLER_VID, PRO_CONTROLLER_PID,
        LIBUSB_HOTPLUG_MATCH_ANY,
        reinterpret_cast<libusb_hotplug_callback_fn>(HotplugCallback),
        nullptr,
        &callback);

    if (hotplug_ret != 0)
    {
        std::cerr << "cannot register hotplug callback (" << hotplug_ret << "), hotplugging not enabled" << std::endl;
    }

    // pump events until shutdown
    for (;;)
    {
        libusb_handle_events_completed(nullptr, nullptr);
    }
}<commit_msg>fix crash on 32-bit builds<commit_after>#include <atomic>
#include <iostream>
#include <thread>

#include <libusb-1.0/libusb.h>

#include "common.h"
#include "switch-pro-x.h"

namespace {
    int LIBUSB_CALL HotplugCallback(struct libusb_context *ctx, struct libusb_device *dev, libusb_hotplug_event event, void *user_data)
    {
        switch (event)
        {
        case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED:
        {
            AddController(dev);
            break;
        }
        case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT:
        {
            RemoveController(dev);
            break;
        }
        }

        return 0;
    }
}

void SetupDeviceNotifications()
{
    libusb_init(nullptr);

    libusb_hotplug_callback_handle callback;
    int hotplug_ret = libusb_hotplug_register_callback(
        nullptr,
        static_cast<libusb_hotplug_event>(LIBUSB_HOTPLUG_MATCH_ANY),
        LIBUSB_HOTPLUG_ENUMERATE,
        PRO_CONTROLLER_VID, PRO_CONTROLLER_PID,
        LIBUSB_HOTPLUG_MATCH_ANY,
        reinterpret_cast<libusb_hotplug_callback_fn>(HotplugCallback),
        nullptr,
        &callback);

    if (hotplug_ret != 0)
    {
        std::cerr << "cannot register hotplug callback (" << hotplug_ret << "), hotplugging not enabled" << std::endl;
    }

    // pump events until shutdown
    for (;;)
    {
        libusb_handle_events_completed(nullptr, nullptr);
    }
}
{'fraction_non_alphanumeric': 0.09227467811158799, 'fraction_numerical': 0.00357653791130186, 'mean_word_length': 2.646675358539765, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '393486', 'n_tokens_mistral': 949, 'n_tokens_neox': 921, 'n_words': 156}