added key parsing
Signed-off-by: Jolan Rathelot <jrathelo@student.42nice.fr>
This commit is contained in:
parent
1b685c68cb
commit
450512799c
66
.idea/workspace.xml
generated
66
.idea/workspace.xml
generated
@ -17,7 +17,8 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="2686ebbf-1c6c-4484-bb57-dec59a208d53" name="Changes" comment="">
|
<list default="true" id="2686ebbf-1c6c-4484-bb57-dec59a208d53" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/keyboard_logger.c" beforeDir="false" afterPath="$PROJECT_DIR$/src/keyboard_logger.c" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -65,30 +66,30 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"cf.first.check.clang-format": "false",
|
"cf.first.check.clang-format": "false",
|
||||||
"cidr.known.project.marker": "true",
|
"cidr.known.project.marker": "true",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
||||||
"org.rust.hideNoCargoProjectNotifications/root/drivers-and-interrupts/src/fancy_print.rs": "true",
|
"org.rust.hideNoCargoProjectNotifications/root/drivers-and-interrupts/src/fancy_print.rs": "true",
|
||||||
"org.rust.hideNoCargoProjectNotifications/root/drivers-and-interrupts/src/main.rs": "true",
|
"org.rust.hideNoCargoProjectNotifications/root/drivers-and-interrupts/src/main.rs": "true",
|
||||||
"settings.editor.selected.configurable": "MakefileSettings",
|
"settings.editor.selected.configurable": "MakefileSettings",
|
||||||
"structure.view.defaults.are.configured": "true",
|
"structure.view.defaults.are.configured": "true",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RdControllerToolWindowsLayoutState" isNewUi="true">
|
<component name="RdControllerToolWindowsLayoutState" isNewUi="true">
|
||||||
<layout>
|
<layout>
|
||||||
<window_info id="Space Code Reviews" />
|
<window_info id="Space Code Reviews" />
|
||||||
@ -96,9 +97,9 @@
|
|||||||
<window_info id="Merge Requests" />
|
<window_info id="Merge Requests" />
|
||||||
<window_info id="Commit_Guest" />
|
<window_info id="Commit_Guest" />
|
||||||
<window_info id="Pull Requests" weight="0.2032358" />
|
<window_info id="Pull Requests" weight="0.2032358" />
|
||||||
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.50054586" visible="true" weight="0.2032358" />
|
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.50054586" visible="true" weight="0.18550533" />
|
||||||
<window_info id="Commit" order="1" weight="0.25" />
|
<window_info id="Commit" order="1" weight="0.25" />
|
||||||
<window_info active="true" id="Structure" order="2" sideWeight="0.49945414" side_tool="true" visible="true" weight="0.2032358" />
|
<window_info id="Structure" order="2" sideWeight="0.49945414" side_tool="true" weight="0.2032358" />
|
||||||
<window_info anchor="bottom" id="CMake" weight="0.22384511" />
|
<window_info anchor="bottom" id="CMake" weight="0.22384511" />
|
||||||
<window_info anchor="bottom" id="Database Changes" />
|
<window_info anchor="bottom" id="Database Changes" />
|
||||||
<window_info anchor="bottom" id="TypeScript" />
|
<window_info anchor="bottom" id="TypeScript" />
|
||||||
@ -111,7 +112,7 @@
|
|||||||
<window_info anchor="bottom" id="clangd" />
|
<window_info anchor="bottom" id="clangd" />
|
||||||
<window_info anchor="bottom" id="Version Control" order="0" weight="0.32982337" />
|
<window_info anchor="bottom" id="Version Control" order="0" weight="0.32982337" />
|
||||||
<window_info anchor="bottom" id="Problems View" order="1" />
|
<window_info anchor="bottom" id="Problems View" order="1" />
|
||||||
<window_info active="true" anchor="bottom" id="Terminal" order="2" visible="true" weight="0.32982337" />
|
<window_info active="true" anchor="bottom" id="Terminal" order="2" visible="true" weight="0.26324728" />
|
||||||
<window_info anchor="bottom" id="Services" order="3" weight="0.22384511" />
|
<window_info anchor="bottom" id="Services" order="3" weight="0.22384511" />
|
||||||
<window_info anchor="right" id="make" side_tool="true" />
|
<window_info anchor="right" id="make" side_tool="true" />
|
||||||
<window_info anchor="right" id="Meet New UI" side_tool="true" />
|
<window_info anchor="right" id="Meet New UI" side_tool="true" />
|
||||||
@ -120,7 +121,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</component>
|
</component>
|
||||||
<component name="RustProjectSettings">
|
<component name="RustProjectSettings">
|
||||||
<option name="toolchainHomeDirectory" value="$PROJECT_DIR$/../.cargo/bin" />
|
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
@ -145,7 +146,14 @@
|
|||||||
<workItem from="1710237482962" duration="1467000" />
|
<workItem from="1710237482962" duration="1467000" />
|
||||||
<workItem from="1710239039309" duration="441000" />
|
<workItem from="1710239039309" duration="441000" />
|
||||||
<workItem from="1710239561572" duration="2000" />
|
<workItem from="1710239561572" duration="2000" />
|
||||||
<workItem from="1710242577588" duration="3883000" />
|
<workItem from="1710242577588" duration="7515000" />
|
||||||
|
<workItem from="1710341418305" duration="265000" />
|
||||||
|
<workItem from="1710341838935" duration="656000" />
|
||||||
|
<workItem from="1710342627627" duration="2000" />
|
||||||
|
<workItem from="1710342965253" duration="804000" />
|
||||||
|
<workItem from="1710406290228" duration="3416000" />
|
||||||
|
<workItem from="1710410667925" duration="2000" />
|
||||||
|
<workItem from="1710410734122" duration="877000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Removed Rust code, added misc device and irq handle. Began work on correctly formatting print msg and logging files.">
|
<task id="LOCAL-00001" summary="Removed Rust code, added misc device and irq handle. Began work on correctly formatting print msg and logging files.">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
@ -27,12 +27,12 @@ struct linked_list_node {
|
|||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mutex lock;
|
|
||||||
|
|
||||||
#ifndef EXTERN
|
#ifndef EXTERN
|
||||||
# define EXTERN extern
|
# define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
extern struct list_head keyboard_log;
|
extern struct list_head keyboard_log;
|
||||||
|
extern struct mutex lock;
|
||||||
|
|
||||||
|
|
||||||
void print_keyboard_line(struct KeyboardCaptureData data);
|
void print_keyboard_line(struct KeyboardCaptureData data);
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
LIST_HEAD(keyboard_log);
|
LIST_HEAD(keyboard_log);
|
||||||
|
|
||||||
const struct KeyboardCaptureData KEY_DICTIONARY[] = {
|
#define DICT_SIZE 249
|
||||||
|
|
||||||
|
const struct KeyboardCaptureData KEY_DICTIONARY[DICT_SIZE] = {
|
||||||
{ 0x1, "Escape", PRESSED, 0 },
|
{ 0x1, "Escape", PRESSED, 0 },
|
||||||
{ 0x2, "1", PRESSED, '1' },
|
{ 0x2, "1", PRESSED, '1' },
|
||||||
{ 0x3, "2", PRESSED, '2' },
|
{ 0x3, "2", PRESSED, '2' },
|
||||||
@ -260,20 +262,42 @@ const struct KeyboardCaptureData KEY_DICTIONARY[] = {
|
|||||||
{ 0xe11d45e19dc5, "Pause", PRESSED, 0 },
|
{ 0xe11d45e19dc5, "Pause", PRESSED, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
void printk_key_event(char code) {
|
struct KeyboardCaptureData find_key_from_code(uint64_t code) {
|
||||||
|
for (size_t i = 0; i < DICT_SIZE; i++) {
|
||||||
|
if (KEY_DICTIONARY[i].code == code) {
|
||||||
|
return KEY_DICTIONARY[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct KeyboardCaptureData dummy = { 0, "", PRESSED, 0 };
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printk_key_event(struct KeyboardCaptureData key) {
|
||||||
struct timespec64 now;
|
struct timespec64 now;
|
||||||
ktime_get_real_ts64(&now);
|
ktime_get_real_ts64(&now);
|
||||||
char sec = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) % 60;
|
char sec = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) % 60;
|
||||||
char min = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 % 60;
|
char min = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 % 60;
|
||||||
char hour = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 / 60 % 24;
|
char hour = (now.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 / 60 % 24;
|
||||||
printk("%d:%d:%d code: %d", hour, min, sec, code);
|
printk(KERN_INFO "%d:%d:%d \"%s\" ", hour, min, sec, key.key_name);
|
||||||
|
if (key.ascii_value) {
|
||||||
|
printk(KERN_CONT "(0x%x) ", key.ascii_value);
|
||||||
|
}
|
||||||
|
if (key.state == PRESSED) {
|
||||||
|
printk(KERN_CONT "PRESSED\n");
|
||||||
|
} else {
|
||||||
|
printk(KERN_CONT "RELEASED\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqreturn_t key_logger_isr(int i, void *dummy) {
|
irqreturn_t key_logger_isr(int i, void *dummy) {
|
||||||
mb();
|
uint64_t code = inb(0x60);
|
||||||
char code = inb(0x60);
|
struct KeyboardCaptureData key = find_key_from_code(code);
|
||||||
|
if (!key.code) {
|
||||||
printk_key_event(code);
|
return IRQ_NONE;
|
||||||
|
}
|
||||||
|
mutex_lock(&lock);
|
||||||
|
printk_key_event(key);
|
||||||
|
mutex_unlock(&lock);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,10 @@ static struct miscdevice device = {
|
|||||||
|
|
||||||
struct logger {
|
struct logger {
|
||||||
char code;
|
char code;
|
||||||
}key_logger;
|
} key_logger;
|
||||||
|
|
||||||
|
|
||||||
|
struct mutex lock = __MUTEX_INITIALIZER(lock);
|
||||||
|
|
||||||
static int __init m_init(void) {
|
static int __init m_init(void) {
|
||||||
struct linked_list_node *ptr, *tmp;
|
struct linked_list_node *ptr, *tmp;
|
||||||
|
Reference in New Issue
Block a user