ceckb

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

commit 99e2c9004b9d97b6ffc72b1606f108324e9cc1ad
parent 22aeb4e58ca7663f0ae088447eb6b4b6bc4323c7
Author: lostd <lostd@2f30.org>
Date:   Mon, 30 Mar 2015 12:11:10 +0300

Fix workaround logic and properly initialize prev state

Diffstat:
Mceckb.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ceckb.c b/ceckb.c @@ -124,7 +124,7 @@ sendkeypress(unsigned ceccode) int onkeypress(void *cbparam, const cec_keypress key) { - static unsigned prevcode; + static unsigned prevcode = CEC_USER_CONTROL_CODE_UNKNOWN; DPRINTF_X(key.keycode); DPRINTF_X(key.duration); @@ -135,10 +135,12 @@ 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 || key.keycode != prevcode) + if (key.duration == 0) { sendkeypress(key.keycode); - - prevcode = key.keycode; + prevcode = key.keycode; + } else if (key.keycode != prevcode) { + sendkeypress(key.keycode); + } return 0; }