File: input.h

package info (click to toggle)
nestopia 1.46.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,180 kB
  • ctags: 16,195
  • sloc: cpp: 78,615; xml: 26,798; ansic: 1,490; makefile: 634; sh: 19
file content (123 lines) | stat: -rw-r--r-- 2,559 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef _INPUT_H_
#define _INPUT_H_

#define NUMGAMEPADS 2
#define NUMBUTTONS 10
#define TOTALBUTTONS (NUMGAMEPADS*NUMBUTTONS)
#define DEADZONE (32768/3)

#include <SDL.h>
#include "core/api/NstApiInput.hpp"
#include "core/api/NstApiVideo.hpp"

using namespace Nes::Api;

typedef struct {
	SDL_Scancode u;
	SDL_Scancode d;
	SDL_Scancode l;
	SDL_Scancode r;
	SDL_Scancode select;
	SDL_Scancode start;
	SDL_Scancode a;
	SDL_Scancode b;
	SDL_Scancode ta;
	SDL_Scancode tb;
	
	SDL_Event ju;
	SDL_Event jd;
	SDL_Event jl;
	SDL_Event jr;
	SDL_Event jselect;
	SDL_Event jstart;
	SDL_Event ja;
	SDL_Event jb;
	SDL_Event jta;
	SDL_Event jtb;
} gamepad_t;

typedef struct {
	// Player 1
	char *kb_p1u;
	char *kb_p1d;
	char *kb_p1l;
	char *kb_p1r;
	char *kb_p1select;
	char *kb_p1start;
	char *kb_p1a;
	char *kb_p1b;
	char *kb_p1ta;
	char *kb_p1tb;
	
	char *js_p1u;
	char *js_p1d;
	char *js_p1l;
	char *js_p1r;
	char *js_p1select;
	char *js_p1start;
	char *js_p1a;
	char *js_p1b;
	char *js_p1ta;
	char *js_p1tb;
	
	// Player 2
	char *kb_p2u;
	char *kb_p2d;
	char *kb_p2l;
	char *kb_p2r;
	char *kb_p2select;
	char *kb_p2start;
	char *kb_p2a;
	char *kb_p2b;
	char *kb_p2ta;
	char *kb_p2tb;
	
	char *js_p2u;
	char *js_p2d;
	char *js_p2l;
	char *js_p2r;
	char *js_p2select;
	char *js_p2start;
	char *js_p2a;
	char *js_p2b;
	char *js_p2ta;
	char *js_p2tb;
} inputsettings_t;

typedef struct {
	unsigned char player;
	unsigned char nescode;
	unsigned char pressed;
	unsigned char turboa;
	unsigned char turbob;
} nesinput_t;

typedef struct {
	int p1a;
	int p1b;
	int p2a;
	int p2b;
} turbo_t;

void input_init();
void input_joysticks_detect();
void input_joysticks_close();
void input_process(Input::Controllers *controllers, SDL_Event event);
void input_pulse_turbo(Input::Controllers *controllers);
void input_inject(Input::Controllers *controllers, nesinput_t input);
void input_match_joystick(Input::Controllers *controllers, SDL_Event event);
void input_match_keyboard(Input::Controllers *controllers, SDL_Event event);
void input_match_mouse(Input::Controllers *controllers, SDL_Event event);
char* input_translate_event(SDL_Event event);
SDL_Event input_translate_string(char *string);
int input_checksign(int axisvalue);
void input_config_read_new();
void input_config_read();
void input_config_write();
void input_set_default();
static int input_config_match(void* user, const char* section, const char* name, const char* value);

int input_configure_item(int pnum, int bnum, int type);
void input_set_item(SDL_Event event, int type, int pnum, int counter);

#endif