diff --git a/keyhandler/Makefile b/keyhandler/Makefile new file mode 100644 index 0000000..259a2a6 --- /dev/null +++ b/keyhandler/Makefile @@ -0,0 +1,53 @@ +# * +# * If not stated otherwise in this file or this component's LICENSE file the +# * following copyright and licenses apply: +# * +# * Copyright 2023 RDK Management +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# * +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +BIN_DIR := $(ROOT_DIR)/build/bin +#TOP_DIR := $(ROOT_DIR) +ECHOE = /bin/echo -e +TARGET_EXEC = ut_core_key_input + +# Variables +CC = gcc -ggdb -o0 -Wall +#CFLAGS = -Wall -Wextra -pedantic -std=c11 +SRC = keyhandler.c ../src/ut_kvp_profile.c +INC_DIRS = ../include ../framework/CUnit-2.1-3/CUnit/Headers ../framework/ut-control/include + +# Final flags +INC_FLAGS := $(addprefix -I,$(INC_DIRS)) +XCFLAGS += $(CFLAGS) $(INC_FLAGS) -DUT_CUNIT +XLDFLAGS += -L../framework/ut-control/build/linux/lib -lut_control -Wl,-rpath, -pthread -lpthread + +# Default target +all: $(TARGET_EXEC) + +# Build target +$(TARGET_EXEC): $(SRC) + $(CC) $(SRC) $(XCFLAGS) $(XLDFLAGS) -o $(TARGET_EXEC) + @cp -r ../framework/ut-control/build/linux/lib/libut_control.* . + +# Clean target +clean: + rm -f $(TARGET_EXEC) + +# # Run target +# run: $(TARGTARGET_EXECET) +# ./$(TARGET_EXEC) -p linux_profile_5.28.yaml -m mykeymessage.yaml + +# Phony targets +.PHONY: all clean \ No newline at end of file diff --git a/keyhandler/input-event-codes-5.15.yaml b/keyhandler/input-event-codes-5.15.yaml new file mode 100644 index 0000000..cbaa046 --- /dev/null +++ b/keyhandler/input-event-codes-5.15.yaml @@ -0,0 +1,635 @@ +--- +button_codes: + BTN_0: "0x100" + BTN_1: "0x101" + BTN_2: "0x102" + BTN_3: "0x103" + BTN_4: "0x104" + BTN_5: "0x105" + BTN_6: "0x106" + BTN_7: "0x107" + BTN_8: "0x108" + BTN_9: "0x109" + BTN_A: BTN_SOUTH + BTN_B: BTN_EAST + BTN_BACK: "0x116" + BTN_BASE: "0x126" + BTN_BASE2: "0x127" + BTN_BASE3: "0x128" + BTN_BASE4: "0x129" + BTN_BASE5: "0x12a" + BTN_BASE6: "0x12b" + BTN_C: "0x132" + BTN_DEAD: "0x12f" + BTN_DIGI: "0x140" + BTN_DPAD_DOWN: "0x221" + BTN_DPAD_LEFT: "0x222" + BTN_DPAD_RIGHT: "0x223" + BTN_DPAD_UP: "0x220" + BTN_EAST: "0x131" + BTN_EXTRA: "0x114" + BTN_FORWARD: "0x115" + BTN_GAMEPAD: "0x130" + BTN_GEAR_DOWN: "0x150" + BTN_GEAR_UP: "0x151" + BTN_JOYSTICK: "0x120" + BTN_LEFT: "0x110" + BTN_MIDDLE: "0x112" + BTN_MISC: "0x100" + BTN_MODE: "0x13c" + BTN_MOUSE: "0x110" + BTN_NORTH: "0x133" + BTN_PINKIE: "0x125" + BTN_RIGHT: "0x111" + BTN_SELECT: "0x13a" + BTN_SIDE: "0x113" + BTN_SOUTH: "0x130" + BTN_START: "0x13b" + BTN_STYLUS: "0x14b" + BTN_STYLUS2: "0x14c" + BTN_STYLUS3: "0x149" # Added in 5.15 + BTN_TASK: "0x117" + BTN_THUMB: "0x121" + BTN_THUMB2: "0x122" + BTN_THUMBL: "0x13d" + BTN_THUMBR: "0x13e" + BTN_TL: "0x136" + BTN_TL2: "0x138" + BTN_TOOL_AIRBRUSH: "0x144" + BTN_TOOL_BRUSH: "0x142" + BTN_TOOL_DOUBLETAP: "0x14d" + BTN_TOOL_FINGER: "0x145" + BTN_TOOL_LENS: "0x147" + BTN_TOOL_MOUSE: "0x146" + BTN_TOOL_PEN: "0x140" + BTN_TOOL_PENCIL: "0x143" + BTN_TOOL_QUADTAP: "0x14f" + BTN_TOOL_QUINTTAP: "0x148" + BTN_TOOL_RUBBER: "0x141" + BTN_TOOL_TRIPLETAP: "0x14e" + BTN_TOP: "0x123" + BTN_TOP2: "0x124" + BTN_TOUCH: "0x14a" + BTN_TR: "0x137" + BTN_TR2: "0x139" + BTN_TRIGGER: "0x120" + BTN_TRIGGER_HAPPY: "0x2c0" + BTN_TRIGGER_HAPPY1: "0x2c0" + BTN_TRIGGER_HAPPY10: "0x2c9" + BTN_TRIGGER_HAPPY11: "0x2ca" + BTN_TRIGGER_HAPPY12: "0x2cb" + BTN_TRIGGER_HAPPY13: "0x2cc" + BTN_TRIGGER_HAPPY14: "0x2cd" + BTN_TRIGGER_HAPPY15: "0x2ce" + BTN_TRIGGER_HAPPY16: "0x2cf" + BTN_TRIGGER_HAPPY17: "0x2d0" + BTN_TRIGGER_HAPPY18: "0x2d1" + BTN_TRIGGER_HAPPY19: "0x2d2" + BTN_TRIGGER_HAPPY2: "0x2c1" + BTN_TRIGGER_HAPPY20: "0x2d3" + BTN_TRIGGER_HAPPY21: "0x2d4" + BTN_TRIGGER_HAPPY22: "0x2d5" + BTN_TRIGGER_HAPPY23: "0x2d6" + BTN_TRIGGER_HAPPY24: "0x2d7" + BTN_TRIGGER_HAPPY25: "0x2d8" + BTN_TRIGGER_HAPPY26: "0x2d9" + BTN_TRIGGER_HAPPY27: "0x2da" + BTN_TRIGGER_HAPPY28: "0x2db" + BTN_TRIGGER_HAPPY29: "0x2dc" + BTN_TRIGGER_HAPPY3: "0x2c2" + BTN_TRIGGER_HAPPY30: "0x2dd" + BTN_TRIGGER_HAPPY31: "0x2de" + BTN_TRIGGER_HAPPY32: "0x2df" + BTN_TRIGGER_HAPPY33: "0x2e0" + BTN_TRIGGER_HAPPY34: "0x2e1" + BTN_TRIGGER_HAPPY35: "0x2e2" + BTN_TRIGGER_HAPPY36: "0x2e3" + BTN_TRIGGER_HAPPY37: "0x2e4" + BTN_TRIGGER_HAPPY38: "0x2e5" + BTN_TRIGGER_HAPPY39: "0x2e6" + BTN_TRIGGER_HAPPY4: "0x2c3" + BTN_TRIGGER_HAPPY40: "0x2e7" + BTN_TRIGGER_HAPPY5: "0x2c4" + BTN_TRIGGER_HAPPY6: "0x2c5" + BTN_TRIGGER_HAPPY7: "0x2c6" + BTN_TRIGGER_HAPPY8: "0x2c7" + BTN_TRIGGER_HAPPY9: "0x2c8" + BTN_WEST: "0x134" + BTN_WHEEL: "0x150" + BTN_X: BTN_NORTH + BTN_Y: BTN_WEST + BTN_Z: "0x135" +event_types: + EV_ABS: "0x03" + EV_CNT: (EV_MAX+1) + EV_FF: "0x15" + EV_FF_STATUS: "0x17" + EV_KEY: "0x01" + EV_LED: "0x11" + EV_MAX: "0x1f" + EV_MSC: "0x04" + EV_PWR: "0x16" + EV_REL: "0x02" + EV_REP: "0x14" + EV_SND: "0x12" + EV_SW: "0x05" + EV_SYN: "0x00" +key_codes: + KEY_0: "11" + KEY_1: "2" + KEY_102ND: "86" + KEY_10CHANNELSDOWN: "0x1b9" + KEY_10CHANNELSUP: "0x1b8" + KEY_2: "3" + KEY_3: "4" + KEY_3D_MODE: "0x26f" + KEY_4: "5" + KEY_5: "6" + KEY_6: "7" + KEY_7: "8" + KEY_8: "9" + KEY_9: "10" + KEY_A: "30" + KEY_AB: "0x196" + KEY_ADDRESSBOOK: "0x1ad" + KEY_AGAIN: "129" + KEY_ALS_TOGGLE: "0x230" + KEY_ALTERASE: "222" + KEY_ANGLE: "0x173" + KEY_APOSTROPHE: "40" + KEY_APPSELECT: "0x244" + KEY_ARCHIVE: "0x169" + KEY_ASPECT_RATIO: "0x177" # Renamed in 5.15 + KEY_ASSISTANT: "0x247" # Added in 5.15 + KEY_ATTENDANT_OFF: "0x21c" + KEY_ATTENDANT_ON: "0x21b" + KEY_ATTENDANT_TOGGLE: "0x21d" + KEY_AUDIO: "0x188" + KEY_AUDIO_DESC: "0x26e" + KEY_AUX: "0x186" + KEY_B: "48" + KEY_BACK: "158" + KEY_BACKSLASH: "43" + KEY_BACKSPACE: "14" + KEY_BASSBOOST: "209" + KEY_BATTERY: "236" + KEY_BLUE: "0x191" + KEY_BLUETOOTH: "237" + KEY_BOOKMARKS: "156" + KEY_BREAK: "0x19b" + KEY_BRIGHTNESSDOWN: "224" + KEY_BRIGHTNESSUP: "225" + KEY_BRIGHTNESS_AUTO: "244" + KEY_BRIGHTNESS_CYCLE: "243" + KEY_BRIGHTNESS_MAX: "0x251" + KEY_BRIGHTNESS_MIN: "0x250" + KEY_BRIGHTNESS_TOGGLE: KEY_DISPLAYTOGGLE + KEY_BRIGHTNESS_ZERO: KEY_BRIGHTNESS_AUTO + KEY_BRL_DOT1: "0x1f1" + KEY_BRL_DOT10: "0x1fa" + KEY_BRL_DOT2: "0x1f2" + KEY_BRL_DOT3: "0x1f3" + KEY_BRL_DOT4: "0x1f4" + KEY_BRL_DOT5: "0x1f5" + KEY_BRL_DOT6: "0x1f6" + KEY_BRL_DOT7: "0x1f7" + KEY_BRL_DOT8: "0x1f8" + KEY_BRL_DOT9: "0x1f9" + KEY_BUTTONCONFIG: "0x240" + KEY_C: "46" + KEY_CALC: "140" + KEY_CALENDAR: "0x18d" + KEY_CAMERA: "212" + KEY_CAMERA_DOWN: "0x218" + KEY_CAMERA_FOCUS: "0x210" + KEY_CAMERA_LEFT: "0x219" + KEY_CAMERA_RIGHT: "0x21a" + KEY_CAMERA_UP: "0x217" + KEY_CAMERA_ZOOMIN: "0x215" + KEY_CAMERA_ZOOMOUT: "0x216" + KEY_CANCEL: "223" + KEY_CAPSLOCK: "58" + KEY_CD: "0x17f" + KEY_CHANNEL: "0x16b" + KEY_CHANNELDOWN: "0x193" + KEY_CHANNELUP: "0x192" + KEY_CHAT: "216" + KEY_CLEAR: "0x163" + KEY_CLOSE: "206" + KEY_CLOSECD: "160" + KEY_CNT: (KEY_MAX+1) + KEY_COFFEE: "152" + KEY_COMMA: "51" + KEY_COMPOSE: "127" + KEY_COMPUTER: "157" + KEY_CONFIG: "171" + KEY_CONNECT: "218" + KEY_CONTEXT_MENU: "0x1b6" + KEY_CONTROLPANEL: "0x243" + KEY_COPY: "133" + KEY_CUT: "137" + KEY_CYCLEWINDOWS: "154" + KEY_D: "32" + KEY_DASHBOARD: "204" + KEY_DATA: "0x277" + KEY_DATABASE: "0x1aa" + KEY_DELETE: "111" + KEY_DELETEFILE: "146" + KEY_DEL_EOL: "0x1c0" + KEY_DEL_EOS: "0x1c1" + KEY_DEL_LINE: "0x1c3" + KEY_DIGITS: "0x19d" + KEY_DIRECTION: KEY_ROTATE_DISPLAY + KEY_DIRECTORY: "0x18a" + KEY_DISPLAYTOGGLE: "0x1af" + KEY_DISPLAY_OFF: "245" + KEY_DOCUMENTS: "235" + KEY_DOLLAR: "0x1b2" + KEY_DOT: "52" + KEY_DOWN: "108" + KEY_DVD: "0x185" + KEY_E: "18" + KEY_EDIT: "176" + KEY_EDITOR: "0x1a6" + KEY_EJECTCD: "161" + KEY_EJECTCLOSECD: "162" + KEY_EMAIL: "215" + KEY_EMOJI_PICKER: "0x249" # Added in 5.15 + KEY_END: "107" + KEY_ENTER: "28" + KEY_EPG: "0x16d" + KEY_EQUAL: "13" + KEY_ESC: "1" + KEY_EURO: "0x1b3" + KEY_EXIT: "174" + KEY_F: "33" + KEY_F1: "59" + KEY_F10: "68" + KEY_F11: "87" + KEY_F12: "88" + KEY_F13: "183" + KEY_F14: "184" + KEY_F15: "185" + KEY_F16: "186" + KEY_F17: "187" + KEY_F18: "188" + KEY_F19: "189" + KEY_F2: "60" + KEY_F20: "190" + KEY_F21: "191" + KEY_F22: "192" + KEY_F23: "193" + KEY_F24: "194" + KEY_F3: "61" + KEY_F4: "62" + KEY_F5: "63" + KEY_F6: "64" + KEY_F7: "65" + KEY_F8: "66" + KEY_F9: "67" + KEY_FASTFORWARD: "208" + KEY_FASTREVERSE: "0x275" + KEY_FAVORITES: "0x16c" + KEY_FILE: "144" + KEY_FINANCE: "219" + KEY_FIND: "136" + KEY_FIRST: "0x194" + KEY_FN: "0x1d0" + KEY_FN_1: "0x1de" + KEY_FN_2: "0x1df" + KEY_FN_B: "0x1e4" + KEY_FN_D: "0x1e0" + KEY_FN_E: "0x1e1" + KEY_FN_ESC: "0x1d1" + KEY_FN_F: "0x1e2" + KEY_FN_F1: "0x1d2" + KEY_FN_F10: "0x1db" + KEY_FN_F11: "0x1dc" + KEY_FN_F12: "0x1dd" + KEY_FN_F2: "0x1d3" + KEY_FN_F3: "0x1d4" + KEY_FN_F4: "0x1d5" + KEY_FN_F5: "0x1d6" + KEY_FN_F6: "0x1d7" + KEY_FN_F7: "0x1d8" + KEY_FN_F8: "0x1d9" + KEY_FN_F9: "0x1da" + KEY_FN_RIGHT_SHIFT: "0x1e5" # Added in 5.15 + KEY_FN_S: "0x1e3" + KEY_FORWARD: "159" + KEY_FORWARDMAIL: "233" + KEY_FRAMEBACK: "0x1b4" + KEY_FRAMEFORWARD: "0x1b5" + KEY_FRONT: "132" + KEY_FULL_SCREEN: "0x174" # Renamed in 5.15 + KEY_G: "34" + KEY_GAMES: "0x1a1" + KEY_GOTO: "0x162" + KEY_GRAPHICSEDITOR: "0x1a8" + KEY_GRAVE: "41" + KEY_GREEN: "0x18f" + KEY_H: "35" + KEY_HANGEUL: "122" + KEY_HANGUEL: KEY_HANGEUL + KEY_HANGUP_PHONE: "0x1be" # Added in 5.15 + KEY_HANJA: "123" + KEY_HELP: "138" + KEY_HENKAN: "92" + KEY_HIRAGANA: "91" + KEY_HOME: "102" + KEY_HOMEPAGE: "172" + KEY_HP: "211" + KEY_I: "23" + KEY_IMAGES: "0x1ba" + KEY_INFO: "0x166" + KEY_INSERT: "110" + KEY_INS_LINE: "0x1c2" + KEY_ISO: "170" + KEY_J: "36" + KEY_JOURNAL: "0x242" + KEY_K: "37" + KEY_KATAKANA: "90" + KEY_KATAKANAHIRAGANA: "93" + KEY_KBDILLUMDOWN: "229" + KEY_KBDILLUMTOGGLE: "228" + KEY_KBDILLUMUP: "230" + KEY_KBDINPUTASSIST_ACCEPT: "0x264" + KEY_KBDINPUTASSIST_CANCEL: "0x265" + KEY_KBDINPUTASSIST_NEXT: "0x261" + KEY_KBDINPUTASSIST_NEXTGROUP: "0x263" + KEY_KBDINPUTASSIST_PREV: "0x260" + KEY_KBDINPUTASSIST_PREVGROUP: "0x262" + KEY_KBD_LAYOUT_NEXT: "0x248" # Added in 5.15 + KEY_KBD_LCD_MENU1: "0x2b8" # Added in 5.15 + KEY_KBD_LCD_MENU2: "0x2b9" # Added in 5.15 + KEY_KBD_LCD_MENU3: "0x2ba" # Added in 5.15 + KEY_KBD_LCD_MENU4: "0x2bb" # Added in 5.15 + KEY_KBD_LCD_MENU5: "0x2bc" # Added in 5.15 + KEY_KEYBOARD: "0x176" + KEY_KP0: "82" + KEY_KP1: "79" + KEY_KP2: "80" + KEY_KP3: "81" + KEY_KP4: "75" + KEY_KP5: "76" + KEY_KP6: "77" + KEY_KP7: "71" + KEY_KP8: "72" + KEY_KP9: "73" + KEY_KPASTERISK: "55" + KEY_KPCOMMA: "121" + KEY_KPDOT: "83" + KEY_KPENTER: "96" + KEY_KPEQUAL: "117" + KEY_KPJPCOMMA: "95" + KEY_KPLEFTPAREN: "179" + KEY_KPMINUS: "74" + KEY_KPPLUS: "78" + KEY_KPPLUSMINUS: "118" + KEY_KPRIGHTPAREN: "180" + KEY_KPSLASH: "98" + KEY_L: "38" + KEY_LANGUAGE: "0x170" + KEY_LAST: "0x195" + KEY_LEFT: "105" + KEY_LEFTALT: "56" + KEY_LEFTBRACE: "26" + KEY_LEFTCTRL: "29" + KEY_LEFTMETA: "125" + KEY_LEFTSHIFT: "42" + KEY_LEFT_DOWN: "0x269" + KEY_LEFT_UP: "0x268" + KEY_LIGHTS_TOGGLE: "0x21e" + KEY_LINEFEED: "101" + KEY_LIST: "0x18b" + KEY_LOGOFF: "0x1b1" + KEY_M: "50" + KEY_MACRO: "112" + KEY_MACRO1: "0x290" # Added in 5.15 + KEY_MACRO10: "0x299" # Added in 5.15 + KEY_MACRO11: "0x29a" # Added in 5.15 + KEY_MACRO12: "0x29b" # Added in 5.15 + KEY_MACRO13: "0x29c" # Added in 5.15 + KEY_MACRO14: "0x29d" # Added in 5.15 + KEY_MACRO15: "0x29e" # Added in 5.15 + KEY_MACRO16: "0x29f" # Added in 5.15 + KEY_MACRO17: "0x2a0" # Added in 5.15 + KEY_MACRO18: "0x2a1" # Added in 5.15 + KEY_MACRO19: "0x2a2" # Added in 5.15 + KEY_MACRO2: "0x291" # Added in 5.15 + KEY_MACRO20: "0x2a3" # Added in 5.15 + KEY_MACRO21: "0x2a4" # Added in 5.15 + KEY_MACRO22: "0x2a5" # Added in 5.15 + KEY_MACRO23: "0x2a6" # Added in 5.15 + KEY_MACRO24: "0x2a7" # Added in 5.15 + KEY_MACRO25: "0x2a8" # Added in 5.15 + KEY_MACRO26: "0x2a9" # Added in 5.15 + KEY_MACRO27: "0x2aa" # Added in 5.15 + KEY_MACRO28: "0x2ab" # Added in 5.15 + KEY_MACRO29: "0x2ac" # Added in 5.15 + KEY_MACRO3: "0x292" # Added in 5.15 + KEY_MACRO30: "0x2ad" # Added in 5.15 + KEY_MACRO4: "0x293" # Added in 5.15 + KEY_MACRO5: "0x294" # Added in 5.15 + KEY_MACRO6: "0x295" # Added in 5.15 + KEY_MACRO7: "0x296" # Added in 5.15 + KEY_MACRO8: "0x297" # Added in 5.15 + KEY_MACRO9: "0x298" # Added in 5.15 + KEY_MACRO_PRESET1: "0x2b3" # Added in 5.15 + KEY_MACRO_PRESET2: "0x2b4" # Added in 5.15 + KEY_MACRO_PRESET3: "0x2b5" # Added in 5.15 + KEY_MACRO_PRESET_CYCLE: "0x2b2" # Added in 5.15 + KEY_MACRO_RECORD_START: "0x2b0" # Added in 5.15 + KEY_MACRO_RECORD_STOP: "0x2b1" # Added in 5.15 + KEY_MAIL: "155" + KEY_MAX: "0x2ff" + KEY_MEDIA: "226" + KEY_MEDIA_REPEAT: "0x1b7" + KEY_MEDIA_TOP_MENU: "0x26b" + KEY_MEMO: "0x18c" + KEY_MENU: "139" + KEY_MESSENGER: "0x1ae" + KEY_MHP: "0x16f" + KEY_MICMUTE: "248" + KEY_MINUS: "12" + KEY_MIN_INTERESTING: KEY_MUTE + KEY_MODE: "0x175" + KEY_MOVE: "175" + KEY_MP3: "0x187" + KEY_MSDOS: "151" + KEY_MUHENKAN: "94" + KEY_MUTE: "113" + KEY_N: "49" + KEY_NEW: "181" + KEY_NEWS: "0x1ab" + KEY_NEXT: "0x197" + KEY_NEXTSONG: "163" + KEY_NEXT_FAVORITE: "0x270" + KEY_NOTIFICATION_CENTER: "0x1bc" # Added in 5.15 + KEY_NUMERIC_0: "0x200" + KEY_NUMERIC_1: "0x201" + KEY_NUMERIC_11: "0x26c" + KEY_NUMERIC_12: "0x26d" + KEY_NUMERIC_2: "0x202" + KEY_NUMERIC_3: "0x203" + KEY_NUMERIC_4: "0x204" + KEY_NUMERIC_5: "0x205" + KEY_NUMERIC_6: "0x206" + KEY_NUMERIC_7: "0x207" + KEY_NUMERIC_8: "0x208" + KEY_NUMERIC_9: "0x209" + KEY_NUMERIC_A: "0x20c" + KEY_NUMERIC_B: "0x20d" + KEY_NUMERIC_C: "0x20e" + KEY_NUMERIC_D: "0x20f" + KEY_NUMERIC_POUND: "0x20b" + KEY_NUMERIC_STAR: "0x20a" + KEY_NUMLOCK: "69" + KEY_O: "24" + KEY_OK: "0x160" + KEY_ONSCREEN_KEYBOARD: "0x278" # Added in 5.15 + KEY_OPEN: "134" + KEY_OPTION: "0x165" + KEY_P: "25" + KEY_PAGEDOWN: "109" + KEY_PAGEUP: "104" + KEY_PASTE: "135" + KEY_PAUSE: "119" + KEY_PAUSECD: "201" + KEY_PAUSE_RECORD: "0x272" + KEY_PC: "0x178" + KEY_PHONE: "169" + KEY_PICKUP_PHONE: "0x1bd" # Added in 5.15 + KEY_PLAY: "207" + KEY_PLAYCD: "200" + KEY_PLAYER: "0x183" + KEY_PLAYPAUSE: "164" + KEY_POWER: "116" + KEY_POWER2: "0x164" + KEY_PRESENTATION: "0x1a9" + KEY_PREVIOUS: "0x19c" + KEY_PREVIOUSSONG: "165" + KEY_PRINT: "210" + KEY_PRIVACY_SCREEN_TOGGLE: "0x279" # Added in 5.15 + KEY_PROG1: "148" + KEY_PROG2: "149" + KEY_PROG3: "202" + KEY_PROG4: "203" + KEY_PROGRAM: "0x16a" + KEY_PROPS: "130" + KEY_PVR: "0x16e" + KEY_Q: "16" + KEY_QUESTION: "214" + KEY_R: "19" + KEY_RADIO: "0x181" + KEY_RECORD: "167" + KEY_RED: "0x18e" + KEY_REDO: "182" + KEY_REFRESH: "173" + KEY_REPLY: "232" + KEY_RESERVED: "0" + KEY_RESTART: "0x198" + KEY_REWIND: "168" + KEY_RFKILL: "247" + KEY_RIGHT: "106" + KEY_RIGHTALT: "100" + KEY_RIGHTBRACE: "27" + KEY_RIGHTCTRL: "97" + KEY_RIGHTMETA: "126" + KEY_RIGHTSHIFT: "54" + KEY_RIGHT_DOWN: "0x267" + KEY_RIGHT_UP: "0x266" + KEY_RO: "89" + KEY_ROOT_MENU: "0x26a" + KEY_ROTATE_DISPLAY: "153" + KEY_ROTATE_LOCK_TOGGLE: "0x231" # Added in 5.15 + KEY_S: "31" + KEY_SAT: "0x17d" + KEY_SAT2: "0x17e" + KEY_SAVE: "234" + KEY_SCALE: "120" + KEY_SCREEN: KEY_ASPECT_RATIO + KEY_SCREENLOCK: KEY_COFFEE + KEY_SCREENSAVER: "0x245" + KEY_SCROLLDOWN: "178" + KEY_SCROLLLOCK: "70" + KEY_SCROLLUP: "177" + KEY_SEARCH: "217" + KEY_SELECT: "0x161" + KEY_SELECTIVE_SCREENSHOT: "0x27a" # Added in 5.15 + KEY_SEMICOLON: "39" + KEY_SEND: "231" + KEY_SENDFILE: "145" + KEY_SETUP: "141" + KEY_SHOP: "221" + KEY_SHUFFLE: "0x19a" + KEY_SLASH: "53" + KEY_SLEEP: "142" + KEY_SLOW: "0x199" + KEY_SLOWREVERSE: "0x276" + KEY_SOUND: "213" + KEY_SPACE: "57" + KEY_SPELLCHECK: "0x1b0" + KEY_SPORT: "220" + KEY_SPREADSHEET: "0x1a7" + KEY_STOP: "128" + KEY_STOPCD: "166" + KEY_STOP_RECORD: "0x271" + KEY_SUBTITLE: "0x172" + KEY_SUSPEND: "205" + KEY_SWITCHVIDEOMODE: "227" + KEY_SYSRQ: "99" + KEY_T: "20" + KEY_TAB: "15" + KEY_TAPE: "0x180" + KEY_TASKMANAGER: "0x241" + KEY_TEEN: "0x19e" + KEY_TEXT: "0x184" + KEY_TIME: "0x167" + KEY_TITLE: "0x171" + KEY_TOUCHPAD_OFF: "0x214" + KEY_TOUCHPAD_ON: "0x213" + KEY_TOUCHPAD_TOGGLE: "0x212" + KEY_TUNER: "0x182" + KEY_TV: "0x179" + KEY_TV2: "0x17a" + KEY_TWEN: "0x19f" + KEY_U: "22" + KEY_UNDO: "131" + KEY_UNKNOWN: "240" + KEY_UNMUTE: "0x274" + KEY_UP: "103" + KEY_UWB: "239" + KEY_V: "47" + KEY_VCR: "0x17b" + KEY_VCR2: "0x17c" + KEY_VENDOR: "0x168" + KEY_VIDEO: "0x189" + KEY_VIDEOPHONE: "0x1a0" + KEY_VIDEO_NEXT: "241" + KEY_VIDEO_PREV: "242" + KEY_VOD: "0x273" + KEY_VOICECOMMAND: "0x246" + KEY_VOICEMAIL: "0x1ac" + KEY_VOLUMEDOWN: "114" + KEY_VOLUMEUP: "115" + KEY_W: "17" + KEY_WAKEUP: "143" + KEY_WIMAX: KEY_WWAN + KEY_WLAN: "238" + KEY_WORDPROCESSOR: "0x1a5" + KEY_WPS_BUTTON: "0x211" + KEY_WWAN: "246" + KEY_WWW: "150" + KEY_X: "45" + KEY_XFER: "147" + KEY_Y: "21" + KEY_YELLOW: "0x190" + KEY_YEN: "124" + KEY_Z: "44" + KEY_ZENKAKUHANKAKU: "85" + KEY_ZOOM: KEY_FULL_SCREEN + KEY_ZOOMIN: "0x1a2" + KEY_ZOOMOUT: "0x1a3" + KEY_ZOOMRESET: "0x1a4" +include: mykeyMessage.yaml diff --git a/keyhandler/keyhandler.c b/keyhandler/keyhandler.c new file mode 100644 index 0000000..595420a --- /dev/null +++ b/keyhandler/keyhandler.c @@ -0,0 +1,242 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2023 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include // For write(), close(), and sleep() +#include // For open(), O_WRONLY, O_NONBLOCK +#include + +#include +#include +#include +#include + +void print_usage(const char *program_name) +{ + printf("Usage: %s -p -t -c -v \n", program_name); + printf("OR if keys are included in the profile yaml file then\n"); + printf("Usage: %s -p \n", program_name); +} + +void emit(int fd, int type, int code, int val) +{ + struct input_event ie; + + ie.type = type; + ie.code = code; + ie.value = val; + /* timestamp values below are ignored */ + ie.time.tv_sec = 0; + ie.time.tv_usec = 0; + + write(fd, &ie, sizeof(ie)); + + ie.type = EV_SYN; + ie.code = SYN_REPORT; + ie.value = 0; + + write(fd, &ie, sizeof(ie)); +} + +int get_code(ut_kvp_instance_t *pInstance, char *code) +{ + char key_code_str[256]; + int key_code; + + snprintf(key_code_str, sizeof(key_code_str), "%s%s", "key_codes/", code); + UT_LOG( "key_code_str=[%s]", key_code_str ); + key_code = ut_kvp_getUInt32Field( pInstance, key_code_str ); + + UT_LOG( "key_code=[%d]", key_code ); + return key_code; +} + +int get_type(ut_kvp_instance_t *pInstance, char *type) +{ + char event_type_str[256]; + int event_type_code; + + snprintf(event_type_str, sizeof(event_type_str), "%s%s", "event_types/", type); + UT_LOG("event_type_str=[%s]", event_type_str); + event_type_code = ut_kvp_getUInt32Field(pInstance, event_type_str); + + UT_LOG("event_type_code=[%d]", event_type_code); + return event_type_code; +} + +void print_yaml(ut_kvp_instance_t *instance) +{ + char* kvpData; + + kvpData = ut_kvp_getData(instance); + + if(kvpData != NULL) + { + // Print the emitted KVP string + printf("%s\n", kvpData); + + // Free the emitted KVP string + free(kvpData); + } +} + +int main(int argc, char *argv[]) +{ + int opt; + char *profile_file = NULL; + char *type = NULL; + char *code = NULL; + int value; + int list_count; + ut_kvp_status_t status; + ut_kvp_instance_t *pInstance; + //char result_code[UT_KVP_MAX_ELEMENT_SIZE]={-1}; + struct uinput_setup usetup; + + //char* kvpData; + + + // Parse command-line arguments + while ((opt = getopt(argc, argv, "p:t:c:v:")) != -1) + { + switch (opt) + { + case 'p': + profile_file = optarg; + status = ut_kvp_profile_open(optarg); + if (status != UT_KVP_STATUS_SUCCESS) + { + UT_LOG_ERROR("Failed to Load profile_file [%s]", optarg); + } + break; + case 't': + type = optarg; + break; + case 'c': + code = optarg; + break; + case 'v': + value = atoi(optarg); + break; + default: + print_usage(argv[0]); + return 1; + } + } + + // Validate required arguments + if (profile_file == NULL ) { + fprintf(stderr, "Error: Missing required arguments.\n"); + print_usage(argv[0]); + return 1; + } + + pInstance = ut_kvp_profile_getInstance(); + ///UT_ASSERT( pInstance != NULL ); + if(pInstance == NULL) + { + UT_LOG_ERROR("perhaps platform profile was not passed using -p switch"); + return -1; + } + + list_count = ut_kvp_getListCount(pInstance, "remote/events"); + UT_LOG_DEBUG("listcount = [%d]", list_count); + + //print_yaml(pInstance); + + int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); + + + /* + * The ioctls below will enable the device that is about to be + * created, to pass key events, in this case the space key. + */ + //ioctl(fd, UI_SET_EVBIT, EV_KEY); + //ioctl(fd, UI_SET_KEYBIT, result_kvp); + + memset(&usetup, 0, sizeof(usetup)); + usetup.id.bustype = BUS_USB; + usetup.id.vendor = 0x1234; /* sample vendor */ + usetup.id.product = 0x5678; /* sample product */ + strcpy(usetup.name, "Example device"); + + ioctl(fd, UI_DEV_SETUP, &usetup); + ioctl(fd, UI_DEV_CREATE); + + /* + * On UI_DEV_CREATE the kernel will create the device node for this + * device. We are inserting a pause here so that userspace has time + * to detect, initialize the new device, and can start listening to + * the event, otherwise it will not notice the event we are about + * to send. This pause is only needed in our example code! + */ + sleep(1); + + // for(int i = 0; i < list_count; i++) + // { + if (type == NULL || code == NULL || value == 0) + { + ut_kvp_status_t status; + char result_type[UT_KVP_MAX_ELEMENT_SIZE] = {0xff}; + char result_code[UT_KVP_MAX_ELEMENT_SIZE] = {0xff}; + status = ut_kvp_getStringField(pInstance, "remote/events/0/event/type", result_type, UT_KVP_MAX_ELEMENT_SIZE); + if (status == UT_KVP_STATUS_SUCCESS) + { + UT_LOG_DEBUG("result_kvp for type = [%s]", result_type); + } + type = result_type; + + status = ut_kvp_getStringField(pInstance, "remote/events/0/event/code", result_code, UT_KVP_MAX_ELEMENT_SIZE); + if (status == UT_KVP_STATUS_SUCCESS) + { + UT_LOG_DEBUG("result_kvp for code = [%s]", result_code); + } + code = result_code; + + value = ut_kvp_getUInt32Field(pInstance, "remote/events/0/event/value"); + UT_LOG_DEBUG("result for value = [%d]", value); + } + + // Print the parsed arguments + UT_LOG_DEBUG("Profile file: %s\n", profile_file); + UT_LOG_DEBUG("type: %s\n", type); + UT_LOG_DEBUG("code: %s\n", code); + UT_LOG_DEBUG("value: %d\n", value); + + /* Key press, report the event, send key release, and report again */ + emit(fd, get_type(pInstance, type), get_code(pInstance, code), value); + // } + + + emit(fd, get_type(pInstance, type), get_code(pInstance, code), 0); + /* + * Give userspace some time to read the events before we destroy the + * device with UI_DEV_DESTROY. + */ + sleep(1); + + ioctl(fd, UI_DEV_DESTROY); + close(fd); + ut_kvp_profile_close(); + + return 0; +} \ No newline at end of file diff --git a/keyhandler/mykeyMessage.yaml b/keyhandler/mykeyMessage.yaml new file mode 100644 index 0000000..2903634 --- /dev/null +++ b/keyhandler/mykeyMessage.yaml @@ -0,0 +1,15 @@ +--- +remote: + map: rc6 + events: + - event: + code : KEY_SPACE + type : EV_KEY + value : 1 + - event: + code : KEY_SPACE + type : EV_KEY + value : 0 + - event: + key: KEY_DOWN + repeat: 3