File indexing completed on 2024-05-12 05:27:55
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Bart Ribbers <bribbers@disroot.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "../device.h" 0010 0011 #include <QObject> 0012 0013 #include <xwiimote.h> 0014 #include <poll.h> 0015 0016 enum WiimoteDevtypes { 0017 WIIMOTE_DEVTYPE_UNKNOWN, 0018 WIIMOTE_DEVTYPE_GENERIC, 0019 WIIMOTE_DEVTYPE_GEN10, 0020 WIIMOTE_DEVTYPE_GEN15, 0021 WIIMOTE_DEVTYPE_GEN20, 0022 WIIMOTE_DEVTYPE_BALANCEBOARD, 0023 WIIMOTE_DEVTYPE_PROCONTROLLER 0024 }; 0025 0026 enum WiimoteExtensions { 0027 WIIMOTE_EXTENSION_NONE, 0028 WIIMOTE_EXTENSION_UNKNOWN, 0029 WIIMOTE_EXTENSION_NUNCHUK, 0030 WIIMOTE_EXTENSION_CLASSIC, 0031 WIIMOTE_EXTENSION_BALANCEBOARD, 0032 WIIMOTE_EXTENSION_PROCONTROLLER 0033 }; 0034 0035 class Wiimote : public Device 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit Wiimote(struct xwii_iface *iface, const QString &sysPath); 0041 ~Wiimote(); 0042 0043 WiimoteDevtypes getDevType(); 0044 0045 public Q_SLOTS: 0046 void watchEvents() override; 0047 0048 Q_SIGNALS: 0049 void keyPress(int keyCode, bool pressed); 0050 0051 private: 0052 struct xwii_iface *m_iface; 0053 struct pollfd m_fds[2]; 0054 int m_fdsNum; 0055 WiimoteDevtypes m_devType; 0056 WiimoteExtensions m_extensionType; 0057 int m_previousNunchukAxisTime = 0; 0058 0059 void handleWatch(); 0060 void handleKeypress(struct xwii_event *event); 0061 void handleNunchuk(struct xwii_event *event); 0062 0063 void getExtensionType(); 0064 };