You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
/*
|
|
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 <QObject>
|
|
#include <QPoint>
|
|
|
|
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_
|
|
|