/* Copyright 2020-2021 Brad Parker Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef __INPUT_H_ #define __INPUT_H_ #include #include class QKeyEvent; class QMouseEvent; class Core; class MainWindow; class InputState : public QObject { Q_OBJECT public: InputState(QObject *parent = nullptr); static InputState* instance(); int16_t getInputState(unsigned id); int16_t getAnalogInputState(unsigned id); Qt::MouseButtons getMouseButtonsState(); int getMousePosRelX(); int getMousePosRelY(); bool keyPressEvent(QKeyEvent *e); bool keyReleaseEvent(QKeyEvent *e); void mouseMoveEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); private: int16_t m_inputState[16]; int16_t m_analogInputState[2]; QPoint m_mousePosAbs; QPoint m_mousePos; Qt::MouseButtons m_mouseButtonsState; Core *m_core; MainWindow *m_mainwindow; Q_DISABLE_COPY(InputState) }; #endif // __INPUT_H_