ceckb

libcec to uinput key event mapper
git clone git://git.2f30.org/ceckb
Log | Files | Refs | README | LICENSE

commit 02f0eb0633b04e53c4438a2a53899a7c44908b50
parent 2c2fd5b7e44ce75b31e6152a5d19b07c7ee39fd0
Author: lostd <lostd@2f30.org>
Date:   Wed, 21 Feb 2018 23:46:08 +0200

Build against libcec 4

Diffstat:
Mceckb.c | 77++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 38 insertions(+), 39 deletions(-)

diff --git a/ceckb.c b/ceckb.c @@ -121,13 +121,13 @@ sendkeypress(unsigned ceccode) warnx("unhandled code 0x%x", ceccode); } -int -onkeypress(void *cbparam, const cec_keypress key) +void +onkeypress(void *cbparam, const cec_keypress *key) { static unsigned prevcode = CEC_USER_CONTROL_CODE_UNKNOWN; - DPRINTF_X(key.keycode); - DPRINTF_X(key.duration); + DPRINTF_X(key->keycode); + DPRINTF_X(key->duration); /* No duration means this is a press event. Duration is set on * release events. Repeated press events are emulated by always @@ -135,58 +135,57 @@ onkeypress(void *cbparam, const cec_keypress key) * generate a single release event (the select button for example), * so we inject a key press there by checking with the previous key * press. */ - if (key.duration == 0) { - sendkeypress(key.keycode); - prevcode = key.keycode; - } else if (key.keycode != prevcode) { - sendkeypress(key.keycode); + if (key->duration == 0) { + sendkeypress(key->keycode); + prevcode = key->keycode; + } else if (key->keycode != prevcode) { + sendkeypress(key->keycode); } - - return 0; } -int -onlogmsg(void *cbparam, const cec_log_message msg) +void +onlogmsg(void *cbparam, const cec_log_message *msg) { - DPRINTF_S(msg.message); - - return 0; + DPRINTF_S(msg->message); } -int -oncommand(void *cbparam, const cec_command cmd) +void +oncommand(void *cbparam, const cec_command *cmd) { - return 0; } -int +void onalert(void *cbparam, const libcec_alert type, const libcec_parameter param) { - return 0; } ICECCallbacks callbacks = { - .CBCecKeyPress = onkeypress, - .CBCecLogMessage = onlogmsg, - .CBCecCommand = oncommand, - .CBCecAlert = onalert, + .keyPress = onkeypress, + .logMessage = onlogmsg, + .commandReceived = oncommand, + .alert = onalert, }; libcec_configuration config = { - .clientVersion = CEC_CLIENT_VERSION_CURRENT, - .serverVersion = CEC_SERVER_VERSION_CURRENT, + .clientVersion = LIBCEC_VERSION_CURRENT, + .serverVersion = LIBCEC_VERSION_CURRENT, .strDeviceName = "ceckb", .deviceTypes = { - CEC_DEVICE_TYPE_RECORDING_DEVICE, - CEC_DEVICE_TYPE_RESERVED, - CEC_DEVICE_TYPE_RESERVED, - CEC_DEVICE_TYPE_RESERVED, - CEC_DEVICE_TYPE_RESERVED, + .types = { + CEC_DEVICE_TYPE_RECORDING_DEVICE, + CEC_DEVICE_TYPE_RESERVED, + CEC_DEVICE_TYPE_RESERVED, + CEC_DEVICE_TYPE_RESERVED, + CEC_DEVICE_TYPE_RESERVED, + }, }, .cecVersion = CEC_DEFAULT_SETTING_CEC_VERSION, .callbacks = &callbacks, }; +/* global cec connection handle */ +libcec_connection_t conn; + void setupcec(void) { @@ -194,15 +193,15 @@ setupcec(void) int ret; int n; - ret = cec_initialise(&config); - if (!ret) + conn = libcec_initialise(&config); + if (!conn) errx(1, "cec init"); /* Initialize host stack */ - cec_init_video_standalone(); + libcec_init_video_standalone(conn); /* Auto detect adapters */ - n = cec_find_adapters(devs, LEN(devs), NULL); + n = libcec_find_adapters(conn, devs, LEN(devs), NULL); if (n == -1) errx(1, "find adapters"); if (n == 0) @@ -214,7 +213,7 @@ setupcec(void) DPRINTF_S(dev->path); DPRINTF_S(dev->comm); - ret = cec_open(dev->comm, CEC_DEFAULT_CONNECT_TIMEOUT); + ret = libcec_open(conn, dev->comm, CEC_DEFAULT_CONNECT_TIMEOUT); if (!ret) errx(1, "open port %s", dev->comm); } @@ -222,8 +221,8 @@ setupcec(void) void cleancec(void) { - cec_close(); - cec_destroy(); + libcec_close(conn); + libcec_destroy(conn); } void