X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fkeyboard.c;h=f008fd81e39241de0a5580166c235ad06062cf6c;hb=7ba570fe3cc5418f42decf5b72ac2295cce9e60f;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=45672f51180f1f0af73c2ba75723eca8f8bb8e89;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/keyboard.c b/AcessNative/acesskernel_src/keyboard.c index e69de29b..f008fd81 100644 --- a/AcessNative/acesskernel_src/keyboard.c +++ b/AcessNative/acesskernel_src/keyboard.c @@ -0,0 +1,66 @@ +/* + * Acess2 Native Kernel + * + * Keyboard Driver + */ +#include +#include +#include +#include +#include "ui.h" + +// === PROTOTYPES === + int NativeKeyboard_Install(char **Arguments); + int NativeKeyboard_IOCtl(tVFS_Node *Node, int Id, void *Data); + +// === GLOBALS === +MODULE_DEFINE(0, 0x0100, NativeKeyboard, NativeKeyboard_Install, NULL, NULL); +tVFS_NodeType gKB_NodeType = { + .IOCtl = NativeKeyboard_IOCtl +}; +tDevFS_Driver gKB_DevInfo = { + NULL, "NativeKeyboard", + { .Type = &gKB_NodeType } +}; + +// === CODE === +/** + * \brief Install the keyboard driver + */ +int NativeKeyboard_Install(char **Arguments) +{ + DevFS_AddDevice( &gKB_DevInfo ); + return MODULE_ERR_OK; +} + +static const char * csaIOCTL_NAMES[] = { + DRV_IOCTLNAMES, + DRV_KEYBAORD_IOCTLNAMES, + NULL +}; + +/** + * \fn int KB_IOCtl(tVFS_Node *Node, int Id, void *Data) + * \brief Calls an IOCtl Command + */ +int NativeKeyboard_IOCtl(tVFS_Node *Node, int Id, void *Data) +{ + switch(Id) + { + BASE_IOCTLS(DRV_TYPE_KEYBOARD, "NativeKeyboard", 0x10000, csaIOCTL_NAMES); + + // Sets the Keyboard Callback + case KB_IOCTL_SETCALLBACK: + // Sanity Check + if(Threads_GetUID() != 0) + return 0; + // Can only be set once + if(gUI_KeyboardCallback != NULL) return 0; + // Set Callback + gUI_KeyboardCallback = Data; + return 1; + + default: + return 0; + } +}