| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2018 Torsten Sadowski <tsadowski[at]gmx.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
#ifndef GUINATIVEEVENT_H |
| 24 |
#define GUINATIVEEVENT_H |
| 25 |
|
| 26 |
#include "GuiAbstractNativeEvent.h" |
| 27 |
|
| 28 |
class QMainWindow; |
| 29 |
|
| 30 |
#include <IOKit/IOKitLib.h> |
| 31 |
#include <ConnexionClientAPI.h> |
| 32 |
extern int16_t SetConnexionHandlers( |
| 33 |
ConnexionMessageHandlerProc messageHandler, |
| 34 |
ConnexionAddedHandlerProc addedHandler, |
| 35 |
ConnexionRemovedHandlerProc removedHandler, |
| 36 |
bool useSeparateThread |
| 37 |
) __attribute__((weak_import)); |
| 38 |
// Note that InstallConnexionHandlers will be replaced with |
| 39 |
// SetConnexionHandlers "in the future". |
| 40 |
extern OSErr InstallConnexionHandlers( |
| 41 |
ConnexionMessageHandlerProc messageHandler, |
| 42 |
ConnexionAddedHandlerProc addedHandler, |
| 43 |
ConnexionRemovedHandlerProc removedHandler |
| 44 |
) __attribute__((weak_import)); |
| 45 |
extern UInt16 RegisterConnexionClient(UInt32 signature, UInt8* name, UInt16 mode, UInt32 mask) |
| 46 |
__attribute__((weak_import)); |
| 47 |
extern void SetConnexionClientMask(uint16_t clientID, uint32_t mask) __attribute__((weak_import)); |
| 48 |
extern void SetConnexionClientButtonMask(uint16_t clientID, uint32_t buttonMask) |
| 49 |
__attribute__((weak_import)); |
| 50 |
extern void UnregisterConnexionClient(UInt16 clientID) __attribute__((weak_import)); |
| 51 |
extern void CleanupConnexionHandlers(void) __attribute__((weak_import)); |
| 52 |
|
| 53 |
extern int16_t ConnexionControl(uint32_t message, int32_t param, int32_t* result); |
| 54 |
extern int16_t ConnexionClientControl(uint16_t clientID, uint32_t message, int32_t param, int32_t* result); |
| 55 |
extern int16_t ConnexionGetCurrentDevicePrefs(uint32_t deviceID, ConnexionDevicePrefs* prefs); |
| 56 |
extern int16_t ConnexionSetButtonLabels(uint8_t* labels, uint16_t size); |
| 57 |
|
| 58 |
namespace Gui |
| 59 |
{ |
| 60 |
class GUIApplicationNativeEventAware; |
| 61 |
|
| 62 |
class GuiNativeEvent: public GuiAbstractNativeEvent |
| 63 |
{ |
| 64 |
Q_OBJECT |
| 65 |
public: |
| 66 |
explicit GuiNativeEvent(GUIApplicationNativeEventAware* app); |
| 67 |
~GuiNativeEvent() override; |
| 68 |
void initSpaceball(QMainWindow* window) final; |
| 69 |
|
| 70 |
private: |
| 71 |
GuiNativeEvent(); |
| 72 |
GuiNativeEvent(const GuiNativeEvent&); |
| 73 |
GuiNativeEvent& operator=(const GuiNativeEvent&); |
| 74 |
|
| 75 |
private: |
| 76 |
static UInt16 tdxClientID; /* ID assigned by the driver */ |
| 77 |
static uint32_t lastButtons; |
| 78 |
static void tdx_drv_handler(io_connect_t connection, natural_t messageType, void* messageArgument); |
| 79 |
}; |
| 80 |
} // namespace Gui |
| 81 |
|
| 82 |
#endif // GUINATIVEEVENT_H |