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");
 | 
			
		||||
        open(dev);
 | 
			
		||||
        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 {
 | 
			
		||||
        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();
 | 
			
		||||
    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
 | 
			
		||||
    axisCount = 0;
 | 
			
		||||
    ioctl (joydev, JSIOCGAXES, &axisCount);
 | 
			
		||||
@@ -176,7 +177,7 @@ bool JoyPad::readConfig( QTextStream &stream ) {
 | 
			
		||||
//only actually writes something if this JoyPad is NON DEFAULT.
 | 
			
		||||
void JoyPad::write( QTextStream &stream ) {
 | 
			
		||||
    if (!axes.empty() || !buttons.empty()) {
 | 
			
		||||
        stream << getName() << " {\n";
 | 
			
		||||
        stream << "Joystick " << index << " {\n";
 | 
			
		||||
        foreach (Axis *axis, axes) {
 | 
			
		||||
            axis->write(stream);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,8 +46,8 @@ class JoyPad : public QObject {
 | 
			
		||||
        bool isDefault();
 | 
			
		||||
		//read the dimensions on the real joystick and use them
 | 
			
		||||
        void open( int dev );
 | 
			
		||||
		//generates a name ("Joystick 1")
 | 
			
		||||
        QString getName() const { return QString("Joystick %1").arg(index+1);}
 | 
			
		||||
        const QString& getDeviceId() const { return deviceId; }
 | 
			
		||||
        QString getName() const { return QString("Joystick %1 (%2)").arg(index+1).arg(deviceId); }
 | 
			
		||||
        int getIndex() const { return index; }
 | 
			
		||||
		
 | 
			
		||||
    private:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user