Celluon CL800TB keryboard support
PATCH 1/1 Celluon CL800TB keryboard support
The attached patch implements support for the Celluon CL800BT keyboard. It adds decoding of the data received to the current non-functional framework in the fakehid driver. It currently only implements keyboard functionality, "mouse mode" data is ignored.
Tested on x86-64 and Arm hosts.
Paul
Index: hidd/fakehid.c
===================================================================
RCS file: /cvsroot/bluez/utils/hidd/fakehid.c,v
retrieving revision 1.12
fakehid.c +159 -1
@@ -453,6 +453,158 @@ int jthree_keyboard(const bdaddr_t *src,return 0 ; } +static const int celluon_xlate_num[10 ] = { +KEY_0 ,KEY_1 ,KEY_2 ,KEY_3 ,KEY_4 ,KEY_5 ,KEY_6 ,KEY_7 ,KEY_8 ,KEY_9 +}; + +static const int celluon_xlate_char[26 ] = { +KEY_A ,KEY_B ,KEY_C ,KEY_D ,KEY_E ,KEY_F ,KEY_G ,KEY_H ,KEY_I ,KEY_J , +KEY_K ,KEY_L ,KEY_M ,KEY_N ,KEY_O ,KEY_P ,KEY_Q ,KEY_R ,KEY_S ,KEY_T , +KEY_U ,KEY_V ,KEY_W ,KEY_X ,KEY_Y ,KEY_Z +}; + +static int celluon_xlate (int c) +{ +if (c >='0' && c <='9' ) +return celluon_xlate_num[c -'0' ]; +if (c >='A' && c <='Z' ) +return celluon_xlate_char[c -'A' ]; +switch (c) { +case 0x08 : +return KEY_BACKSPACE ; +case 0x09 : +return KEY_TAB ; +case 0x0d : +return KEY_ENTER ; +case 0x11 : +return KEY_LEFTCTRL ; +case 0x14 : +return KEY_CAPSLOCK ; +case 0x20 : +return KEY_SPACE ; +case 0x25 : +return KEY_LEFT ; +case 0x26 : +return KEY_UP ; +case 0x27 : +return KEY_RIGHT ; +case 0x28 : +return KEY_DOWN ; +case 0x2e : +return KEY_DELETE ; +case 0x5b : +return KEY_MENU ; +case 0xa1 : +return KEY_RIGHTSHIFT ; +case 0xa0 : +return KEY_LEFTSHIFT ; +case 0xba : +return KEY_SEMICOLON ; +case 0xbd : +return KEY_MINUS ; +case 0xbc : +return KEY_COMMA ; +case 0xbb : +return KEY_EQUAL ; +case 0xbe : +return KEY_DOT ; +case 0xbf : +return KEY_SLASH ; +case 0xc0 : +return KEY_GRAVE ; +case 0xdb : +return KEY_LEFTBRACE ; +case 0xdc : +return KEY_BACKSLASH ; +case 0xdd : +return KEY_RIGHTBRACE ; +case 0xde : +return KEY_APOSTROPHE ; +case 0xff03 : +return KEY_HOMEPAGE ; +case 0xff04 : +return KEY_TIME ; +case 0xff06 : +return KEY_OPEN ; +case 0xff07 : +return KEY_LIST ; +case 0xff08 : +return KEY_MAIL ; +case 0xff30 : +return KEY_CALC ; +case 0xff1a :/* Map FN to ALT. */ +return KEY_LEFTALT ; +case 0xff2f : +return KEY_INFO ; +default : +printf ("Unknown Key %x\n" , c); +return c; + } +} + +/* Packet format is as follows (all fields little-endian): +0 uint16 magic; # 0x5a5a +2 uint32 unknown; # ??? +6 uint8 action; # 0 = keyup, 1 = keydown, 2 = repeat +# 3, 4, 5, 6 = ??? (Mouse mode) +7 uint8 unknown2[9] # ??? +16 uint8 action2; # ??? same as action +17 uint16 x; # Horizontal coordinate +19 uint16 y; # Vertical coordinate +21 uint16 time; # Some sort of timestamp +23 uint8 unknown3[5]; # ??? +28 uint8 key[]; # single byte keycode or 0xff byte +# follwed by special keycode byte. +Each packet followed by a checksum byte. */ + +struct celluon_state { +int len;/* Expected length of current packet. */ +int count;/* Number of bytes received. */ +int action; +int key; +}; + +static void celluon_decode (int fd,struct celluon_state *s,uint8_t c) +{ +if (s->count <2 && c !=0xa5 ) { +/* Lost Sync. */ + s->count =0 ; +return ; + } +switch (s->count) { +case 0 : +/* New packet. Reset state. */ + s->len =30 ; + s->key =0 ; +break ; +case 1 : +break ; +case 6 : + s->action = c; +break ; +case 28 : + s->key = c; +if (c ==0xff ) + s->len =31 ; +break ; +case 29 : +case 30 : +if (s->count == s->len -1 ) { +/* TODO: Verify checksum. */ +if (s->action <2 ) { +send_event (fd,EV_KEY ,celluon_xlate (s->key), + s->action); + } + s->count =-1 ; + }else { + s->key = (s->key <<8 ) | c; + } +break ; + } + s->count++; +return ; +} +int celluon_keyboard (const bdaddr_t *src,const bdaddr_t *dst,uint8_t channel) {unsigned char buf[16 ];
@@ -460,7 +612,8 @@ int celluon_keyboard(const bdaddr_t *srcstruct pollfd p;sigset_t sigs;char addr[18 ]; -int fd, sk, len; +int i, fd, sk, len; +struct celluon_state s; sk =rfcomm_connect (src, dst, channel);if (sk <0 )
@@ -500,6 +653,8 @@ int celluon_keyboard(const bdaddr_t *src p.fd = sk; p.events =POLLIN |POLLERR |POLLHUP ; +memset (&s,0 ,sizeof (s)); +while (!__io_canceled) { p.revents =0 ;if (ppoll (&p,1 ,NULL , &sigs) <1 )
@@ -508,6 +663,9 @@ int celluon_keyboard(const bdaddr_t *src len =read (sk, buf,sizeof (buf));if (len <0 )break ; + +for (i =0 ; i < len; i++) +celluon_decode (fd, &s, buf[i]); }printf ("Disconnected\n" );
Index: hidd/uinput.h
===================================================================
RCS file: /cvsroot/bluez/utils/hidd/uinput.h,v
retrieving revision 1.3
uinput.h +65 -0
71 lines not on this page · raw message
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Paul,
Quoted 4 lines
The attached patch implements support for the Celluon CL800BT keyboard. It adds decoding of the data received to the current non-functional framework in the fakehid driver. It currently only implements keyboard functionality, "mouse mode" data is ignored.
the patch has been committed to the CVS. Thanks.
Regards
Marcel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel