#include #include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_GetKeyboardControl PRIV_GetKeyboardControl; struct priv_GetKeyboardControl { LX_KEYBOARDCONTROL *kc; } ; static void done_GetKeyboardControl(LX_OP *op, const unsigned char *rep) { PRIV_GetKeyboardControl *p; p = op->reqpriv; do <"ret"> { if (r_card32(rep+4) != 5) { lx__protoerr(op->conn,"GetKeyboardControl response length wrong (%u, expecting 5)",r_card32(rep+4)); break <"ret">; } if (p->kc) { p->kc->clickpercent = rep[12]; p->kc->bellpercent = rep[13]; p->kc->bellpitch = r_card16(rep+14); p->kc->bellduration = r_card16(rep+16); p->kc->leds = r_card32(rep+8); switch (rep[1]) { case 0: case 1: p->kc->global_repeat = rep[1]; break; default: lx__protoerr(op->conn,"GetKeyboardControl returned invalid global autorepeat value %d",rep[1]); break <"ret">; } bcopy(rep+32,&p->kc->key_repeat[0],32); } } while (0); op->reqpriv = 0; free(p); } LX_OP *lx_GetKeyboardControl(LX_CONN *xc, LX_KEYBOARDCONTROL *kc) { unsigned char req[4]; PRIV_GetKeyboardControl *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_GetKeyboardControl"); return(0); } p = malloc(sizeof(PRIV_GetKeyboardControl)); if (! p) { lx__nomem_fail(xc); return(0); } p->kc = kc; req[0] = XP_REQ_GetKeyboardControl; req[1] = 0; w_card16(&req[2],1); return(lx__expect_reply(xc,&req[0],-1,&done_GetKeyboardControl,p)); }