xref: /btstack/platform/qt/btstack_run_loop_qt.h (revision 9988cd6f47e1b527b9e08dd8e33df29ca28e3b7a)
11b464e99SMatthias Ringwald /*
21b464e99SMatthias Ringwald  * Copyright (C) 2019 BlueKitchen GmbH
31b464e99SMatthias Ringwald  *
41b464e99SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
51b464e99SMatthias Ringwald  * modification, are permitted provided that the following conditions
61b464e99SMatthias Ringwald  * are met:
71b464e99SMatthias Ringwald  *
81b464e99SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
91b464e99SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
101b464e99SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
111b464e99SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
121b464e99SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
131b464e99SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
141b464e99SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
151b464e99SMatthias Ringwald  *    from this software without specific prior written permission.
161b464e99SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
171b464e99SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
181b464e99SMatthias Ringwald  *    monetary gain.
191b464e99SMatthias Ringwald  *
201b464e99SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
211b464e99SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
221b464e99SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
231b464e99SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
241b464e99SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
251b464e99SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
261b464e99SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
271b464e99SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
281b464e99SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
291b464e99SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
301b464e99SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311b464e99SMatthias Ringwald  * SUCH DAMAGE.
321b464e99SMatthias Ringwald  *
331b464e99SMatthias Ringwald  * Please inquire about commercial licensing options at
341b464e99SMatthias Ringwald  * [email protected]
351b464e99SMatthias Ringwald  *
361b464e99SMatthias Ringwald  */
371b464e99SMatthias Ringwald 
381b464e99SMatthias Ringwald /*
391b464e99SMatthias Ringwald  *  btstack_run_loop_qt.h
401b464e99SMatthias Ringwald  *  Functionality special to the Qt event loop
411b464e99SMatthias Ringwald  */
421b464e99SMatthias Ringwald 
431b464e99SMatthias Ringwald #ifndef btstack_run_loop_QT_H
441b464e99SMatthias Ringwald #define btstack_run_loop_QT_H
451b464e99SMatthias Ringwald 
461b464e99SMatthias Ringwald #include "btstack_run_loop.h"
471b464e99SMatthias Ringwald 
481b464e99SMatthias Ringwald // BTstack Run Loop Object for Qt integration
491b464e99SMatthias Ringwald #if defined __cplusplus
501b464e99SMatthias Ringwald #include <QObject>
511b464e99SMatthias Ringwald #include <QTimer>
52*9988cd6fSMatthias Ringwald #ifdef Q_OS_WIN
53*9988cd6fSMatthias Ringwald #include <windows.h>
54*9988cd6fSMatthias Ringwald #include <QWinEventNotifier>
55*9988cd6fSMatthias Ringwald #endif
561b464e99SMatthias Ringwald class BTstackRunLoopQt : public QObject {
571b464e99SMatthias Ringwald     Q_OBJECT
581b464e99SMatthias Ringwald public slots:
591b464e99SMatthias Ringwald     void processTimers(void);
60*9988cd6fSMatthias Ringwald #ifdef Q_OS_WIN
61*9988cd6fSMatthias Ringwald     void processDataSource(HANDLE handle);
62*9988cd6fSMatthias Ringwald #endif
631b464e99SMatthias Ringwald };
641b464e99SMatthias Ringwald #endif
651b464e99SMatthias Ringwald 
661b464e99SMatthias Ringwald #if defined __cplusplus
671b464e99SMatthias Ringwald extern "C" {
681b464e99SMatthias Ringwald #endif
691b464e99SMatthias Ringwald 
701b464e99SMatthias Ringwald /**
711b464e99SMatthias Ringwald  * Provide btstack_run_loop_qt instance
721b464e99SMatthias Ringwald  */
731b464e99SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_qt_get_instance(void);
741b464e99SMatthias Ringwald 
751b464e99SMatthias Ringwald /* API_END */
761b464e99SMatthias Ringwald 
771b464e99SMatthias Ringwald #if defined __cplusplus
781b464e99SMatthias Ringwald }
791b464e99SMatthias Ringwald #endif
801b464e99SMatthias Ringwald 
811b464e99SMatthias Ringwald #endif // btstack_run_loop_QT_H
82