]> Joshua Wise's Git repositories - netwatch.git/commitdiff
kbd_has_injected_scancode
authorJacob Potter <jdpotter@andrew.cmu.edu>
Mon, 6 Oct 2008 07:26:06 +0000 (03:26 -0400)
committerJacob Potter <jdpotter@andrew.cmu.edu>
Mon, 6 Oct 2008 07:26:06 +0000 (03:26 -0400)
aseg/keyboard.c
aseg/keyboard.h

index 878fa33879883c404fb82b039048b3246b9369e2..d2bb62700e22e6656d6afaf47e73feafcd893644 100644 (file)
@@ -122,15 +122,18 @@ const unsigned char convert_table[] = {
        0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
 };
 
-unsigned char sc_convert_1(unsigned char in) {
+unsigned char sc_convert_1(unsigned char in)
+{
        static int shifted = 0;
 
-       if (shifted) {
+       if (shifted)
+       {
                shifted = 0;
                return convert_table[in] | 0x80;
        }
 
-       if (in == 0xF0) {
+       if (in == 0xF0)
+       {
                shifted = 1;
                return 0;
        } else {
@@ -138,17 +141,20 @@ unsigned char sc_convert_1(unsigned char in) {
        } 
 }
 
-void kbd_inject_scancode (unsigned char sc) {
+void kbd_inject_scancode (unsigned char sc)
+{
        outputf("Buffering %02x", sc);
        kbd_inj_buffer[kbd_inj_end] = sc;
        kbd_inj_end += 1;
        kbd_inj_end %= sizeof(kbd_inj_buffer);
 }
 
-void kbd_inject_key(unsigned char k) {
+void kbd_inject_key(unsigned char k)
+{
+       const char * c;
 
        if (kbd_mode == 1) {
-               const char * c = scancodes2[k];
+               c = scancodes2[k];
                if (!c) return;
                while (*c) {
                        char cconv = sc_convert_1(*c);
@@ -156,7 +162,7 @@ void kbd_inject_key(unsigned char k) {
                        c++;
                }
        } else {
-               const char * c = scancodes2[k];
+               c = scancodes2[k];
                if (!c) return;
                while (*c) {
                        kbd_inject_scancode(*c);
@@ -169,7 +175,8 @@ unsigned char kbd_get_injected_scancode()
 {
        unsigned char b;
 
-       if (kbd_inj_end != kbd_inj_start) {
+       if (kbd_inj_end != kbd_inj_start)
+       {
                b = kbd_inj_buffer[kbd_inj_start];
                kbd_inj_start += 1;
                kbd_inj_start %= sizeof(kbd_inj_buffer);
@@ -180,3 +187,13 @@ unsigned char kbd_get_injected_scancode()
                return 0;
        }
 }
+
+int kbd_has_injected_scancode()
+{
+       if (kbd_inj_end != kbd_inj_start)
+       {
+               return 1;
+       } else {
+               return 0;
+       }
+}
index 684ce45ab1711973b5078592f599967c0cfb766f..3f668674127bed781bbf25254321b994495b11e2 100644 (file)
@@ -4,6 +4,7 @@
 void kbd_inject_key(unsigned char k);
 
 unsigned char kbd_get_injected_scancode();
+int kbd_has_injected_scancode();
 
 extern int kbd_mode;
 
This page took 0.024172 seconds and 4 git commands to generate.