GitHub PullRequestReviewCommentEvent at 2014-01-30 22:08:31
Repository: libcec-daemon
Actor: 9000h
Payload: {"comment":{"url":"https://api.github.com/repos/bramp/libcec-daemon/pulls/comments/9325730","id":9325730,"diff_hunk":"@@ -201,37 +324,241 @@ int Main::onCecLogMessage(const cec_log_message &message) {\n int Main::onCecKeyPress(const cec_keypress &key) {\n \tLOG4CPLUS_DEBUG(logger, \"Main::onCecKeyPress(\" << key << \")\");\n \n-\tint uinputKey = 0;\n-\n \t// Check bounds and find uinput code for this cec keypress\n-\tif (key.keycode >= 0 && key.keycode <= CEC_USER_CONTROL_CODE_MAX)\n-\t\tuinputKey = uinputCecMap[key.keycode];\n-\n-\tif (uinputKey != 0) {\n-\t\tLOG4CPLUS_DEBUG(logger, \"sent \" << uinputKey);\n-\n-\t\t#if LIBCEC_VERSION_CURRENT < 0x2005\n-\t\tuinput.send_event(EV_KEY, uinputKey, key.duration == 0 ? EV_KEY_PRESSED : EV_KEY_RELEASED);\n-\t\t#else\n-\t\tuinput.send_event(EV_KEY, uinputKey, key.duration == 0 ? EV_KEY_REPEAT : EV_KEY_RELEASED);\n-\t\t#endif\n-\t\tuinput.sync();\n+\tif (key.keycode >= 0 && key.keycode <= CEC_USER_CONTROL_CODE_MAX) {\n+\t\tconst list<__u16> & uinputKeys = uinputCecMap[key.keycode];\n+\n+\t\tif ( !uinputKeys.empty() ) {\n+\t\t\tif( key.duration == 0 ) {\n+\t\t\t\tif( uinputKeys == lastUInputKeys )\n+\t\t\t\t{\n+\t\t\t\t\t/*\n+\t\t\t\t\t** KEY REPEAT\n+\t\t\t\t\t*/\n+\t\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = uinputKeys.begin(); ukeys != uinputKeys.end(); ++ukeys) {\n+\t\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"repeat \" << ukey);\n+\n+\t\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_REPEAT);\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t{\n+\t\t\t\t\t/*\n+\t\t\t\t\t** KEY PRESSED\n+\t\t\t\t\t*/\n+\t\t\t\t\tif( ! lastUInputKeys.empty() )\n+\t\t\t\t\t{\n+\t\t\t\t\t\t/* what happened with the last key release ? */\n+\t\t\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = lastUInputKeys.begin(); ukeys != lastUInputKeys.end(); ++ukeys) {\n+\t\t\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"release \" << ukey);\n+\n+\t\t\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_RELEASED);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = uinputKeys.begin(); ukeys != uinputKeys.end(); ++ukeys) {\n+\t\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"send \" << ukey);\n+\n+\t\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_PRESSED);\n+\t\t\t\t\t}\n+\t\t\t\t\tlastUInputKeys = uinputKeys;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\tif( lastUInputKeys != uinputKeys ) {\n+\t\t\t\t\tif( ! lastUInputKeys.empty() ) {\n+\t\t\t\t\t\t/* what happened with the last key release ? */\n+\t\t\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = lastUInputKeys.begin(); ukeys != lastUInputKeys.end(); ++ukeys) {\n+\t\t\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"release \" << ukey);\n+\n+\t\t\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_RELEASED);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = uinputKeys.begin(); ukeys != uinputKeys.end(); ++ukeys) {\n+\t\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"send \" << ukey);\n+\n+\t\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_PRESSED);\n+\t\t\t\t\t}\n+\t\t\t\t\tboost::this_thread::sleep(boost::posix_time::milliseconds(100));\n+\t\t\t\t}\n+\t\t\t\t/*\n+\t\t\t\t** KEY RELEASED\n+\t\t\t\t*/\n+\t\t\t\tfor (std::list<__u16>::const_iterator ukeys = uinputKeys.begin(); ukeys != uinputKeys.end(); ++ukeys) {\n+\t\t\t\t\t__u16 ukey = *ukeys;\n+\n+\t\t\t\t\tLOG4CPLUS_DEBUG(logger, \"release \" << ukey);\n+\n+\t\t\t\t\tuinput.send_event(EV_KEY, ukey, EV_KEY_RELEASED);\n+\n+\t\t\t\t}\n+\t\t\t\tlastUInputKeys.clear();\n+\t\t\t}\n+\t\t\tuinput.sync();\n+\t\t}\n \t}\n \n \treturn 1;\n }\n \n+int Main::onCecKeyPress(const cec_user_control_code & keycode) {\n+\tcec_keypress key = { .keycode=keycode };","path":"src/main.cpp","position":493,"original_position":493,"commit_id":"e494489bf5b69c15bd9f313e37bea1d6615b5468","original_commit_id":"e494489bf5b69c15bd9f313e37bea1d6615b5468","user":{"login":"9000h","id":3009073,"avatar_url":"https://gravatar.com/avatar/86454cb04cccb882804992a79ddfe1ce?d=https%3A%2F%2Fidenticons.github.com%2F38547e1176108c4c3fe80a925f02ad4a.png&r=x","gravatar_id":"86454cb04cccb882804992a79ddfe1ce","url":"https://api.github.com/users/9000h","html_url":"https://github.com/9000h","followers_url":"https://api.github.com/users/9000h/followers","following_url":"https://api.github.com/users/9000h/following{/other_user}","gists_url":"https://api.github.com/users/9000h/gists{/gist_id}","starred_url":"https://api.github.com/users/9000h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9000h/subscriptions","organizations_url":"https://api.github.com/users/9000h/orgs","repos_url":"https://api.github.com/users/9000h/repos","events_url":"https://api.github.com/users/9000h/events{/privacy}","received_events_url":"https://api.github.com/users/9000h/received_events","type":"User","site_admin":false},"body":"+  cec_keypress key = { .keycode=keycode };\r\ntypo should be \r\n+  cec_keypress key = { key.keycode=keycode };","created_at":"2014-01-30T22:08:31Z","updated_at":"2014-01-30T22:08:31Z","html_url":"https://github.com/bramp/libcec-daemon/pull/14#discussion_r9325730","pull_request_url":"https://api.github.com/repos/bramp/libcec-daemon/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/bramp/libcec-daemon/pulls/comments/9325730"},"html":{"href":"https://github.com/bramp/libcec-daemon/pull/14#discussion_r9325730"},"pull_request":{"href":"https://api.github.com/repos/bramp/libcec-daemon/pulls/14"}}}}