naev 0.11.5
input.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include "SDL.h"
10#define NMOD_NONE 0
11#define NMOD_SHIFT (1<<0)
12#define NMOD_CTRL (1<<1)
13#define NMOD_ALT (1<<2)
14#define NMOD_META (1<<3)
15#define NMOD_ANY 0xFFFF
17#define KEY_PRESS ( 1.)
18#define KEY_RELEASE (-1.)
20/* input types */
21typedef enum {
22 KEYBIND_NULL,
23 KEYBIND_KEYBOARD,
24 KEYBIND_JAXISPOS,
25 KEYBIND_JAXISNEG,
26 KEYBIND_JBUTTON,
27 KEYBIND_JHAT_UP,
28 KEYBIND_JHAT_DOWN,
29 KEYBIND_JHAT_LEFT,
30 KEYBIND_JHAT_RIGHT
31} KeybindType;
33extern const char *keybind_info[][ 3 ];
34extern const int input_numbinds;
35
36/*
37 * set input
38 */
39void input_setDefault( int wasd );
40SDL_Keycode input_keyConv( const char *name );
41void input_setKeybind( const char *keybind, KeybindType type, SDL_Keycode key, SDL_Keymod mod );
42const char *input_modToText( SDL_Keymod mod );
43SDL_Keycode input_getKeybind( const char *keybind, KeybindType *type, SDL_Keymod *mod );
44void input_getKeybindDisplay( const char *keybind, char *buf, int len );
45const char *input_getKeybindDescription( const char *keybind );
46const char *input_keyAlreadyBound( KeybindType type, SDL_Keycode key, SDL_Keymod mod );
47
48/*
49 * Misc.
50 */
51SDL_Keymod input_translateMod( SDL_Keymod mod );
52void input_enableAll (void);
53void input_disableAll (void);
54void input_toggleEnable( const char *key, int enable );
55int input_clickPos( SDL_Event *event, double x, double y, double zoom, double minpr, double minr );
56int input_clickedJump( int jump, int autonav );
57int input_clickedSpob( int spob, int autonav );
58int input_clickedAsteroid( int field, int asteroid );
59int input_clickedPilot( unsigned int pilot, int autonav );
60void input_clicked( void *clicked );
61int input_isDoubleClick( void *clicked );
62
63/*
64 * handle input
65 */
66void input_handle( SDL_Event* event );
67
68/*
69 * init/exit
70 */
71void input_init (void);
72void input_exit (void);
73
74/*
75 * Updating.
76 */
77void input_update( double dt );
78
79/*
80 * Mouse.
81 */
82void input_mouseShow (void);
83void input_mouseHide (void);
void input_init(void)
Initializes the input subsystem (does not set keys).
Definition input.c:278
SDL_Keycode input_getKeybind(const char *keybind, KeybindType *type, SDL_Keymod *mod)
Gets the value of a keybind.
Definition input.c:431
void input_disableAll(void)
Disables all the keybinds.
Definition input.c:346
int input_clickedPilot(unsigned int pilot, int autonav)
Performs an appropriate action when a pilot is clicked.
Definition input.c:1416
const char * keybind_info[][3]
Definition input.c:50
void input_clicked(void *clicked)
Sets the last-clicked item, for double-click detection.
Definition input.c:1449
SDL_Keycode input_keyConv(const char *name)
Gets the key id from its name.
Definition input.c:392
void input_toggleEnable(const char *key, int enable)
Enables or disables a keybind.
Definition input.c:355
void input_handle(SDL_Event *event)
Handles global input.
Definition input.c:1485
void input_mouseShow(void)
Shows the mouse.
Definition input.c:368
int input_isDoubleClick(void *clicked)
Checks whether a clicked item is the same as the last-clicked.
Definition input.c:1462
const char * input_keyAlreadyBound(KeybindType type, SDL_Keycode key, SDL_Keymod mod)
Checks to see if a key is already bound.
Definition input.c:537
void input_setDefault(int wasd)
Sets the default input keys.
Definition input.c:172
int input_clickPos(SDL_Event *event, double x, double y, double zoom, double minpr, double minr)
Handles a click at a position in the current system.
Definition input.c:1234
int input_clickedAsteroid(int field, int asteroid)
Performs an appropriate action when an asteroid is clicked.
Definition input.c:1400
int input_clickedSpob(int spob, int autonav)
Performs an appropriate action when a spob is clicked.
Definition input.c:1357
void input_update(double dt)
Handles key repeating.
Definition input.c:614
void input_setKeybind(const char *keybind, KeybindType type, SDL_Keycode key, SDL_Keymod mod)
Binds key of type type to action keybind.
Definition input.c:409
void input_exit(void)
exits the input subsystem.
Definition input.c:329
const char * input_getKeybindDescription(const char *keybind)
Gets the description of the keybinding.
Definition input.c:582
SDL_Keymod input_translateMod(SDL_Keymod mod)
Translates SDL modifier to Naev modifier.
Definition input.c:597
const int input_numbinds
Definition input.c:129
void input_enableAll(void)
Enables all the keybinds.
Definition input.c:337
int input_clickedJump(int jump, int autonav)
Performs an appropriate action when a jump point is clicked.
Definition input.c:1322
const char * input_modToText(SDL_Keymod mod)
Gets the human readable version of mod.
Definition input.c:516
void input_getKeybindDisplay(const char *keybind, char *buf, int len)
Gets the display name (translated and human-readable) of a keybind.
Definition input.c:453
void input_mouseHide(void)
Hides the mouse.
Definition input.c:377