NAME
UAV::Pilot::SDL::Joystick
SYNOPSIS
my $control = UAV::Pilot::Controller::ARDrone->new( ... );
my $condvar = AnyEvent->condvar;
my $joy = UAV::Pilot::SDL::Joystick->new({
condvar => $condvar,
controller => $control,
conf_path => '/path/to/config.yml', # optional
});
my $sdl_events = UAV::Pilot::SDL::Events->new({
condvar => $condvar,
controller => $control,
});
$sdl_events->register( $joy );
DESCRIPTION
Handles joystick control for SDL joysticks. This does the role UAV::Pilot::EventHandler
, so it can be passed to <UAV::Pilot::Events-
register()>>. It's recommended to also add the UAV::Pilot::SDL::Events
handler to the events object, as that will take care of the SDL_QUIT
events. Without that, there's no way to stop the process other than kill -9
.
Joystick configuration will be loaded from a YAML
config file. You can find the path with <UAV::Pilot-
default_config_dir()>>. If the file does not exist, it will be created automatically.
CONFIGURATION FILE
The config file is in YAML
format. It contains the following keys:
joystick_num
The SDL joystick number to use
pitch_axis
Axis number of joystick to use for pitch.
roll_axis
Axis number of joystick to use for roll.
yaw_axis
Axis number of joystick to use for yaw.
throttle_axis
Axis number of joystick to use for throttle.
btn_action_map
This is a mapping of button numbers to some kind of action, such as takeoff/land or flip. The format is "btn_num: action". Actions are:
takeoff_land
emergency
wave
flip_ahead
flip_behind
flip_left
flip_right
Axis Corrections
These can be used to cut the inputs by a percentage. All should be numbers between 1.0 and -1.0, with negative numbers reversing the axis.