File: input.h

package info (click to toggle)
nestopia 1.52.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,140 kB
  • sloc: cpp: 127,444; xml: 27,234; ansic: 3,635; makefile: 949; sh: 19
file content (164 lines) | stat: -rw-r--r-- 2,915 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef _INPUT_H_
#define _INPUT_H_

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

#include "core/api/NstApiInput.hpp"

typedef struct {
	int u;
	int d;
	int l;
	int r;
	int select;
	int start;
	int a;
	int b;
	int ta;
	int 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;
	SDL_Event rwstart;
	SDL_Event rwstop;
	SDL_Event softreset;
	SDL_Event hardreset;
} gamepad_t;

typedef struct {
	// User Interface
	int qsave1;
	int qsave2;
	int qload1;
	int qload2;

	int screenshot;

	int fdsflip;
	int fdsswitch;

	int insertcoin1;
	int insertcoin2;

	int reset;

	int ffspeed;
	int rwstart;
	int rwstop;

	int fullscreen;

	// Player 1
	int kb_p1u;
	int kb_p1d;
	int kb_p1l;
	int kb_p1r;
	int kb_p1select;
	int kb_p1start;
	int kb_p1a;
	int kb_p1b;
	int kb_p1ta;
	int 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;

	char *js_rwstart;
	char *js_rwstop;

	char *js_softreset;
	char *js_hardreset;

	// Player 2
	int kb_p2u;
	int kb_p2d;
	int kb_p2l;
	int kb_p2r;
	int kb_p2select;
	int kb_p2start;
	int kb_p2a;
	int kb_p2b;
	int kb_p2ta;
	int 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;

using namespace Nes::Api;

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 nst_input_init();

void nst_input_inject(Input::Controllers *controllers, nesinput_t input);
void nst_input_inject_mouse(Input::Controllers *controllers, int b, int s, int x, int y);

void nst_input_turbo_init();
void nst_input_turbo_pulse(Input::Controllers *controllers);

int nst_input_zapper_present();

int input_configure_item(int pnum, int bnum, int type);

void nstsdl_input_conf(int type, int pnum);
void nstsdl_input_conf_button(int pnum, int bnum);
void nstsdl_input_conf_defaults();
void nstsdl_input_conf_set(SDL_Event event, int pnum, int bnum);
void nstsdl_input_conf_read();
void nstsdl_input_conf_write();

void nstsdl_input_joysticks_detect();
void nstsdl_input_joysticks_close();

void nstsdl_input_match_joystick(Input::Controllers *controllers, SDL_Event event);
int nstsdl_input_checksign(int axisvalue);

void nstsdl_input_process(Input::Controllers *controllers, SDL_Event event);

char* nstsdl_input_translate_event(SDL_Event event);
SDL_Event nstsdl_input_translate_string(const char *string);

void fltkui_input_conf_set(int kval, int pnum, int bnum);
void fltkui_input_process_key(int e);
#endif