mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-16 03:06:45 -04:00
fix bug, controller info, remove old stuff
This commit is contained in:
parent
e2fb5b9910
commit
1297cccd70
21 changed files with 98 additions and 66 deletions
|
@ -104,3 +104,6 @@ void init_joystick(const INI_CONFIG_SECTION *section) {
|
|||
char is_joystick_used() {
|
||||
return get_sdl_global_context().is_joystick_used()?1:0;
|
||||
}
|
||||
char is_joystick_enabled() {
|
||||
return get_sdl_global_context().is_joystick_enabled()?1:0;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ void ShareCPU();
|
|||
|
||||
void init_joystick(const INI_CONFIG_SECTION *section);
|
||||
char is_joystick_used();
|
||||
char is_joystick_enabled();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -349,24 +349,25 @@ void SDLContext::joystick_handle() {
|
|||
|
||||
void SDLContext::configure_controller(const JoystickConfig &cfg) {
|
||||
_jcontrol_map = cfg;
|
||||
if (_jcontrol_map.enabled) {
|
||||
if (init_context.controller) {
|
||||
SDL_AddTimer(25,[](Uint32 tm, void *ptr){
|
||||
SDLContext *me = reinterpret_cast<SDLContext *>(ptr);
|
||||
me->joystick_handle();
|
||||
return tm;
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool SDLContext::is_joystick_used() const {
|
||||
return _jcontrol_used;
|
||||
}
|
||||
|
||||
bool SDLContext::is_joystick_enabled() const {
|
||||
return init_context.controller != 0 && _jcontrol_map.enabled;
|
||||
}
|
||||
|
||||
void SDLContext::generate_j_event(int button, char up) {
|
||||
if (_jcontrol_map.enabled && button >= 0 && button < static_cast<int>(sizeof(_jcontrol_map.buttons)/sizeof(JoystickButton))) {
|
||||
_jcontrol_used = true;
|
||||
if (!_jcontrol_used) {
|
||||
SDL_AddTimer(25,[](Uint32 tm, void *ptr){
|
||||
SDLContext *me = reinterpret_cast<SDLContext *>(ptr);
|
||||
me->joystick_handle();
|
||||
return tm;
|
||||
}, this);
|
||||
_jcontrol_used = true;
|
||||
}
|
||||
JoystickButton b = _jcontrol_mod_key?_jcontrol_map.buttons_mod[button]:_jcontrol_map.buttons[button];
|
||||
SDL_Scancode cd = {};
|
||||
switch (b) {
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
|
||||
|
||||
bool is_joystick_used() const;
|
||||
bool is_joystick_enabled() const;
|
||||
protected:
|
||||
|
||||
struct SDL_Deleter {
|
||||
|
@ -240,7 +241,7 @@ protected:
|
|||
std::jthread _render_thread;
|
||||
|
||||
bool _fullscreen_mode = false;
|
||||
bool _present = false;
|
||||
bool _present = false;
|
||||
std::atomic<bool> _key_control = false;
|
||||
std::atomic<bool> _key_shift = false;
|
||||
std::atomic<bool> _key_capslock = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue