joystick name++
This commit is contained in:
@ -19,14 +19,6 @@ JoyPad::JoyPad( int i, int dev, QObject *parent )
|
|||||||
debug_mesg("Valid file handle, setting up handlers and reading axis configs...\n");
|
debug_mesg("Valid file handle, setting up handlers and reading axis configs...\n");
|
||||||
open(dev);
|
open(dev);
|
||||||
debug_mesg("done resetting and setting up device index %d\n", i);
|
debug_mesg("done resetting and setting up device index %d\n", i);
|
||||||
char id[256];
|
|
||||||
memset(id, 0, sizeof(id));
|
|
||||||
if (ioctl(joydev, JSIOCGNAME(sizeof(id)), id) < 0) {
|
|
||||||
deviceId = "Unknown";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
deviceId = id;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
debug_mesg("This joypad does not have a valid file handle, not setting up event listeners\n");
|
debug_mesg("This joypad does not have a valid file handle, not setting up event listeners\n");
|
||||||
}
|
}
|
||||||
@ -70,6 +62,15 @@ void JoyPad::open(int dev) {
|
|||||||
close();
|
close();
|
||||||
joydev = dev;
|
joydev = dev;
|
||||||
|
|
||||||
|
char id[256];
|
||||||
|
memset(id, 0, sizeof(id));
|
||||||
|
if (ioctl(joydev, JSIOCGNAME(sizeof(id)), id) < 0) {
|
||||||
|
deviceId = "Unknown";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deviceId = id;
|
||||||
|
}
|
||||||
|
|
||||||
//read in the number of axes / buttons
|
//read in the number of axes / buttons
|
||||||
axisCount = 0;
|
axisCount = 0;
|
||||||
ioctl (joydev, JSIOCGAXES, &axisCount);
|
ioctl (joydev, JSIOCGAXES, &axisCount);
|
||||||
@ -176,7 +177,7 @@ bool JoyPad::readConfig( QTextStream &stream ) {
|
|||||||
//only actually writes something if this JoyPad is NON DEFAULT.
|
//only actually writes something if this JoyPad is NON DEFAULT.
|
||||||
void JoyPad::write( QTextStream &stream ) {
|
void JoyPad::write( QTextStream &stream ) {
|
||||||
if (!axes.empty() || !buttons.empty()) {
|
if (!axes.empty() || !buttons.empty()) {
|
||||||
stream << getName() << " {\n";
|
stream << "Joystick " << index << " {\n";
|
||||||
foreach (Axis *axis, axes) {
|
foreach (Axis *axis, axes) {
|
||||||
axis->write(stream);
|
axis->write(stream);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ class JoyPad : public QObject {
|
|||||||
bool isDefault();
|
bool isDefault();
|
||||||
//read the dimensions on the real joystick and use them
|
//read the dimensions on the real joystick and use them
|
||||||
void open( int dev );
|
void open( int dev );
|
||||||
//generates a name ("Joystick 1")
|
const QString& getDeviceId() const { return deviceId; }
|
||||||
QString getName() const { return QString("Joystick %1").arg(index+1);}
|
QString getName() const { return QString("Joystick %1 (%2)").arg(index+1).arg(deviceId); }
|
||||||
int getIndex() const { return index; }
|
int getIndex() const { return index; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user