[OpenBIOS] Forgot the signed-of-by line

Programmingkid programmingkidx at gmail.com
Sun Nov 4 04:32:42 CET 2012


signed-off-by: John Arbuckle <programmingkidx at gmail.com>

---
drivers/adb_kbd.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/drivers/adb_kbd.c b/drivers/adb_kbd.c
index e38798a..82382d5 100644
--- a/drivers/adb_kbd.c
+++ b/drivers/adb_kbd.c
@@ -42,11 +42,13 @@ keyboard_close(int *idx)
}

static void keyboard_read(void);
+void getKeyMap(void);

NODE_METHODS( keyboard ) = {
-	{ "open",		keyboard_open		},
-	{ "close",		keyboard_close		},
-	{ "read",               keyboard_read		},
+	{ "open",         keyboard_open		},
+	{ "close",        keyboard_close		},
+	{ "read",         keyboard_read		},
+	{ "get-key-map",  getKeyMap	      },
};

/* VT100 escape sequences */
@@ -566,3 +568,75 @@ static void keyboard_read(void)
	}
	PUSH(i);
}
+
+
+// Returns the base to the exponent power
+static int pow(int base, int exponent)
+{
+  int index, answer;
+  answer = base;
+  for(index = 1; index < exponent; index++)
+  {
+     answer = answer * base;
+  }
+  return answer;
+}
+
+// The implementation of the get-key-map word.
+// Returns an array of 32 bytes. Certain bits 
+// are used to determine which keys are being
+// held down.
+
+void getKeyMap(void)
+{
+   int keyPushed, *keyMapArray, offset;
+   const int sizeOfArray = 8;
+   const int modifierKeyIndex = 7;
+   const int commandKeyValue = pow(2,28);
+   const int shiftKeyValue = pow(2,30);
+   const int theAKeyValue = pow(2,27);   
+
+   keyMapArray = (char *) malloc(sizeOfArray);
+   if(!keyMapArray)
+   {
+       printk("Failed to allocate memory for keyMapArray!\n");
+       PUSH(NULL);
+       return;
+   }
+
+   // Set all the elements to zero
+   int index;
+   for(index = 0; index < sizeOfArray; index++)
+   {
+      keyMapArray[index] = 0;
+   }
+   
+   feval("key?");
+   if(POP() != -1)         // if no key was pushed
+       PUSH(keyMapArray);  // returns the address of keyMapArray
+   
+   feval("key");
+   keyPushed = POP();
+   
+   if(keyPushed > 0 && keyPushed < 27) // control key combination
+   {
+      offset = 1;
+      keyMapArray[modifierKeyIndex] = commandKeyValue;
+   }
+   
+   else if(keyPushed > 64 && keyPushed < 91)    // shift key combination
+   {
+      offset = 65;
+      keyMapArray[modifierKeyIndex] = shiftKeyValue;
+   }
+   
+   else     // just a letter is being held down
+   {
+      offset = 97;
+   }
+
+   // Determines the value and location of a bit in the array. 
+   *keyMapArray = theAKeyValue >> (keyPushed - offset);
+   
+   PUSH(keyMapArray);
+}
\ No newline at end of file
-- 
1.7.5.4



More information about the OpenBIOS mailing list