ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
libkbd.h File Reference
#include <ps2kbd.h>
+ Include dependency graph for libkbd.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef kbd_rawkey PS2KbdRawKey
 
typedef kbd_keymap PS2KbdKeyMap
 

Functions

int PS2KbdInit (void)
 
int PS2KbdRead (char *key)
 
int PS2KbdReadRaw (PS2KbdRawKey *key)
 
int PS2KbdSetReadmode (u32 readMode)
 
int PS2KbdSetBlockingMode (u32 readMode)
 
int PS2KbdSetRepeatRate (u32 repeat)
 
int PS2KbdSetLeds (u8 leds)
 
int PS2KbdSetKeymap (PS2KbdKeyMap *keymaps)
 
int PS2KbdSetCtrlmap (u8 *ctrlmap)
 
int PS2KbdSetAltmap (u8 *altmap)
 
int PS2KbdSetSpecialmap (u8 *special)
 
int PS2KbdFlushBuffer (void)
 
int PS2KbdResetKeymap (void)
 
int PS2KbdClose (void)
 

Detailed Description

USB Keyboard Driver for PS2

Definition in file libkbd.h.

Typedef Documentation

◆ PS2KbdKeyMap

Definition at line 22 of file libkbd.h.

◆ PS2KbdRawKey

Definition at line 21 of file libkbd.h.

Function Documentation

◆ PS2KbdClose()

int PS2KbdClose ( void  )

Close down the keyboard library

Definition at line 166 of file libkbd.c.

167 {
168  if(kbd_fd >= 0)
169  {
170  close(kbd_fd);
171  kbd_fd = -1;
172  }
173 
174  return 1;
175 }
static int kbd_fd
Definition: libkbd.c:24

References kbd_fd.

◆ PS2KbdFlushBuffer()

int PS2KbdFlushBuffer ( void  )

Flushes the keyboard buffer

Definition at line 144 of file libkbd.c.

145 {
146  int dummy;
147 
148  if(kbd_fd >= 0)
149  {
151  }
152  return 0;
153 }
#define PS2KBD_IOCTL_FLUSHBUFFER
Definition: ps2kbd.h:99
int(* _ps2sdk_ioctl)(int, int, void *)
Definition: ps2sdkapi.c:177

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_FLUSHBUFFER.

◆ PS2KbdInit()

int PS2KbdInit ( void  )

Initialise the keyboard library

Definition at line 28 of file libkbd.c.

29 {
31  {
33  kbd_fd = -1;
34  }
35 
36  if(kbd_fd >= 0) /* Already initialised */
37  {
38  return 2;
39  }
40 
41  kbd_fd = open(PS2KBD_DEVFILE, O_RDONLY);
42  if(kbd_fd < 0)
43  {
44  return 0;
45  }
46 
47  return 1;
48 }
static int kbd_iop
Definition: libkbd.c:23
int _iop_reboot_count
#define PS2KBD_DEVFILE
Definition: ps2kbd.h:23

References _iop_reboot_count, kbd_fd, kbd_iop, and PS2KBD_DEVFILE.

◆ PS2KbdRead()

int PS2KbdRead ( char *  key)

Reads 1 character from the keyboard

Definition at line 50 of file libkbd.c.

51 {
53  {
54  return read(kbd_fd, key, 1);
55  }
56 
57  return 0;
58 }
static int curr_readmode
Definition: libkbd.c:26
#define PS2KBD_READMODE_NORMAL
Definition: ps2kbd.h:58

References curr_readmode, kbd_fd, and PS2KBD_READMODE_NORMAL.

◆ PS2KbdReadRaw()

int PS2KbdReadRaw ( PS2KbdRawKey key)

Reads 1 raw character from the keyboard

Definition at line 60 of file libkbd.c.

61 {
62  if((kbd_fd >= 0) && (curr_readmode == PS2KBD_READMODE_RAW))
63  {
64  return read(kbd_fd, key, 2) / 2;
65  }
66 
67  return 0;
68 }
#define PS2KBD_READMODE_RAW
Definition: ps2kbd.h:59

References curr_readmode, kbd_fd, and PS2KBD_READMODE_RAW.

◆ PS2KbdResetKeymap()

int PS2KbdResetKeymap ( void  )

Resets the keymap to the default US mapping

Definition at line 155 of file libkbd.c.

156 {
157  int dummy;
158 
159  if(kbd_fd >= 0)
160  {
162  }
163  return 0;
164 }
#define PS2KBD_IOCTL_RESETKEYMAP
Definition: ps2kbd.h:101

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_RESETKEYMAP.

◆ PS2KbdSetAltmap()

int PS2KbdSetAltmap ( u8 altmap)

Sets the alt key mappings

Definition at line 126 of file libkbd.c.

127 {
128  if(kbd_fd >= 0)
129  {
131  }
132  return 0;
133 }
#define PS2KBD_IOCTL_SETALTMAP
Definition: ps2kbd.h:93

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETALTMAP.

◆ PS2KbdSetBlockingMode()

int PS2KbdSetBlockingMode ( u32  readMode)

Sets the blocking mode on or off

Definition at line 80 of file libkbd.c.

81 {
82  if((kbd_fd >= 0) && (curr_blockmode != blockmode))
83  {
84  return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETBLOCKMODE, &blockmode);
85  }
86 
87  return 0;
88 }
static int curr_blockmode
Definition: libkbd.c:25
#define PS2KBD_IOCTL_SETBLOCKMODE
Definition: ps2kbd.h:97

References _ps2sdk_ioctl, curr_blockmode, kbd_fd, and PS2KBD_IOCTL_SETBLOCKMODE.

◆ PS2KbdSetCtrlmap()

int PS2KbdSetCtrlmap ( u8 ctrlmap)

Sets the control key mappings

Definition at line 117 of file libkbd.c.

118 {
119  if(kbd_fd >= 0)
120  {
121  return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETCTRLMAP, ctrlmap);
122  }
123  return 0;
124 }
#define PS2KBD_IOCTL_SETCTRLMAP
Definition: ps2kbd.h:91

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETCTRLMAP.

◆ PS2KbdSetKeymap()

int PS2KbdSetKeymap ( PS2KbdKeyMap keymaps)

Sets the current keymap

Definition at line 108 of file libkbd.c.

109 {
110  if(kbd_fd >= 0)
111  {
112  return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETKEYMAP, keymaps);
113  }
114  return 0;
115 }
#define PS2KBD_IOCTL_SETKEYMAP
Definition: ps2kbd.h:89

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETKEYMAP.

◆ PS2KbdSetLeds()

int PS2KbdSetLeds ( u8  leds)

Sets all connected keyboards leds

Definition at line 99 of file libkbd.c.

100 {
101  if(kbd_fd >= 0)
102  {
103  return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETLEDS, &leds);
104  }
105  return 0;
106 }
#define PS2KBD_IOCTL_SETLEDS
Definition: ps2kbd.h:85

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETLEDS.

◆ PS2KbdSetReadmode()

int PS2KbdSetReadmode ( u32  readMode)

Sets the read mode to normal or raw

Definition at line 70 of file libkbd.c.

71 {
72  if((kbd_fd >= 0) && (curr_readmode != readmode))
73  {
74  curr_readmode = readmode;
75  return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETREADMODE, &readmode);
76  }
77  return 0;
78 }
#define PS2KBD_IOCTL_SETREADMODE
Definition: ps2kbd.h:83

References _ps2sdk_ioctl, curr_readmode, kbd_fd, and PS2KBD_IOCTL_SETREADMODE.

◆ PS2KbdSetRepeatRate()

int PS2KbdSetRepeatRate ( u32  repeat)

Sets the repeat rate in millseconds

Definition at line 90 of file libkbd.c.

91 {
92  if(kbd_fd >= 0)
93  {
95  }
96  return 0;
97 }
#define PS2KBD_IOCTL_SETREPEATRATE
Definition: ps2kbd.h:87

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETREPEATRATE.

◆ PS2KbdSetSpecialmap()

int PS2KbdSetSpecialmap ( u8 special)

Sets the special key mappings

Definition at line 135 of file libkbd.c.

136 {
137  if(kbd_fd >= 0)
138  {
140  }
141  return 0;
142 }
#define PS2KBD_IOCTL_SETSPECIALMAP
Definition: ps2kbd.h:95

References _ps2sdk_ioctl, kbd_fd, and PS2KBD_IOCTL_SETSPECIALMAP.