DGen/SDL
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
rc.h
Go to the documentation of this file.
1
// DGen/SDL v1.23+
2
#ifndef RC_H_
3
#define RC_H_
4
5
#include <stddef.h>
6
#include <stdio.h>
7
#include <stdint.h>
8
9
// Define the different craptv types
10
#define NUM_CTV 5 // Include CTV_OFF
11
#define NUM_SCALING 7
12
#define CTV_OFF 0
13
#define CTV_BLUR 1
14
#define CTV_SCANLINE 2
15
#define CTV_INTERLACE 3
16
#define CTV_SWAB 4
17
18
// Define OR masks for key modifiers
19
#define KEYSYM_MOD_ALT 0x40000000
20
#define KEYSYM_MOD_SHIFT 0x20000000
21
#define KEYSYM_MOD_CTRL 0x10000000
22
#define KEYSYM_MOD_META 0x08000000
23
#define KEYSYM_MOD_MASK 0x78000000
24
25
// Macros to manage joystick buttons.
26
//
27
// Integer format (32b): 000000tt iiiiiiii aaaaaaaa bbbbbbbb
28
//
29
// t: type (0-3):
30
// 0 if not configured/invalid.
31
// 1 for a normal button, "a" is ignored, "b" is the button index.
32
// 2 for an axis, "a" is the axis index, "b" is the axis direction.
33
// 3 for a hat, "a" is the hat index, "b" is the hat direction.
34
// i: system identifier for joystick/joypad (0-255).
35
// a: axis or hat index (0-255).
36
// b: button number (0-255), axis direction (0 if negative, 128 if between,
37
// 255 if positive), or hat direction (0 = center, 1 = up, 2 = right,
38
// 3 = down, 4 = left).
39
#define JS_AXIS_NEGATIVE 0x00
40
#define JS_AXIS_BETWEEN 0x80
41
#define JS_AXIS_POSITIVE 0xff
42
43
#define JS_HAT_CENTERED 0
44
#define JS_HAT_UP 1
45
#define JS_HAT_RIGHT 2
46
#define JS_HAT_DOWN 3
47
#define JS_HAT_LEFT 4
48
49
#define JS_TYPE_BUTTON 0x01
50
#define JS_TYPE_AXIS 0x02
51
#define JS_TYPE_HAT 0x03
52
53
#define JS_MAKE_IDENTIFIER(i) (((i) & 0xff) << 16)
54
#define JS_MAKE_BUTTON(b) \
55
((JS_TYPE_BUTTON << 24) | ((b) & 0xff))
56
#define JS_MAKE_AXIS(a, d) \
57
((JS_TYPE_AXIS << 24) | (((a) & 0xff) << 8) | ((d) & 0xff))
58
#define JS_MAKE_HAT(h, d) \
59
((JS_TYPE_HAT << 24) | (((h) & 0xff) << 8) | ((d) & 0xff))
60
61
#define JS_GET_IDENTIFIER(v) (((v) >> 16) & 0xff)
62
#define JS_IS_BUTTON(v) ((((v) >> 24) & 0xff) == JS_TYPE_BUTTON)
63
#define JS_IS_AXIS(v) ((((v) >> 24) & 0xff) == JS_TYPE_AXIS)
64
#define JS_IS_HAT(v) ((((v) >> 24) & 0xff) == JS_TYPE_HAT)
65
#define JS_GET_BUTTON(v) ((v) & 0xff)
66
#define JS_GET_AXIS(v) (((v) >> 8) & 0xff)
67
#define JS_GET_AXIS_DIR(v) JS_GET_BUTTON(v)
68
#define JS_GET_HAT(v) JS_GET_AXIS(v)
69
#define JS_GET_HAT_DIR(v) JS_GET_BUTTON(v)
70
71
#define JS_BUTTON(id, button) \
72
(JS_MAKE_IDENTIFIER(id) | \
73
JS_MAKE_BUTTON(button))
74
#define JS_AXIS(id, axis, direction) \
75
(JS_MAKE_IDENTIFIER(id) | \
76
JS_MAKE_AXIS((axis), (direction)))
77
#define JS_HAT(id, hat, direction) \
78
(JS_MAKE_IDENTIFIER(id) | \
79
JS_MAKE_HAT((hat), (direction)))
80
81
// Macros to manage mouse events.
82
//
83
// Integer format (32b): 000000tt iiiiiiii 00000000 aaaaaaaa
84
//
85
// t: type (0-3):
86
// 0 if not configured/invalid.
87
// 1 for a button, "a" is the button index.
88
// 2 for a motion, "a" is the direction.
89
// i: system identifier for mouse (0-255).
90
// a: button number (0-255), motion direction ('u', 'd', 'l' and 'r' for "up",
91
// "down", "left" and "right").
92
#define MO_TYPE_BUTTON JS_TYPE_BUTTON
93
#define MO_TYPE_MOTION JS_TYPE_AXIS
94
95
#define MO_GET_IDENTIFIER(v) JS_GET_IDENTIFIER(v)
96
#define MO_IS_BUTTON(v) JS_IS_BUTTON(v)
97
#define MO_IS_MOTION(v) JS_IS_AXIS(v)
98
#define MO_GET_BUTTON(v) JS_GET_BUTTON(v)
99
#define MO_GET_MOTION(v) MO_GET_BUTTON(v)
100
101
#define MO_BUTTON(id, button) JS_BUTTON(id, button)
102
#define MO_MOTION(id, direction) JS_AXIS(id, 0, direction)
103
104
// All the CTV engine names, in string form for the RC and message bar
105
extern
const
char
*
ctv_names
[];
106
107
// Scaling algorithms names
108
extern
const
char
*
scaling_names
[];
109
110
// CPU names
111
extern
const
char
*
emu_z80_names
[];
112
extern
const
char
*
emu_m68k_names
[];
113
114
// Provide a prototype to the parse_rc function in rc.cpp
115
extern
void
parse_rc
(FILE *file,
const
char
*
name
);
116
117
extern
char
*
dump_keysym
(intptr_t k);
118
extern
char
*
dump_joypad
(intptr_t k);
119
extern
char
*
dump_mouse
(intptr_t k);
120
extern
void
dump_rc
(FILE *file);
121
122
extern
intptr_t
rc_number
(
const
char
*value, intptr_t *);
123
extern
intptr_t
rc_keysym
(
const
char
*
code
, intptr_t *);
124
extern
intptr_t
rc_boolean
(
const
char
*value, intptr_t *);
125
extern
intptr_t
rc_joypad
(
const
char
*desc, intptr_t *);
126
extern
intptr_t
rc_mouse
(
const
char
*desc, intptr_t *);
127
extern
intptr_t
rc_ctv
(
const
char
*value, intptr_t *);
128
extern
intptr_t
rc_scaling
(
const
char
*value, intptr_t *);
129
extern
intptr_t
rc_emu_z80
(
const
char
*value, intptr_t *);
130
extern
intptr_t
rc_emu_m68k
(
const
char
*value, intptr_t *);
131
extern
intptr_t
rc_region
(
const
char
*value, intptr_t *);
132
extern
intptr_t
rc_string
(
const
char
*value, intptr_t *);
133
extern
intptr_t
rc_rom_path
(
const
char
*value, intptr_t *);
134
extern
intptr_t
rc_bind
(
const
char
*value, intptr_t *variable);
135
extern
intptr_t
rc_soundrate
(
const
char
*value, intptr_t *);
136
137
extern
struct
rc_str
*
rc_str_list
;
138
extern
void
rc_str_cleanup
(
void
);
139
140
struct
rc_field
{
141
const
char
*
fieldname
;
142
intptr_t (*
parser
)(
const
char
*, intptr_t *);
143
intptr_t *
variable
;
144
};
145
146
#define RC_BIND_PREFIX "bind_"
147
#define RC_BIND_ITEMS 8
148
149
enum
rc_binding_type
{
150
RCBK
,
// Keysym.
151
RCBJ
,
// Joypad.
152
RCBM
,
// Mouse.
153
RCB_NUM
154
};
155
156
struct
rc_binding_item
{
157
unsigned
int
assigned
:1;
// Whether item contains valid data.
158
enum
rc_binding_type
type
:4;
// See enum rc_binding_type.
159
intptr_t
code
;
// keysym, joypad or mouse code.
160
};
161
162
struct
rc_binding
{
163
struct
rc_binding
*
prev
;
164
struct
rc_binding
*
next
;
165
struct
rc_binding_item
item
[
RC_BIND_ITEMS
];
166
char
*
rc
;
// RC name for this binding.
167
// struct rc_field.variable points to the following member.
168
char
*
to
;
// Related action.
169
// Internal storage, don't touch.
170
// char rc[];
171
};
172
173
#define RC_FIELDS_SIZE 1024
174
175
extern
struct
rc_field
rc_fields
[
RC_FIELDS_SIZE
];
176
extern
struct
rc_binding
rc_binding_head
;
177
178
extern
struct
rc_field
*
rc_binding_add
(
const
char
*rc,
const
char
*to);
179
extern
void
rc_binding_del
(
struct
rc_field
*rcf);
180
181
struct
rc_keysym
{
182
const
char
*
name
;
183
long
keysym
;
184
};
185
186
extern
struct
rc_keysym
rc_keysyms
[];
187
188
#endif // RC_H_
Generated on Sat Jul 26 2014 23:48:33 for DGen/SDL by
1.8.1.1