User manual
Linux Guide taskit GmbH
for(y = 0; y < PORTUXMATRIX_MAX_Y; y++) {
map[layer][y][x].flags = PORTUXINPUT_MASK_LSHIFT;
if(layer == 0) // if is first layer assign 'A'
map[layer][y][x].value = KEY_A;
else
map[layer][y][x].value = KEY_B;
}
}
// assign the key for switching the keymap to the first key
map[layer][0][0].flags = PORTUXINPUT_MASK_SETKEYMAP;
if( layer < PORTUXMATRIX_MAX_LAYER – 1)
// switch to next keymap
map[layer][0][0].value = layer + 1;
else
// key on the last keymap switches to the first keymap
map[layer][0][0].value = 0;
}
if(ioctl(fd, PORTUXMATRIX_IOC_SETKEYMAP, &map))
perror("Error changing keymap!");
Example 4: Configure the keymap to clone mobile phone like keys. If you press a key on
the matrixkeyboard several times it cycles through several characters (a->s-
>d->f->g->h->j->k->l). This function can also be used for IR remote controllers.
The maximum number of characters that can be assigned to a key is 16
(PORTUX_MAX_KEYARRAYELEMENTS), and the maximum number of keys
that can be used with a keyarray is 10 (PORTUX_MAX_KEYARRAYS) as
defined in portuxinput.h.
/* This sample can be found on the starter-kit cd:
/dev/cdrom/examples/input/matrixsample4.c */
// note: if you don't want to use all 16 characters then the last
// character has to be 0 terminated
int arrayNR;
int charNR;
keyarray characters;
matrixmap map;
int fd = open("/dev/portuxinput", O_RDWR);
for(arrayNR = 0; arrayNR < PORTUX_MAX_KEYARRAYS; arrayNR++) {
for(charNR=0; charNR < PORTUX_MAX_KEYARRAYELEMENTS; charNR++)
{
// Note: PORTUX_MAX_KEYARRAYELEMENTS = 16 ~ 0 .. 15
characters[arrayNR][charNR].flags = 0;
characters[arrayNR][charNR].value = KEY_A + charNR;
}
// 0-termination of keyarray elements if needed
if(characterNR < PORTUX_MAX_KEYARRAYELEMENTS - 1) {
characters[arrayNR][characterNR + 1].flags = 0;
characters[arrayNR][characterNR + 1].value = 0;
Page 31 of 65 Version 1.26 (2008-04-30)