Disabled joystick support per default.
This commit is contained in:
parent
b1c9c33016
commit
df1fe2d2a0
4 changed files with 24 additions and 3 deletions
|
@ -21,6 +21,8 @@
|
|||
#include "language.hpp"
|
||||
#include "preferences_display.hpp"
|
||||
|
||||
#include "preferences.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
game_controller_abstract::game_controller_abstract(const commandline_options &cmdline_opts) :
|
||||
|
@ -44,6 +46,9 @@ game_display& game_controller_abstract::disp()
|
|||
|
||||
bool game_controller_abstract::init_joystick()
|
||||
{
|
||||
if (!preferences::joystick_support_enabled())
|
||||
return false;
|
||||
|
||||
if(SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
|
||||
return false;
|
||||
|
|
|
@ -57,6 +57,11 @@ bool joystick_manager::close() {
|
|||
}
|
||||
|
||||
bool joystick_manager::init() {
|
||||
if (!preferences::joystick_support_enabled()) {
|
||||
LOG_JOY << "Joystick support is disabled.";
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_JOY << "Initializing joysticks...\n";
|
||||
if(SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
|
||||
|
@ -159,6 +164,9 @@ double joystick_manager::get_thrust_xaxis() {
|
|||
|
||||
std::pair<int, int> joystick_manager::get_axis_pair(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis) {
|
||||
|
||||
if(!SDL_WasInit(SDL_INIT_JOYSTICK))
|
||||
return std::make_pair(0, 0);
|
||||
|
||||
int x_axis = 0, y_axis = 0;
|
||||
bool get_xaxis = false, get_yaxis = false;
|
||||
|
||||
|
@ -180,6 +188,8 @@ std::pair<int, int> joystick_manager::get_axis_pair(int joystick_xaxis, int xaxi
|
|||
}
|
||||
|
||||
int joystick_manager::get_axis(int joystick_axis, int axis) {
|
||||
if(!SDL_WasInit(SDL_INIT_JOYSTICK))
|
||||
return 0;
|
||||
|
||||
if(SDL_JoystickOpened(joystick_axis))
|
||||
if(SDL_JoystickNumAxes(joysticks_[joystick_axis]) > axis)
|
||||
|
|
|
@ -473,9 +473,14 @@ namespace {
|
|||
double scroll = 0.2;
|
||||
}
|
||||
|
||||
bool joystick_support_enabled()
|
||||
{
|
||||
return get("joystick_support_enabled", false);
|
||||
}
|
||||
|
||||
int joystick_mouse_deadzone()
|
||||
{
|
||||
const int value = lexical_cast_in_range<int>(get("scroll_deathzone"), 1200, 0, 16000);
|
||||
const int value = lexical_cast_in_range<int>(get("joystick_scroll_deadzone"), 1200, 0, 16000);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -505,13 +510,13 @@ int joystick_mouse_yaxis_num()
|
|||
|
||||
int joystick_scroll_deadzone()
|
||||
{
|
||||
const int value = lexical_cast_in_range<int>(get("joystick_scroll_deathzone"), 1200, 0, 16000);
|
||||
const int value = lexical_cast_in_range<int>(get("joystick_scroll_deadzone"), 1200, 0, 16000);
|
||||
return value;
|
||||
}
|
||||
|
||||
int joystick_cursor_deadzone()
|
||||
{
|
||||
const int value = lexical_cast_in_range<int>(get("joystick_cursor_deathzone"), 1200, 0, 16000);
|
||||
const int value = lexical_cast_in_range<int>(get("joystick_cursor_deadzone"), 1200, 0, 16000);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ namespace preferences {
|
|||
bool use_color_cursors();
|
||||
void _set_color_cursors(bool value);
|
||||
|
||||
bool joystick_support_enabled();
|
||||
int joystick_mouse_deadzone();
|
||||
int joystick_num_mouse_xaxis();
|
||||
int joystick_num_mouse_yaxis();
|
||||
|
|
Loading…
Add table
Reference in a new issue