Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Disabling the keyboard
Ref. No. QNX.000001528
Category(ies) Development
Issue Is there an easy way to disable the keyboard in a c program?


Solution Use:
x09outp(0x64, ad) -> to disable
x09outp(0x64, ae) -> to re-enable

OR

You could use the following code:

NOTE:this is an example on how to flash the keyboard lights, good starting point for actual code.



#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/qioctl.h>
#include <sys/keycodes.h>

int set_lights(int fd, unsigned long lights);

int
main(int argc, char *argv[])
{

        int            fd, i;
        unsigned long  lights;

        if ((fd = open("/dev/kbd", O_RDWR)) <0) {
                perror("open");
                return (EXIT_FAILURE);
        }

        lights = KEYIND_SCROLL_LOCK | KEYIND_NUM_LOCK | KEYIND_CAPS_LOCK;

        for (i = 0; i <5; i++) {

                set_lights(fd, lights);
                delay(500);
                set_lights(fd, 0);
                delay(500);
        }

        return (EXIT_SUCCESS);
}


int
set_lights(int fd, unsigned long lights)
{
        unsigned long  bits[2];

        bits[0] = lights;
        bits[1] = KEYIND_SCROLL_LOCK | KEYIND_NUM_LOCK | KEYIND_CAPS_LOCK;

        if (qnx_ioctl(fd, QCTL_DEV_CTL, &bits, sizeof(bits), 0, 0) <0) {
                perror("qnx_ioctl");
                return (-1);
        }

        return (0);
}