Output data to keyboard LEDs

compile with “gcc -lm caps.c -o caps”
try “lynx google.com | caps”

N.B needs to be run as root
#include <stdio.h>
#include <stropts.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>

int main(){
 int fd = open("/dev/console",O_RDWR);
 char chr, tmp;
 int pw,i;
 while(chr = getc(stdin)){
  if(chr >= 65 && chr <= 122){
  printf("%d",chr);
  for (i=0;i<=7;i++){
    tmp = chr;
    pw = pow(2,i);
    tmp &= pw;
    tmp == pw ? ioctl(fd, 0x4b32, 1) :  ioctl(fd, 0x4b32, 0);
    //ioctl(fd,0x4b32,1); //stop bit
    usleep(500);
   }
  }
 }

close(fd);

}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: