psl1ght
A free SDK for Sony's PS3 console
Loading...
Searching...
No Matches
kb.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <ppu-types.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define MAX_KEYBOARDS 127
14#define MAX_KB_PORT_NUM 7
15#define MAX_KEYCODES 62
16
17/* Raw Data Code and Keypad Code Data definition */
18#define KB_RAWDAT 0x8000U
19#define KB_KEYPAD 0x4000U
20
21/* Keyboard RAWDAT Key code (can't be converted to ASCII codes) */
22#define KB_RAWKEY_NO_EVENT 0x00
23#define KB_RAWKEY_E_ROLLOVER 0x01
24#define KB_RAWKEY_E_POSTFAIL 0x02
25#define KB_RAWKEY_E_UNDEF 0x03
26#define KB_RAWKEY_ESCAPE 0x29
27#define KB_RAWKEY_106_KANJI 0x35 /* The half-width/full width Kanji key code */
28#define KB_RAWKEY_CAPS_LOCK 0x39
29#define KB_RAWKEY_F1 0x3a
30#define KB_RAWKEY_F2 0x3b
31#define KB_RAWKEY_F3 0x3c
32#define KB_RAWKEY_F4 0x3d
33#define KB_RAWKEY_F5 0x3e
34#define KB_RAWKEY_F6 0x3f
35#define KB_RAWKEY_F7 0x40
36#define KB_RAWKEY_F8 0x41
37#define KB_RAWKEY_F9 0x42
38#define KB_RAWKEY_F10 0x43
39#define KB_RAWKEY_F11 0x44
40#define KB_RAWKEY_F12 0x45
41#define KB_RAWKEY_PRINTSCREEN 0x46
42#define KB_RAWKEY_SCROLL_LOCK 0x47
43#define KB_RAWKEY_PAUSE 0x48
44#define KB_RAWKEY_INSERT 0x49
45#define KB_RAWKEY_HOME 0x4a
46#define KB_RAWKEY_PAGE_UP 0x4b
47#define KB_RAWKEY_DELETE 0x4c
48#define KB_RAWKEY_END 0x4d
49#define KB_RAWKEY_PAGE_DOWN 0x4e
50#define KB_RAWKEY_RIGHT_ARROW 0x4f
51#define KB_RAWKEY_LEFT_ARROW 0x50
52#define KB_RAWKEY_DOWN_ARROW 0x51
53#define KB_RAWKEY_UP_ARROW 0x52
54#define KB_RAWKEY_NUM_LOCK 0x53
55#define KB_RAWKEY_APPLICATION 0x65 /* Application key code */
56#define KB_RAWKEY_KANA 0x88 /* Katakana/Hiragana/Romaji key code */
57#define KB_RAWKEY_HENKAN 0x8a /* Conversion key code */
58#define KB_RAWKEY_MUHENKAN 0x8b /* No Conversion key code */
59
60/* Keyboard RAW Key Code definition */
61#define KB_RAWKEY_A 0x04
62#define KB_RAWKEY_B 0x05
63#define KB_RAWKEY_C 0x06
64#define KB_RAWKEY_D 0x07
65#define KB_RAWKEY_E 0x08
66#define KB_RAWKEY_F 0x09
67#define KB_RAWKEY_G 0x0A
68#define KB_RAWKEY_H 0x0B
69#define KB_RAWKEY_I 0x0C
70#define KB_RAWKEY_J 0x0D
71#define KB_RAWKEY_K 0x0E
72#define KB_RAWKEY_L 0x0F
73#define KB_RAWKEY_M 0x10
74#define KB_RAWKEY_N 0x11
75#define KB_RAWKEY_O 0x12
76#define KB_RAWKEY_P 0x13
77#define KB_RAWKEY_Q 0x14
78#define KB_RAWKEY_R 0x15
79#define KB_RAWKEY_S 0x16
80#define KB_RAWKEY_T 0x17
81#define KB_RAWKEY_U 0x18
82#define KB_RAWKEY_V 0x19
83#define KB_RAWKEY_W 0x1A
84#define KB_RAWKEY_X 0x1B
85#define KB_RAWKEY_Y 0x1C
86#define KB_RAWKEY_Z 0x1D
87#define KB_RAWKEY_1 0x1E
88#define KB_RAWKEY_2 0x1F
89#define KB_RAWKEY_3 0x20
90#define KB_RAWKEY_4 0x21
91#define KB_RAWKEY_5 0x22
92#define KB_RAWKEY_6 0x23
93#define KB_RAWKEY_7 0x24
94#define KB_RAWKEY_8 0x25
95#define KB_RAWKEY_9 0x26
96#define KB_RAWKEY_0 0x27
97#define KB_RAWKEY_ENTER 0x28
98#define KB_RAWKEY_ESC 0x29
99#define KB_RAWKEY_BS 0x2A
100#define KB_RAWKEY_TAB 0x2B
101#define KB_RAWKEY_SPACE 0x2C
102#define KB_RAWKEY_MINUS 0x2D
103#define KB_RAWKEY_EQUAL_101 0x2E /* = and + */
104#define KB_RAWKEY_ACCENT_CIRCONFLEX_106 0x2E /* ^ and ~ */
105#define KB_RAWKEY_LEFT_BRACKET_101 0x2F /* [ */
106#define KB_RAWKEY_ATMARK_106 0x2F /* @ */
107#define KB_RAWKEY_RIGHT_BRACKET_101 0x30 /* ] */
108#define KB_RAWKEY_LEFT_BRACKET_106 0x30 /* [ */
109#define KB_RAWKEY_BACKSLASH_101 0x31 /* \ and | */
110#define KB_RAWKEY_RIGHT_BRACKET_106 0x32 /* ] */
111#define KB_RAWKEY_SEMICOLON 0x33 /* ; */
112#define KB_RAWKEY_QUOTATION_101 0x34 /* ' and " */
113#define KB_RAWKEY_COLON_106 0x34 /* : and * */
114#define KB_RAWKEY_COMMA 0x36
115#define KB_RAWKEY_PERIOD 0x37
116#define KB_RAWKEY_SLASH 0x38
117#define KB_RAWKEY_CAPS_LOCK 0x39
118#define KB_RAWKEY_KPAD_NUMLOCK 0x53
119#define KB_RAWKEY_KPAD_SLASH 0x54
120#define KB_RAWKEY_KPAD_ASTERISK 0x55
121#define KB_RAWKEY_KPAD_MINUS 0x56
122#define KB_RAWKEY_KPAD_PLUS 0x57
123#define KB_RAWKEY_KPAD_ENTER 0x58
124#define KB_RAWKEY_KPAD_1 0x59
125#define KB_RAWKEY_KPAD_2 0x5A
126#define KB_RAWKEY_KPAD_3 0x5B
127#define KB_RAWKEY_KPAD_4 0x5C
128#define KB_RAWKEY_KPAD_5 0x5D
129#define KB_RAWKEY_KPAD_6 0x5E
130#define KB_RAWKEY_KPAD_7 0x5F
131#define KB_RAWKEY_KPAD_8 0x60
132#define KB_RAWKEY_KPAD_9 0x61
133#define KB_RAWKEY_KPAD_0 0x62
134#define KB_RAWKEY_KPAD_PERIOD 0x63
135#define KB_RAWKEY_BACKSLASH_106 0x87
136#define KB_RAWKEY_YEN_106 0x89
137
139typedef struct KbLed {
140 union {
141 u32 leds;
142 struct {
143 u32 reserved : 27;
144 u32 kana : 1;
145 u32 compose : 1;
146 u32 scroll_lock : 1;
147 u32 caps_lock : 1;
148 u32 num_lock : 1;
152
154typedef struct KbMkey {
155 union {
156 u32 mkeys;
157 struct {
158 u32 reserved : 24;
159 u32 r_win : 1;
160 u32 r_alt : 1;
161 u32 r_shift : 1;
162 u32 r_ctrl : 1;
163 u32 l_win : 1;
164 u32 l_alt : 1;
165 u32 l_shift : 1;
166 u32 l_ctrl : 1;
167 /* For Macintosh Keyboard ALT & WIN correspond respectively to OPTION & APPLE keys */
171
179
185
191
216
225
227typedef struct KbConfig {
229 u32 rmode;
232
239s32 ioKbInit(const u32 max);
240
246s32 ioKbEnd(void);
247
255s32 ioKbRead(const u32 kb_no, KbData* data);
256
264s32 ioKbSetReadMode(const u32 kb_no, const KbRmode kb_rmode);
265
273s32 ioKbSetCodeType(const u32 kb_no, const KbCodeType kb_codetype);
274
284u16 ioKbCnvRawCode(const KbMapping mapping, const KbMkey mkey, const KbLed led, const u16 rawcode);
285
293s32 ioKbSetLEDStatus(const u32 kb_no, const KbLed led_state);
294
301s32 ioKbGetInfo(KbInfo* kb_info);
302
310s32 ioKbGetConfiguration(const u32 kb_no, KbConfig* kb_config);
311
318s32 ioKbClearBuf(const u32 kb_no);
319
320#ifdef __cplusplus
321 }
322#endif
323
s32 ioKbGetConfiguration(const u32 kb_no, KbConfig *kb_config)
Get Keyboard Configuration.
s32 ioKbSetLEDStatus(const u32 kb_no, const KbLed led_state)
Control Keyboard LED.
KbRmode
Keyboard input mode values.
Definition kb.h:181
@ KB_RMODE_INPUTCHAR
Character Input Mode.
Definition kb.h:182
@ KB_RMODE_PACKET
Packet Mode.
Definition kb.h:183
KbMapping
Keyboard mapping values.
Definition kb.h:193
@ KB_MAPPING_PORTUGUESE_PORTUGAL
Definition kb.h:202
@ KB_MAPPING_SPANISH_SPAIN
Definition kb.h:198
@ KB_MAPPING_SWISS_FRENCH_SWITZERLAND
Definition kb.h:212
@ KB_MAPPING_RUSSIAN_RUSSIA
Definition kb.h:203
@ KB_MAPPING_DANISH_DENMARK
Definition kb.h:208
@ KB_MAPPING_106_KANA
Definition kb.h:196
@ KB_MAPPING_106
Definition kb.h:195
@ KB_MAPPING_CANADIAN_FRENCH_CANADA
Definition kb.h:214
@ KB_MAPPING_101
Definition kb.h:194
@ KB_MAPPING_FINNISH_FINLAND
Definition kb.h:207
@ KB_MAPPING_ITALIAN_ITALY
Definition kb.h:200
@ KB_MAPPING_CHINESE_TRADITIONAL
Definition kb.h:210
@ KB_MAPPING_DUTCH_NETHERLANDS
Definition kb.h:201
@ KB_MAPPING_NORWEGIAN_NORWAY
Definition kb.h:206
@ KB_MAPPING_ENGLISH_UK
Definition kb.h:204
@ KB_MAPPING_SWEDISH_SWEDEN
Definition kb.h:209
@ KB_MAPPING_GERMAN_GERMANY
Definition kb.h:197
@ KB_MAPPING_KOREAN_KOREA
Definition kb.h:205
@ KB_MAPPING_FRENCH_FRANCE
Definition kb.h:199
@ KB_MAPPING_CHINESE_SIMPLIFIED
Definition kb.h:211
@ KB_MAPPING_SWISS_GERMAN_SWITZERLAND
Definition kb.h:213
#define MAX_KEYBOARDS
Definition kb.h:13
s32 ioKbGetInfo(KbInfo *kb_info)
Get Keyboard Information.
s32 ioKbSetCodeType(const u32 kb_no, const KbCodeType kb_codetype)
Set Keyboard code type.
s32 ioKbInit(const u32 max)
Initialize Keyboard library.
#define MAX_KEYCODES
Definition kb.h:15
s32 ioKbClearBuf(const u32 kb_no)
Clear Keyboard Buffer Data.
KbCodeType
Keyboard raw or ASCII mode values.
Definition kb.h:187
@ KB_CODETYPE_RAW
Obtain device code as RAW code type.
Definition kb.h:188
@ KB_CODETYPE_ASCII
Obtain device code as ASCII code type.
Definition kb.h:189
s32 ioKbRead(const u32 kb_no, KbData *data)
Read data from keyboard data buffer.
u16 ioKbCnvRawCode(const KbMapping mapping, const KbMkey mkey, const KbLed led, const u16 rawcode)
Convert Keyboard device key code.
s32 ioKbSetReadMode(const u32 kb_no, const KbRmode kb_rmode)
Set Keyboard data read mode.
s32 ioKbEnd(void)
Close/End Keyboard library.
Keyboard config data structure.
Definition kb.h:227
u32 mapping
See KbMapping enum definition.
Definition kb.h:228
u32 rmode
See KbRmode enum definition.
Definition kb.h:229
u32 codetype
See KbCodeType enum definition.
Definition kb.h:230
Keyboard input data data structure.
Definition kb.h:173
KbMkey mkey
Keyboard Modifier Key State.
Definition kb.h:175
u16 keycode[62]
Keycode values.
Definition kb.h:177
KbLed led
Keyboard Led State.
Definition kb.h:174
s32 nb_keycode
Number of key codes (0 equal no data)
Definition kb.h:176
Keyboard info data structure.
Definition kb.h:218
u32 connected
how many kb connected
Definition kb.h:220
u32 max
max kb allowed to connect
Definition kb.h:219
u32 info
Bit 0 lets the system intercept keyboard? other bits are reserved.
Definition kb.h:221
u8 status[127]
Connections status, status Index equal to Keyboard Number value 0: Not connected and 1: Connected.
Definition kb.h:222
Keyboard Led State.
Definition kb.h:139
u32 compose
LED Compose 0:OFF 1:ON Bit3.
Definition kb.h:145
u32 kana
LED Kana 0:OFF 1:ON Bit4.
Definition kb.h:144
u32 num_lock
LED Num Lock 0:OFF 1:ON Bit0 LSB.
Definition kb.h:148
u32 caps_lock
LED Caps Lock 0:OFF 1:ON Bit1.
Definition kb.h:147
union KbLed::@4 _KbLedU
struct KbLed::@4::@5 _KbLedS
u32 scroll_lock
LED Scroll Lock 0:OFF 1:ON Bit2.
Definition kb.h:146
u32 reserved
Reserved MSB.
Definition kb.h:143
u32 leds
Definition kb.h:141
Keyboard Modifier Key State.
Definition kb.h:154
u32 l_win
Modifier Key Left WIN 0:OFF 1:ON Bit3.
Definition kb.h:163
union KbMkey::@6 _KbMkeyU
u32 l_alt
Modifier Key Left ALT 0:OFF 1:ON Bit2.
Definition kb.h:164
u32 r_alt
Modifier Key Right ALT 0:OFF 1:ON Bit6.
Definition kb.h:160
u32 mkeys
Definition kb.h:156
u32 l_ctrl
Modifier Key Left CTRL 0:OFF 1:ON Bit0 LSB.
Definition kb.h:166
u32 r_shift
Modifier Key Right SHIFT 0:OFF 1:ON Bit5.
Definition kb.h:161
u32 r_ctrl
Modifier Key Right CTRL 0:OFF 1:ON Bit4.
Definition kb.h:162
struct KbMkey::@6::@7 _KbMkeyS
u32 l_shift
Modifier Key Left SHIFT 0:OFF 1:ON Bit1.
Definition kb.h:165
u32 reserved
Reserved MSB.
Definition kb.h:158
u32 r_win
Modifier Key Right WIN 0:OFF 1:ON Bit7.
Definition kb.h:159