-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard.h
130 lines (95 loc) · 3.15 KB
/
keyboard.h
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
/* keyboard.h: Routines for dealing with the Spectrum's keyboard
Copyright (c) 1999-2016 Philip Kendall
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author contact information:
E-mail: philip-fuse@shadowmagic.org.uk
*/
#ifndef FUSE_KEYBOARD_H
#define FUSE_KEYBOARD_H
#include "libspectrum.h"
#include "input.h"
extern libspectrum_byte keyboard_default_value;
extern libspectrum_byte keyboard_return_values[8];
/* A numeric identifier for each Spectrum key. Chosen to map to ASCII in
most cases */
typedef enum keyboard_key_name {
KEYBOARD_NONE = 0x00, /* No key */
KEYBOARD_space = 0x20,
KEYBOARD_0 = 0x30,
KEYBOARD_1,
KEYBOARD_2,
KEYBOARD_3,
KEYBOARD_4,
KEYBOARD_5,
KEYBOARD_6,
KEYBOARD_7,
KEYBOARD_8,
KEYBOARD_9,
KEYBOARD_a = 0x61,
KEYBOARD_b,
KEYBOARD_c,
KEYBOARD_d,
KEYBOARD_e,
KEYBOARD_f,
KEYBOARD_g,
KEYBOARD_h,
KEYBOARD_i,
KEYBOARD_j,
KEYBOARD_k,
KEYBOARD_l,
KEYBOARD_m,
KEYBOARD_n,
KEYBOARD_o,
KEYBOARD_p,
KEYBOARD_q,
KEYBOARD_r,
KEYBOARD_s,
KEYBOARD_t,
KEYBOARD_u,
KEYBOARD_v,
KEYBOARD_w,
KEYBOARD_x,
KEYBOARD_y,
KEYBOARD_z,
KEYBOARD_Enter = 0x100,
KEYBOARD_Caps,
KEYBOARD_Symbol,
/* Used by the configuration code to signify that a real joystick fire
button should map to the emulated joystick fire button */
KEYBOARD_JOYSTICK_FIRE = 0x1000,
} keyboard_key_name;
void keyboard_register_startup( void );
libspectrum_byte keyboard_read( libspectrum_byte porth );
void keyboard_press(keyboard_key_name key);
void keyboard_release(keyboard_key_name key);
int keyboard_release_all( void );
/* Which Spectrum keys should be emulated as pressed when each input
layer key is pressed */
typedef struct keyboard_spectrum_keys_t {
keyboard_key_name key1,key2;
} keyboard_spectrum_keys_t;
const keyboard_spectrum_keys_t* keyboard_get_spectrum_keys( input_key keysym );
/* The mapping from UI layer keysyms to Fuse input layer keysyms */
typedef struct keysyms_map_t {
/* FIXME: this should really be the UI specific type used for keysyms */
libspectrum_dword ui;
input_key fuse;
} keysyms_map_t;
extern keysyms_map_t keysyms_map[];
input_key keysyms_remap( libspectrum_dword ui_keysym );
const char* keyboard_key_text( keyboard_key_name key );
/* Simulate what would be returned by the ULA if it is read from with
the high byte of the port as "porth" and "key" is pressed */
libspectrum_byte
keyboard_simulate_keypress( libspectrum_byte porth, keyboard_key_name key );
#endif /* #ifndef FUSE_KEYBOARD_H */