-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoystick.cpp
More file actions
30 lines (24 loc) · 888 Bytes
/
Copy pathjoystick.cpp
File metadata and controls
30 lines (24 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "joystick.h"
#include <stickitem.h>
#include <QBrush>
#include <QGraphicsTextItem>
#include <QFont>
#include <QString>
#include <QGraphicsPixmapItem>
#include <QSvgRenderer>
#include <QGraphicsSvgItem>
Joystick::Joystick(int posX, int posY, int rectWidth, int rectHeight, bool fixX, bool fixY) :
QGraphicsRectItem(0, 0, rectWidth, rectHeight)
{
setPos(posX, posY);
QSvgRenderer *m_renderer = new QSvgRenderer(this);
m_renderer->load(QString(":/images/joystick.svg"));
QGraphicsSvgItem *m_background = new QGraphicsSvgItem(this);
m_background->setSharedRenderer(m_renderer);
m_background->setElementId(QString("background"));
StickItem *stick = new StickItem(fixX, fixY, this);
connect(stick,SIGNAL(stickUpdated(int,int)),this,SLOT(updateJoystick(int,int)));
}
void Joystick::updateJoystick(int x, int y){
emit JoystickUpdate(y,x);
}