Jo Engine  2020.06.22
Jo Sega Saturn Engine
keyboard.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2020, 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 */
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 
58 
63 
67 # define __JO_KEYBOARD_MAPPING_SIZE (128)
68 
69 /*
70 ** Special Keys
71 */
74 typedef enum
75 {
101 
103 
104 static __jo_force_inline unsigned char jo_keyboard_get_char(void)
105 {
106  PerKeyBoard *keyboard;
107 
108  keyboard = (PerKeyBoard *)&Smpc_Peripheral[0];
109  if ((keyboard->cond & PER_KBD_MK) == 0 || keyboard->code >= __JO_KEYBOARD_MAPPING_SIZE)
110  return (0);
111  if (keyboard->cond & PER_KBD_CL)
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)
__JO_KEYBOARD_MAPPING_SIZE
#define __JO_KEYBOARD_MAPPING_SIZE
Keyboard mapping size (internal engine usage)
Definition: keyboard.h:67
JO_KEYBOARD_LEFT
@ JO_KEYBOARD_LEFT
Definition: keyboard.h:78
JO_KEYBOARD_F9
@ JO_KEYBOARD_F9
Definition: keyboard.h:96
JO_KEYBOARD_HOME
@ JO_KEYBOARD_HOME
Definition: keyboard.h:86
JO_KEYBOARD_DELETE
@ JO_KEYBOARD_DELETE
Definition: keyboard.h:85
JO_KEYBOARD_F6
@ JO_KEYBOARD_F6
Definition: keyboard.h:93
JO_KEYBOARD_F11
@ JO_KEYBOARD_F11
Definition: keyboard.h:98
JO_KEYBOARD_RIGHT
@ JO_KEYBOARD_RIGHT
Definition: keyboard.h:77
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: conf.h:154
JO_KEYBOARD_TAB
@ JO_KEYBOARD_TAB
Definition: keyboard.h:84
JO_KEYBOARD_F5
@ JO_KEYBOARD_F5
Definition: keyboard.h:92
JO_KEYBOARD_F2
@ JO_KEYBOARD_F2
Definition: keyboard.h:89
JO_KEYBOARD_UP
@ JO_KEYBOARD_UP
Definition: keyboard.h:80
JO_KEYBOARD_BACKSPACE
@ JO_KEYBOARD_BACKSPACE
Definition: keyboard.h:83
JO_KEYBOARD_F1
@ JO_KEYBOARD_F1
Definition: keyboard.h:88
JO_KEYBOARD_F3
@ JO_KEYBOARD_F3
Definition: keyboard.h:90
JO_KEYBOARD_F8
@ JO_KEYBOARD_F8
Definition: keyboard.h:95
JO_KEYBOARD_DOWN
@ JO_KEYBOARD_DOWN
Definition: keyboard.h:79
JO_KEYBOARD_F12
@ JO_KEYBOARD_F12
Definition: keyboard.h:99
jo_keyboard_special_key
jo_keyboard_special_key
Keyboard special keys.
Definition: keyboard.h:75
JO_KEYBOARD_F4
@ JO_KEYBOARD_F4
Definition: keyboard.h:91
JO_KEYBOARD_ENTER
@ JO_KEYBOARD_ENTER
Definition: keyboard.h:82
__internal_keyboard_normal_mapping
char __internal_keyboard_normal_mapping[]
Keyboard mapping (internal engine usage)
JO_KEYBOARD_F7
@ JO_KEYBOARD_F7
Definition: keyboard.h:94
jo_keyboard_get_char
static __jo_force_inline unsigned char jo_keyboard_get_char(void)
Definition: keyboard.h:104
JO_KEYBOARD_END
@ JO_KEYBOARD_END
Definition: keyboard.h:87
JO_KEYBOARD_F10
@ JO_KEYBOARD_F10
Definition: keyboard.h:97
JO_KEYBOARD_NO_SPECIAL_KEY
@ JO_KEYBOARD_NO_SPECIAL_KEY
Definition: keyboard.h:76
JO_KEYBOARD_ESCAPE
@ JO_KEYBOARD_ESCAPE
Definition: keyboard.h:81
jo_keyboard_get_special_key
jo_keyboard_special_key jo_keyboard_get_special_key(void)