]>
git.defcon.no Git - rctxduino/blob - tools/jstt/jstt.cpp
4 jstt::jstt(QWidget
*parent
) :
11 bars
[0] = ui
->Chan_1_bar
;
12 bars
[1] = ui
->Chan_2_bar
;
13 bars
[2] = ui
->Chan_3_bar
;
14 bars
[3] = ui
->Chan_4_bar
;
15 labels
[0] = ui
->Chan_1_val
;
16 labels
[1] = ui
->Chan_2_val
;
17 labels
[2] = ui
->Chan_3_val
;
18 labels
[3] = ui
->Chan_4_val
;
25 if( jsIsOpen() ) jsClose();
30 //delete joystick; // This causes warnings that i don't understand
31 delete [] bars
; // Will this be deleted when i delete ui? Does it matter? We're deleting the whole object anyway
32 delete [] labels
; // Same here, will it be deleted when ui is deleted?
39 if( SDL_Init(SDL_INIT_JOYSTICK
) == 0 ) {
41 for(int i
= 0; i
< SDL_NumJoysticks(); i
++) {
42 jsNames
.append(SDL_JoystickName(i
));
45 connect(&jsPullTimer
, SIGNAL(timeout()), this, SLOT(processJs()));
47 ui
->Joysticks
->addItems(jsNames
);
48 ui
->Joysticks
->setCurrentIndex(0); // This will trigger on_Joysticks_currentIndexChanged(int)
52 void jstt::jsOpen(int js
)
54 if( jsIsOpen() ) jsClose();
56 joystick
= SDL_JoystickOpen(js
);
62 numAxes = SDL_JoystickNumAxes(joystick);
63 numButtons = SDL_JoystickNumButtons(joystick);
64 numHats = SDL_JoystickNumHats(joystick);
65 numTrackballs = SDL_JoystickNumBalls(joystick);
66 JoystickTimer.start(eventTimeout);
68 When we have found out how many axes, buttons etc, we can expand the GUI further
71 jsPullTimer
.start(eventTimeout
);
76 One should make sure the program will react on this situation instead of just
87 if( joystick
) SDL_JoystickClose(joystick
);
91 void jstt::processJs()
98 This code needs to be fixed so that it iterates through all
99 axes instead of just the four i am setting up now.
102 for(int i
= 0; i
< 4; i
++) {
103 value
= SDL_JoystickGetAxis(joystick
, i
);
104 labels
[i
]->setNum(value
);
105 bars
[i
]->setValue(percentBar(value
));
109 void jstt::on_actionAbout_triggered()
114 void jstt::on_actionHelp_triggered()
119 void jstt::on_actionQuit_triggered()