Browse Source

Rename game_controller to gamepad

master
C. J. Howard 2 years ago
parent
commit
695a14a406
21 changed files with 298 additions and 298 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +19
    -19
      src/application.cpp
  3. +7
    -7
      src/application.hpp
  4. +10
    -10
      src/event/input-events.cpp
  5. +14
    -14
      src/event/input-events.hpp
  6. +3
    -3
      src/game/bootloader.cpp
  7. +50
    -50
      src/game/states/loading.cpp
  8. +1
    -1
      src/game/states/splash.cpp
  9. +26
    -26
      src/input/event-router.cpp
  10. +10
    -10
      src/input/event-router.hpp
  11. +37
    -37
      src/input/gamepad.cpp
  12. +33
    -34
      src/input/gamepad.hpp
  13. +1
    -1
      src/input/input.hpp
  14. +6
    -6
      src/input/listener.cpp
  15. +4
    -4
      src/input/listener.hpp
  16. +8
    -8
      src/input/mapper.cpp
  17. +4
    -4
      src/input/mapper.hpp
  18. +6
    -6
      src/input/mapping.cpp
  19. +27
    -27
      src/input/mapping.hpp
  20. +24
    -24
      src/input/sdl-game-controller-tables.cpp
  21. +7
    -7
      src/input/sdl-game-controller-tables.hpp

+ 1
- 0
CMakeLists.txt View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
option(VERSION_STRING "Project version string" "0.0.0") option(VERSION_STRING "Project version string" "0.0.0")
project(antkeeper VERSION ${VERSION_STRING} LANGUAGES CXX) project(antkeeper VERSION ${VERSION_STRING} LANGUAGES CXX)

+ 19
- 19
src/application.cpp View File

@ -174,7 +174,7 @@ application::application():
logger->pop_task(EXIT_SUCCESS); logger->pop_task(EXIT_SUCCESS);
} }
// Init SDL joystick and game controller subsystems
// Init SDL joystick and gamepad subsystems
logger->push_task("Initializing SDL Joystick and Game Controller subsystems"); logger->push_task("Initializing SDL Joystick and Game Controller subsystems");
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) != 0) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) != 0)
{ {
@ -185,9 +185,9 @@ application::application():
logger->pop_task(EXIT_SUCCESS); logger->pop_task(EXIT_SUCCESS);
} }
// Load SDL game controller mappings
// Load SDL gamepad mappings
/* /*
logger->push_task("Loading SDL game controller mappings from database");
logger->push_task("Loading SDL gamepad mappings from database");
std::string gamecontrollerdb_path = data_path + "controls/gamecontrollerdb.txt"; std::string gamecontrollerdb_path = data_path + "controls/gamecontrollerdb.txt";
if (SDL_GameControllerAddMappingsFromFile(gamecontrollerdb_path.c_str()) == -1) if (SDL_GameControllerAddMappingsFromFile(gamecontrollerdb_path.c_str()) == -1)
{ {
@ -211,7 +211,7 @@ application::application():
mouse = new input::mouse(); mouse = new input::mouse();
mouse->set_event_dispatcher(event_dispatcher); mouse->set_event_dispatcher(event_dispatcher);
// Connect game controllers
// Connect gamepads
translate_sdl_events(); translate_sdl_events();
// Setup frame scheduler // Setup frame scheduler
@ -600,9 +600,9 @@ void application::translate_sdl_events()
{ {
if (sdl_event.cbutton.button != SDL_CONTROLLER_BUTTON_INVALID) if (sdl_event.cbutton.button != SDL_CONTROLLER_BUTTON_INVALID)
{ {
if (auto it = game_controller_map.find(sdl_event.cdevice.which); it != game_controller_map.end())
if (auto it = gamepad_map.find(sdl_event.cdevice.which); it != gamepad_map.end())
{ {
input::game_controller_button button = input::sdl_button_table[sdl_event.cbutton.button];
input::gamepad_button button = input::sdl_button_table[sdl_event.cbutton.button];
it->second->press(button); it->second->press(button);
} }
} }
@ -613,9 +613,9 @@ void application::translate_sdl_events()
{ {
if (sdl_event.cbutton.button != SDL_CONTROLLER_BUTTON_INVALID) if (sdl_event.cbutton.button != SDL_CONTROLLER_BUTTON_INVALID)
{ {
if (auto it = game_controller_map.find(sdl_event.cdevice.which); it != game_controller_map.end())
if (auto it = gamepad_map.find(sdl_event.cdevice.which); it != gamepad_map.end())
{ {
input::game_controller_button button = input::sdl_button_table[sdl_event.cbutton.button];
input::gamepad_button button = input::sdl_button_table[sdl_event.cbutton.button];
it->second->release(button); it->second->release(button);
} }
} }
@ -626,9 +626,9 @@ void application::translate_sdl_events()
{ {
if (sdl_event.caxis.axis != SDL_CONTROLLER_AXIS_INVALID) if (sdl_event.caxis.axis != SDL_CONTROLLER_AXIS_INVALID)
{ {
if (auto it = game_controller_map.find(sdl_event.cdevice.which); it != game_controller_map.end())
if (auto it = gamepad_map.find(sdl_event.cdevice.which); it != gamepad_map.end())
{ {
input::game_controller_axis axis = input::sdl_axis_table[sdl_event.caxis.axis];
input::gamepad_axis axis = input::sdl_axis_table[sdl_event.caxis.axis];
float value = sdl_event.caxis.value; float value = sdl_event.caxis.value;
value /= (value < 0.0f) ? 32768.0f : 32767.0f; value /= (value < 0.0f) ? 32768.0f : 32767.0f;
it->second->move(axis, value); it->second->move(axis, value);
@ -646,27 +646,27 @@ void application::translate_sdl_events()
std::string controller_name = SDL_GameControllerNameForIndex(sdl_event.cdevice.which); std::string controller_name = SDL_GameControllerNameForIndex(sdl_event.cdevice.which);
if (sdl_controller) if (sdl_controller)
{ {
if (auto it = game_controller_map.find(sdl_event.cdevice.which); it != game_controller_map.end())
if (auto it = gamepad_map.find(sdl_event.cdevice.which); it != gamepad_map.end())
{ {
logger->log("Reconnected game controller \"" + controller_name + "\"");
logger->log("Reconnected gamepad \"" + controller_name + "\"");
it->second->connect(true); it->second->connect(true);
} }
else else
{ {
logger->log("Connected game controller \"" + controller_name + "\"");
logger->log("Connected gamepad \"" + controller_name + "\"");
input::game_controller* controller = new input::game_controller();
input::gamepad* controller = new input::gamepad();
controller->set_event_dispatcher(event_dispatcher); controller->set_event_dispatcher(event_dispatcher);
game_controllers.push_back(controller);
game_controller_map[sdl_event.cdevice.which] = controller;
gamepads.push_back(controller);
gamepad_map[sdl_event.cdevice.which] = controller;
controller->connect(false); controller->connect(false);
} }
} }
else else
{ {
logger->error("Failed to connected game controller \"" + controller_name + "\"");
logger->error("Failed to connected gamepad \"" + controller_name + "\"");
} }
} }
@ -680,9 +680,9 @@ void application::translate_sdl_events()
if (sdl_controller) if (sdl_controller)
{ {
SDL_GameControllerClose(sdl_controller); SDL_GameControllerClose(sdl_controller);
logger->log("Disconnected game controller");
logger->log("Disconnected gamepad");
if (auto it = game_controller_map.find(sdl_event.cdevice.which); it != game_controller_map.end())
if (auto it = gamepad_map.find(sdl_event.cdevice.which); it != gamepad_map.end())
{ {
it->second->disconnect(); it->second->disconnect();
} }

+ 7
- 7
src/application.hpp View File

@ -28,7 +28,7 @@
#include "gl/rasterizer.hpp" #include "gl/rasterizer.hpp"
#include "input/keyboard.hpp" #include "input/keyboard.hpp"
#include "input/mouse.hpp" #include "input/mouse.hpp"
#include "input/game-controller.hpp"
#include "input/gamepad.hpp"
// Forward declarations // Forward declarations
typedef struct SDL_Window SDL_Window; typedef struct SDL_Window SDL_Window;
@ -210,8 +210,8 @@ public:
/// Returns the virtual mouse. /// Returns the virtual mouse.
input::mouse* get_mouse(); input::mouse* get_mouse();
/// Returns the list of virtual game controllers.
const std::list<input::game_controller*>& get_game_controllers();
/// Returns the list of virtual gamepads.
const std::list<input::gamepad*>& get_gamepads();
/// Returns the application's event dispatcher. /// Returns the application's event dispatcher.
event_dispatcher* get_event_dispatcher(); event_dispatcher* get_event_dispatcher();
@ -254,8 +254,8 @@ private:
// Input devices // Input devices
input::keyboard* keyboard; input::keyboard* keyboard;
input::mouse* mouse; input::mouse* mouse;
std::list<input::game_controller*> game_controllers;
std::unordered_map<int, input::game_controller*> game_controller_map;
std::list<input::gamepad*> gamepads;
std::unordered_map<int, input::gamepad*> gamepad_map;
}; };
inline debug::logger* application::get_logger() inline debug::logger* application::get_logger()
@ -298,9 +298,9 @@ inline input::mouse* application::get_mouse()
return mouse; return mouse;
} }
inline const std::list<input::game_controller*>& application::get_game_controllers()
inline const std::list<input::gamepad*>& application::get_gamepads()
{ {
return game_controllers;
return gamepads;
} }
inline event_dispatcher* application::get_event_dispatcher() inline event_dispatcher* application::get_event_dispatcher()

+ 10
- 10
src/event/input-events.cpp View File

@ -75,40 +75,40 @@ event_base* mouse_wheel_scrolled_event::clone() const
return event; return event;
} }
event_base* game_controller_connected_event::clone() const
event_base* gamepad_connected_event::clone() const
{ {
game_controller_connected_event* event = new game_controller_connected_event();
gamepad_connected_event* event = new gamepad_connected_event();
event->controller = controller; event->controller = controller;
event->reconnected = reconnected; event->reconnected = reconnected;
return event; return event;
} }
event_base* game_controller_disconnected_event::clone() const
event_base* gamepad_disconnected_event::clone() const
{ {
game_controller_disconnected_event* event = new game_controller_disconnected_event();
gamepad_disconnected_event* event = new gamepad_disconnected_event();
event->controller = controller; event->controller = controller;
return event; return event;
} }
event_base* game_controller_button_pressed_event::clone() const
event_base* gamepad_button_pressed_event::clone() const
{ {
game_controller_button_pressed_event* event = new game_controller_button_pressed_event();
gamepad_button_pressed_event* event = new gamepad_button_pressed_event();
event->controller = controller; event->controller = controller;
event->button = button; event->button = button;
return event; return event;
} }
event_base* game_controller_button_released_event::clone() const
event_base* gamepad_button_released_event::clone() const
{ {
game_controller_button_released_event* event = new game_controller_button_released_event();
gamepad_button_released_event* event = new gamepad_button_released_event();
event->controller = controller; event->controller = controller;
event->button = button; event->button = button;
return event; return event;
} }
event_base* game_controller_axis_moved_event::clone() const
event_base* gamepad_axis_moved_event::clone() const
{ {
game_controller_axis_moved_event* event = new game_controller_axis_moved_event();
gamepad_axis_moved_event* event = new gamepad_axis_moved_event();
event->controller = controller; event->controller = controller;
event->axis = axis; event->axis = axis;
event->value = value; event->value = value;

+ 14
- 14
src/event/input-events.hpp View File

@ -24,7 +24,7 @@
#include "input/scancode.hpp" #include "input/scancode.hpp"
#include "input/keyboard.hpp" #include "input/keyboard.hpp"
#include "input/mouse.hpp" #include "input/mouse.hpp"
#include "input/game-controller.hpp"
#include "input/gamepad.hpp"
/** /**
* Input event which indicates a keyboard key has been pressed. * Input event which indicates a keyboard key has been pressed.
@ -109,60 +109,60 @@ public:
/** /**
* Input event which indicates a controller has been connected. * Input event which indicates a controller has been connected.
*/ */
class game_controller_connected_event: public event<game_controller_connected_event>
class gamepad_connected_event: public event<gamepad_connected_event>
{ {
public: public:
virtual event_base* clone() const; virtual event_base* clone() const;
input::game_controller* controller;
input::gamepad* controller;
bool reconnected; bool reconnected;
}; };
/** /**
* Input event which indicates a controller has been disconnected. * Input event which indicates a controller has been disconnected.
*/ */
class game_controller_disconnected_event: public event<game_controller_disconnected_event>
class gamepad_disconnected_event: public event<gamepad_disconnected_event>
{ {
public: public:
virtual event_base* clone() const; virtual event_base* clone() const;
input::game_controller* controller;
input::gamepad* controller;
}; };
/** /**
* Input event which indicates a controller button has been pressed. * Input event which indicates a controller button has been pressed.
*/ */
class game_controller_button_pressed_event: public event<game_controller_button_pressed_event>
class gamepad_button_pressed_event: public event<gamepad_button_pressed_event>
{ {
public: public:
virtual event_base* clone() const; virtual event_base* clone() const;
input::game_controller* controller;
input::game_controller_button button;
input::gamepad* controller;
input::gamepad_button button;
}; };
/** /**
* Input event which indicates a controller button has been released. * Input event which indicates a controller button has been released.
*/ */
class game_controller_button_released_event: public event<game_controller_button_released_event>
class gamepad_button_released_event: public event<gamepad_button_released_event>
{ {
public: public:
virtual event_base* clone() const; virtual event_base* clone() const;
input::game_controller* controller;
input::game_controller_button button;
input::gamepad* controller;
input::gamepad_button button;
}; };
/** /**
* Input event which indicates a controller axis has been moved. * Input event which indicates a controller axis has been moved.
*/ */
class game_controller_axis_moved_event: public event<game_controller_axis_moved_event>
class gamepad_axis_moved_event: public event<gamepad_axis_moved_event>
{ {
public: public:
virtual event_base* clone() const; virtual event_base* clone() const;
input::game_controller* controller;
input::game_controller_axis axis;
input::gamepad* controller;
input::gamepad_axis axis;
float value; float value;
}; };

+ 3
- 3
src/game/bootloader.cpp View File

@ -81,7 +81,7 @@
#include "input/event-router.hpp" #include "input/event-router.hpp"
#include "input/mapper.hpp" #include "input/mapper.hpp"
#include "input/listener.hpp" #include "input/listener.hpp"
#include "input/game-controller.hpp"
#include "input/gamepad.hpp"
#include "input/mouse.hpp" #include "input/mouse.hpp"
#include "input/keyboard.hpp" #include "input/keyboard.hpp"
#include "configuration.hpp" #include "configuration.hpp"
@ -892,9 +892,9 @@ void setup_controls(game::context* ctx)
/* /*
// Add menu control mappings // Add menu control mappings
ctx->input_event_router->add_mapping(input::game_controller_button_mapping(ctx->menu_back_control, nullptr, input::game_controller_button::b));
ctx->input_event_router->add_mapping(input::gamepad_button_mapping(ctx->menu_back_control, nullptr, input::gamepad_button::b));
//ctx->input_event_router->add_mapping(input::key_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::scancode::left_shift)); //ctx->input_event_router->add_mapping(input::key_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::scancode::left_shift));
ctx->input_event_router->add_mapping(input::game_controller_button_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::game_controller_button::x));
ctx->input_event_router->add_mapping(input::gamepad_button_mapping(ctx->control_system->get_tool_menu_control(), nullptr, input::gamepad_button::x));
ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::enter)); ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::enter));
ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::space)); ctx->input_event_router->add_mapping(input::key_mapping(ctx->menu_select_control, nullptr, input::scancode::space));

+ 50
- 50
src/game/states/loading.cpp View File

@ -56,7 +56,7 @@ namespace loading {
/// Creates or loads control configuration /// Creates or loads control configuration
static void load_controls(game::context* ctx); static void load_controls(game::context* ctx);
static input::game_controller_response_curve parse_response_curve(const std::string& curve);
static input::gamepad_response_curve parse_response_curve(const std::string& curve);
/// Creates the universe and solar system. /// Creates the universe and solar system.
static void cosmogenesis(game::context* ctx); static void cosmogenesis(game::context* ctx);
@ -155,7 +155,7 @@ void load_controls(game::context* ctx)
ctx->controls["tilt_down_mouse"] = new input::control(); ctx->controls["tilt_down_mouse"] = new input::control();
ctx->controls["use_tool"] = new input::control(); ctx->controls["use_tool"] = new input::control();
// Set activation threshold for menu navigation controls to mitigate drifting game controller axes
// Set activation threshold for menu navigation controls to mitigate drifting gamepad axes
const float menu_activation_threshold = 0.1f; const float menu_activation_threshold = 0.1f;
ctx->controls["menu_up"]->set_activation_threshold(menu_activation_threshold); ctx->controls["menu_up"]->set_activation_threshold(menu_activation_threshold);
ctx->controls["menu_down"]->set_activation_threshold(menu_activation_threshold); ctx->controls["menu_down"]->set_activation_threshold(menu_activation_threshold);
@ -166,33 +166,33 @@ void load_controls(game::context* ctx)
input::keyboard* keyboard = ctx->app->get_keyboard(); input::keyboard* keyboard = ctx->app->get_keyboard();
input::mouse* mouse = ctx->app->get_mouse(); input::mouse* mouse = ctx->app->get_mouse();
const std::unordered_map<std::string, input::game_controller_button> gamepad_button_map =
const std::unordered_map<std::string, input::gamepad_button> gamepad_button_map =
{ {
{"a", input::game_controller_button::a},
{"b", input::game_controller_button::b},
{"x", input::game_controller_button::x},
{"y", input::game_controller_button::y},
{"back", input::game_controller_button::back},
{"guide", input::game_controller_button::guide},
{"start", input::game_controller_button::start},
{"leftstick", input::game_controller_button::left_stick},
{"rightstick", input::game_controller_button::right_stick},
{"leftshoulder", input::game_controller_button::left_shoulder},
{"rightshoulder", input::game_controller_button::right_shoulder},
{"dpup", input::game_controller_button::dpad_up},
{"dpdown", input::game_controller_button::dpad_down},
{"dpleft", input::game_controller_button::dpad_left},
{"dpright", input::game_controller_button::dpad_right}
{"a", input::gamepad_button::a},
{"b", input::gamepad_button::b},
{"x", input::gamepad_button::x},
{"y", input::gamepad_button::y},
{"back", input::gamepad_button::back},
{"guide", input::gamepad_button::guide},
{"start", input::gamepad_button::start},
{"leftstick", input::gamepad_button::left_stick},
{"rightstick", input::gamepad_button::right_stick},
{"leftshoulder", input::gamepad_button::left_shoulder},
{"rightshoulder", input::gamepad_button::right_shoulder},
{"dpup", input::gamepad_button::dpad_up},
{"dpdown", input::gamepad_button::dpad_down},
{"dpleft", input::gamepad_button::dpad_left},
{"dpright", input::gamepad_button::dpad_right}
}; };
const std::unordered_map<std::string, input::game_controller_axis> gamepad_axis_map =
const std::unordered_map<std::string, input::gamepad_axis> gamepad_axis_map =
{ {
{"leftx", input::game_controller_axis::left_x},
{"lefty", input::game_controller_axis::left_y},
{"rightx", input::game_controller_axis::right_x},
{"righty", input::game_controller_axis::right_y},
{"lefttrigger", input::game_controller_axis::left_trigger},
{"righttrigger", input::game_controller_axis::right_trigger}
{"leftx", input::gamepad_axis::left_x},
{"lefty", input::gamepad_axis::left_y},
{"rightx", input::gamepad_axis::right_x},
{"righty", input::gamepad_axis::right_y},
{"lefttrigger", input::gamepad_axis::left_trigger},
{"righttrigger", input::gamepad_axis::right_trigger}
}; };
// Check if a control profile is set in the config file // Check if a control profile is set in the config file
@ -335,7 +335,7 @@ void load_controls(game::context* ctx)
} }
// Map control to gamepad button // Map control to gamepad button
ctx->input_event_router->add_mapping(input::game_controller_button_mapping(control, nullptr, button_it->second));
ctx->input_event_router->add_mapping(input::gamepad_button_mapping(control, nullptr, button_it->second));
ctx->logger->log("Mapped control \"" + name + "\" to gamepad button " + button); ctx->logger->log("Mapped control \"" + name + "\" to gamepad button " + button);
} }
@ -362,7 +362,7 @@ void load_controls(game::context* ctx)
bool axis_negative = (axis_sign == '-'); bool axis_negative = (axis_sign == '-');
// Map control to gamepad axis // Map control to gamepad axis
ctx->input_event_router->add_mapping(input::game_controller_axis_mapping(control, nullptr, axis_it->second, axis_negative));
ctx->input_event_router->add_mapping(input::gamepad_axis_mapping(control, nullptr, axis_it->second, axis_negative));
ctx->logger->log("Mapped control \"" + name + "\" to gamepad axis " + axis); ctx->logger->log("Mapped control \"" + name + "\" to gamepad axis " + axis);
} }
@ -396,12 +396,12 @@ void load_controls(game::context* ctx)
bool gamepad_right_deadzone_cross = true; bool gamepad_right_deadzone_cross = true;
float gamepad_left_deadzone_roundness = 0.0f; float gamepad_left_deadzone_roundness = 0.0f;
float gamepad_right_deadzone_roundness = 0.0f; float gamepad_right_deadzone_roundness = 0.0f;
input::game_controller_response_curve gamepad_leftx_response_curve = input::game_controller_response_curve::linear;
input::game_controller_response_curve gamepad_lefty_response_curve = input::game_controller_response_curve::linear;
input::game_controller_response_curve gamepad_rightx_response_curve = input::game_controller_response_curve::linear;
input::game_controller_response_curve gamepad_righty_response_curve = input::game_controller_response_curve::linear;
input::game_controller_response_curve gamepad_lefttrigger_response_curve = input::game_controller_response_curve::linear;
input::game_controller_response_curve gamepad_righttrigger_response_curve = input::game_controller_response_curve::linear;
input::gamepad_response_curve gamepad_leftx_response_curve = input::gamepad_response_curve::linear;
input::gamepad_response_curve gamepad_lefty_response_curve = input::gamepad_response_curve::linear;
input::gamepad_response_curve gamepad_rightx_response_curve = input::gamepad_response_curve::linear;
input::gamepad_response_curve gamepad_righty_response_curve = input::gamepad_response_curve::linear;
input::gamepad_response_curve gamepad_lefttrigger_response_curve = input::gamepad_response_curve::linear;
input::gamepad_response_curve gamepad_righttrigger_response_curve = input::gamepad_response_curve::linear;
if (ctx->config->contains("gamepad_leftx_activation_min")) if (ctx->config->contains("gamepad_leftx_activation_min"))
gamepad_leftx_activation_min = (*ctx->config)["gamepad_leftx_activation_min"].get<float>(); gamepad_leftx_activation_min = (*ctx->config)["gamepad_leftx_activation_min"].get<float>();
@ -448,24 +448,24 @@ void load_controls(game::context* ctx)
if (ctx->config->contains("gamepad_righttrigger_response_curve")) if (ctx->config->contains("gamepad_righttrigger_response_curve"))
gamepad_righttrigger_response_curve = parse_response_curve((*ctx->config)["gamepad_righttrigger_response_curve"].get<std::string>()); gamepad_righttrigger_response_curve = parse_response_curve((*ctx->config)["gamepad_righttrigger_response_curve"].get<std::string>());
for (input::game_controller* gamepad: ctx->app->get_game_controllers())
for (input::gamepad* gamepad: ctx->app->get_gamepads())
{ {
gamepad->set_activation_threshold(input::game_controller_axis::left_x, gamepad_leftx_activation_min, gamepad_leftx_activation_max);
gamepad->set_activation_threshold(input::game_controller_axis::left_y, gamepad_lefty_activation_min, gamepad_lefty_activation_max);
gamepad->set_activation_threshold(input::game_controller_axis::right_x, gamepad_rightx_activation_min, gamepad_rightx_activation_max);
gamepad->set_activation_threshold(input::game_controller_axis::right_y, gamepad_righty_activation_min, gamepad_righty_activation_max);
gamepad->set_activation_threshold(input::game_controller_axis::left_trigger, gamepad_lefttrigger_activation_min, gamepad_lefttrigger_activation_max);
gamepad->set_activation_threshold(input::game_controller_axis::right_trigger, gamepad_righttrigger_activation_min, gamepad_righttrigger_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::left_x, gamepad_leftx_activation_min, gamepad_leftx_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::left_y, gamepad_lefty_activation_min, gamepad_lefty_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::right_x, gamepad_rightx_activation_min, gamepad_rightx_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::right_y, gamepad_righty_activation_min, gamepad_righty_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::left_trigger, gamepad_lefttrigger_activation_min, gamepad_lefttrigger_activation_max);
gamepad->set_activation_threshold(input::gamepad_axis::right_trigger, gamepad_righttrigger_activation_min, gamepad_righttrigger_activation_max);
gamepad->set_left_deadzone_cross(gamepad_left_deadzone_cross); gamepad->set_left_deadzone_cross(gamepad_left_deadzone_cross);
gamepad->set_right_deadzone_cross(gamepad_right_deadzone_cross); gamepad->set_right_deadzone_cross(gamepad_right_deadzone_cross);
gamepad->set_left_deadzone_roundness(gamepad_left_deadzone_roundness); gamepad->set_left_deadzone_roundness(gamepad_left_deadzone_roundness);
gamepad->set_right_deadzone_roundness(gamepad_right_deadzone_roundness); gamepad->set_right_deadzone_roundness(gamepad_right_deadzone_roundness);
gamepad->set_response_curve(input::game_controller_axis::left_x, gamepad_leftx_response_curve);
gamepad->set_response_curve(input::game_controller_axis::left_y, gamepad_lefty_response_curve);
gamepad->set_response_curve(input::game_controller_axis::right_x, gamepad_rightx_response_curve);
gamepad->set_response_curve(input::game_controller_axis::right_y, gamepad_righty_response_curve);
gamepad->set_response_curve(input::game_controller_axis::left_trigger, gamepad_lefttrigger_response_curve);
gamepad->set_response_curve(input::game_controller_axis::right_trigger, gamepad_righttrigger_response_curve);
gamepad->set_response_curve(input::gamepad_axis::left_x, gamepad_leftx_response_curve);
gamepad->set_response_curve(input::gamepad_axis::left_y, gamepad_lefty_response_curve);
gamepad->set_response_curve(input::gamepad_axis::right_x, gamepad_rightx_response_curve);
gamepad->set_response_curve(input::gamepad_axis::right_y, gamepad_righty_response_curve);
gamepad->set_response_curve(input::gamepad_axis::left_trigger, gamepad_lefttrigger_response_curve);
gamepad->set_response_curve(input::gamepad_axis::right_trigger, gamepad_righttrigger_response_curve);
} }
// Toggle fullscreen // Toggle fullscreen
@ -507,13 +507,13 @@ void load_controls(game::context* ctx)
); );
} }
static input::game_controller_response_curve parse_response_curve(const std::string& curve)
static input::gamepad_response_curve parse_response_curve(const std::string& curve)
{ {
if (curve == "square") if (curve == "square")
return input::game_controller_response_curve::square;
return input::gamepad_response_curve::square;
else if (curve == "cube") else if (curve == "cube")
return input::game_controller_response_curve::cube;
return input::game_controller_response_curve::linear;
return input::gamepad_response_curve::cube;
return input::gamepad_response_curve::linear;
} }
void cosmogenesis(game::context* ctx) void cosmogenesis(game::context* ctx)

+ 1
- 1
src/game/states/splash.cpp View File

@ -74,7 +74,7 @@ void enter(game::context* ctx)
[ctx](const event_base& event) [ctx](const event_base& event)
{ {
auto id = event.get_event_type_id(); auto id = event.get_event_type_id();
if (id != mouse_moved_event::event_type_id && id != mouse_wheel_scrolled_event::event_type_id && id != game_controller_axis_moved_event::event_type_id)
if (id != mouse_moved_event::event_type_id && id != mouse_wheel_scrolled_event::event_type_id && id != gamepad_axis_moved_event::event_type_id)
{ {
ctx->timeline->clear(); ctx->timeline->clear();
ctx->fade_transition->get_animation()->stop(); ctx->fade_transition->get_animation()->stop();

+ 26
- 26
src/input/event-router.cpp View File

@ -77,20 +77,20 @@ void event_router::add_mapping(const mapping& mapping)
break; break;
} }
case mapping_type::game_controller_axis:
case mapping_type::gamepad_axis:
{ {
input::game_controller_axis_mapping* game_controller_axis_mapping = new input::game_controller_axis_mapping(static_cast<const input::game_controller_axis_mapping&>(mapping));
game_controller_axis_mappings.push_back(game_controller_axis_mapping);
controls[control].push_back(game_controller_axis_mapping);
input::gamepad_axis_mapping* gamepad_axis_mapping = new input::gamepad_axis_mapping(static_cast<const input::gamepad_axis_mapping&>(mapping));
gamepad_axis_mappings.push_back(gamepad_axis_mapping);
controls[control].push_back(gamepad_axis_mapping);
break; break;
} }
case mapping_type::game_controller_button:
case mapping_type::gamepad_button:
{ {
input::game_controller_button_mapping* game_controller_button_mapping = new input::game_controller_button_mapping(static_cast<const input::game_controller_button_mapping&>(mapping));
game_controller_button_mappings.push_back(game_controller_button_mapping);
controls[control].push_back(game_controller_button_mapping);
input::gamepad_button_mapping* gamepad_button_mapping = new input::gamepad_button_mapping(static_cast<const input::gamepad_button_mapping&>(mapping));
gamepad_button_mappings.push_back(gamepad_button_mapping);
controls[control].push_back(gamepad_button_mapping);
break; break;
} }
@ -125,12 +125,12 @@ void event_router::remove_mappings(control* control)
mouse_button_mappings.remove(static_cast<mouse_button_mapping*>(mapping)); mouse_button_mappings.remove(static_cast<mouse_button_mapping*>(mapping));
break; break;
case mapping_type::game_controller_axis:
game_controller_axis_mappings.remove(static_cast<game_controller_axis_mapping*>(mapping));
case mapping_type::gamepad_axis:
gamepad_axis_mappings.remove(static_cast<gamepad_axis_mapping*>(mapping));
break; break;
case mapping_type::game_controller_button:
game_controller_button_mappings.remove(static_cast<game_controller_button_mapping*>(mapping));
case mapping_type::gamepad_button:
gamepad_button_mappings.remove(static_cast<gamepad_button_mapping*>(mapping));
break; break;
default: default:
@ -154,9 +154,9 @@ void event_router::set_event_dispatcher(::event_dispatcher* event_dispatcher)
this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this); this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this);
this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this); this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<mouse_button_released_event>(this); this->event_dispatcher->unsubscribe<mouse_button_released_event>(this);
this->event_dispatcher->unsubscribe<game_controller_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<game_controller_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<game_controller_button_released_event>(this);
this->event_dispatcher->unsubscribe<gamepad_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<gamepad_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<gamepad_button_released_event>(this);
} }
this->event_dispatcher = event_dispatcher; this->event_dispatcher = event_dispatcher;
@ -169,9 +169,9 @@ void event_router::set_event_dispatcher(::event_dispatcher* event_dispatcher)
event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this); event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this);
event_dispatcher->subscribe<mouse_button_pressed_event>(this); event_dispatcher->subscribe<mouse_button_pressed_event>(this);
event_dispatcher->subscribe<mouse_button_released_event>(this); event_dispatcher->subscribe<mouse_button_released_event>(this);
event_dispatcher->subscribe<game_controller_axis_moved_event>(this);
event_dispatcher->subscribe<game_controller_button_pressed_event>(this);
event_dispatcher->subscribe<game_controller_button_released_event>(this);
event_dispatcher->subscribe<gamepad_axis_moved_event>(this);
event_dispatcher->subscribe<gamepad_button_pressed_event>(this);
event_dispatcher->subscribe<gamepad_button_released_event>(this);
} }
} }
@ -190,8 +190,8 @@ void event_router::remove_mappings()
mouse_motion_mappings.clear(); mouse_motion_mappings.clear();
mouse_wheel_mappings.clear(); mouse_wheel_mappings.clear();
mouse_button_mappings.clear(); mouse_button_mappings.clear();
game_controller_axis_mappings.clear();
game_controller_button_mappings.clear();
gamepad_axis_mappings.clear();
gamepad_button_mappings.clear();
} }
const std::list<mapping*>* event_router::get_mappings(control* control) const const std::list<mapping*>* event_router::get_mappings(control* control) const
@ -301,9 +301,9 @@ void event_router::handle_event(const mouse_button_released_event& event)
} }
} }
void event_router::handle_event(const game_controller_axis_moved_event& event)
void event_router::handle_event(const gamepad_axis_moved_event& event)
{ {
for (const game_controller_axis_mapping* mapping: game_controller_axis_mappings)
for (const gamepad_axis_mapping* mapping: gamepad_axis_mappings)
{ {
if ((!mapping->controller || mapping->controller == event.controller) && mapping->axis == event.axis) if ((!mapping->controller || mapping->controller == event.controller) && mapping->axis == event.axis)
{ {
@ -319,9 +319,9 @@ void event_router::handle_event(const game_controller_axis_moved_event& event)
} }
} }
void event_router::handle_event(const game_controller_button_pressed_event& event)
void event_router::handle_event(const gamepad_button_pressed_event& event)
{ {
for (const game_controller_button_mapping* mapping: game_controller_button_mappings)
for (const gamepad_button_mapping* mapping: gamepad_button_mappings)
{ {
if ((!mapping->controller || mapping->controller == event.controller) && mapping->button == event.button) if ((!mapping->controller || mapping->controller == event.controller) && mapping->button == event.button)
{ {
@ -330,9 +330,9 @@ void event_router::handle_event(const game_controller_button_pressed_event& even
} }
} }
void event_router::handle_event(const game_controller_button_released_event& event)
void event_router::handle_event(const gamepad_button_released_event& event)
{ {
for (const game_controller_button_mapping* mapping: game_controller_button_mappings)
for (const gamepad_button_mapping* mapping: gamepad_button_mappings)
{ {
if ((!mapping->controller || mapping->controller == event.controller) && mapping->button == event.button) if ((!mapping->controller || mapping->controller == event.controller) && mapping->button == event.button)
{ {

+ 10
- 10
src/input/event-router.hpp View File

@ -34,8 +34,8 @@ class key_mapping;
class mouse_motion_mapping; class mouse_motion_mapping;
class mouse_wheel_mapping; class mouse_wheel_mapping;
class mouse_button_mapping; class mouse_button_mapping;
class game_controller_axis_mapping;
class game_controller_button_mapping;
class gamepad_axis_mapping;
class gamepad_button_mapping;
enum class mouse_motion_axis; enum class mouse_motion_axis;
enum class mouse_wheel_axis; enum class mouse_wheel_axis;
@ -49,9 +49,9 @@ class event_router:
public event_handler<mouse_wheel_scrolled_event>, public event_handler<mouse_wheel_scrolled_event>,
public event_handler<mouse_button_pressed_event>, public event_handler<mouse_button_pressed_event>,
public event_handler<mouse_button_released_event>, public event_handler<mouse_button_released_event>,
public event_handler<game_controller_axis_moved_event>,
public event_handler<game_controller_button_pressed_event>,
public event_handler<game_controller_button_released_event>
public event_handler<gamepad_axis_moved_event>,
public event_handler<gamepad_button_pressed_event>,
public event_handler<gamepad_button_released_event>
{ {
public: public:
/** /**
@ -99,9 +99,9 @@ private:
virtual void handle_event(const mouse_wheel_scrolled_event& event); virtual void handle_event(const mouse_wheel_scrolled_event& event);
virtual void handle_event(const mouse_button_pressed_event& event); virtual void handle_event(const mouse_button_pressed_event& event);
virtual void handle_event(const mouse_button_released_event& event); virtual void handle_event(const mouse_button_released_event& event);
virtual void handle_event(const game_controller_axis_moved_event& event);
virtual void handle_event(const game_controller_button_pressed_event& event);
virtual void handle_event(const game_controller_button_released_event& event);
virtual void handle_event(const gamepad_axis_moved_event& event);
virtual void handle_event(const gamepad_button_pressed_event& event);
virtual void handle_event(const gamepad_button_released_event& event);
event_dispatcher* event_dispatcher; event_dispatcher* event_dispatcher;
std::map<control*, std::list<mapping*>> controls; std::map<control*, std::list<mapping*>> controls;
@ -109,8 +109,8 @@ private:
std::list<mouse_motion_mapping*> mouse_motion_mappings; std::list<mouse_motion_mapping*> mouse_motion_mappings;
std::list<mouse_wheel_mapping*> mouse_wheel_mappings; std::list<mouse_wheel_mapping*> mouse_wheel_mappings;
std::list<mouse_button_mapping*> mouse_button_mappings; std::list<mouse_button_mapping*> mouse_button_mappings;
std::list<game_controller_axis_mapping*> game_controller_axis_mappings;
std::list<game_controller_button_mapping*> game_controller_button_mappings;
std::list<gamepad_axis_mapping*> gamepad_axis_mappings;
std::list<gamepad_button_mapping*> gamepad_button_mappings;
}; };
} // namespace input } // namespace input

src/input/game-controller.cpp → src/input/gamepad.cpp View File

@ -17,7 +17,7 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "game-controller.hpp"
#include "gamepad.hpp"
#include "event/input-events.hpp" #include "event/input-events.hpp"
#include "event/event-dispatcher.hpp" #include "event/event-dispatcher.hpp"
#include "math/map.hpp" #include "math/map.hpp"
@ -26,7 +26,7 @@
namespace input { namespace input {
game_controller::game_controller():
gamepad::gamepad():
connected(true), connected(true),
left_deadzone_cross(true), left_deadzone_cross(true),
right_deadzone_cross(true), right_deadzone_cross(true),
@ -38,70 +38,70 @@ game_controller::game_controller():
axis_values[i] = 0.0f; axis_values[i] = 0.0f;
axis_activation_min[i] = 0.0f; axis_activation_min[i] = 0.0f;
axis_activation_max[i] = 1.0f; axis_activation_max[i] = 1.0f;
axis_response_curves[i] = game_controller_response_curve::linear;
axis_response_curves[i] = gamepad_response_curve::linear;
} }
} }
void game_controller::set_activation_threshold(game_controller_axis axis, float min, float max)
void gamepad::set_activation_threshold(gamepad_axis axis, float min, float max)
{ {
axis_activation_min[static_cast<int>(axis)] = min; axis_activation_min[static_cast<int>(axis)] = min;
axis_activation_max[static_cast<int>(axis)] = max; axis_activation_max[static_cast<int>(axis)] = max;
} }
void game_controller::set_response_curve(game_controller_axis axis, game_controller_response_curve curve)
void gamepad::set_response_curve(gamepad_axis axis, gamepad_response_curve curve)
{ {
axis_response_curves[static_cast<int>(axis)] = curve; axis_response_curves[static_cast<int>(axis)] = curve;
} }
void game_controller::set_left_deadzone_cross(bool cross)
void gamepad::set_left_deadzone_cross(bool cross)
{ {
left_deadzone_cross = cross; left_deadzone_cross = cross;
} }
void game_controller::set_right_deadzone_cross(bool cross)
void gamepad::set_right_deadzone_cross(bool cross)
{ {
right_deadzone_cross = cross; right_deadzone_cross = cross;
} }
void game_controller::set_left_deadzone_roundness(float roundness)
void gamepad::set_left_deadzone_roundness(float roundness)
{ {
left_deadzone_roundness = roundness; left_deadzone_roundness = roundness;
} }
void game_controller::set_right_deadzone_roundness(float roundness)
void gamepad::set_right_deadzone_roundness(float roundness)
{ {
right_deadzone_roundness = roundness; right_deadzone_roundness = roundness;
} }
void game_controller::press(game_controller_button button)
void gamepad::press(gamepad_button button)
{ {
if (!device::event_dispatcher) if (!device::event_dispatcher)
{ {
return; return;
} }
game_controller_button_pressed_event event;
gamepad_button_pressed_event event;
event.controller = this; event.controller = this;
event.button = button; event.button = button;
device::event_dispatcher->queue(event); device::event_dispatcher->queue(event);
} }
void game_controller::release(game_controller_button button)
void gamepad::release(gamepad_button button)
{ {
if (!device::event_dispatcher) if (!device::event_dispatcher)
{ {
return; return;
} }
game_controller_button_released_event event;
gamepad_button_released_event event;
event.controller = this; event.controller = this;
event.button = button; event.button = button;
device::event_dispatcher->queue(event); device::event_dispatcher->queue(event);
} }
void game_controller::move(game_controller_axis axis, float value)
void gamepad::move(gamepad_axis axis, float value)
{ {
// Update axis value // Update axis value
axis_values[static_cast<int>(axis)] = value; axis_values[static_cast<int>(axis)] = value;
@ -113,20 +113,20 @@ void game_controller::move(game_controller_axis axis, float value)
switch (axis) switch (axis)
{ {
case game_controller_axis::left_x:
case game_controller_axis::left_y:
case gamepad_axis::left_x:
case gamepad_axis::left_y:
if (left_deadzone_cross) if (left_deadzone_cross)
handle_axial_motion(axis); handle_axial_motion(axis);
else else
handle_biaxial_motion(game_controller_axis::left_x, game_controller_axis::left_y);
handle_biaxial_motion(gamepad_axis::left_x, gamepad_axis::left_y);
break; break;
case game_controller_axis::right_x:
case game_controller_axis::right_y:
case gamepad_axis::right_x:
case gamepad_axis::right_y:
if (right_deadzone_cross) if (right_deadzone_cross)
handle_axial_motion(axis); handle_axial_motion(axis);
else else
handle_biaxial_motion(game_controller_axis::right_x, game_controller_axis::right_y);
handle_biaxial_motion(gamepad_axis::right_x, gamepad_axis::right_y);
break; break;
default: default:
@ -135,17 +135,17 @@ void game_controller::move(game_controller_axis axis, float value)
} }
} }
void game_controller::handle_axial_motion(game_controller_axis axis)
void gamepad::handle_axial_motion(gamepad_axis axis)
{ {
// Get axis parameters // Get axis parameters
const int axis_index = static_cast<int>(axis); const int axis_index = static_cast<int>(axis);
const float activation_min = axis_activation_min[axis_index]; const float activation_min = axis_activation_min[axis_index];
const float activation_max = axis_activation_max[axis_index]; const float activation_max = axis_activation_max[axis_index];
const float axis_value = axis_values[axis_index]; const float axis_value = axis_values[axis_index];
const game_controller_response_curve response_curve = axis_response_curves[axis_index];
const gamepad_response_curve response_curve = axis_response_curves[axis_index];
// Build event // Build event
game_controller_axis_moved_event event;
gamepad_axis_moved_event event;
event.controller = this; event.controller = this;
event.axis = axis; event.axis = axis;
@ -172,7 +172,7 @@ void game_controller::handle_axial_motion(game_controller_axis axis)
device::event_dispatcher->queue(event); device::event_dispatcher->queue(event);
} }
void game_controller::handle_biaxial_motion(game_controller_axis axis_x, game_controller_axis axis_y)
void gamepad::handle_biaxial_motion(gamepad_axis axis_x, gamepad_axis axis_y)
{ {
// Get axis parameters // Get axis parameters
const int x_axis_index = static_cast<int>(axis_x); const int x_axis_index = static_cast<int>(axis_x);
@ -183,9 +183,9 @@ void game_controller::handle_biaxial_motion(game_controller_axis axis_x, game_co
const float y_activation_max = axis_activation_max[y_axis_index]; const float y_activation_max = axis_activation_max[y_axis_index];
const float x_axis_value = axis_values[x_axis_index]; const float x_axis_value = axis_values[x_axis_index];
const float y_axis_value = axis_values[y_axis_index]; const float y_axis_value = axis_values[y_axis_index];
const game_controller_response_curve x_response_curve = axis_response_curves[x_axis_index];
const game_controller_response_curve y_response_curve = axis_response_curves[y_axis_index];
const float deadzone_roundness = (axis_x == game_controller_axis::left_x) ? left_deadzone_roundness : right_deadzone_roundness;
const gamepad_response_curve x_response_curve = axis_response_curves[x_axis_index];
const gamepad_response_curve y_response_curve = axis_response_curves[y_axis_index];
const float deadzone_roundness = (axis_x == gamepad_axis::left_x) ? left_deadzone_roundness : right_deadzone_roundness;
const float radius = std::min<float>(x_activation_min, y_activation_min) * deadzone_roundness; const float radius = std::min<float>(x_activation_min, y_activation_min) * deadzone_roundness;
const float dx = std::max<float>(0.0f, std::abs(x_axis_value) - x_activation_min + radius); const float dx = std::max<float>(0.0f, std::abs(x_axis_value) - x_activation_min + radius);
@ -193,7 +193,7 @@ void game_controller::handle_biaxial_motion(game_controller_axis axis_x, game_co
const float distance = std::sqrt(dx * dx + dy * dy) - radius; const float distance = std::sqrt(dx * dx + dy * dy) - radius;
// Build event // Build event
game_controller_axis_moved_event event;
gamepad_axis_moved_event event;
event.controller = this; event.controller = this;
if (distance > 0.0f) if (distance > 0.0f)
@ -230,20 +230,20 @@ void game_controller::handle_biaxial_motion(game_controller_axis axis_x, game_co
} }
} }
float game_controller::curve_response(game_controller_axis axis, float response) const
float gamepad::curve_response(gamepad_axis axis, float response) const
{ {
const game_controller_response_curve response_curve = axis_response_curves[static_cast<int>(axis)];
const gamepad_response_curve response_curve = axis_response_curves[static_cast<int>(axis)];
switch (response_curve) switch (response_curve)
{ {
case game_controller_response_curve::linear:
case gamepad_response_curve::linear:
break; break;
case game_controller_response_curve::square:
case gamepad_response_curve::square:
response = response * response; response = response * response;
break; break;
case game_controller_response_curve::cube:
case gamepad_response_curve::cube:
response = response * response * response; response = response * response * response;
break; break;
} }
@ -251,22 +251,22 @@ float game_controller::curve_response(game_controller_axis axis, float response)
return response; return response;
} }
void game_controller::connect(bool reconnected)
void gamepad::connect(bool reconnected)
{ {
connected = true; connected = true;
game_controller_connected_event event;
gamepad_connected_event event;
event.controller = this; event.controller = this;
event.reconnected = reconnected; event.reconnected = reconnected;
device::event_dispatcher->queue(event); device::event_dispatcher->queue(event);
} }
void game_controller::disconnect()
void gamepad::disconnect()
{ {
connected = false; connected = false;
game_controller_disconnected_event event;
gamepad_disconnected_event event;
event.controller = this; event.controller = this;
device::event_dispatcher->queue(event); device::event_dispatcher->queue(event);

src/input/game-controller.hpp → src/input/gamepad.hpp View File

@ -17,15 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ANTKEEPER_INPUT_GAME_CONTROLLER_HPP
#define ANTKEEPER_INPUT_GAME_CONTROLLER_HPP
#ifndef ANTKEEPER_INPUT_GAMEPAD_HPP
#define ANTKEEPER_INPUT_GAMEPAD_HPP
#include "device.hpp" #include "device.hpp"
namespace input { namespace input {
/// Game controller buttons.
enum class game_controller_button
/// Gamepad buttons.
enum class gamepad_button
{ {
a, a,
b, b,
@ -44,8 +44,8 @@ enum class game_controller_button
dpad_right dpad_right
}; };
/// Game controller axes.
enum class game_controller_axis
/// Gamepad axes.
enum class gamepad_axis
{ {
/// Left stick x-axis. /// Left stick x-axis.
left_x, left_x,
@ -66,8 +66,8 @@ enum class game_controller_axis
right_trigger, right_trigger,
}; };
/// Game controller axis activation response curves.
enum class game_controller_response_curve
/// Gamepad axis activation response curves.
enum class gamepad_response_curve
{ {
/// Linear response curve. /// Linear response curve.
linear, linear,
@ -80,37 +80,37 @@ enum class game_controller_response_curve
}; };
/** /**
* A virtual game controller which can generate game controller-related input events and pass them to an event dispatcher.
* A virtual gamepad which can generate gamepad-related input events and pass them to an event dispatcher.
* *
* @ingroup input * @ingroup input
*/ */
class game_controller: public device
class gamepad: public device
{ {
public: public:
/** /**
* Creates a game controller input device.
* Creates a gamepad input device.
*/ */
game_controller();
gamepad();
/// Destroys a game controller input device.
virtual ~game_controller() = default;
/// Destroys a gamepad input device.
virtual ~gamepad() = default;
/** /**
* Sets the activation threshold for a game controller axis.
* Sets the activation threshold for a gamepad axis.
* *
* @param axis Game controller axis.
* @param axis Gamepad axis.
* @param min Axis minimum activation threshold. * @param min Axis minimum activation threshold.
* @param max Axis maximum activation threshold. * @param max Axis maximum activation threshold.
*/ */
void set_activation_threshold(game_controller_axis axis, float min, float max);
void set_activation_threshold(gamepad_axis axis, float min, float max);
/** /**
* Sets the activation response curve of an axis. * Sets the activation response curve of an axis.
* *
* @param axis Game controller axis.
* @param axis Gamepad axis.
* @param curve Activation response curve. * @param curve Activation response curve.
*/ */
void set_response_curve(game_controller_axis axis, game_controller_response_curve curve);
void set_response_curve(gamepad_axis axis, gamepad_response_curve curve);
/** /**
* Sets the type of deadzone shape for the axes on the left stick. * Sets the type of deadzone shape for the axes on the left stick.
@ -141,51 +141,51 @@ public:
void set_right_deadzone_roundness(float roundness); void set_right_deadzone_roundness(float roundness);
/** /**
* Simulates a game controller button press.
* Simulates a gamepad button press.
* *
* @param button Index of the pressed button. * @param button Index of the pressed button.
*/ */
void press(game_controller_button button);
void press(gamepad_button button);
/** /**
* Simulates a game controller button release.
* Simulates a gamepad button release.
* *
* @param button Index of the released button. * @param button Index of the released button.
*/ */
void release(game_controller_button button);
void release(gamepad_button button);
/** /**
* Simulates a game controller axis movement.
* Simulates a gamepad axis movement.
* *
* @param axis Index of the moved axis. * @param axis Index of the moved axis.
* @param negative Whether the movement was negative or positive. * @param negative Whether the movement was negative or positive.
* @param value Normalized degree of movement. * @param value Normalized degree of movement.
*/ */
void move(game_controller_axis axis, float value);
void move(gamepad_axis axis, float value);
/** /**
* Simulates a game controller being connected.
* Simulates a gamepad being connected.
* *
* @param reconnected `true` if the controller is being reconnected, or `false` if the controller is being connected for the first time. * @param reconnected `true` if the controller is being reconnected, or `false` if the controller is being connected for the first time.
*/ */
void connect(bool reconnnected); void connect(bool reconnnected);
/// Simulates a game controller being disconnected.
/// Simulates a gamepad being disconnected.
void disconnect(); void disconnect();
/// Returns `true` if the controller is currently connected. /// Returns `true` if the controller is currently connected.
bool is_connected() const; bool is_connected() const;
private: private:
void handle_axial_motion(game_controller_axis axis);
void handle_biaxial_motion(game_controller_axis axis_x, game_controller_axis axis_y);
float curve_response(game_controller_axis axis, float response) const;
void handle_axial_motion(gamepad_axis axis);
void handle_biaxial_motion(gamepad_axis axis_x, gamepad_axis axis_y);
float curve_response(gamepad_axis axis, float response) const;
bool connected; bool connected;
float axis_values[6]; float axis_values[6];
float axis_activation_min[6]; float axis_activation_min[6];
float axis_activation_max[6]; float axis_activation_max[6];
game_controller_response_curve axis_response_curves[6];
gamepad_response_curve axis_response_curves[6];
bool left_deadzone_cross; bool left_deadzone_cross;
bool right_deadzone_cross; bool right_deadzone_cross;
@ -193,12 +193,11 @@ private:
float right_deadzone_roundness; float right_deadzone_roundness;
}; };
inline bool game_controller::is_connected() const
inline bool gamepad::is_connected() const
{ {
return connected; return connected;
} }
} // namespace input } // namespace input
#endif // ANTKEEPER_INPUT_GAME_CONTROLLER_HPP
#endif // ANTKEEPER_INPUT_GAMEPAD_HPP

+ 1
- 1
src/input/input.hpp View File

@ -27,7 +27,7 @@ namespace input {}
#include "control-set.hpp" #include "control-set.hpp"
#include "device.hpp" #include "device.hpp"
#include "event-router.hpp" #include "event-router.hpp"
#include "game-controller.hpp"
#include "gamepad.hpp"
#include "keyboard.hpp" #include "keyboard.hpp"
#include "listener.hpp" #include "listener.hpp"
#include "mapper.hpp" #include "mapper.hpp"

+ 6
- 6
src/input/listener.cpp View File

@ -41,8 +41,8 @@ void listener::set_event_dispatcher(::event_dispatcher* event_dispatcher)
this->event_dispatcher->unsubscribe<mouse_moved_event>(this); this->event_dispatcher->unsubscribe<mouse_moved_event>(this);
this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this); this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this);
this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this); this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<game_controller_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<game_controller_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<gamepad_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<gamepad_button_pressed_event>(this);
} }
this->event_dispatcher = event_dispatcher; this->event_dispatcher = event_dispatcher;
@ -53,8 +53,8 @@ void listener::set_event_dispatcher(::event_dispatcher* event_dispatcher)
event_dispatcher->subscribe<mouse_moved_event>(this); event_dispatcher->subscribe<mouse_moved_event>(this);
event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this); event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this);
event_dispatcher->subscribe<mouse_button_pressed_event>(this); event_dispatcher->subscribe<mouse_button_pressed_event>(this);
event_dispatcher->subscribe<game_controller_axis_moved_event>(this);
event_dispatcher->subscribe<game_controller_button_pressed_event>(this);
event_dispatcher->subscribe<gamepad_axis_moved_event>(this);
event_dispatcher->subscribe<gamepad_button_pressed_event>(this);
} }
} }
@ -108,7 +108,7 @@ void listener::handle_event(const mouse_wheel_scrolled_event& event)
callback(event); callback(event);
} }
void listener::handle_event(const game_controller_button_pressed_event& event)
void listener::handle_event(const gamepad_button_pressed_event& event)
{ {
if (!is_enabled() || !callback) if (!is_enabled() || !callback)
{ {
@ -118,7 +118,7 @@ void listener::handle_event(const game_controller_button_pressed_event& event)
callback(event); callback(event);
} }
void listener::handle_event(const game_controller_axis_moved_event& event)
void listener::handle_event(const gamepad_axis_moved_event& event)
{ {
if (!is_enabled() || !callback) if (!is_enabled() || !callback)
{ {

+ 4
- 4
src/input/listener.hpp View File

@ -35,8 +35,8 @@ class listener:
public event_handler<mouse_moved_event>, public event_handler<mouse_moved_event>,
public event_handler<mouse_wheel_scrolled_event>, public event_handler<mouse_wheel_scrolled_event>,
public event_handler<mouse_button_pressed_event>, public event_handler<mouse_button_pressed_event>,
public event_handler<game_controller_axis_moved_event>,
public event_handler<game_controller_button_pressed_event>
public event_handler<gamepad_axis_moved_event>,
public event_handler<gamepad_button_pressed_event>
{ {
public: public:
/** /**
@ -78,8 +78,8 @@ private:
void handle_event(const mouse_moved_event& event); void handle_event(const mouse_moved_event& event);
void handle_event(const mouse_wheel_scrolled_event& event); void handle_event(const mouse_wheel_scrolled_event& event);
void handle_event(const mouse_button_pressed_event& event); void handle_event(const mouse_button_pressed_event& event);
void handle_event(const game_controller_axis_moved_event& event);
void handle_event(const game_controller_button_pressed_event& event);
void handle_event(const gamepad_axis_moved_event& event);
void handle_event(const gamepad_button_pressed_event& event);
event_dispatcher* event_dispatcher; event_dispatcher* event_dispatcher;
std::function<void(const event_base&)> callback; std::function<void(const event_base&)> callback;

+ 8
- 8
src/input/mapper.cpp View File

@ -43,8 +43,8 @@ void mapper::set_event_dispatcher(::event_dispatcher* event_dispatcher)
this->event_dispatcher->unsubscribe<mouse_moved_event>(this); this->event_dispatcher->unsubscribe<mouse_moved_event>(this);
this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this); this->event_dispatcher->unsubscribe<mouse_wheel_scrolled_event>(this);
this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this); this->event_dispatcher->unsubscribe<mouse_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<game_controller_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<game_controller_button_pressed_event>(this);
this->event_dispatcher->unsubscribe<gamepad_axis_moved_event>(this);
this->event_dispatcher->unsubscribe<gamepad_button_pressed_event>(this);
} }
this->event_dispatcher = event_dispatcher; this->event_dispatcher = event_dispatcher;
@ -55,8 +55,8 @@ void mapper::set_event_dispatcher(::event_dispatcher* event_dispatcher)
event_dispatcher->subscribe<mouse_moved_event>(this); event_dispatcher->subscribe<mouse_moved_event>(this);
event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this); event_dispatcher->subscribe<mouse_wheel_scrolled_event>(this);
event_dispatcher->subscribe<mouse_button_pressed_event>(this); event_dispatcher->subscribe<mouse_button_pressed_event>(this);
event_dispatcher->subscribe<game_controller_axis_moved_event>(this);
event_dispatcher->subscribe<game_controller_button_pressed_event>(this);
event_dispatcher->subscribe<gamepad_axis_moved_event>(this);
event_dispatcher->subscribe<gamepad_button_pressed_event>(this);
} }
} }
@ -135,24 +135,24 @@ void mapper::handle_event(const mouse_wheel_scrolled_event& event)
} }
} }
void mapper::handle_event(const game_controller_button_pressed_event& event)
void mapper::handle_event(const gamepad_button_pressed_event& event)
{ {
if (!is_enabled() || !callback) if (!is_enabled() || !callback)
{ {
return; return;
} }
callback(game_controller_button_mapping(control, event.controller, event.button));
callback(gamepad_button_mapping(control, event.controller, event.button));
} }
void mapper::handle_event(const game_controller_axis_moved_event& event)
void mapper::handle_event(const gamepad_axis_moved_event& event)
{ {
if (!is_enabled() || !callback) if (!is_enabled() || !callback)
{ {
return; return;
} }
callback(game_controller_axis_mapping(control, event.controller, event.axis, (event.value < 0.0f)));
callback(gamepad_axis_mapping(control, event.controller, event.axis, (event.value < 0.0f)));
} }
} // namespace input } // namespace input

+ 4
- 4
src/input/mapper.hpp View File

@ -36,8 +36,8 @@ class mapper:
public event_handler<mouse_moved_event>, public event_handler<mouse_moved_event>,
public event_handler<mouse_wheel_scrolled_event>, public event_handler<mouse_wheel_scrolled_event>,
public event_handler<mouse_button_pressed_event>, public event_handler<mouse_button_pressed_event>,
public event_handler<game_controller_axis_moved_event>,
public event_handler<game_controller_button_pressed_event>
public event_handler<gamepad_axis_moved_event>,
public event_handler<gamepad_button_pressed_event>
{ {
public: public:
/** /**
@ -86,8 +86,8 @@ private:
void handle_event(const mouse_moved_event& event); void handle_event(const mouse_moved_event& event);
void handle_event(const mouse_wheel_scrolled_event& event); void handle_event(const mouse_wheel_scrolled_event& event);
void handle_event(const mouse_button_pressed_event& event); void handle_event(const mouse_button_pressed_event& event);
void handle_event(const game_controller_axis_moved_event& event);
void handle_event(const game_controller_button_pressed_event& event);
void handle_event(const gamepad_axis_moved_event& event);
void handle_event(const gamepad_button_pressed_event& event);
event_dispatcher* event_dispatcher; event_dispatcher* event_dispatcher;
control* control; control* control;

+ 6
- 6
src/input/mapping.cpp View File

@ -101,19 +101,19 @@ mouse_button_mapping& mouse_button_mapping::operator=(const mouse_button_mapping
return *this; return *this;
} }
game_controller_axis_mapping::game_controller_axis_mapping(const game_controller_axis_mapping& mapping)
gamepad_axis_mapping::gamepad_axis_mapping(const gamepad_axis_mapping& mapping)
{ {
*this = mapping; *this = mapping;
} }
game_controller_axis_mapping::game_controller_axis_mapping(input::control* control, game_controller* controller, game_controller_axis axis, bool negative):
gamepad_axis_mapping::gamepad_axis_mapping(input::control* control, gamepad* controller, gamepad_axis axis, bool negative):
mapping(control), mapping(control),
controller(controller), controller(controller),
axis(axis), axis(axis),
negative(negative) negative(negative)
{} {}
game_controller_axis_mapping& game_controller_axis_mapping::operator=(const game_controller_axis_mapping& mapping)
gamepad_axis_mapping& gamepad_axis_mapping::operator=(const gamepad_axis_mapping& mapping)
{ {
control = mapping.control; control = mapping.control;
controller = mapping.controller; controller = mapping.controller;
@ -122,18 +122,18 @@ game_controller_axis_mapping& game_controller_axis_mapping::operator=(const game
return *this; return *this;
} }
game_controller_button_mapping::game_controller_button_mapping(const game_controller_button_mapping& mapping)
gamepad_button_mapping::gamepad_button_mapping(const gamepad_button_mapping& mapping)
{ {
*this = mapping; *this = mapping;
} }
game_controller_button_mapping::game_controller_button_mapping(input::control* control, game_controller* controller, game_controller_button button):
gamepad_button_mapping::gamepad_button_mapping(input::control* control, gamepad* controller, gamepad_button button):
mapping(control), mapping(control),
controller(controller), controller(controller),
button(button) button(button)
{} {}
game_controller_button_mapping& game_controller_button_mapping::operator=(const game_controller_button_mapping& mapping)
gamepad_button_mapping& gamepad_button_mapping::operator=(const gamepad_button_mapping& mapping)
{ {
control = mapping.control; control = mapping.control;
controller = mapping.controller; controller = mapping.controller;

+ 27
- 27
src/input/mapping.hpp View File

@ -25,12 +25,12 @@ namespace input {
enum class mouse_motion_axis; enum class mouse_motion_axis;
enum class mouse_wheel_axis; enum class mouse_wheel_axis;
enum class scancode; enum class scancode;
enum class game_controller_axis;
enum class game_controller_button;
enum class gamepad_axis;
enum class gamepad_button;
class control; class control;
class keyboard; class keyboard;
class mouse; class mouse;
class game_controller;
class gamepad;
/** /**
* Enumerates the supported types of control mappings. * Enumerates the supported types of control mappings.
@ -41,8 +41,8 @@ enum class mapping_type
mouse_motion, mouse_motion,
mouse_wheel, mouse_wheel,
mouse_button, mouse_button,
game_controller_axis,
game_controller_button
gamepad_axis,
gamepad_button
}; };
/** /**
@ -150,50 +150,50 @@ inline mapping_type mouse_button_mapping::get_type() const
} }
/** /**
* A mapping between a control and a game controller axis.
* A mapping between a control and a gamepad axis.
*/ */
class game_controller_axis_mapping: public mapping
class gamepad_axis_mapping: public mapping
{ {
public: public:
game_controller_axis_mapping() = default;
game_controller_axis_mapping(const game_controller_axis_mapping& mapping);
game_controller_axis_mapping(input::control* control, game_controller* controller, game_controller_axis axis, bool negative);
virtual ~game_controller_axis_mapping() = default;
game_controller_axis_mapping& operator=(const game_controller_axis_mapping& mapping);
gamepad_axis_mapping() = default;
gamepad_axis_mapping(const gamepad_axis_mapping& mapping);
gamepad_axis_mapping(input::control* control, gamepad* controller, gamepad_axis axis, bool negative);
virtual ~gamepad_axis_mapping() = default;
gamepad_axis_mapping& operator=(const gamepad_axis_mapping& mapping);
virtual mapping_type get_type() const; virtual mapping_type get_type() const;
game_controller* controller;
game_controller_axis axis;
gamepad* controller;
gamepad_axis axis;
bool negative; bool negative;
}; };
inline mapping_type game_controller_axis_mapping::get_type() const
inline mapping_type gamepad_axis_mapping::get_type() const
{ {
return mapping_type::game_controller_axis;
return mapping_type::gamepad_axis;
} }
/** /**
* A mapping between a control and a game controller button.
* A mapping between a control and a gamepad button.
* *
* @ingroup input. * @ingroup input.
*/ */
class game_controller_button_mapping: public mapping
class gamepad_button_mapping: public mapping
{ {
public: public:
game_controller_button_mapping() = default;
game_controller_button_mapping(const game_controller_button_mapping& mapping);
game_controller_button_mapping(input::control* control, game_controller* controller, game_controller_button button);
virtual ~game_controller_button_mapping() = default;
game_controller_button_mapping& operator=(const game_controller_button_mapping& mapping);
gamepad_button_mapping() = default;
gamepad_button_mapping(const gamepad_button_mapping& mapping);
gamepad_button_mapping(input::control* control, gamepad* controller, gamepad_button button);
virtual ~gamepad_button_mapping() = default;
gamepad_button_mapping& operator=(const gamepad_button_mapping& mapping);
virtual mapping_type get_type() const; virtual mapping_type get_type() const;
game_controller* controller;
game_controller_button button;
gamepad* controller;
gamepad_button button;
}; };
inline mapping_type game_controller_button_mapping::get_type() const
inline mapping_type gamepad_button_mapping::get_type() const
{ {
return mapping_type::game_controller_button;
return mapping_type::gamepad_button;
} }
} // namespace input } // namespace input

+ 24
- 24
src/input/sdl-game-controller-tables.cpp View File

@ -18,37 +18,37 @@
*/ */
#include "sdl-game-controller-tables.hpp" #include "sdl-game-controller-tables.hpp"
#include "game-controller.hpp"
#include "gamepad.hpp"
namespace input { namespace input {
const game_controller_button sdl_button_table[15] =
const gamepad_button sdl_button_table[15] =
{ {
game_controller_button::a, // SDL_CONTROLLER_BUTTON_A,
game_controller_button::b, // SDL_CONTROLLER_BUTTON_B,
game_controller_button::x, // SDL_CONTROLLER_BUTTON_X,
game_controller_button::y, // SDL_CONTROLLER_BUTTON_Y,
game_controller_button::back, // SDL_CONTROLLER_BUTTON_BACK,
game_controller_button::guide, // SDL_CONTROLLER_BUTTON_GUIDE,
game_controller_button::start, // SDL_CONTROLLER_BUTTON_START,
game_controller_button::left_stick, // SDL_CONTROLLER_BUTTON_LEFTSTICK,
game_controller_button::right_stick, // SDL_CONTROLLER_BUTTON_RIGHTSTICK,
game_controller_button::left_shoulder, // SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
game_controller_button::right_shoulder, // SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
game_controller_button::dpad_up, // SDL_CONTROLLER_BUTTON_DPAD_UP,
game_controller_button::dpad_down, // SDL_CONTROLLER_BUTTON_DPAD_DOWN,
game_controller_button::dpad_left, // SDL_CONTROLLER_BUTTON_DPAD_LEFT,
game_controller_button::dpad_right, // SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
gamepad_button::a, // SDL_CONTROLLER_BUTTON_A,
gamepad_button::b, // SDL_CONTROLLER_BUTTON_B,
gamepad_button::x, // SDL_CONTROLLER_BUTTON_X,
gamepad_button::y, // SDL_CONTROLLER_BUTTON_Y,
gamepad_button::back, // SDL_CONTROLLER_BUTTON_BACK,
gamepad_button::guide, // SDL_CONTROLLER_BUTTON_GUIDE,
gamepad_button::start, // SDL_CONTROLLER_BUTTON_START,
gamepad_button::left_stick, // SDL_CONTROLLER_BUTTON_LEFTSTICK,
gamepad_button::right_stick, // SDL_CONTROLLER_BUTTON_RIGHTSTICK,
gamepad_button::left_shoulder, // SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
gamepad_button::right_shoulder, // SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
gamepad_button::dpad_up, // SDL_CONTROLLER_BUTTON_DPAD_UP,
gamepad_button::dpad_down, // SDL_CONTROLLER_BUTTON_DPAD_DOWN,
gamepad_button::dpad_left, // SDL_CONTROLLER_BUTTON_DPAD_LEFT,
gamepad_button::dpad_right, // SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
}; };
const game_controller_axis sdl_axis_table[6] =
const gamepad_axis sdl_axis_table[6] =
{ {
game_controller_axis::left_x, // SDL_CONTROLLER_AXIS_LEFTX,
game_controller_axis::left_y, // SDL_CONTROLLER_AXIS_LEFTY,
game_controller_axis::right_x, // SDL_CONTROLLER_AXIS_RIGHTX,
game_controller_axis::right_y, // SDL_CONTROLLER_AXIS_RIGHTY,
game_controller_axis::left_trigger, // SDL_CONTROLLER_AXIS_TRIGGERLEFT,
game_controller_axis::right_trigger, // SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
gamepad_axis::left_x, // SDL_CONTROLLER_AXIS_LEFTX,
gamepad_axis::left_y, // SDL_CONTROLLER_AXIS_LEFTY,
gamepad_axis::right_x, // SDL_CONTROLLER_AXIS_RIGHTX,
gamepad_axis::right_y, // SDL_CONTROLLER_AXIS_RIGHTY,
gamepad_axis::left_trigger, // SDL_CONTROLLER_AXIS_TRIGGERLEFT,
gamepad_axis::right_trigger, // SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
}; };
} // namespace input } // namespace input

+ 7
- 7
src/input/sdl-game-controller-tables.hpp View File

@ -17,18 +17,18 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ANTKEEPER_INPUT_SDL_GAME_CONTROLLER_TABLES_HPP
#define ANTKEEPER_INPUT_SDL_GAME_CONTROLLER_TABLES_HPP
#ifndef ANTKEEPER_INPUT_SDL_GAMEPAD_TABLES_HPP
#define ANTKEEPER_INPUT_SDL_GAMEPAD_TABLES_HPP
namespace input { namespace input {
enum class game_controller_button;
enum class game_controller_axis;
enum class gamepad_button;
enum class gamepad_axis;
extern const game_controller_button sdl_button_table[15];
extern const game_controller_axis sdl_axis_table[6];
extern const gamepad_button sdl_button_table[15];
extern const gamepad_axis sdl_axis_table[6];
} // namespace input } // namespace input
#endif // ANTKEEPER_INPUT_SDL_GAME_CONTROLLER_TABLES_HPP
#endif // ANTKEEPER_INPUT_SDL_GAMEPAD_TABLES_HPP

Loading…
Cancel
Save