-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.cpp
More file actions
47 lines (41 loc) · 1.28 KB
/
client.cpp
File metadata and controls
47 lines (41 loc) · 1.28 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "client.h"
#include <QDebug>
Client::Client(QObject *parent) :
QObject(parent)
{
_socket.bind(545454);
connect(&_socket,SIGNAL(readyRead()),this,SLOT(receive()));
}
void Client::receive()
{
while(_socket.hasPendingDatagrams()){
QByteArray data;
_socket.readDatagram(data.data(),512);
_socket.flush();
XINPUT_VIBRATION Vibration;
// Zeroise the Vibration
ZeroMemory(&Vibration, sizeof(XINPUT_VIBRATION));
if(data.toInt()&XINPUT_GAMEPAD_A){
// Set the Vibration Values
Vibration.wLeftMotorSpeed = 0;
Vibration.wRightMotorSpeed = 0;
}
if(data.toInt()&XINPUT_GAMEPAD_X){
// Set the Vibration Values
Vibration.wLeftMotorSpeed = 65535;
Vibration.wRightMotorSpeed = 65535;
}
if(data.toInt()&XINPUT_GAMEPAD_Y){
// Set the Vibration Values
Vibration.wLeftMotorSpeed = 65535;
Vibration.wRightMotorSpeed = 65535;
}
if(data.toInt()&XINPUT_GAMEPAD_B){
// Set the Vibration Values
Vibration.wLeftMotorSpeed = 65535;
Vibration.wRightMotorSpeed = 65535;
}
// Vibrate the controller
XInputSetState(0, &Vibration);
}
}