#include <stdio.h> 
#include <unistd.h> 
#include <sys/io.h> 

int main() 
  { 
  int i = 0; 
  /* Get access to the port */ 
  if (ioperm(0x201, 1, 1)) 
    { perror("ioperm"); exit(1); } 
  while (i < 0x0F ) 
    { 
    i = inb(0x201);
    /* shift to lower nibble */
    i = i >> 4; 
    printf("Buttons %X\n",i);
    /* Sleep for a while */ 
    sleep(1); 
    } 
  /* We don't need the ports anymore */ 
  if (ioperm(0x201, 1, 0)) 
    { perror("ioperm"); exit(1); } 
  exit(0); 
  }

