2012-08-15 02:41:21 +02:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
* See COPYING for further information.
|
2012-08-15 02:41:21 +02:00
|
|
|
* ---
|
2017-09-12 03:28:15 +02:00
|
|
|
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
|
2012-08-15 02:41:21 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GAMEPAD_H
|
|
|
|
#define GAMEPAD_H
|
|
|
|
|
2017-02-04 03:56:40 +01:00
|
|
|
#include <SDL.h>
|
2017-02-17 17:03:49 +01:00
|
|
|
#include <stdbool.h>
|
2012-08-15 02:41:21 +02:00
|
|
|
#include "events.h"
|
2017-02-17 17:03:49 +01:00
|
|
|
#include "config.h"
|
2012-08-15 02:41:21 +02:00
|
|
|
|
|
|
|
void gamepad_init(void);
|
|
|
|
void gamepad_shutdown(void);
|
|
|
|
void gamepad_restart(void);
|
2017-02-04 14:41:15 +01:00
|
|
|
float gamepad_axis_sens(int);
|
2012-08-15 02:41:21 +02:00
|
|
|
void gamepad_event(SDL_Event*, EventHandler, EventFlags, void*);
|
|
|
|
|
2017-08-28 13:51:05 +02:00
|
|
|
int gamepad_devicecount(void);
|
|
|
|
const char* gamepad_devicename(int);
|
2017-09-16 08:44:39 +02:00
|
|
|
void gamepad_deviceguid(int num, char *guid_str, size_t guid_str_sz);
|
2017-08-28 13:51:05 +02:00
|
|
|
int gamepad_numfromguid(const char *guid_str);
|
|
|
|
int gamepad_currentdevice(void);
|
|
|
|
|
2017-02-17 17:03:49 +01:00
|
|
|
bool gamepad_buttonpressed(int btn);
|
|
|
|
bool gamepad_gamekeypressed(KeyIndex key);
|
2012-08-17 20:58:23 +02:00
|
|
|
|
2017-07-15 05:22:56 +02:00
|
|
|
const char* gamepad_button_name(SDL_GameControllerButton btn);
|
|
|
|
const char* gamepad_axis_name(SDL_GameControllerAxis btn);
|
|
|
|
|
2012-08-16 23:35:48 +02:00
|
|
|
// shitty workaround for the options menu. Used to list devices while the gamepad subsystem is off.
|
|
|
|
// only initializes the SDL subsystem so you can use gamepad_devicecount/gamepad_devicename.
|
|
|
|
// if gamepad has been initialized already, these do nothing.
|
|
|
|
void gamepad_init_bare(void);
|
|
|
|
void gamepad_shutdown_bare(void);
|
|
|
|
|
2012-08-15 02:41:21 +02:00
|
|
|
enum {
|
|
|
|
AXISVAL_LEFT = -1,
|
|
|
|
AXISVAL_RIGHT = 1,
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-15 02:41:21 +02:00
|
|
|
AXISVAL_UP = -1,
|
|
|
|
AXISVAL_DOWN = 1,
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-15 02:41:21 +02:00
|
|
|
AXISVAL_NULL = 0
|
|
|
|
};
|
|
|
|
|
2017-02-27 23:58:47 +01:00
|
|
|
#define GAMEPAD_AXIS_MAX 32767
|
|
|
|
#define GAMEPAD_AXIS_MIN -32768
|
2017-03-06 16:32:51 +01:00
|
|
|
#define AXISVAL sign
|
2012-08-15 02:41:21 +02:00
|
|
|
|
|
|
|
#endif
|