summaryrefslogtreecommitdiff
path: root/include/keyboard.h
blob: f0671f0c808bdbd52c698aa1db8fcdef2e6f36ca (plain)
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
/*
   3ds81 - Nintendo ZX81 emulator.

   Copyright (C) 2021  Ian Cowburn <ianc@noddybox.co.uk>
   
   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 3
   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, see <http://www.gnu.org/licenses/>.
  
   $Id: keyboard.h 61 2008-11-03 17:07:32Z ianc $
*/
#ifndef DS81_KEYBOARD_H
#define DS81_KEYBOARD_H

#include <stdio.h>

/* Note that the first 40 values purposefully are the keyboard matrix keys.
   Note also that they are in display order, not matrix order.
*/
typedef enum
{
    SK_1,
    SK_2,
    SK_3,
    SK_4,
    SK_5,

    SK_6,
    SK_7,
    SK_8,
    SK_9,
    SK_0,

    SK_Q,
    SK_W,
    SK_E,
    SK_R,
    SK_T,

    SK_Y,
    SK_U,
    SK_I,
    SK_O,
    SK_P,

    SK_A,
    SK_S,
    SK_D,
    SK_F,
    SK_G,

    SK_H,
    SK_J,
    SK_K,
    SK_L,
    SK_NEWLINE,

    SK_SHIFT,
    SK_Z,
    SK_X,
    SK_C,
    SK_V,

    SK_B,
    SK_N,
    SK_M,
    SK_PERIOD,
    SK_SPACE,

    SK_ABOUT,
    SK_CONFIG,
    SK_PAD_UP,
    SK_PAD_DOWN,
    SK_PAD_LEFT,
    SK_PAD_RIGHT,
    SK_PAD_A,
    SK_PAD_B,
    SK_PAD_X,
    SK_PAD_Y,
    SK_PAD_R,
    SK_PAD_L,
    SK_PAD_START,
    SK_PAD_SELECT,

    NUM_SOFT_KEYS
} SoftKey;

typedef struct
{
    SoftKey	key;
    int		pressed;
} SoftKeyEvent;


/* Display the soft keyboard.
*/
void	SK_DisplayKeyboard(void);

/* Returns TRUE while there are still key events for this cycle
*/
int	SK_GetEvent(SoftKeyEvent *ev);

/* Returns TRUE while there are still key events for this cycle.  Unlike 
   SK_GetEvent this does not do joypad mappings.
*/
int	SK_GetBareEvent(SoftKeyEvent *ev);

/* Sets a key to be 'sticky'.
*/
void	SK_SetSticky(SoftKey key, int is_sticky);

/* Map the joypad to keys.  Note that when mapped that both the key and the
   joypad code will be generated.
*/
void	SK_DefinePad(SoftKey pad, SoftKey key);

/* Returns a name for key symbols.
*/
const char *SK_KeyName(SoftKey pad);

/* Allows the keyboard to save/restore its state from a stream
*/
void	SK_SaveSnapshot(FILE *fp);
void	SK_LoadSnapshot(FILE *fp);

#endif	/* DS81_KEYBOARD_H */