File: input_functions.h

package info (click to toggle)
rockdodger 1.0.2-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 2,352 kB
  • ctags: 852
  • sloc: ansic: 5,790; makefile: 159; sh: 21
file content (74 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __INPUT_FUNCTIONS_H_2013__
#define __INPUT_FUNCTIONS_H_2013__
#include <SDL/SDL_joystick.h>

#define JOYSTICK_DEADZONE 1024

/*
 * The input states are names for mappings between input device states and game
 * inputs.
 */
enum inputstates {
  UP,
  DOWN,
  LEFT,
  RIGHT,
  LASER,
  SHIELD,
  FAST,
  NOFAST,
  SCREENSHOT,
  INPUT_SELECT,
  _INPUTSTATESEND
};
#define NUM_INPUTS (_INPUTSTATESEND + 1)

/*! \brief input state data
 *
 * This struct will hold all the information about input, e.g.,
 * movement and laser and shields.
 */
typedef struct {
  int inputstate[NUM_INPUTS]; //!< The input states for each valid input
} inputstate_t;


extern int joystick_flag; //!< If == 1 then joystick is enabled.
extern SDL_Joystick *joysticks[1]; //!< Joystick data


/*! \brief input subsystem function
 *
 * This will call the get joystick/keyboard functions.
 *
 * \param inputstate Write current state there.
 * \return keyboard state for quick check of pressed keys
 */
Uint8 *input_subsystem(inputstate_t *inputstate);


/*! \brief get the joystick input
 *
 * \param inputstate The input state to write the information to.
 * \return The modified inputstate (same as inputstate)
 */
inputstate_t *get_joystick_input(inputstate_t *inputstate);


/*! \brief get the keyboard input
 *
 * The keyboad input is handled differently according to the current
 * game state...
 *
 * \param keystate current keyboard states
 * \param inputstate updated after call
 */
void get_keyboard_input(Uint8 *keystate, inputstate_t *inputstate);

/*! \brief temporaryly disable keyboard input
 *
 * This function uses the global variable last_ticks.
 */
void temporary_disable_key_input();

#endif