]>
git.defcon.no Git - rctxduino/blob - tools/jstt/jstt.cpp
4 jstt::jstt(QWidget
*parent
) :
10 this->joystick
= NULL
;
18 if( jsIsOpen() ) jsClose();
27 if( SDL_Init(SDL_INIT_JOYSTICK
) == 0 ) {
29 for(int i
= 0; i
< SDL_NumJoysticks(); i
++) {
30 jsNames
.append(SDL_JoystickName(i
));
32 connect(&jsPullTimer
, SIGNAL(timeout()), this, SLOT(processJs()));
34 ui
->Joysticks
->addItems(jsNames
);
35 ui
->Joysticks
->setCurrentIndex(0); // This will trigger on_Joysticks_currentIndexChanged(int)
39 void jstt::jsOpen(int js
)
41 if( jsIsOpen() ) jsClose();
43 joystick
= SDL_JoystickOpen(js
);
45 jsPullTimer
.start(eventTimeout
);
50 numAxes = SDL_JoystickNumAxes(joystick);
51 numButtons = SDL_JoystickNumButtons(joystick);
52 numHats = SDL_JoystickNumHats(joystick);
53 numTrackballs = SDL_JoystickNumBalls(joystick);
54 JoystickTimer.start(eventTimeout);
56 When we have found out how many axes, buttons etc, we can expand the GUI further
61 One should make sure the program will react on this situation instead of just
70 this->jsPullTimer
.stop();
71 if( joystick
) SDL_JoystickClose(joystick
);
75 void jstt::processJs()
77 ui
->Chan_1_bar
->setValue(30);
80 void jstt::on_Joysticks_currentIndexChanged(int index
)