-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #729 from LordEidi/master
Introducing game controller rumble in SDL builds
- Loading branch information
Showing
4 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,47 @@ | ||
#include <map> | ||
#include <vector> | ||
#include <algorithm> | ||
class System; | ||
|
||
struct GameController | ||
{ | ||
SDL_GameController* gc_id; | ||
bool can_rumble; | ||
}; | ||
|
||
class Input { | ||
public: | ||
static std::map<int, int> keys; | ||
static std::map<int, int> buttons; | ||
|
||
static int find_key(int key); | ||
static int find_key(int key); | ||
static int find_button(int button); | ||
|
||
Input(System *system); | ||
explicit Input(System *system); | ||
~Input(); | ||
|
||
// Input handlers return true if they handled the event | ||
bool handle_mouse(int button, bool state, int x, int y); | ||
bool handle_keyboard(int key, bool state); | ||
bool handle_controller_button(int button, bool state); | ||
bool handle_controller_motion(int axis, int value); | ||
|
||
private: | ||
// controller specific functions | ||
void handle_controller_added(Sint32 joystick_index); | ||
void handle_controller_removed(Sint32 joystick_index); | ||
|
||
void rumble_controllers(const float& volume); | ||
|
||
private: | ||
System *target; | ||
|
||
void _virtual_analog(int, int, int, int); | ||
std::vector<GameController> game_controllers; | ||
|
||
void _virtual_analog(int, int, int, int); | ||
void _virtual_tilt(int, int, int, int); | ||
|
||
void _add_controller(SDL_GameController* gc); | ||
void _remove_controller(SDL_GameController* gc); | ||
|
||
bool left_ctrl = false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters