| 1 | // FGHIDEventInput.hxx -- handle event driven input devices via HIDAPI |
| 2 | // |
| 3 | // Written by James Turner |
| 4 | // |
| 5 | // Copyright (C) 2017, James Turner <[email protected]> |
| 6 | // |
| 7 | // This program is free software; you can redistribute it and/or |
| 8 | // modify it under the terms of the GNU General Public License as |
| 9 | // published by the Free Software Foundation; either version 2 of the |
| 10 | // License, or (at your option) any later version. |
| 11 | // |
| 12 | // This program is distributed in the hope that it will be useful, but |
| 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | // General Public License for more details. |
| 16 | // |
| 17 | // You should have received a copy of the GNU General Public License |
| 18 | // along with this program; if not, write to the Free Software |
| 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | // |
| 21 | |
| 22 | |
| 23 | #ifndef __FGHIDEVENTINPUT_HXX_ |
| 24 | #define __FGHIDEVENTINPUT_HXX_ |
| 25 | |
| 26 | #include <memory> |
| 27 | |
| 28 | #include "FGEventInput.hxx" |
| 29 | |
| 30 | |
| 31 | int extractBits(uint8_t* bytes, size_t lengthInBytes, size_t bitOffset, size_t bitSize); |
| 32 | int signExtend(int inValue, size_t bitSize); |
| 33 | void writeBits(uint8_t* bytes, size_t bitOffset, size_t bitSize, int value); |
| 34 | |
| 35 | |
| 36 | class FGHIDEventInput : public FGEventInput { |
| 37 | public: |
| 38 | FGHIDEventInput(); |
| 39 | |
| 40 | virtual ~FGHIDEventInput(); |
| 41 | |
| 42 | // Subsystem API. |
| 43 | void postinit() override; |
| 44 | void reinit() override; |
| 45 | void shutdown() override; |
| 46 | void update(double dt) override; |
| 47 | |
| 48 | // Subsystem identification. |
| 49 | static const char* staticSubsystemClassId() { return "input-event-hid"; } |
| 50 | |
| 51 | private: |
| 52 | class FGHIDEventInputPrivate; |
| 53 | |
| 54 | std::unique_ptr<FGHIDEventInputPrivate> d; |
| 55 | }; |
| 56 | |
| 57 | #endif |