//#define DEFAULT_OUTPUT "BochsGA"
#define DEFAULT_OUTPUT "Vesa"
#define FALLBACK_OUTPUT "x86_VGAText"
-#define DEFAULT_INPUT "PS2Keyboard"
+#define DEFAULT_INPUT "Keyboard"
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen
*/\r
};\r
\r
+#include "keysyms.h"\r
\r
#endif\r
--- /dev/null
+/*
+ * Acess2 USB Stack HID Driver
+ * - By John Hodge (thePowersGang)
+ *
+ * usb_keysyms.h
+ * - USB HID Keyboard Symbols
+ */
+#ifndef _USB_KEYSYMS_H_
+#define _USB_KEYSYMS_H_
+
+enum eUSB_Keysyms
+{
+ KEYSYM_NONE,
+ KEYSYM_ERRORROLLOVER,
+ KEYSYM_POSTFAIL,
+ KEYSYM_ERRORUNDEFINED,
+ // 0x04 / 4
+ KEYSYM_a, KEYSYM_b, KEYSYM_c,
+ KEYSYM_d, KEYSYM_e, KEYSYM_f,
+ KEYSYM_g, KEYSYM_h, KEYSYM_i,
+ KEYSYM_j, KEYSYM_k, KEYSYM_l,
+ KEYSYM_m, KEYSYM_n, KEYSYM_o,
+ KEYSYM_p, KEYSYM_q, KEYSYM_r,
+ KEYSYM_s, KEYSYM_t, KEYSYM_u,
+ KEYSYM_v, KEYSYM_w, KEYSYM_x,
+ KEYSYM_y, KEYSYM_z,
+
+ // 0x1E / 30
+ KEYSYM_1, KEYSYM_2,
+ KEYSYM_3, KEYSYM_4,
+ KEYSYM_5, KEYSYM_6,
+ KEYSYM_7, KEYSYM_8,
+ KEYSYM_9, KEYSYM_0,
+
+ KEYSYM_RETURN, // Enter
+ KEYSYM_ESC, // Esc.
+ KEYSYM_BACKSP, // Backspace
+ KEYSYM_TAB, // Tab
+ KEYSYM_SPACE, // Spacebar
+ KEYSYM_MINUS, // - _
+ KEYSYM_EQUALS, // = +
+ KEYSYM_SQUARE_OPEN, // [ {
+ KEYSYM_SQUARE_CLOSE, // ] }
+ KEYSYM_BACKSLASH, // \ |
+ KEYSYM_HASH_TILDE, // # ~ (Non-US)
+ KEYSYM_SEMICOLON, // ; :
+ KEYSYM_QUOTE, // ' "
+ KEYSYM_GRAVE_TILDE, // Grave Accent, Tilde
+ KEYSYM_COMMA, // , <
+ KEYSYM_PERIOD, // . >
+ KEYSYM_SLASH, // / ?
+ KEYSYM_CAPS, // Caps Lock
+ KEYSYM_F1, KEYSYM_F2,
+ KEYSYM_F3, KEYSYM_F4,
+ KEYSYM_F5, KEYSYM_F6,
+ KEYSYM_F7, KEYSYM_F8,
+ KEYSYM_F9, KEYSYM_F10,
+ KEYSYM_F11, KEYSYM_F12,
+ KEYSYM_PRINTSCREEN,
+ KEYSYM_SCROLLLOCK,
+ KEYSYM_PAUSE,
+ KEYSYM_INSERT,
+ KEYSYM_HOME,
+ KEYSYM_PGUP,
+ KEYSYM_DELETE,
+ KEYSYM_END,
+ KEYSYM_PGDN,
+ KEYSYM_RIGHTARROW,
+ KEYSYM_LEFTARROW,
+ KEYSYM_DOWNARROW,
+ KEYSYM_UPARROW,
+
+ KEYSYM_NUMLOCK,
+ KEYSYM_KPSLASH,
+ KEYSYM_KPSTAR,
+ KEYSYM_KPMINUS,
+ KEYSYM_KPPLUS,
+ KEYSYM_KPENTER,
+ KEYSYM_KP1,
+ KEYSYM_KP2,
+ KEYSYM_KP3,
+ KEYSYM_KP4,
+ KEYSYM_KP5,
+ KEYSYM_KP6,
+ KEYSYM_KP7,
+ KEYSYM_KP8,
+ KEYSYM_KP9,
+ KEYSYM_KP0,
+ KEYSYM_KPPERIOD,
+
+ KEYSYM_NONUS_BACKSLASH,
+ KEYSYM_APPLICATION, // Windows Key
+ KEYSYM_POWER,
+ KEYSYM_KPEQUALS,
+
+ KEYSYM_F13, KEYSYM_F14,
+ KEYSYM_F15, KEYSYM_F16,
+ KEYSYM_F17, KEYSYM_F18,
+ KEYSYM_F19, KEYSYM_F20,
+ KEYSYM_F21, KEYSYM_F22,
+ KEYSYM_F23, KEYSYM_F24,
+ KEYSYM_EXECUTE,
+ KEYSYM_HELP,
+ KEYSYM_MENU,
+ KEYSYM_SELECT,
+ KEYSYM_STOP,
+ KEYSYM_AGAIN,
+ KEYSYM_UNDO,
+ KEYSYM_CUT,
+ KEYSYM_COPY,
+ KEYSYM_PASTE,
+ KEYSYM_FIND,
+ KEYSYM_MUTE,
+ KEYSYM_VOLUP,
+ KEYSYM_VOLDN,
+ KEYSYM_LOCKING_CAPS, // Physically toggles
+ KEYSYM_LOGKING_NUM,
+ KEYSYM_LOGKING_SCROLL,
+ KEYSYM_KPCOMMA,
+ KEYSYM_KPEQUAL,
+ KEYSYM_KBINT1,
+ KEYSYM_KBINT2,
+ KEYSYM_KBINT3,
+ KEYSYM_KBINT4,
+ KEYSYM_KBINT5,
+ KEYSYM_KBINT6,
+ KEYSYM_KBINT7,
+ KEYSYM_KBINT8,
+ KEYSYM_KBINT9,
+
+ KEYSYM_LEFTCTRL = 0xE0,
+ KEYSYM_LEFTSHIFT,
+ KEYSYM_LEFTALT,
+ KEYSYM_LEFTGUI, // Menu?
+ KEYSYM_RIGHTCTRL,
+ KEYSYM_RIGHTSHIFT,
+ KEYSYM_RIGHTALT,
+ KEYSYM_RIGHTGUI
+
+ // TODO: Define the rest
+};
+
+#endif
+
--- /dev/null
+#
+#
+
+OBJ = main.o
+NAME = Keyboard
+
+-include ../Makefile.tpl
--- /dev/null
+/*
+ * Acess2 Kernel - Keyboard mulitplexer/translation
+ * - By John Hodge (thePowersGang)
+ *
+ * keyboard.h
+ * - Interface header
+ */
+#ifndef _KEYBOARD__KEYBOARD_H_
+#define _KEYBOARD__KEYBAORD_H_
+
+#include <api_drv_keyboard.h>
+
+typedef struct sKeyboard tKeyboard;
+
+extern tKeyboard *Keyboard_CreateInstance(int MaxSym, const char *Ident);
+extern void Keyboard_RemoveInstance(tKeyboard *Instance);
+extern void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 Kernel - Keyboard Character Mappings
+ * - By John Hodge (thePowersGang)
+ *
+ * keymap.h
+ * - Core keymap "library" header
+ */
+#ifndef _KEYMAP__KEYMAP_INT_H_
+#define _KEYMAP__KEYMAP_INT_H_
+
+typedef struct sKeymap tKeymap;
+typedef struct sKeymapLayer tKeymapLayer;
+
+struct sKeymapLayer
+{
+ int nSyms;
+ Uint32 Sym[];
+};
+
+struct sKeymap
+{
+ char *Name;
+ int nLayers;
+ tKeymapLayer *Layers[];
+};
+
+struct sKeyboard
+{
+ struct sKeyboard *Next;
+ char *Name;
+ struct sVFS_Node *Node;
+
+ tKeymap *Keymap;
+
+ Uint32 State;
+ int MaxKeysym;
+ Uint8 KeyStates[];
+};
+
+#endif
+
--- /dev/null
+\r
+#ifndef _KEYMAP__LAYOUT_KBDUS_H_\r
+#define _KEYMAP__LAYOUT_KBDUS_H_\r
+\r
+#include "keymap_int.h"\r
+\r
+// - Base (NO PREFIX)\r
+tKeymapLayer gpKBDUS1 = {\r
+ KEYSYM_SLASH+1,\r
+ {\r
+ 0, 0, 0, 0,\r
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',\r
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\r
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',\r
+ '\n', '\x1b', '\b', '\t', ' ', '-', '=', '[', ']', '\\', '#', ';',\r
+ '\'', '`', ',', '.', '/',\r
+// KEY_CAPSLOCK,\r
+// KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,\r
+// KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,\r
+// 0, KEY_SCROLLLOCK, KEY_PAUSE, KEY_INS, KEY_HOME, KEY_PGUP, KEY_PGDOWN,\r
+// KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN,\r
+// KEY_NUMLOCK, KEY_KPSLASH, KEY_KPSTAR, KEY_KPMINUS,\r
+// KEY_KPPLUS, KEY_KPENTER,\r
+// KEY_KPEND, KEY_KPDOWN, KEY_KPLEFT,\r
+ }\r
+};\r
+tKeymapLayer gpKBDUS1s = {\r
+ KEYSYM_SLASH+1,\r
+ {\r
+ 0, 0, 0, 0,\r
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\r
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\r
+ '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',\r
+ '\n', '\x1b', '\b', '\t', ' ', '_', '+', '{', '}', '|', '~', ':',\r
+ '\'', '~', '<', '>', '?',\r
+ }\r
+};\r
+\r
+tKeymap gKeymap_KBDUS = {\r
+ "en-us",\r
+ 2,\r
+ {&gpKBDUS1, &gpKBDUS1s}\r
+};\r
+\r
+#endif\r
+\r
--- /dev/null
+/*
+ * Acess2 Kernel - Keyboard Character Mappings
+ * - By John Hodge (thePowersGang)
+ *
+ * main.c
+ * - Core keyboard multiplexer
+ *
+ * TODO: Make the key transation code more general (for non-US layouts)
+ * TODO: Support multiple virtual keyboards
+ */
+#define DEBUG 0
+#define VERSION VER2(1,0)
+#include <acess.h>
+#include <modules.h>
+#include <fs_devfs.h>
+#include <Input/Keyboard/include/keyboard.h>
+#include "keymap_int.h"
+#include "layout_kbdus.h"
+
+#define USE_KERNEL_MAGIC 1
+
+// === IMPORTS ===
+#if USE_KERNEL_MAGIC
+extern void Threads_ToggleTrace(int TID);
+extern void Threads_Dump(void);
+extern void Heap_Stats(void);
+#endif
+
+// === PROTOTYPES ===
+ int Keyboard_Install(char **Arguments);
+void Keyboard_Cleanup(void);
+// - Internal
+tKeymap *Keyboard_LoadMap(const char *Name);
+void Keyboard_FreeMap(tKeymap *Keymap);
+// - User side
+ int Keyboard_IOCtl(tVFS_Node *Node, int ID, void *Data);
+// - Device Side
+tKeyboard *Keyboard_CreateInstance(int MaxSym, const char *Name);
+void Keyboard_RemoveInstance(tKeyboard *Instance);
+void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym);
+
+// === GLOBALS ===
+MODULE_DEFINE(0, VERSION, Keyboard, Keyboard_Install, Keyboard_Cleanup, NULL);
+tVFS_NodeType gKB_NodeType = {
+ .IOCtl = Keyboard_IOCtl
+};
+tDevFS_Driver gKB_DevInfo = {
+ NULL, "Keyboard",
+ { .Type = &gKB_NodeType }
+};
+#if USE_KERNEL_MAGIC
+ int giKB_MagicAddress = 0;
+ int giKB_MagicAddressPos = 0;
+#endif
+
+// === CODE ===
+int Keyboard_Install(char **Arguments)
+{
+ DevFS_AddDevice( &gKB_DevInfo );
+ return 0;
+}
+
+void Keyboard_Cleanup(void)
+{
+ // TODO: Do I need this?
+}
+
+tKeymap *Keyboard_LoadMap(const char *Name)
+{
+ return NULL;
+}
+
+void Keyboard_FreeMap(tKeymap *Keymap)
+{
+}
+
+// --- VFS Interface ---
+static const char *csaIOCTL_NAMES[] = {DRV_IOCTLNAMES, DRV_KEYBAORD_IOCTLNAMES, NULL};
+int Keyboard_IOCtl(tVFS_Node *Node, int Id, void *Data)
+{
+ switch(Id)
+ {
+ BASE_IOCTLS(DRV_TYPE_KEYBOARD, "Keyboard", 0x100, csaIOCTL_NAMES);
+
+ case KB_IOCTL_SETCALLBACK:
+ if( Threads_GetUID() != 0 ) return -1;
+ if( MM_IsUser( (tVAddr)Data ) ) return -1;
+ if( Node->ImplInt ) return 0; // Can only be set once
+ Node->ImplInt = (Uint)Data;
+ return 1;
+ }
+ return -1;
+}
+
+// --- Device Interface ---
+tKeyboard *Keyboard_CreateInstance(int MaxSym, const char *Name)
+{
+ tKeyboard *ret;
+ int sym_bitmap_size = (MaxSym + 7)/8;
+ int string_size = strlen(Name) + 1;
+
+ ret = malloc( sizeof(tKeyboard) + sym_bitmap_size + string_size );
+ if( !ret ) {
+ return NULL;
+ }
+ // Clear
+ memset(ret, 0, sizeof(tKeyboard) + sym_bitmap_size );
+ // Set name
+ ret->Name = (char*)ret + sizeof(tKeyboard) + sym_bitmap_size;
+ memcpy(ret->Name, Name, string_size);
+ // Set node and default keymap
+ ret->Node = &gKB_DevInfo.RootNode;
+ ret->Keymap = &gKeymap_KBDUS;
+
+ return ret;
+}
+
+void Keyboard_RemoveInstance(tKeyboard *Instance)
+{
+ // TODO: Implement
+ Log_Error("Keyboard", "TODO: Implement Keyboard_RemoveInstance");
+}
+
+void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym)
+{
+ int bPressed;
+ Uint32 trans;
+ Uint32 flag;
+ Uint8 layer;
+
+ bPressed = !(HIDKeySym & (1 << 31));
+ HIDKeySym &= 0x7FFFFFFF;
+
+ // Determine action
+ {
+ Uint8 mask = 1 << (HIDKeySym&7);
+ int ofs = HIDKeySym / 8;
+ int oldstate = !!(Source->KeyStates[ofs] & mask);
+
+ // Get the state of all other devices attached
+ int otherstate = 0;
+ for( tKeyboard *kb = Source->Node->ImplPtr; kb; kb = kb->Next )
+ {
+ if( kb == Source ) continue ;
+ if( kb->MaxKeysym <= HIDKeySym ) continue ;
+ otherstate = otherstate || (kb->KeyStates[ofs] & mask);
+ }
+
+ // Update key state
+ if( bPressed )
+ Source->KeyStates[ ofs ] |= mask;
+ else
+ Source->KeyStates[ ofs ] &= ~mask;
+
+ // Get the action (Press, Refire or Release)
+ if( bPressed )
+ {
+ if( !oldstate && !otherstate )
+ flag = KEY_ACTION_PRESS; // Down
+ else
+ flag = KEY_ACTION_REFIRE; // Refire
+ }
+ else
+ {
+ if( !otherstate )
+ flag = KEY_ACTION_RELEASE; // Up
+ else
+ flag = -1 ; // Do nothing
+ }
+ }
+
+ // Translate \a State into layer
+ // TODO: Support non-trivial layouts
+ layer = !!(Source->State & 3);
+
+ // Send raw symbol
+ if( flag == KEY_ACTION_RELEASE )
+ trans = 0;
+ else {
+
+ // Translate the keysym into a character
+ if( layer >= Source->Keymap->nLayers )
+ trans = 0;
+ else if( HIDKeySym >= Source->Keymap->Layers[layer]->nSyms )
+ trans = 0;
+ else
+ trans = Source->Keymap->Layers[layer]->Sym[HIDKeySym];
+ // - No translation in \a layer, fall back to layer=0
+ if(!trans && HIDKeySym < Source->Keymap->Layers[0]->nSyms)
+ trans = Source->Keymap->Layers[0]->Sym[HIDKeySym];
+ }
+
+ if( flag != -1 )
+ {
+ tKeybardCallback Callback = (void*)Source->Node->ImplInt;
+ Callback( HIDKeySym | KEY_ACTION_RAWSYM );
+ Callback( flag | trans );
+ }
+
+ // TODO: Translate this into agnostic code
+ switch( HIDKeySym )
+ {
+ case KEYSYM_LEFTSHIFT:
+ if(bPressed) Source->State |= 1;
+ else Source->State &= ~1;
+ break;
+ case KEYSYM_RIGHTSHIFT:
+ if(bPressed) Source->State |= 2;
+ else Source->State &= ~2;
+ break;
+ }
+
+ // --- Check for Kernel Magic Combos
+ #if USE_KERNEL_MAGIC
+ if(Source->KeyStates[KEYSYM_LEFTCTRL/8] & (1 << (KEYSYM_LEFTCTRL&7))
+ && Source->KeyStates[KEYSYM_LEFTALT/8] & (1 << (KEYSYM_LEFTALT &7)) )
+ {
+ int val;
+ switch(trans)
+ {
+ case '0': val = 0; goto _av; case '1': val = 1; goto _av;
+ case '2': val = 2; goto _av; case '3': val = 3; goto _av;
+ case '4': val = 4; goto _av; case '5': val = 5; goto _av;
+ case '6': val = 6; goto _av; case '7': val = 7; goto _av;
+ case '8': val = 8; goto _av; case '9': val = 9; goto _av;
+ case 'a': val = 10; goto _av; case 'b': val = 11; goto _av;
+ case 'c': val = 12; goto _av; case 'd': val = 13; goto _av;
+ case 'e': val = 14; goto _av; case 'f': val = 15; goto _av;
+ _av:
+ if(giKB_MagicAddressPos == BITS/4) break;
+ giKB_MagicAddress |= (Uint)val << giKB_MagicAddressPos;
+ giKB_MagicAddressPos ++;
+ break;
+
+ // Instruction Tracing
+ case 't':
+ Log("Toggle instruction tracing on %i\n", giKB_MagicAddress);
+ Threads_ToggleTrace( giKB_MagicAddress );
+ giKB_MagicAddress = 0; giKB_MagicAddressPos = 0;
+ return;
+
+ // Thread List Dump
+ case 'p': Threads_Dump(); return;
+ // Heap Statistics
+ case 'h': Heap_Stats(); return;
+ // Dump Structure
+ case 's': return;
+ }
+ }
+ #endif
+
+}
+
#include <fs_devfs.h>
#include <api_drv_common.h>
#include <api_drv_keyboard.h>
-#include "kb_kbdus.h"
+#include <Input/Keyboard/include/keyboard.h>
+#include "kb_transtab.h"
// === CONSTANTS ===
#define KB_BUFFER_SIZE 1024
#define USE_KERNEL_MAGIC 1
-// === IMPORTS ===
-extern void Threads_ToggleTrace(int TID);
-extern void Threads_Dump(void);
-extern void Heap_Stats(void);
-
// === PROTOTYPES ===
int KB_Install(char **Arguments);
void KB_HandleScancode(Uint8 scancode);
int KB_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === GLOBALS ===
-tVFS_NodeType gKB_NodeType = {
- .IOCtl = KB_IOCtl
-};
-tDevFS_Driver gKB_DevInfo = {
- NULL, "PS2Keyboard",
- { .Type = &gKB_NodeType }
-};
-tKeybardCallback gKB_Callback = NULL;
-Uint32 **gpKB_Map = gpKBDUS;
-Uint8 gbaKB_States[3][256];
- int gbKB_ShiftState = 0;
- int gbKB_CapsState = 0;
- int gbKB_KeyUp = 0;
- int giKB_KeyLayer = 0;
-#if USE_KERNEL_MAGIC
- int gbKB_MagicState = 0;
- int giKB_MagicAddress = 0;
- int giKB_MagicAddressPos = 0;
-#endif
+ int giPS2Kb_Layer;
+ int gbPS2Kb_KeyUp;
+tKeyboard *gPS2Kb_Info;
// === CODE ===
/**
*/
int KB_Install(char **Arguments)
{
- DevFS_AddDevice( &gKB_DevInfo );
- //Log("KB_Install: Installed");
+ gPS2Kb_Info = Keyboard_CreateInstance(KEYSYM_RIGHTGUI, "PS2Keyboard");
return MODULE_ERR_OK;
}
*/
void KB_HandleScancode(Uint8 scancode)
{
- Uint32 ch;
- int bCaseSwitch = (gbKB_ShiftState != 0) != (gbKB_CapsState != 0);
-
- //Log_Debug("Keyboard", "scancode = %02x", scancode);
+ Uint32 hidcode;
// Ignore ACKs
- if(scancode == 0xFA) {
- // Oh man! This is anarchic (I'm leaving it here to represent
- // the mess that Acess once was)
- //kb_lastChar = KB_ACK;
- return;
- }
+ if(scancode == 0xFA) return;
- // Layer +1
+ // Layer 1
if(scancode == 0xE0) {
- giKB_KeyLayer = 1;
+ giPS2Kb_Layer = 1;
return;
}
- // Layer +2
+ // Layer 2
if(scancode == 0xE1) {
- giKB_KeyLayer = 2;
+ giPS2Kb_Layer = 2;
return;
}
#if KB_ALT_SCANCODES
if(scancode == 0xF0)
{
- gbKB_KeyUp = 1;
+ gbPS2Kb_KeyUp = 1;
return;
}
#else
if(scancode & 0x80)
{
scancode &= 0x7F;
- gbKB_KeyUp = 1;
+ gbPS2Kb_KeyUp = 1;
}
#endif
-
- if( gKB_Callback )
- gKB_Callback( (giKB_KeyLayer << 8) | scancode | KEY_ACTION_RAWSYM );
-
- // Translate
- ch = gpKB_Map[giKB_KeyLayer*2+bCaseSwitch][scancode];
- // - Unknown characters in the shift layer fall through to lower
- if(bCaseSwitch && ch == 0)
- ch = gpKB_Map[giKB_KeyLayer*2][scancode];
- // Check for unknown key
- if(!ch)
- {
- if(!gbKB_KeyUp)
- Log_Warning("Keyboard", "UNK %i %x", giKB_KeyLayer, scancode);
-// return ;
- // Can pass through to ensure each raw message has a up/down with it
- }
-
- // Key Up?
- if (gbKB_KeyUp)
- {
- gbKB_KeyUp = 0;
- gbaKB_States[giKB_KeyLayer][scancode] = 0; // Unset key state flag
-
- #if USE_KERNEL_MAGIC
- if(ch == KEY_LCTRL) gbKB_MagicState &= ~1;
- if(ch == KEY_LALT) gbKB_MagicState &= ~2;
- #endif
-
- if(ch == KEY_LSHIFT) gbKB_ShiftState &= ~1;
- if(ch == KEY_RSHIFT) gbKB_ShiftState &= ~2;
- // Call callback
- if(gKB_Callback) gKB_Callback( ch | KEY_ACTION_RELEASE );
-
- // Reset Layer
- giKB_KeyLayer = 0;
- return;
- }
-
- // Refire?
- if( gbaKB_States[giKB_KeyLayer][scancode] == 1 )
+ hidcode = gp101_to_HID[giPS2Kb_Layer][scancode];
+ if( !hidcode )
{
- if(gKB_Callback) gKB_Callback(ch | KEY_ACTION_REFIRE);
- giKB_KeyLayer = 0;
+ Log_Warning("PS2Kb", "Unknown scancode %i:0x%x", giPS2Kb_Layer, scancode);
return ;
}
-
- // Set the bit relating to the key
- gbaKB_States[giKB_KeyLayer][scancode] = 1;
- // Set shift key bits
- if(ch == KEY_LSHIFT) gbKB_ShiftState |= 1;
- if(ch == KEY_RSHIFT) gbKB_ShiftState |= 2;
-
- // Check for Caps Lock
- if(ch == KEY_CAPSLOCK) {
- gbKB_CapsState = !gbKB_CapsState;
- KB_UpdateLEDs();
- }
-
- // --- Check for Kernel Magic Combos
- #if USE_KERNEL_MAGIC
- if(ch == KEY_LCTRL) {
- gbKB_MagicState |= 1;
- //Log_Log("Keyboard", "Kernel Magic LCTRL Down\n");
- }
- if(ch == KEY_LALT) {
- gbKB_MagicState |= 2;
- //Log_Log("Keyboard", "Kernel Magic LALT Down\n");
- }
- if(gbKB_MagicState == 3)
+ else
{
- switch(ch)
- {
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- case '8': case '9': case 'a': case 'b':
- case 'c': case 'd': case 'e': case 'f':
- {
- char str[4] = {'0', 'x', ch, 0};
- if(giKB_MagicAddressPos == BITS/4) return;
- giKB_MagicAddress |= atoi(str) << giKB_MagicAddressPos;
- giKB_MagicAddressPos ++;
- }
- return;
-
- // Instruction Tracing
- case 't':
- Log("Toggle instruction tracing on %i\n", giKB_MagicAddress);
- Threads_ToggleTrace( giKB_MagicAddress );
- giKB_MagicAddress = 0; giKB_MagicAddressPos = 0;
- return;
-
- // Thread List Dump
- case 'p': Threads_Dump(); return;
- // Heap Statistics
- case 'h': Heap_Stats(); return;
- // Dump Structure
- case 's': return;
- }
+ if( gbPS2Kb_KeyUp )
+ Keyboard_HandleKey( gPS2Kb_Info, (1 << 31) | hidcode );
+ else
+ Keyboard_HandleKey( gPS2Kb_Info, (0 << 31) | hidcode );
}
- #endif
-
- if(gKB_Callback)
- gKB_Callback(ch | KEY_ACTION_PRESS);
-
- // Reset Layer
- giKB_KeyLayer = 0;
+
+ giPS2Kb_Layer = 0;
+ gbPS2Kb_KeyUp = 0;
}
/**
*/
void KB_UpdateLEDs(void)
{
- Uint8 leds;
+// Uint8 leds;
- leds = (gbKB_CapsState ? 4 : 0);
+// leds = (gbKB_CapsState ? 4 : 0);
// TODO: Update LEDS
Log_Warning("Keyboard", "TODO: Update LEDs");
}
-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 KB_IOCtl(tVFS_Node *Node, int Id, void *Data)
-{
- switch(Id)
- {
- BASE_IOCTLS(DRV_TYPE_KEYBOARD, "KB", 0x100, csaIOCTL_NAMES);
-
- // Sets the Keyboard Callback
- case KB_IOCTL_SETCALLBACK:
- // Sanity Check
- if((Uint)Data < KERNEL_BASE) return 0;
- // Can only be set once
- if(gKB_Callback != NULL) return 0;
- // Set Callback
- gKB_Callback = Data;
- return 1;
-
- default:
- return 0;
- }
-}
+++ /dev/null
-\r
-#ifndef _KBDUS_H\r
-#define _KBDUS_H\r
-\r
-// - Base (NO PREFIX)\r
-Uint32 gpKBDUS1[256] = {\r
- 0,\r
- KEY_ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', // 0x01 - 0x0e\r
- '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', // 0x0f - 0x1c\r
- KEY_LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';','\'', // 0x1d - 0x28\r
- '`', KEY_LSHIFT,'\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT, // 0x29 - 0x3e\r
- KEY_KPSTAR,\r
- KEY_LALT, ' ', KEY_CAPSLOCK,\r
- KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,\r
- KEY_NUMLOCK, KEY_SCROLLLOCK,\r
- KEY_KPHOME, KEY_KPUP, KEY_KPPGUP, KEY_KPMINUS,\r
- KEY_KPLEFT, KEY_KP5, KEY_KPRIGHT, KEY_KPPLUS,\r
- KEY_KPEND, KEY_KPDOWN, KEY_KPPGDN,\r
- KEY_KPINS, KEY_KPDEL,\r
- 0, 0, 0, KEY_F11, KEY_F12, 0, 0, 0, 0, 0, 0, 0,\r
-/*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
-/*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
-};\r
-// Shift Key pressed\r
-Uint32 gpKBDUS1s[256] = {\r
- 0,\r
- KEY_ESC, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', // 0x01 - 0x0e\r
- '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', // 0x0f - 0x1c\r
- KEY_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':','"', // 0x1d - 0x28\r
- '~', KEY_LSHIFT,'|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', KEY_RSHIFT, // 0x29 - 0x3e\r
- 0\r
- };\r
-// - 0xE0 Prefixed\r
-Uint32 gpKBDUS2[256] = {\r
-// 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
-/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-F\r
-/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_KPENTER, K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BDUS[6] = { gpKBDUS1, gpKBDUS1s, gpKBDUS2, gpKBDUS2, gpKBDUS3, gpKBDUS3 };\r
-\r
-#endif\r
--- /dev/null
+\r
+#ifndef _KBDUS_H\r
+#define _KBDUS_H\r
+\r
+// - Base (NO PREFIX)\r
+Uint32 gp101_to_HID_1[128] = {\r
+ 0,\r
+ // First row (0x01 - 0x0e)\r
+ KEYSYM_ESC, KEYSYM_1, KEYSYM_2, KEYSYM_3, KEYSYM_4, KEYSYM_5, KEYSYM_6,\r
+ KEYSYM_7, KEYSYM_8, KEYSYM_9, KEYSYM_0, KEYSYM_MINUS, KEYSYM_EQUALS,\r
+ KEYSYM_BACKSP,\r
+ // Second Row (0x0f - 0x1c)\r
+ KEYSYM_TAB, KEYSYM_q, KEYSYM_w, KEYSYM_e, KEYSYM_r, KEYSYM_t, KEYSYM_y,\r
+ KEYSYM_u, KEYSYM_i, KEYSYM_o, KEYSYM_p, KEYSYM_SQUARE_OPEN, KEYSYM_SQUARE_CLOSE,\r
+ KEYSYM_RETURN,\r
+ // Third Row (0x1d - 0x28)\r
+ KEYSYM_LEFTCTRL, KEYSYM_a, KEYSYM_s, KEYSYM_d, KEYSYM_f, KEYSYM_g, KEYSYM_h,\r
+ KEYSYM_j, KEYSYM_k, KEYSYM_l, KEYSYM_SEMICOLON, KEYSYM_QUOTE, // 0x1d - 0x28\r
+ // Fourth Row (0x20 - 0x3e)\r
+ KEYSYM_GRAVE_TILDE, KEYSYM_LEFTSHIFT, KEYSYM_BACKSLASH, KEYSYM_z, KEYSYM_x,\r
+ KEYSYM_c, KEYSYM_v, KEYSYM_b, KEYSYM_n, KEYSYM_m, KEYSYM_COMMA, KEYSYM_PERIOD,\r
+ KEYSYM_SLASH, KEYSYM_RIGHTSHIFT,\r
+ // Bottom row (0x3f - 0x42)\r
+ KEYSYM_KPSTAR, KEYSYM_LEFTALT, KEYSYM_SPACE, KEYSYM_CAPS,\r
+ // F Keys (0x43 - 0x4d)\r
+ KEYSYM_F1, K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ELETE, 0, 0, 0, 0,\r
+ 0, 0, 0, KEYSYM_LEFTGUI, KEYSYM_RIGHTGUI, KEYSYM_APPLICATION, 0, 0,\r
+/*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+};\r
+// - 0xE1 Prefixed\r
+Uint32 gp101_to_HID_3[128] = {\r
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
+/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-F\r
+/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEYSYM_PAUSE, 0, 0,\r
+/*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*30*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*40*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*50*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+/*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
+};\r
+\r
+\r
+Uint32 *gp101_to_HID[3] = { gp101_to_HID_1, gp101_to_HID_2, gp101_to_HID_3 };\r
+\r
+#endif\r
// === GLOBALS ===
MODULE_DEFINE(0, 0x0100, Input_PS2KbMouse, PS2_Install, NULL, NULL); // Shuts the makefile up
-MODULE_DEFINE(0, 0x0100, PS2Keyboard, KB_Install, NULL, "Input_PS2KbMouse", NULL);
+MODULE_DEFINE(0, 0x0100, PS2Keyboard, KB_Install, NULL, "Input_PS2KbMouse", "Keyboard", NULL);
MODULE_DEFINE(0, 0x0100, PS2Mouse, PS2Mouse_Install, NULL, "Input_PS2KbMouse", NULL);
// === CODE ===
LIBINCLUDES := $(addsuffix /include,$(LIBINCLUDES))
CPPFLAGS := -I$(ACESSDIR)/KernelLand/Kernel/include -I$(ACESSDIR)/KernelLand/Kernel/arch/$(ARCHDIR)/include
+CPPFLAGS += -I$(ACESSDIR)/KernelLand/Modules
CPPFLAGS += -DARCH=$(ARCH) -DARCH_is_$(ARCH) -DARCHDIR_is_$(ARCHDIR)
CPPFLAGS += $(_CPPFLAGS)
CPPFLAGS += $(LIBINCLUDES)
+++ /dev/null
-/*
- * Acess2 USB Stack HID Driver
- * - By John Hodge (thePowersGang)
- *
- * usb_keysyms.h
- * - USB HID Keyboard Symbols
- */
-#ifndef _USB_KEYSYMS_H_
-#define _USB_KEYSYMS_H_
-
-enum eUSB_Keysyms
-{
- KEYSYM_NONE,
- KEYSYM_ERRORROLLOVER,
- KEYSYM_POSTFAIL,
- KEYSYM_ERRORUNDEFINED,
- // 0x04 / 4
- KEYSYM_a, KEYSYM_b, KEYSYM_c,
- KEYSYM_d, KEYSYM_e, KEYSYM_f,
- KEYSYM_g, KEYSYM_h, KEYSYM_i,
- KEYSYM_j, KEYSYM_k, KEYSYM_l,
- KEYSYM_m, KEYSYM_n, KEYSYM_o,
- KEYSYM_p, KEYSYM_q, KEYSYM_r,
- KEYSYM_s, KEYSYM_t, KEYSYM_u,
- KEYSYM_v, KEYSYM_w, KEYSYM_x,
- KEYSYM_y, KEYSYM_z,
-
- // 0x1E / 30
- KEYSYM_1, KEYSYM_2,
- KEYSYM_3, KEYSYM_4,
- KEYSYM_5, KEYSYM_6,
- KEYSYM_7, KEYSYM_8,
- KEYSYM_9, KEYSYM_0,
-
- KEYSYM_RETURN, // Enter
- KEYSYM_ESC, // Esc.
- KEYSYM_BACKSP, // Backspace
- KEYSYM_TAB, // Tab
- KEYSYM_SPACE, // Spacebar
- KEYSYM_MINUS, // - _
- KEYSYM_EQUALS, // = +
- KEYSYM_SQUARE_OPEN, // [ {
- KEYSYM_SQUARE_CLOSE, // ] }
- KEYSYM_BACKSLASH, // \ |
- KEYSYM_HASH_TILDE, // # ~ (Non-US)
- KEYSYM_SEMICOLON, // ; :
- KEYSYM_QUOTE, // ' "
- KEYSYM_GRAVE_TILDE, // Grave Accent, Tilde
- KEYSYM_COMMA, // , <
- KEYSYM_PERIOD, // . >
- KEYSYM_SLASH, // / ?
- KEYSYM_CAPS, // Caps Lock
- KEYSYM_F1, KEYSYM_F2,
- KEYSYM_F3, KEYSYM_F4,
- KEYSYM_F5, KEYSYM_F6,
- KEYSYM_F7, KEYSYM_F8,
- KEYSYM_F9, KEYSYM_F10,
- KEYSYM_F11, KEYSYM_F12,
- KEYSYM_PRINTSCREEN,
- KEYSYM_SCROLLLOCK,
- KEYSYM_PAUSE,
- KEYSYM_INSERT,
- KEYSYM_HOME,
- KEYSYM_PGUP,
- KEYSYM_DELETE,
- KEYSYM_END,
- KEYSYM_PGDN,
- KEYSYM_RIGHTARROW,
- KEYSYM_LEFTARROW,
- KEYSYM_DOWNARROW,
- KEYSYM_UPARROW,
-
- KEYSYM_NUMLOCK,
- KEYSYM_KPSLASH,
- KEYSYM_KPSTAR,
- KEYSYM_KPMINUS,
- KEYSYM_KPPLUS,
- KEYSYM_KPENTER,
- KEYSYM_KP1,
- KEYSYM_KP2,
- KEYSYM_KP3,
- KEYSYM_KP4,
- KEYSYM_KP5,
- KEYSYM_KP7,
- KEYSYM_KP8,
- KEYSYM_KP9
- KEYSYM_KP0,
- KEYSYM_KPPERIOD,
-
- KEYSYM_NONUS_BACKSLASH,
- KEYSYM_APPLICATION, // Windows Key
- KEYSYM_POWER,
- KEYSYM_KPEQUALS,
-
- KEYSYM_F13, KEYSYM_F14,
- KEYSYM_F15, KEYSYM_F16,
- KEYSYM_F17, KEYSYM_F18,
- KEYSYM_F19, KEYSYM_F20,
- KEYSYM_F21, KEYSYM_F22,
- KEYSYM_F23, KEYSYM_F24,
- KEYSYM_EXECUTE,
- KEYSYM_HELP,
- KEYSYM_MENU,
- KEYSYM_SELECT,
- KEYSYM_STOP,
- KEYSYM_AGAIN,
- KEYSYM_UNDO,
- KEYSYM_CUT,
- KEYSYM_COPY,
- KEYSYM_PASTE,
- KEYSYM_FIND,
- KEYSYM_MUTE,
- KEYSYM_VOLUP,
- KEYSYM_VOLDN,
- KEYSYM_LOCKING_CAPS, // Physically toggles
- KEYSYM_LOGKING_NUM,
- KEYSYM_LOGKING_SCROLL,
- KEYSYM_KPCOMMA
-
- // TODO: Define the rest
-};
-
-#endif
-
include $(ACESSDIR)/BuildConf/$(ARCH)/$(PLATFORM).mk
+MODULES += Input/Keyboard
MODULES += IPStack # So the other modules are loaded before it
#DYNMODS := USB/Core
#DYNMODS += Filesystems/InitRD