Nice userspace wrappers for ps2kb driver
This commit is contained in:
@ -10,6 +10,7 @@ SRCFILES := $(call GRABSRC, \
|
|||||||
string \
|
string \
|
||||||
system \
|
system \
|
||||||
printf \
|
printf \
|
||||||
|
devices \
|
||||||
)
|
)
|
||||||
|
|
||||||
CFLAGS += -isystem $(ROOT)/share -isystem $(ROOT)/ulib -isystem $(ROOT)/std/include \
|
CFLAGS += -isystem $(ROOT)/share -isystem $(ROOT)/ulib -isystem $(ROOT)/std/include \
|
||||||
|
8
ulib/devices/ps2kb.c
Normal file
8
ulib/devices/ps2kb.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <sysdefs/ipcpipe.h>
|
||||||
|
#include <system/ipcpipe.h>
|
||||||
|
|
||||||
|
int32_t dev_ps2kb_read(int32_t *ch) {
|
||||||
|
return ipcpipe(1, 0, IPCPIPE_READ, (uint8_t *)ch, sizeof(*ch));
|
||||||
|
}
|
10
ulib/devices/ps2kb.h
Normal file
10
ulib/devices/ps2kb.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef ULIB_DEVICES_PS2KB_H_
|
||||||
|
#define ULIB_DEVICES_PS2KB_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define PS2KB_C(x) ((x) - '@')
|
||||||
|
|
||||||
|
int32_t dev_ps2kb_read(int32_t *ch);
|
||||||
|
|
||||||
|
#endif // ULIB_DEVICES_PS2KB_H_
|
@ -7,6 +7,7 @@
|
|||||||
#include <ansiq/all.h>
|
#include <ansiq/all.h>
|
||||||
#include <sysdefs/ipcpipe.h>
|
#include <sysdefs/ipcpipe.h>
|
||||||
#include <system/ipcpipe.h>
|
#include <system/ipcpipe.h>
|
||||||
|
#include <devices/ps2kb.h>
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
debugprint(ANSIQ_SCR_CLR_ALL);
|
debugprint(ANSIQ_SCR_CLR_ALL);
|
||||||
@ -28,10 +29,10 @@ void main(void) {
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int32_t kbchar;
|
int32_t kbchar;
|
||||||
int32_t read = ipcpipe(1, 0, IPCPIPE_READ, (uint8_t *)&kbchar, sizeof(kbchar));
|
int32_t read = dev_ps2kb_read(&kbchar);
|
||||||
|
|
||||||
if (read > 0 && (kbchar >= 0x20 && kbchar <= 0x7F)) {
|
if (read > 0 && (kbchar >= 0x20 && kbchar <= 0x7F || kbchar == 0xA)) {
|
||||||
uprintf("%c", (char)kbchar);
|
uprintf("%c", kbchar & 0xFF);
|
||||||
ipcpipe(3, 1, IPCPIPE_WRITE, (uint8_t *)&kbchar, 1);
|
ipcpipe(3, 1, IPCPIPE_WRITE, (uint8_t *)&kbchar, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user