MikroKopter.de
Wiki
Forum
Bilder
SVN
Videos
FAQ
Map
SHOP
Datenschutz
Impressum
BL-Ctrl
FlightCtrl
MK3Mag
NaviCtrl
Projects
Català-Valencià - Catalan
中文 - Chinese (Simplified)
中文 - Chinese (Traditional)
Česky - Czech
Dansk - Danish
Nederlands - Dutch
English - English
Suomi - Finnish
Français - French
Deutsch - German
עברית - Hebrew
Magyar - Hungarian
Bahasa Indonesia - Indonesian
Italiano - Italian
日本語 - Japanese
한국어 - Korean
Norsk - Norwegian
Polski - Polish
Português - Portuguese
Português - Portuguese (Brazil)
Русский - Russian
Slovenčina - Slovak
Slovenčina - Slovenian
Español - Spanish
Svenska - Swedish
Türkçe - Turkish
Oëzbekcha - Uzbek
Subversion Repositories
Projects
(root)
/
Riddim
/
joy_handler.c @ r130
- Rev 130
Rev
Blame
|
View Log
int
connect_joy
(
)
{
axis
=
(
int
*
)
calloc
(
100
,
sizeof
(
int
)
)
;
button
=
(
char
*
)
calloc
(
100
,
sizeof
(
char
)
)
;
button_trigger
=
(
char
*
)
calloc
(
100
,
sizeof
(
char
)
)
;
// axis = (int *) calloc( num_of_axis, sizeof( int ) );
// button = (char *)calloc( num_of_buttons, sizeof( char ) );
// button_trigger = (char *) calloc( num_of_buttons, sizeof( char ) );
if
(
(
x52_input_fd
=
open
(
JOY_DEV
,
O_RDONLY
)
)
<
0
)
{
printf
(
"Couldn't open joystick device %s
\n
"
,
JOY_DEV
)
;
printf
(
"try modprobe joydev
\n
"
)
;
return
0
;
}
ioctl
(
x52_input_fd
,
JSIOCGAXES
,
&
num_of_axis
)
;
ioctl
(
x52_input_fd
,
JSIOCGBUTTONS
,
&
num_of_buttons
)
;
ioctl
(
x52_input_fd
,
JSIOCGNAME
(
80
)
,
&
name_of_joystick
)
;
printf
(
"Joystick detected: %s
\n
\t
%d axis
\n
\t
%d buttons
\n
\n
"
,
name_of_joystick
,
num_of_axis
,
num_of_buttons
)
;
fcntl
(
x52_input_fd
,
F_SETFL
,
O_NONBLOCK
)
;
/* use non-blocking mode */
return
1
;
}