Jo Engine
2026.11.1
Jo Sega Saturn Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
jo_engine
jo
keyboard.h
Go to the documentation of this file.
1
/*
2
** Jo Sega Saturn Engine
3
** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4
** All rights reserved.
5
**
6
** Redistribution and use in source and binary forms, with or without
7
** modification, are permitted provided that the following conditions are met:
8
** * Redistributions of source code must retain the above copyright
9
** notice, this list of conditions and the following disclaimer.
10
** * Redistributions in binary form must reproduce the above copyright
11
** notice, this list of conditions and the following disclaimer in the
12
** documentation and/or other materials provided with the distribution.
13
** * Neither the name of the Johannes Fetz nor the
14
** names of its contributors may be used to endorse or promote products
15
** derived from this software without specific prior written permission.
16
**
17
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
34
35
#ifndef __JO_KEYBOARD_H__
36
# define __JO_KEYBOARD_H__
37
38
#ifdef JO_COMPILE_WITH_KEYBOARD_SUPPORT
39
40
/*
41
** HOW TO USE YOUR KEYBOARD WITH MEDNAFEN
42
**
43
** 1) Edit \Emulators\mednafen\mednafen.cfg and search "ss.input.port1" and set the value to "keyboard" instead of "gamepad"
44
** 2) When the emulator is running press [Ctrl]+[Shift]+[Menu] to toggle keyboard emulation in Mednafen.
45
** 3) When your game runs press [Esc]+[Down] with your keyboard or [Start]+[Down] with your gamepad to display the console.
46
**
47
** Full documentation here: https://mednafen.github.io/documentation/ss.html
48
*/
49
50
/*
51
** Internals
52
*/
53
57
extern
char
__internal_keyboard_normal_mapping
[];
58
62
extern
char
__internal_keyboard_caps_lock_mapping
[];
63
67
# define __JO_KEYBOARD_MAPPING_SIZE (128)
68
69
/*
70
** Special Keys
71
*/
74
typedef
enum
75
{
76
JO_KEYBOARD_NO_SPECIAL_KEY
= 0,
77
JO_KEYBOARD_RIGHT
,
78
JO_KEYBOARD_LEFT
,
79
JO_KEYBOARD_DOWN
,
80
JO_KEYBOARD_UP
,
81
JO_KEYBOARD_ESCAPE
,
82
JO_KEYBOARD_ENTER
,
83
JO_KEYBOARD_BACKSPACE
,
84
JO_KEYBOARD_TAB
,
85
JO_KEYBOARD_DELETE
,
86
JO_KEYBOARD_HOME
,
87
JO_KEYBOARD_END
,
88
JO_KEYBOARD_F1
,
89
JO_KEYBOARD_F2
,
90
JO_KEYBOARD_F3
,
91
JO_KEYBOARD_F4
,
92
JO_KEYBOARD_F5
,
93
JO_KEYBOARD_F6
,
94
JO_KEYBOARD_F7
,
95
JO_KEYBOARD_F8
,
96
JO_KEYBOARD_F9
,
97
JO_KEYBOARD_F10
,
98
JO_KEYBOARD_F11
,
99
JO_KEYBOARD_F12
100
}
jo_keyboard_special_key
;
101
102
jo_keyboard_special_key
jo_keyboard_get_special_key
(
void
);
103
104
static
__jo_force_inline
unsigned
char
jo_keyboard_get_char
(
void
)
105
{
106
jo_peripheral_keyboard
*keyboard;
107
108
keyboard = (
jo_peripheral_keyboard
*)&
__jo_smpc_peripherals
[0];
109
if
((keyboard->
condition
&
JO_PERIPHERAL_KEYBOARD_MAKE
) == 0 || keyboard->
code
>=
__JO_KEYBOARD_MAPPING_SIZE
)
110
return
(0);
111
if
(keyboard->
condition
&
JO_PERIPHERAL_KEYBOARD_CAPS_LOCK
)
112
return
(
__internal_keyboard_caps_lock_mapping
[keyboard->
code
]);
113
return
(
__internal_keyboard_normal_mapping
[keyboard->
code
]);
114
}
115
116
#endif
/* !JO_COMPILE_WITH_KEYBOARD_SUPPORT */
117
118
#endif
/* !__JO_KEYBOARD_H__ */
119
120
/*
121
** END OF FILE
122
*/
__internal_keyboard_caps_lock_mapping
char __internal_keyboard_caps_lock_mapping[]
Keyboard mapping (internal engine usage).
__internal_keyboard_normal_mapping
char __internal_keyboard_normal_mapping[]
Keyboard mapping (internal engine usage).
jo_keyboard_get_char
static __jo_force_inline unsigned char jo_keyboard_get_char(void)
Definition
keyboard.h:104
jo_keyboard_get_special_key
jo_keyboard_special_key jo_keyboard_get_special_key(void)
jo_keyboard_special_key
jo_keyboard_special_key
Keyboard special keys.
Definition
keyboard.h:75
JO_KEYBOARD_RIGHT
@ JO_KEYBOARD_RIGHT
Definition
keyboard.h:77
JO_KEYBOARD_F10
@ JO_KEYBOARD_F10
Definition
keyboard.h:97
JO_KEYBOARD_END
@ JO_KEYBOARD_END
Definition
keyboard.h:87
JO_KEYBOARD_F2
@ JO_KEYBOARD_F2
Definition
keyboard.h:89
JO_KEYBOARD_F8
@ JO_KEYBOARD_F8
Definition
keyboard.h:95
JO_KEYBOARD_F1
@ JO_KEYBOARD_F1
Definition
keyboard.h:88
JO_KEYBOARD_ENTER
@ JO_KEYBOARD_ENTER
Definition
keyboard.h:82
JO_KEYBOARD_LEFT
@ JO_KEYBOARD_LEFT
Definition
keyboard.h:78
JO_KEYBOARD_TAB
@ JO_KEYBOARD_TAB
Definition
keyboard.h:84
JO_KEYBOARD_UP
@ JO_KEYBOARD_UP
Definition
keyboard.h:80
JO_KEYBOARD_F12
@ JO_KEYBOARD_F12
Definition
keyboard.h:99
JO_KEYBOARD_NO_SPECIAL_KEY
@ JO_KEYBOARD_NO_SPECIAL_KEY
Definition
keyboard.h:76
JO_KEYBOARD_F11
@ JO_KEYBOARD_F11
Definition
keyboard.h:98
JO_KEYBOARD_F7
@ JO_KEYBOARD_F7
Definition
keyboard.h:94
JO_KEYBOARD_HOME
@ JO_KEYBOARD_HOME
Definition
keyboard.h:86
JO_KEYBOARD_F3
@ JO_KEYBOARD_F3
Definition
keyboard.h:90
JO_KEYBOARD_F9
@ JO_KEYBOARD_F9
Definition
keyboard.h:96
JO_KEYBOARD_DOWN
@ JO_KEYBOARD_DOWN
Definition
keyboard.h:79
JO_KEYBOARD_F6
@ JO_KEYBOARD_F6
Definition
keyboard.h:93
JO_KEYBOARD_ESCAPE
@ JO_KEYBOARD_ESCAPE
Definition
keyboard.h:81
JO_KEYBOARD_BACKSPACE
@ JO_KEYBOARD_BACKSPACE
Definition
keyboard.h:83
JO_KEYBOARD_DELETE
@ JO_KEYBOARD_DELETE
Definition
keyboard.h:85
JO_KEYBOARD_F4
@ JO_KEYBOARD_F4
Definition
keyboard.h:91
JO_KEYBOARD_F5
@ JO_KEYBOARD_F5
Definition
keyboard.h:92
__JO_KEYBOARD_MAPPING_SIZE
#define __JO_KEYBOARD_MAPPING_SIZE
Keyboard mapping size (internal engine usage).
Definition
keyboard.h:67
jo_peripheral_keyboard::code
unsigned char code
Definition
smpc.h:249
__jo_smpc_peripherals
jo_peripheral __jo_smpc_peripherals[(15) *2]
Peripherals (Internal usage): 15 entries for port 1 followed by 15 entries for port 2.
jo_peripheral_keyboard::condition
unsigned char condition
Definition
smpc.h:248
JO_PERIPHERAL_KEYBOARD_MAKE
#define JO_PERIPHERAL_KEYBOARD_MAKE
Keyboard condition: a key is pressed (make).
Definition
smpc.h:189
JO_PERIPHERAL_KEYBOARD_CAPS_LOCK
#define JO_PERIPHERAL_KEYBOARD_CAPS_LOCK
Keyboard condition: caps lock is on.
Definition
smpc.h:183
jo_peripheral_keyboard
Keyboard data.
Definition
smpc.h:242
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition
types.h:39
Generated by
1.18.0