diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ccc9b93
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,743 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# clang-format configuration file. Intended for clang-format >= 11.
+#
+# For more information, see:
+#
+# Documentation/process/clang-format.rst
+# https://clang.llvm.org/docs/ClangFormat.html
+# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+#
+---
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: false
+ AfterControlStatement: false
+ AfterEnum: false
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: false
+ BeforeCatch: false
+ BeforeElse: false
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeComma
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: false
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+
+# Taken from:
+# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \
+# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
+# | LC_ALL=C sort -u
+ForEachMacros:
+ - '__ata_qc_for_each'
+ - '__bio_for_each_bvec'
+ - '__bio_for_each_segment'
+ - '__evlist__for_each_entry'
+ - '__evlist__for_each_entry_continue'
+ - '__evlist__for_each_entry_from'
+ - '__evlist__for_each_entry_reverse'
+ - '__evlist__for_each_entry_safe'
+ - '__for_each_mem_range'
+ - '__for_each_mem_range_rev'
+ - '__for_each_thread'
+ - '__hlist_for_each_rcu'
+ - '__map__for_each_symbol_by_name'
+ - '__pci_bus_for_each_res0'
+ - '__pci_bus_for_each_res1'
+ - '__pci_dev_for_each_res0'
+ - '__pci_dev_for_each_res1'
+ - '__perf_evlist__for_each_entry'
+ - '__perf_evlist__for_each_entry_reverse'
+ - '__perf_evlist__for_each_entry_safe'
+ - '__rq_for_each_bio'
+ - '__shost_for_each_device'
+ - '__sym_for_each'
+ - 'apei_estatus_for_each_section'
+ - 'ata_for_each_dev'
+ - 'ata_for_each_link'
+ - 'ata_qc_for_each'
+ - 'ata_qc_for_each_raw'
+ - 'ata_qc_for_each_with_internal'
+ - 'ax25_for_each'
+ - 'ax25_uid_for_each'
+ - 'bio_for_each_bvec'
+ - 'bio_for_each_bvec_all'
+ - 'bio_for_each_folio_all'
+ - 'bio_for_each_integrity_vec'
+ - 'bio_for_each_segment'
+ - 'bio_for_each_segment_all'
+ - 'bio_list_for_each'
+ - 'bip_for_each_vec'
+ - 'bond_for_each_slave'
+ - 'bond_for_each_slave_rcu'
+ - 'bpf_for_each'
+ - 'bpf_for_each_reg_in_vstate'
+ - 'bpf_for_each_reg_in_vstate_mask'
+ - 'bpf_for_each_spilled_reg'
+ - 'bpf_object__for_each_map'
+ - 'bpf_object__for_each_program'
+ - 'btree_for_each_safe128'
+ - 'btree_for_each_safe32'
+ - 'btree_for_each_safe64'
+ - 'btree_for_each_safel'
+ - 'card_for_each_dev'
+ - 'cgroup_taskset_for_each'
+ - 'cgroup_taskset_for_each_leader'
+ - 'cpu_aggr_map__for_each_idx'
+ - 'cpufreq_for_each_efficient_entry_idx'
+ - 'cpufreq_for_each_entry'
+ - 'cpufreq_for_each_entry_idx'
+ - 'cpufreq_for_each_valid_entry'
+ - 'cpufreq_for_each_valid_entry_idx'
+ - 'css_for_each_child'
+ - 'css_for_each_descendant_post'
+ - 'css_for_each_descendant_pre'
+ - 'damon_for_each_region'
+ - 'damon_for_each_region_from'
+ - 'damon_for_each_region_safe'
+ - 'damon_for_each_scheme'
+ - 'damon_for_each_scheme_safe'
+ - 'damon_for_each_target'
+ - 'damon_for_each_target_safe'
+ - 'damos_for_each_filter'
+ - 'damos_for_each_filter_safe'
+ - 'data__for_each_file'
+ - 'data__for_each_file_new'
+ - 'data__for_each_file_start'
+ - 'device_for_each_child_node'
+ - 'displayid_iter_for_each'
+ - 'dma_fence_array_for_each'
+ - 'dma_fence_chain_for_each'
+ - 'dma_fence_unwrap_for_each'
+ - 'dma_resv_for_each_fence'
+ - 'dma_resv_for_each_fence_unlocked'
+ - 'do_for_each_ftrace_op'
+ - 'drm_atomic_crtc_for_each_plane'
+ - 'drm_atomic_crtc_state_for_each_plane'
+ - 'drm_atomic_crtc_state_for_each_plane_state'
+ - 'drm_atomic_for_each_plane_damage'
+ - 'drm_client_for_each_connector_iter'
+ - 'drm_client_for_each_modeset'
+ - 'drm_connector_for_each_possible_encoder'
+ - 'drm_exec_for_each_locked_object'
+ - 'drm_exec_for_each_locked_object_reverse'
+ - 'drm_for_each_bridge_in_chain'
+ - 'drm_for_each_connector_iter'
+ - 'drm_for_each_crtc'
+ - 'drm_for_each_crtc_reverse'
+ - 'drm_for_each_encoder'
+ - 'drm_for_each_encoder_mask'
+ - 'drm_for_each_fb'
+ - 'drm_for_each_legacy_plane'
+ - 'drm_for_each_plane'
+ - 'drm_for_each_plane_mask'
+ - 'drm_for_each_privobj'
+ - 'drm_gem_for_each_gpuva'
+ - 'drm_gem_for_each_gpuva_safe'
+ - 'drm_gpuva_for_each_op'
+ - 'drm_gpuva_for_each_op_from_reverse'
+ - 'drm_gpuva_for_each_op_safe'
+ - 'drm_gpuvm_for_each_va'
+ - 'drm_gpuvm_for_each_va_range'
+ - 'drm_gpuvm_for_each_va_range_safe'
+ - 'drm_gpuvm_for_each_va_safe'
+ - 'drm_mm_for_each_hole'
+ - 'drm_mm_for_each_node'
+ - 'drm_mm_for_each_node_in_range'
+ - 'drm_mm_for_each_node_safe'
+ - 'dsa_switch_for_each_available_port'
+ - 'dsa_switch_for_each_cpu_port'
+ - 'dsa_switch_for_each_cpu_port_continue_reverse'
+ - 'dsa_switch_for_each_port'
+ - 'dsa_switch_for_each_port_continue_reverse'
+ - 'dsa_switch_for_each_port_safe'
+ - 'dsa_switch_for_each_user_port'
+ - 'dsa_tree_for_each_cpu_port'
+ - 'dsa_tree_for_each_user_port'
+ - 'dsa_tree_for_each_user_port_continue_reverse'
+ - 'dso__for_each_symbol'
+ - 'dsos__for_each_with_build_id'
+ - 'elf_hash_for_each_possible'
+ - 'elf_symtab__for_each_symbol'
+ - 'evlist__for_each_cpu'
+ - 'evlist__for_each_entry'
+ - 'evlist__for_each_entry_continue'
+ - 'evlist__for_each_entry_from'
+ - 'evlist__for_each_entry_reverse'
+ - 'evlist__for_each_entry_safe'
+ - 'flow_action_for_each'
+ - 'for_each_acpi_consumer_dev'
+ - 'for_each_acpi_dev_match'
+ - 'for_each_active_dev_scope'
+ - 'for_each_active_drhd_unit'
+ - 'for_each_active_iommu'
+ - 'for_each_active_route'
+ - 'for_each_aggr_pgid'
+ - 'for_each_and_bit'
+ - 'for_each_andnot_bit'
+ - 'for_each_available_child_of_node'
+ - 'for_each_bench'
+ - 'for_each_bio'
+ - 'for_each_board_func_rsrc'
+ - 'for_each_btf_ext_rec'
+ - 'for_each_btf_ext_sec'
+ - 'for_each_bvec'
+ - 'for_each_card_auxs'
+ - 'for_each_card_auxs_safe'
+ - 'for_each_card_components'
+ - 'for_each_card_dapms'
+ - 'for_each_card_pre_auxs'
+ - 'for_each_card_prelinks'
+ - 'for_each_card_rtds'
+ - 'for_each_card_rtds_safe'
+ - 'for_each_card_widgets'
+ - 'for_each_card_widgets_safe'
+ - 'for_each_cgroup_storage_type'
+ - 'for_each_child_of_node'
+ - 'for_each_clear_bit'
+ - 'for_each_clear_bit_from'
+ - 'for_each_clear_bitrange'
+ - 'for_each_clear_bitrange_from'
+ - 'for_each_cmd'
+ - 'for_each_cmsghdr'
+ - 'for_each_collection'
+ - 'for_each_comp_order'
+ - 'for_each_compatible_node'
+ - 'for_each_component_dais'
+ - 'for_each_component_dais_safe'
+ - 'for_each_conduit'
+ - 'for_each_console'
+ - 'for_each_console_srcu'
+ - 'for_each_cpu'
+ - 'for_each_cpu_and'
+ - 'for_each_cpu_andnot'
+ - 'for_each_cpu_or'
+ - 'for_each_cpu_wrap'
+ - 'for_each_dapm_widgets'
+ - 'for_each_dedup_cand'
+ - 'for_each_dev_addr'
+ - 'for_each_dev_scope'
+ - 'for_each_dma_cap_mask'
+ - 'for_each_dpcm_be'
+ - 'for_each_dpcm_be_rollback'
+ - 'for_each_dpcm_be_safe'
+ - 'for_each_dpcm_fe'
+ - 'for_each_drhd_unit'
+ - 'for_each_dss_dev'
+ - 'for_each_efi_memory_desc'
+ - 'for_each_efi_memory_desc_in_map'
+ - 'for_each_element'
+ - 'for_each_element_extid'
+ - 'for_each_element_id'
+ - 'for_each_endpoint_of_node'
+ - 'for_each_event'
+ - 'for_each_event_tps'
+ - 'for_each_evictable_lru'
+ - 'for_each_fib6_node_rt_rcu'
+ - 'for_each_fib6_walker_rt'
+ - 'for_each_free_mem_pfn_range_in_zone'
+ - 'for_each_free_mem_pfn_range_in_zone_from'
+ - 'for_each_free_mem_range'
+ - 'for_each_free_mem_range_reverse'
+ - 'for_each_func_rsrc'
+ - 'for_each_gpiochip_node'
+ - 'for_each_group_evsel'
+ - 'for_each_group_evsel_head'
+ - 'for_each_group_member'
+ - 'for_each_group_member_head'
+ - 'for_each_hstate'
+ - 'for_each_if'
+ - 'for_each_inject_fn'
+ - 'for_each_insn'
+ - 'for_each_insn_prefix'
+ - 'for_each_intid'
+ - 'for_each_iommu'
+ - 'for_each_ip_tunnel_rcu'
+ - 'for_each_irq_nr'
+ - 'for_each_lang'
+ - 'for_each_link_codecs'
+ - 'for_each_link_cpus'
+ - 'for_each_link_platforms'
+ - 'for_each_lru'
+ - 'for_each_matching_node'
+ - 'for_each_matching_node_and_match'
+ - 'for_each_media_entity_data_link'
+ - 'for_each_mem_pfn_range'
+ - 'for_each_mem_range'
+ - 'for_each_mem_range_rev'
+ - 'for_each_mem_region'
+ - 'for_each_member'
+ - 'for_each_memory'
+ - 'for_each_migratetype_order'
+ - 'for_each_missing_reg'
+ - 'for_each_mle_subelement'
+ - 'for_each_mod_mem_type'
+ - 'for_each_net'
+ - 'for_each_net_continue_reverse'
+ - 'for_each_net_rcu'
+ - 'for_each_netdev'
+ - 'for_each_netdev_continue'
+ - 'for_each_netdev_continue_rcu'
+ - 'for_each_netdev_continue_reverse'
+ - 'for_each_netdev_dump'
+ - 'for_each_netdev_feature'
+ - 'for_each_netdev_in_bond_rcu'
+ - 'for_each_netdev_rcu'
+ - 'for_each_netdev_reverse'
+ - 'for_each_netdev_safe'
+ - 'for_each_new_connector_in_state'
+ - 'for_each_new_crtc_in_state'
+ - 'for_each_new_mst_mgr_in_state'
+ - 'for_each_new_plane_in_state'
+ - 'for_each_new_plane_in_state_reverse'
+ - 'for_each_new_private_obj_in_state'
+ - 'for_each_new_reg'
+ - 'for_each_node'
+ - 'for_each_node_by_name'
+ - 'for_each_node_by_type'
+ - 'for_each_node_mask'
+ - 'for_each_node_state'
+ - 'for_each_node_with_cpus'
+ - 'for_each_node_with_property'
+ - 'for_each_nonreserved_multicast_dest_pgid'
+ - 'for_each_numa_hop_mask'
+ - 'for_each_of_allnodes'
+ - 'for_each_of_allnodes_from'
+ - 'for_each_of_cpu_node'
+ - 'for_each_of_pci_range'
+ - 'for_each_old_connector_in_state'
+ - 'for_each_old_crtc_in_state'
+ - 'for_each_old_mst_mgr_in_state'
+ - 'for_each_old_plane_in_state'
+ - 'for_each_old_private_obj_in_state'
+ - 'for_each_oldnew_connector_in_state'
+ - 'for_each_oldnew_crtc_in_state'
+ - 'for_each_oldnew_mst_mgr_in_state'
+ - 'for_each_oldnew_plane_in_state'
+ - 'for_each_oldnew_plane_in_state_reverse'
+ - 'for_each_oldnew_private_obj_in_state'
+ - 'for_each_online_cpu'
+ - 'for_each_online_node'
+ - 'for_each_online_pgdat'
+ - 'for_each_or_bit'
+ - 'for_each_path'
+ - 'for_each_pci_bridge'
+ - 'for_each_pci_dev'
+ - 'for_each_pcm_streams'
+ - 'for_each_physmem_range'
+ - 'for_each_populated_zone'
+ - 'for_each_possible_cpu'
+ - 'for_each_present_blessed_reg'
+ - 'for_each_present_cpu'
+ - 'for_each_prime_number'
+ - 'for_each_prime_number_from'
+ - 'for_each_probe_cache_entry'
+ - 'for_each_process'
+ - 'for_each_process_thread'
+ - 'for_each_prop_codec_conf'
+ - 'for_each_prop_dai_codec'
+ - 'for_each_prop_dai_cpu'
+ - 'for_each_prop_dlc_codecs'
+ - 'for_each_prop_dlc_cpus'
+ - 'for_each_prop_dlc_platforms'
+ - 'for_each_property_of_node'
+ - 'for_each_reg'
+ - 'for_each_reg_filtered'
+ - 'for_each_reloc'
+ - 'for_each_reloc_from'
+ - 'for_each_requested_gpio'
+ - 'for_each_requested_gpio_in_range'
+ - 'for_each_reserved_mem_range'
+ - 'for_each_reserved_mem_region'
+ - 'for_each_rtd_codec_dais'
+ - 'for_each_rtd_components'
+ - 'for_each_rtd_cpu_dais'
+ - 'for_each_rtd_dais'
+ - 'for_each_sband_iftype_data'
+ - 'for_each_script'
+ - 'for_each_sec'
+ - 'for_each_set_bit'
+ - 'for_each_set_bit_from'
+ - 'for_each_set_bit_wrap'
+ - 'for_each_set_bitrange'
+ - 'for_each_set_bitrange_from'
+ - 'for_each_set_clump8'
+ - 'for_each_sg'
+ - 'for_each_sg_dma_page'
+ - 'for_each_sg_page'
+ - 'for_each_sgtable_dma_page'
+ - 'for_each_sgtable_dma_sg'
+ - 'for_each_sgtable_page'
+ - 'for_each_sgtable_sg'
+ - 'for_each_sibling_event'
+ - 'for_each_sta_active_link'
+ - 'for_each_subelement'
+ - 'for_each_subelement_extid'
+ - 'for_each_subelement_id'
+ - 'for_each_sublist'
+ - 'for_each_subsystem'
+ - 'for_each_supported_activate_fn'
+ - 'for_each_supported_inject_fn'
+ - 'for_each_sym'
+ - 'for_each_test'
+ - 'for_each_thread'
+ - 'for_each_token'
+ - 'for_each_unicast_dest_pgid'
+ - 'for_each_valid_link'
+ - 'for_each_vif_active_link'
+ - 'for_each_vma'
+ - 'for_each_vma_range'
+ - 'for_each_vsi'
+ - 'for_each_wakeup_source'
+ - 'for_each_zone'
+ - 'for_each_zone_zonelist'
+ - 'for_each_zone_zonelist_nodemask'
+ - 'func_for_each_insn'
+ - 'fwnode_for_each_available_child_node'
+ - 'fwnode_for_each_child_node'
+ - 'fwnode_for_each_parent_node'
+ - 'fwnode_graph_for_each_endpoint'
+ - 'gadget_for_each_ep'
+ - 'genradix_for_each'
+ - 'genradix_for_each_from'
+ - 'genradix_for_each_reverse'
+ - 'hash_for_each'
+ - 'hash_for_each_possible'
+ - 'hash_for_each_possible_rcu'
+ - 'hash_for_each_possible_rcu_notrace'
+ - 'hash_for_each_possible_safe'
+ - 'hash_for_each_rcu'
+ - 'hash_for_each_safe'
+ - 'hashmap__for_each_entry'
+ - 'hashmap__for_each_entry_safe'
+ - 'hashmap__for_each_key_entry'
+ - 'hashmap__for_each_key_entry_safe'
+ - 'hctx_for_each_ctx'
+ - 'hists__for_each_format'
+ - 'hists__for_each_sort_list'
+ - 'hlist_bl_for_each_entry'
+ - 'hlist_bl_for_each_entry_rcu'
+ - 'hlist_bl_for_each_entry_safe'
+ - 'hlist_for_each'
+ - 'hlist_for_each_entry'
+ - 'hlist_for_each_entry_continue'
+ - 'hlist_for_each_entry_continue_rcu'
+ - 'hlist_for_each_entry_continue_rcu_bh'
+ - 'hlist_for_each_entry_from'
+ - 'hlist_for_each_entry_from_rcu'
+ - 'hlist_for_each_entry_rcu'
+ - 'hlist_for_each_entry_rcu_bh'
+ - 'hlist_for_each_entry_rcu_notrace'
+ - 'hlist_for_each_entry_safe'
+ - 'hlist_for_each_entry_srcu'
+ - 'hlist_for_each_safe'
+ - 'hlist_nulls_for_each_entry'
+ - 'hlist_nulls_for_each_entry_from'
+ - 'hlist_nulls_for_each_entry_rcu'
+ - 'hlist_nulls_for_each_entry_safe'
+ - 'i3c_bus_for_each_i2cdev'
+ - 'i3c_bus_for_each_i3cdev'
+ - 'idr_for_each_entry'
+ - 'idr_for_each_entry_continue'
+ - 'idr_for_each_entry_continue_ul'
+ - 'idr_for_each_entry_ul'
+ - 'in_dev_for_each_ifa_rcu'
+ - 'in_dev_for_each_ifa_rtnl'
+ - 'inet_bind_bucket_for_each'
+ - 'interval_tree_for_each_span'
+ - 'intlist__for_each_entry'
+ - 'intlist__for_each_entry_safe'
+ - 'kcore_copy__for_each_phdr'
+ - 'key_for_each'
+ - 'key_for_each_safe'
+ - 'klp_for_each_func'
+ - 'klp_for_each_func_safe'
+ - 'klp_for_each_func_static'
+ - 'klp_for_each_object'
+ - 'klp_for_each_object_safe'
+ - 'klp_for_each_object_static'
+ - 'kunit_suite_for_each_test_case'
+ - 'kvm_for_each_memslot'
+ - 'kvm_for_each_memslot_in_gfn_range'
+ - 'kvm_for_each_vcpu'
+ - 'libbpf_nla_for_each_attr'
+ - 'list_for_each'
+ - 'list_for_each_codec'
+ - 'list_for_each_codec_safe'
+ - 'list_for_each_continue'
+ - 'list_for_each_entry'
+ - 'list_for_each_entry_continue'
+ - 'list_for_each_entry_continue_rcu'
+ - 'list_for_each_entry_continue_reverse'
+ - 'list_for_each_entry_from'
+ - 'list_for_each_entry_from_rcu'
+ - 'list_for_each_entry_from_reverse'
+ - 'list_for_each_entry_lockless'
+ - 'list_for_each_entry_rcu'
+ - 'list_for_each_entry_reverse'
+ - 'list_for_each_entry_safe'
+ - 'list_for_each_entry_safe_continue'
+ - 'list_for_each_entry_safe_from'
+ - 'list_for_each_entry_safe_reverse'
+ - 'list_for_each_entry_srcu'
+ - 'list_for_each_from'
+ - 'list_for_each_prev'
+ - 'list_for_each_prev_safe'
+ - 'list_for_each_rcu'
+ - 'list_for_each_reverse'
+ - 'list_for_each_safe'
+ - 'llist_for_each'
+ - 'llist_for_each_entry'
+ - 'llist_for_each_entry_safe'
+ - 'llist_for_each_safe'
+ - 'lwq_for_each_safe'
+ - 'map__for_each_symbol'
+ - 'map__for_each_symbol_by_name'
+ - 'maps__for_each_entry'
+ - 'maps__for_each_entry_safe'
+ - 'mas_for_each'
+ - 'mci_for_each_dimm'
+ - 'media_device_for_each_entity'
+ - 'media_device_for_each_intf'
+ - 'media_device_for_each_link'
+ - 'media_device_for_each_pad'
+ - 'media_entity_for_each_pad'
+ - 'media_pipeline_for_each_entity'
+ - 'media_pipeline_for_each_pad'
+ - 'mlx5_lag_for_each_peer_mdev'
+ - 'msi_domain_for_each_desc'
+ - 'msi_for_each_desc'
+ - 'mt_for_each'
+ - 'nanddev_io_for_each_page'
+ - 'netdev_for_each_lower_dev'
+ - 'netdev_for_each_lower_private'
+ - 'netdev_for_each_lower_private_rcu'
+ - 'netdev_for_each_mc_addr'
+ - 'netdev_for_each_synced_mc_addr'
+ - 'netdev_for_each_synced_uc_addr'
+ - 'netdev_for_each_uc_addr'
+ - 'netdev_for_each_upper_dev_rcu'
+ - 'netdev_hw_addr_list_for_each'
+ - 'nft_rule_for_each_expr'
+ - 'nla_for_each_attr'
+ - 'nla_for_each_nested'
+ - 'nlmsg_for_each_attr'
+ - 'nlmsg_for_each_msg'
+ - 'nr_neigh_for_each'
+ - 'nr_neigh_for_each_safe'
+ - 'nr_node_for_each'
+ - 'nr_node_for_each_safe'
+ - 'of_for_each_phandle'
+ - 'of_property_for_each_string'
+ - 'of_property_for_each_u32'
+ - 'pci_bus_for_each_resource'
+ - 'pci_dev_for_each_resource'
+ - 'pcl_for_each_chunk'
+ - 'pcl_for_each_segment'
+ - 'pcm_for_each_format'
+ - 'perf_config_items__for_each_entry'
+ - 'perf_config_sections__for_each_entry'
+ - 'perf_config_set__for_each_entry'
+ - 'perf_cpu_map__for_each_cpu'
+ - 'perf_cpu_map__for_each_idx'
+ - 'perf_evlist__for_each_entry'
+ - 'perf_evlist__for_each_entry_reverse'
+ - 'perf_evlist__for_each_entry_safe'
+ - 'perf_evlist__for_each_evsel'
+ - 'perf_evlist__for_each_mmap'
+ - 'perf_hpp_list__for_each_format'
+ - 'perf_hpp_list__for_each_format_safe'
+ - 'perf_hpp_list__for_each_sort_list'
+ - 'perf_hpp_list__for_each_sort_list_safe'
+ - 'perf_tool_event__for_each_event'
+ - 'plist_for_each'
+ - 'plist_for_each_continue'
+ - 'plist_for_each_entry'
+ - 'plist_for_each_entry_continue'
+ - 'plist_for_each_entry_safe'
+ - 'plist_for_each_safe'
+ - 'pnp_for_each_card'
+ - 'pnp_for_each_dev'
+ - 'protocol_for_each_card'
+ - 'protocol_for_each_dev'
+ - 'queue_for_each_hw_ctx'
+ - 'radix_tree_for_each_slot'
+ - 'radix_tree_for_each_tagged'
+ - 'rb_for_each'
+ - 'rbtree_postorder_for_each_entry_safe'
+ - 'rdma_for_each_block'
+ - 'rdma_for_each_port'
+ - 'rdma_umem_for_each_dma_block'
+ - 'resort_rb__for_each_entry'
+ - 'resource_list_for_each_entry'
+ - 'resource_list_for_each_entry_safe'
+ - 'rhl_for_each_entry_rcu'
+ - 'rhl_for_each_rcu'
+ - 'rht_for_each'
+ - 'rht_for_each_entry'
+ - 'rht_for_each_entry_from'
+ - 'rht_for_each_entry_rcu'
+ - 'rht_for_each_entry_rcu_from'
+ - 'rht_for_each_entry_safe'
+ - 'rht_for_each_from'
+ - 'rht_for_each_rcu'
+ - 'rht_for_each_rcu_from'
+ - 'rq_for_each_bvec'
+ - 'rq_for_each_segment'
+ - 'rq_list_for_each'
+ - 'rq_list_for_each_safe'
+ - 'sample_read_group__for_each'
+ - 'scsi_for_each_prot_sg'
+ - 'scsi_for_each_sg'
+ - 'sctp_for_each_hentry'
+ - 'sctp_skb_for_each'
+ - 'sec_for_each_insn'
+ - 'sec_for_each_insn_continue'
+ - 'sec_for_each_insn_from'
+ - 'sec_for_each_sym'
+ - 'shdma_for_each_chan'
+ - 'shost_for_each_device'
+ - 'sk_for_each'
+ - 'sk_for_each_bound'
+ - 'sk_for_each_bound_bhash2'
+ - 'sk_for_each_entry_offset_rcu'
+ - 'sk_for_each_from'
+ - 'sk_for_each_rcu'
+ - 'sk_for_each_safe'
+ - 'sk_nulls_for_each'
+ - 'sk_nulls_for_each_from'
+ - 'sk_nulls_for_each_rcu'
+ - 'snd_array_for_each'
+ - 'snd_pcm_group_for_each_entry'
+ - 'snd_soc_dapm_widget_for_each_path'
+ - 'snd_soc_dapm_widget_for_each_path_safe'
+ - 'snd_soc_dapm_widget_for_each_sink_path'
+ - 'snd_soc_dapm_widget_for_each_source_path'
+ - 'strlist__for_each_entry'
+ - 'strlist__for_each_entry_safe'
+ - 'sym_for_each_insn'
+ - 'sym_for_each_insn_continue_reverse'
+ - 'symbols__for_each_entry'
+ - 'tb_property_for_each'
+ - 'tcf_act_for_each_action'
+ - 'tcf_exts_for_each_action'
+ - 'ttm_resource_manager_for_each_res'
+ - 'twsk_for_each_bound_bhash2'
+ - 'udp_portaddr_for_each_entry'
+ - 'udp_portaddr_for_each_entry_rcu'
+ - 'usb_hub_for_each_child'
+ - 'v4l2_device_for_each_subdev'
+ - 'v4l2_m2m_for_each_dst_buf'
+ - 'v4l2_m2m_for_each_dst_buf_safe'
+ - 'v4l2_m2m_for_each_src_buf'
+ - 'v4l2_m2m_for_each_src_buf_safe'
+ - 'virtio_device_for_each_vq'
+ - 'while_for_each_ftrace_op'
+ - 'xa_for_each'
+ - 'xa_for_each_marked'
+ - 'xa_for_each_range'
+ - 'xa_for_each_start'
+ - 'xas_for_each'
+ - 'xas_for_each_conflict'
+ - 'xas_for_each_marked'
+ - 'xbc_array_for_each_value'
+ - 'xbc_for_each_key_value'
+ - 'xbc_node_for_each_array_value'
+ - 'xbc_node_for_each_child'
+ - 'xbc_node_for_each_key_value'
+ - 'xbc_node_for_each_subkey'
+ - 'zorro_for_each_dev'
+
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '.*'
+ Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentGotoLabels: false
+IndentPPDirectives: None
+IndentWidth: 8
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 8
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+
+# Taken from git's rules
+PenaltyBreakAssignment: 10
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 60
+
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: false
+SortUsingDeclarations: false
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatementsExceptForEachMacros
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp03
+TabWidth: 8
+UseTab: Always
+...
diff --git a/.gitignore b/.gitignore
index 877b84a..41245d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,4 @@
*.symvers
*.order
-*.tmp*
\ No newline at end of file
+*.tmp*
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 31aca25..56af6eb 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -17,7 +17,14 @@
+
+
+
+
+
+
+
@@ -65,30 +72,31 @@
- {
- "keyToString": {
- "ASKED_ADD_EXTERNAL_FILES": "true",
- "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.cidr.known.project.marker": "true",
- "WebServerToolWindowFactoryState": "false",
- "cf.first.check.clang-format": "false",
- "cidr.known.project.marker": "true",
- "git-widget-placeholder": "master",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "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/main.rs": "true",
- "settings.editor.selected.configurable": "MakefileSettings",
- "structure.view.defaults.are.configured": "true",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -102,7 +110,7 @@
-
+
@@ -111,7 +119,7 @@
-
+
@@ -155,7 +163,10 @@
-
+
+
+
+
diff --git a/Kbuild b/Kbuild
index 19bc6bd..ee33367 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-m := driver_and_interrupts.o
-driver_and_interrupts-y := src/main.o src/misc_device_fops.o src/keyboard_logger.o
\ No newline at end of file
+driver_and_interrupts-y := src/main.o src/misc_device_fops.o src/keyboard_logger.o
diff --git a/Makefile b/Makefile
index b2ca6fd..fcde044 100644
--- a/Makefile
+++ b/Makefile
@@ -25,4 +25,4 @@ modprobe: module_install
rmmod:
rmmod driver_and_interrupts
-.PHONY: all clean modules_install rmmod modprobe install rules_install
\ No newline at end of file
+.PHONY: all clean modules_install rmmod modprobe install rules_install
diff --git a/README.md b/README.md
index d230d35..bcde04b 100644
--- a/README.md
+++ b/README.md
@@ -1 +1 @@
-# Drivers_and_interrupts
\ No newline at end of file
+# Drivers_and_interrupts
diff --git a/src/drivers_and_interrupts.h b/src/drivers_and_interrupts.h
index 19d5976..8b1364e 100644
--- a/src/drivers_and_interrupts.h
+++ b/src/drivers_and_interrupts.h
@@ -7,42 +7,41 @@
#include
#include
-ssize_t read_keyboard_misc_device(struct file *file, char __user *buf, size_t count, loff_t *ppos);
+ssize_t read_keyboard_misc_device(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos);
irqreturn_t key_logger_isr(int i, void *dummy);
enum state {
- PRESSED = true,
- RELEASED = false,
+ PRESSED = true,
+ RELEASED = false,
};
struct KeyboardCaptureData {
- uint64_t code;
- char *key_name;
- enum state state;
- char ascii_value;
+ uint64_t code;
+ char *key_name;
+ enum state state;
+ char ascii_value;
};
struct linked_list_node {
- struct KeyboardCaptureData key;
- struct timespec64 when;
- size_t size;
- struct list_head list;
+ struct KeyboardCaptureData key;
+ struct timespec64 when;
+ size_t size;
+ struct list_head list;
};
struct logger {
- char shifted;
- char capslocked;
+ char shifted;
+ char capslocked;
};
-
#ifndef EXTERN
-# define EXTERN extern
+#define EXTERN extern
#endif
extern struct list_head keyboard_log;
extern struct mutex lock;
-
-void print_keyboard_line(struct KeyboardCaptureData data);
-size_t calc_node_size(struct linked_list_node *node);
+void print_keyboard_line(struct KeyboardCaptureData data);
+size_t calc_node_size(struct linked_list_node *node);
#endif
diff --git a/src/keyboard_logger.c b/src/keyboard_logger.c
index f314000..a55cea8 100644
--- a/src/keyboard_logger.c
+++ b/src/keyboard_logger.c
@@ -11,584 +11,591 @@ LIST_HEAD(keyboard_log);
#define DICT_SIZE 249
const struct KeyboardCaptureData KEY_DICTIONARY[DICT_SIZE] = {
- { 0x1, "Escape", PRESSED, 0 },
- { 0x2, "1", PRESSED, '1' },
- { 0x3, "2", PRESSED, '2' },
- { 0x4, "3", PRESSED, '3' },
- { 0x5, "4", PRESSED, '4' },
- { 0x6, "5", PRESSED, '5' },
- { 0x7, "6", PRESSED, '6' },
- { 0x8, "7", PRESSED, '7' },
- { 0x9, "8", PRESSED, '8' },
- { 0xa, "9", PRESSED, '9' },
- { 0xb, "0", PRESSED, '0' },
- { 0xc, "-", PRESSED, '-' },
- { 0xd, "=", PRESSED, '=' },
- { 0xe, "Backspace", PRESSED, 0 },
- { 0xf, "Tab", PRESSED, '\t' },
- { 0x10, "q", PRESSED, 'q' },
- { 0x11, "w", PRESSED, 'w' },
- { 0x12, "e", PRESSED, 'e' },
- { 0x13, "r", PRESSED, 'r' },
- { 0x14, "t", PRESSED, 't' },
- { 0x15, "y", PRESSED, 'y' },
- { 0x16, "u", PRESSED, 'u' },
- { 0x17, "i", PRESSED, 'i' },
- { 0x18, "o", PRESSED, 'o' },
- { 0x19, "p", PRESSED, 'p' },
- { 0x1a, "[", PRESSED, '[' },
- { 0x1b, "]", PRESSED, ']' },
- { 0x1c, "Enter", PRESSED, '\n' },
- { 0x1d, "Control", PRESSED, 0 },
- { 0x1e, "a", PRESSED, 'a' },
- { 0x1f, "s", PRESSED, 's' },
- { 0x20, "d", PRESSED, 'd' },
- { 0x21, "f", PRESSED, 'f' },
- { 0x22, "g", PRESSED, 'g' },
- { 0x23, "h", PRESSED, 'h' },
- { 0x24, "j", PRESSED, 'j' },
- { 0x25, "k", PRESSED, 'k' },
- { 0x26, "l", PRESSED, 'l' },
- { 0x27, ";", PRESSED, ';' },
- { 0x28, "'", PRESSED, '\'' },
- { 0x29, "`", PRESSED, '`' },
- { 0x2a, "Shift", PRESSED, 0 },
- { 0x2b, "\\", PRESSED, '\\' },
- { 0x2c, "z", PRESSED, 'z' },
- { 0x2d, "x", PRESSED, 'x' },
- { 0x2e, "c", PRESSED, 'c' },
- { 0x2f, "v", PRESSED, 'v' },
- { 0x30, "b", PRESSED, 'b' },
- { 0x31, "n", PRESSED, 'n' },
- { 0x32, "m", PRESSED, 'm' },
- { 0x33, ",", PRESSED, ',' },
- { 0x34, ".", PRESSED, '.' },
- { 0x35, "/", PRESSED, '/' },
- { 0x36, "Right Shift", PRESSED, 0 },
- { 0x37, "* (Keypad)", PRESSED, '*' },
- { 0x38, "Alt", PRESSED, 0 },
- { 0x39, "Space", PRESSED, ' ' },
- { 0x3a, "CapsLock", PRESSED, 0 },
- { 0x3b, "F1", PRESSED, 0 },
- { 0x3c, "F2", PRESSED, 0 },
- { 0x3d, "F3", PRESSED, 0 },
- { 0x3e, "F4", PRESSED, 0 },
- { 0x3f, "F5", PRESSED, 0 },
- { 0x40, "F6", PRESSED, 0 },
- { 0x41, "F7", PRESSED, 0 },
- { 0x42, "F8", PRESSED, 0 },
- { 0x43, "F9", PRESSED, 0 },
- { 0x44, "F10", PRESSED, 0 },
- { 0x45, "NumberLock", PRESSED, 0 },
- { 0x46, "ScrollLock", PRESSED, 0 },
- { 0x47, "7 (Keypad)", PRESSED, '7' },
- { 0x48, "8 (Keypad)", PRESSED, '8' },
- { 0x49, "9 (Keypad)", PRESSED, '9' },
- { 0x4a, "- (Keypad)", PRESSED, '-' },
- { 0x4b, "4 (Keypad)", PRESSED, '4' },
- { 0x4c, "5 (Keypad)", PRESSED, '5' },
- { 0x4d, "6 (Keypad)", PRESSED, '6' },
- { 0x4e, "+ (Keypad)", PRESSED, '+' },
- { 0x4f, "1 (Keypad)", PRESSED, '1' },
- { 0x50, "2 (Keypad)", PRESSED, '2' },
- { 0x51, "3 (Keypad)", PRESSED, '3' },
- { 0x52, "0 (Keypad)", PRESSED, '0' },
- { 0x53, ". (Keypad)", PRESSED, '.' },
- { 0x57, "F11", PRESSED, 0 },
- { 0x58, "F12", PRESSED, 0 },
- { 0x81, "Escape", RELEASED, 0 },
- { 0x82, "1", RELEASED, '1' },
- { 0x83, "2", RELEASED, '2' },
- { 0x84, "3", RELEASED, '3' },
- { 0x85, "4", RELEASED, '4' },
- { 0x86, "5", RELEASED, '5' },
- { 0x87, "6", RELEASED, '6' },
- { 0x88, "7", RELEASED, '6' },
- { 0x89, "8", RELEASED, '8' },
- { 0x8a, "9", RELEASED, '9' },
- { 0x8b, "0", RELEASED, '0' },
- { 0x8c, "-", RELEASED, '-' },
- { 0x8d, "=", RELEASED, '=' },
- { 0x8e, "Backspace", RELEASED, 0 },
- { 0x8f, "Tab", RELEASED, '\t' },
- { 0x90, "q", RELEASED, 'q' },
- { 0x91, "w", RELEASED, 'w' },
- { 0x92, "e", RELEASED, 'e' },
- { 0x93, "r", RELEASED, 'r' },
- { 0x94, "t", RELEASED, 't' },
- { 0x95, "y", RELEASED, 'y' },
- { 0x96, "u", RELEASED, 'u' },
- { 0x97, "i", RELEASED, 'i' },
- { 0x98, "o", RELEASED, 'o' },
- { 0x99, "p", RELEASED, 'p' },
- { 0x9a, "[", RELEASED, '[' },
- { 0x9b, "]", RELEASED, ']' },
- { 0x9c, "Enter", RELEASED, '\n' },
- { 0x9d, "Control", RELEASED, 0 },
- { 0x9e, "a", RELEASED, 'a' },
- { 0x9f, "s", RELEASED, 's' },
- { 0xa0, "d", RELEASED, 'd' },
- { 0xa1, "f", RELEASED, 'f' },
- { 0xa2, "g", RELEASED, 'g' },
- { 0xa3, "h", RELEASED, 'h' },
- { 0xa4, "j", RELEASED, 'j' },
- { 0xa5, "k", RELEASED, 'k' },
- { 0xa6, "l", RELEASED, 'l' },
- { 0xa7, ";", RELEASED, ';' },
- { 0xa8, "'", RELEASED, '\'' },
- { 0xa9, "`", RELEASED, '`' },
- { 0xaa, "Shift", RELEASED, 0 },
- { 0xab, "\\", RELEASED, '\\' },
- { 0xac, "z", RELEASED, 'z' },
- { 0xad, "x", RELEASED, 'x' },
- { 0xae, "c", RELEASED, 'c' },
- { 0xaf, "v", RELEASED, 'v' },
- { 0xb0, "b", RELEASED, 'b' },
- { 0xb1, "n", RELEASED, 'n' },
- { 0xb2, "m", RELEASED, 'm' },
- { 0xb3, ",", RELEASED, ',' },
- { 0xb4, ".", RELEASED, '.' },
- { 0xb5, "/", RELEASED, '/' },
- { 0xb6, "Right Shift", RELEASED, 0 },
- { 0xb7, "* (Keypad)", RELEASED, '*' },
- { 0xb8, "Alt", RELEASED, 0 },
- { 0xb9, "Space", RELEASED, ' ' },
- { 0xba, "CapsLock", RELEASED, 0 },
- { 0xbb, "F1", RELEASED, 0 },
- { 0xbc, "F2", RELEASED, 0 },
- { 0xbd, "F3", RELEASED, 0 },
- { 0xbe, "F4", RELEASED, 0 },
- { 0xbf, "F5", RELEASED, 0 },
- { 0xc0, "F6", RELEASED, 0 },
- { 0xc1, "F7", RELEASED, 0 },
- { 0xc2, "F8", RELEASED, 0 },
- { 0xc3, "F9", RELEASED, 0 },
- { 0xc4, "F10", RELEASED, 0 },
- { 0xc5, "NumberLock", RELEASED, 0 },
- { 0xc6, "ScrollLock", RELEASED, 0 },
- { 0xc7, "7 (Keypad)", RELEASED, '7' },
- { 0xc8, "8 (Keypad)", RELEASED, '8' },
- { 0xc9, "9 (Keypad)", RELEASED, '9' },
- { 0xca, "- (Keypad)", RELEASED, '-' },
- { 0xcb, "4 (Keypad)", RELEASED, '4' },
- { 0xcc, "5 (Keypad)", RELEASED, '5' },
- { 0xcd, "6 (Keypad)", RELEASED, '6' },
- { 0xce, "+ (Keypad)", RELEASED, '+' },
- { 0xcf, "1 (Keypad)", RELEASED, '1' },
- { 0xd0, "2 (Keypad)", RELEASED, '2' },
- { 0xd1, "3 (Keypad)", RELEASED, '4' },
- { 0xd2, "0 (Keypad)", RELEASED, '0' },
- { 0xd3, ". (Keypad)", RELEASED, '.' },
- { 0xd7, "F11", RELEASED, 0 },
- { 0xd8, "F12", RELEASED, 0 },
- { 0xe010, "Previous Track", PRESSED, 0 },
- { 0xe019, "Next Track", PRESSED, 0 },
- { 0xe01c, "Enter (Keypad)", PRESSED, '\n' },
- { 0xe01d, "Right Control", PRESSED, 0 },
- { 0xe020, "Mute", PRESSED, 0 },
- { 0xe021, "Calculator", PRESSED, 0 },
- { 0xe022, "Play", PRESSED, 0 },
- { 0xe024, "Stop", PRESSED, 0 },
- { 0xe02e, "Volume Down", PRESSED, 0 },
- { 0xe030, "Volume Up", PRESSED, 0 },
- { 0xe032, "Home", PRESSED, 0 },
- { 0xe035, "/ (Keypad)", PRESSED, '/' },
- { 0xe038, "AltGr", PRESSED, 0 },
- { 0xe047, "Home", PRESSED, 0 },
- { 0xe048, "Up", PRESSED, 0 },
- { 0xe049, "Page Up", PRESSED, 0 },
- { 0xe04b, "Left", PRESSED, 0 },
- { 0xe04d, "Right", PRESSED, 0 },
- { 0xe04f, "End", PRESSED, 0 },
- { 0xe050, "Down", PRESSED, 0 },
- { 0xe051, "Page Down", PRESSED, 0 },
- { 0xe052, "Insert", PRESSED, 0 },
- { 0xe053, "Delete", PRESSED, 0 },
- { 0xe05b, "Left GUI", PRESSED, 0 },
- { 0xe05c, "Right GUI", PRESSED, 0 },
- { 0xe05d, "\"Apps\"", PRESSED, 0 },
- { 0xe05e, "Power", PRESSED, 0 },
- { 0xe05f, "Sleep", PRESSED, 0 },
- { 0xe063, "Wake", PRESSED, 0 },
- { 0xe065, "Search", PRESSED, 0 },
- { 0xe066, "Favorites", PRESSED, 0 },
- { 0xe067, "Refresh", PRESSED, 0 },
- { 0xe068, "Stop", PRESSED, 0 },
- { 0xe069, "Forward", PRESSED, 0 },
- { 0xe06a, "Back", PRESSED, 0 },
- { 0xe06b, "My Computer", PRESSED, 0 },
- { 0xe06c, "Email", PRESSED, 0 },
- { 0xe06d, "Media Select", PRESSED, 0 },
- { 0xe090, "Previous Track", RELEASED, 0 },
- { 0xe099, "Next Track", RELEASED, 0 },
- { 0xe09c, "Enter", RELEASED, '\n' },
- { 0xe09d, "Right Control", RELEASED, 0 },
- { 0xe0a0, "Mute", RELEASED, 0 },
- { 0xe0a1, "Calculator", RELEASED, 0 },
- { 0xe0a2, "Play", RELEASED, 0 },
- { 0xe0a4, "Stop", RELEASED, 0 },
- { 0xe0ae, "Volume Down", RELEASED, 0 },
- { 0xe0b0, "Volume Up", RELEASED, 0 },
- { 0xe0b2, "Home", RELEASED, 0 },
- { 0xe0b5, "/ (Keypad)", RELEASED, '/' },
- { 0xe0b8, "AltGr", RELEASED, 0 },
- { 0xe0c7, "Home", RELEASED, 0 },
- { 0xe0c8, "Up", RELEASED, 0 },
- { 0xe0c9, "Page Up", RELEASED, 0 },
- { 0xe0cb, "Left", RELEASED, 0 },
- { 0xe0cd, "Right", RELEASED, 0 },
- { 0xe0cf, "End", RELEASED, 0 },
- { 0xe0d0, "Down", RELEASED, 0 },
- { 0xe0d1, "Page Down", RELEASED, 0 },
- { 0xe0d2, "Insert", RELEASED, 0 },
- { 0xe0d3, "Delete", RELEASED, 0 },
- { 0xe0db, "Left GUI", RELEASED, 0 },
- { 0xe0dc, "Right GUI", RELEASED, 0 },
- { 0xe0dd, "\"Apps\"", RELEASED, 0 },
- { 0xe0de, "Power", RELEASED, 0 },
- { 0xe0df, "Sleep", RELEASED, 0 },
- { 0xe0e3, "Wake", RELEASED, 0 },
- { 0xe0e5, "Search", RELEASED, 0 },
- { 0xe0e6, "Favorites", RELEASED, 0 },
- { 0xe0e7, "Refresh", RELEASED, 0 },
- { 0xe0e8, "Stop", RELEASED, 0 },
- { 0xe0e9, "Forward", RELEASED, 0 },
- { 0xe0ea, "Back", RELEASED, 0 },
- { 0xe0eb, "My Computer", RELEASED, 0 },
- { 0xe0ec, "Email", RELEASED, 0 },
- { 0xe0ed, "Media Select", RELEASED, 0 },
- { 0xe02ae037, "Print Screen", PRESSED, 0 },
- { 0xe0b7e0aa, "Print Screen", RELEASED, 0 },
- { 0xe11d45e19dc5, "Pause", PRESSED, 0 },
+ { 0x1, "Escape", PRESSED, 0 },
+ { 0x2, "1", PRESSED, '1' },
+ { 0x3, "2", PRESSED, '2' },
+ { 0x4, "3", PRESSED, '3' },
+ { 0x5, "4", PRESSED, '4' },
+ { 0x6, "5", PRESSED, '5' },
+ { 0x7, "6", PRESSED, '6' },
+ { 0x8, "7", PRESSED, '7' },
+ { 0x9, "8", PRESSED, '8' },
+ { 0xa, "9", PRESSED, '9' },
+ { 0xb, "0", PRESSED, '0' },
+ { 0xc, "-", PRESSED, '-' },
+ { 0xd, "=", PRESSED, '=' },
+ { 0xe, "Backspace", PRESSED, 0 },
+ { 0xf, "Tab", PRESSED, '\t' },
+ { 0x10, "q", PRESSED, 'q' },
+ { 0x11, "w", PRESSED, 'w' },
+ { 0x12, "e", PRESSED, 'e' },
+ { 0x13, "r", PRESSED, 'r' },
+ { 0x14, "t", PRESSED, 't' },
+ { 0x15, "y", PRESSED, 'y' },
+ { 0x16, "u", PRESSED, 'u' },
+ { 0x17, "i", PRESSED, 'i' },
+ { 0x18, "o", PRESSED, 'o' },
+ { 0x19, "p", PRESSED, 'p' },
+ { 0x1a, "[", PRESSED, '[' },
+ { 0x1b, "]", PRESSED, ']' },
+ { 0x1c, "Enter", PRESSED, '\n' },
+ { 0x1d, "Control", PRESSED, 0 },
+ { 0x1e, "a", PRESSED, 'a' },
+ { 0x1f, "s", PRESSED, 's' },
+ { 0x20, "d", PRESSED, 'd' },
+ { 0x21, "f", PRESSED, 'f' },
+ { 0x22, "g", PRESSED, 'g' },
+ { 0x23, "h", PRESSED, 'h' },
+ { 0x24, "j", PRESSED, 'j' },
+ { 0x25, "k", PRESSED, 'k' },
+ { 0x26, "l", PRESSED, 'l' },
+ { 0x27, ";", PRESSED, ';' },
+ { 0x28, "'", PRESSED, '\'' },
+ { 0x29, "`", PRESSED, '`' },
+ { 0x2a, "Shift", PRESSED, 0 },
+ { 0x2b, "\\", PRESSED, '\\' },
+ { 0x2c, "z", PRESSED, 'z' },
+ { 0x2d, "x", PRESSED, 'x' },
+ { 0x2e, "c", PRESSED, 'c' },
+ { 0x2f, "v", PRESSED, 'v' },
+ { 0x30, "b", PRESSED, 'b' },
+ { 0x31, "n", PRESSED, 'n' },
+ { 0x32, "m", PRESSED, 'm' },
+ { 0x33, ",", PRESSED, ',' },
+ { 0x34, ".", PRESSED, '.' },
+ { 0x35, "/", PRESSED, '/' },
+ { 0x36, "Right Shift", PRESSED, 0 },
+ { 0x37, "* (Keypad)", PRESSED, '*' },
+ { 0x38, "Alt", PRESSED, 0 },
+ { 0x39, "Space", PRESSED, ' ' },
+ { 0x3a, "CapsLock", PRESSED, 0 },
+ { 0x3b, "F1", PRESSED, 0 },
+ { 0x3c, "F2", PRESSED, 0 },
+ { 0x3d, "F3", PRESSED, 0 },
+ { 0x3e, "F4", PRESSED, 0 },
+ { 0x3f, "F5", PRESSED, 0 },
+ { 0x40, "F6", PRESSED, 0 },
+ { 0x41, "F7", PRESSED, 0 },
+ { 0x42, "F8", PRESSED, 0 },
+ { 0x43, "F9", PRESSED, 0 },
+ { 0x44, "F10", PRESSED, 0 },
+ { 0x45, "NumberLock", PRESSED, 0 },
+ { 0x46, "ScrollLock", PRESSED, 0 },
+ { 0x47, "7 (Keypad)", PRESSED, '7' },
+ { 0x48, "8 (Keypad)", PRESSED, '8' },
+ { 0x49, "9 (Keypad)", PRESSED, '9' },
+ { 0x4a, "- (Keypad)", PRESSED, '-' },
+ { 0x4b, "4 (Keypad)", PRESSED, '4' },
+ { 0x4c, "5 (Keypad)", PRESSED, '5' },
+ { 0x4d, "6 (Keypad)", PRESSED, '6' },
+ { 0x4e, "+ (Keypad)", PRESSED, '+' },
+ { 0x4f, "1 (Keypad)", PRESSED, '1' },
+ { 0x50, "2 (Keypad)", PRESSED, '2' },
+ { 0x51, "3 (Keypad)", PRESSED, '3' },
+ { 0x52, "0 (Keypad)", PRESSED, '0' },
+ { 0x53, ". (Keypad)", PRESSED, '.' },
+ { 0x57, "F11", PRESSED, 0 },
+ { 0x58, "F12", PRESSED, 0 },
+ { 0x81, "Escape", RELEASED, 0 },
+ { 0x82, "1", RELEASED, '1' },
+ { 0x83, "2", RELEASED, '2' },
+ { 0x84, "3", RELEASED, '3' },
+ { 0x85, "4", RELEASED, '4' },
+ { 0x86, "5", RELEASED, '5' },
+ { 0x87, "6", RELEASED, '6' },
+ { 0x88, "7", RELEASED, '6' },
+ { 0x89, "8", RELEASED, '8' },
+ { 0x8a, "9", RELEASED, '9' },
+ { 0x8b, "0", RELEASED, '0' },
+ { 0x8c, "-", RELEASED, '-' },
+ { 0x8d, "=", RELEASED, '=' },
+ { 0x8e, "Backspace", RELEASED, 0 },
+ { 0x8f, "Tab", RELEASED, '\t' },
+ { 0x90, "q", RELEASED, 'q' },
+ { 0x91, "w", RELEASED, 'w' },
+ { 0x92, "e", RELEASED, 'e' },
+ { 0x93, "r", RELEASED, 'r' },
+ { 0x94, "t", RELEASED, 't' },
+ { 0x95, "y", RELEASED, 'y' },
+ { 0x96, "u", RELEASED, 'u' },
+ { 0x97, "i", RELEASED, 'i' },
+ { 0x98, "o", RELEASED, 'o' },
+ { 0x99, "p", RELEASED, 'p' },
+ { 0x9a, "[", RELEASED, '[' },
+ { 0x9b, "]", RELEASED, ']' },
+ { 0x9c, "Enter", RELEASED, '\n' },
+ { 0x9d, "Control", RELEASED, 0 },
+ { 0x9e, "a", RELEASED, 'a' },
+ { 0x9f, "s", RELEASED, 's' },
+ { 0xa0, "d", RELEASED, 'd' },
+ { 0xa1, "f", RELEASED, 'f' },
+ { 0xa2, "g", RELEASED, 'g' },
+ { 0xa3, "h", RELEASED, 'h' },
+ { 0xa4, "j", RELEASED, 'j' },
+ { 0xa5, "k", RELEASED, 'k' },
+ { 0xa6, "l", RELEASED, 'l' },
+ { 0xa7, ";", RELEASED, ';' },
+ { 0xa8, "'", RELEASED, '\'' },
+ { 0xa9, "`", RELEASED, '`' },
+ { 0xaa, "Shift", RELEASED, 0 },
+ { 0xab, "\\", RELEASED, '\\' },
+ { 0xac, "z", RELEASED, 'z' },
+ { 0xad, "x", RELEASED, 'x' },
+ { 0xae, "c", RELEASED, 'c' },
+ { 0xaf, "v", RELEASED, 'v' },
+ { 0xb0, "b", RELEASED, 'b' },
+ { 0xb1, "n", RELEASED, 'n' },
+ { 0xb2, "m", RELEASED, 'm' },
+ { 0xb3, ",", RELEASED, ',' },
+ { 0xb4, ".", RELEASED, '.' },
+ { 0xb5, "/", RELEASED, '/' },
+ { 0xb6, "Right Shift", RELEASED, 0 },
+ { 0xb7, "* (Keypad)", RELEASED, '*' },
+ { 0xb8, "Alt", RELEASED, 0 },
+ { 0xb9, "Space", RELEASED, ' ' },
+ { 0xba, "CapsLock", RELEASED, 0 },
+ { 0xbb, "F1", RELEASED, 0 },
+ { 0xbc, "F2", RELEASED, 0 },
+ { 0xbd, "F3", RELEASED, 0 },
+ { 0xbe, "F4", RELEASED, 0 },
+ { 0xbf, "F5", RELEASED, 0 },
+ { 0xc0, "F6", RELEASED, 0 },
+ { 0xc1, "F7", RELEASED, 0 },
+ { 0xc2, "F8", RELEASED, 0 },
+ { 0xc3, "F9", RELEASED, 0 },
+ { 0xc4, "F10", RELEASED, 0 },
+ { 0xc5, "NumberLock", RELEASED, 0 },
+ { 0xc6, "ScrollLock", RELEASED, 0 },
+ { 0xc7, "7 (Keypad)", RELEASED, '7' },
+ { 0xc8, "8 (Keypad)", RELEASED, '8' },
+ { 0xc9, "9 (Keypad)", RELEASED, '9' },
+ { 0xca, "- (Keypad)", RELEASED, '-' },
+ { 0xcb, "4 (Keypad)", RELEASED, '4' },
+ { 0xcc, "5 (Keypad)", RELEASED, '5' },
+ { 0xcd, "6 (Keypad)", RELEASED, '6' },
+ { 0xce, "+ (Keypad)", RELEASED, '+' },
+ { 0xcf, "1 (Keypad)", RELEASED, '1' },
+ { 0xd0, "2 (Keypad)", RELEASED, '2' },
+ { 0xd1, "3 (Keypad)", RELEASED, '4' },
+ { 0xd2, "0 (Keypad)", RELEASED, '0' },
+ { 0xd3, ". (Keypad)", RELEASED, '.' },
+ { 0xd7, "F11", RELEASED, 0 },
+ { 0xd8, "F12", RELEASED, 0 },
+ { 0xe010, "Previous Track", PRESSED, 0 },
+ { 0xe019, "Next Track", PRESSED, 0 },
+ { 0xe01c, "Enter (Keypad)", PRESSED, '\n' },
+ { 0xe01d, "Right Control", PRESSED, 0 },
+ { 0xe020, "Mute", PRESSED, 0 },
+ { 0xe021, "Calculator", PRESSED, 0 },
+ { 0xe022, "Play", PRESSED, 0 },
+ { 0xe024, "Stop", PRESSED, 0 },
+ { 0xe02e, "Volume Down", PRESSED, 0 },
+ { 0xe030, "Volume Up", PRESSED, 0 },
+ { 0xe032, "Home", PRESSED, 0 },
+ { 0xe035, "/ (Keypad)", PRESSED, '/' },
+ { 0xe038, "AltGr", PRESSED, 0 },
+ { 0xe047, "Home", PRESSED, 0 },
+ { 0xe048, "Up", PRESSED, 0 },
+ { 0xe049, "Page Up", PRESSED, 0 },
+ { 0xe04b, "Left", PRESSED, 0 },
+ { 0xe04d, "Right", PRESSED, 0 },
+ { 0xe04f, "End", PRESSED, 0 },
+ { 0xe050, "Down", PRESSED, 0 },
+ { 0xe051, "Page Down", PRESSED, 0 },
+ { 0xe052, "Insert", PRESSED, 0 },
+ { 0xe053, "Delete", PRESSED, 0 },
+ { 0xe05b, "Left GUI", PRESSED, 0 },
+ { 0xe05c, "Right GUI", PRESSED, 0 },
+ { 0xe05d, "\"Apps\"", PRESSED, 0 },
+ { 0xe05e, "Power", PRESSED, 0 },
+ { 0xe05f, "Sleep", PRESSED, 0 },
+ { 0xe063, "Wake", PRESSED, 0 },
+ { 0xe065, "Search", PRESSED, 0 },
+ { 0xe066, "Favorites", PRESSED, 0 },
+ { 0xe067, "Refresh", PRESSED, 0 },
+ { 0xe068, "Stop", PRESSED, 0 },
+ { 0xe069, "Forward", PRESSED, 0 },
+ { 0xe06a, "Back", PRESSED, 0 },
+ { 0xe06b, "My Computer", PRESSED, 0 },
+ { 0xe06c, "Email", PRESSED, 0 },
+ { 0xe06d, "Media Select", PRESSED, 0 },
+ { 0xe090, "Previous Track", RELEASED, 0 },
+ { 0xe099, "Next Track", RELEASED, 0 },
+ { 0xe09c, "Enter", RELEASED, '\n' },
+ { 0xe09d, "Right Control", RELEASED, 0 },
+ { 0xe0a0, "Mute", RELEASED, 0 },
+ { 0xe0a1, "Calculator", RELEASED, 0 },
+ { 0xe0a2, "Play", RELEASED, 0 },
+ { 0xe0a4, "Stop", RELEASED, 0 },
+ { 0xe0ae, "Volume Down", RELEASED, 0 },
+ { 0xe0b0, "Volume Up", RELEASED, 0 },
+ { 0xe0b2, "Home", RELEASED, 0 },
+ { 0xe0b5, "/ (Keypad)", RELEASED, '/' },
+ { 0xe0b8, "AltGr", RELEASED, 0 },
+ { 0xe0c7, "Home", RELEASED, 0 },
+ { 0xe0c8, "Up", RELEASED, 0 },
+ { 0xe0c9, "Page Up", RELEASED, 0 },
+ { 0xe0cb, "Left", RELEASED, 0 },
+ { 0xe0cd, "Right", RELEASED, 0 },
+ { 0xe0cf, "End", RELEASED, 0 },
+ { 0xe0d0, "Down", RELEASED, 0 },
+ { 0xe0d1, "Page Down", RELEASED, 0 },
+ { 0xe0d2, "Insert", RELEASED, 0 },
+ { 0xe0d3, "Delete", RELEASED, 0 },
+ { 0xe0db, "Left GUI", RELEASED, 0 },
+ { 0xe0dc, "Right GUI", RELEASED, 0 },
+ { 0xe0dd, "\"Apps\"", RELEASED, 0 },
+ { 0xe0de, "Power", RELEASED, 0 },
+ { 0xe0df, "Sleep", RELEASED, 0 },
+ { 0xe0e3, "Wake", RELEASED, 0 },
+ { 0xe0e5, "Search", RELEASED, 0 },
+ { 0xe0e6, "Favorites", RELEASED, 0 },
+ { 0xe0e7, "Refresh", RELEASED, 0 },
+ { 0xe0e8, "Stop", RELEASED, 0 },
+ { 0xe0e9, "Forward", RELEASED, 0 },
+ { 0xe0ea, "Back", RELEASED, 0 },
+ { 0xe0eb, "My Computer", RELEASED, 0 },
+ { 0xe0ec, "Email", RELEASED, 0 },
+ { 0xe0ed, "Media Select", RELEASED, 0 },
+ { 0xe02ae037, "Print Screen", PRESSED, 0 },
+ { 0xe0b7e0aa, "Print Screen", RELEASED, 0 },
+ { 0xe11d45e19dc5, "Pause", PRESSED, 0 },
};
const struct KeyboardCaptureData KEY_DICTIONARY_SHIFTED[DICT_SIZE] = {
- { 0x1, "Escape", PRESSED, 0 },
- { 0x2, "!", PRESSED, '!' },
- { 0x3, "@", PRESSED, '@' },
- { 0x4, "#", PRESSED, '#' },
- { 0x5, "$", PRESSED, '$' },
- { 0x6, "%", PRESSED, '%' },
- { 0x7, "^", PRESSED, '^' },
- { 0x8, "&", PRESSED, '&' },
- { 0x9, "*", PRESSED, '*' },
- { 0xa, "(", PRESSED, '(' },
- { 0xb, ")", PRESSED, ')' },
- { 0xc, "_", PRESSED, '_' },
- { 0xd, "+", PRESSED, '+' },
- { 0xe, "Backspace", PRESSED, 0 },
- { 0xf, "Tab", PRESSED, '\t' },
- { 0x10, "Q", PRESSED, 'Q' },
- { 0x11, "W", PRESSED, 'W' },
- { 0x12, "E", PRESSED, 'E' },
- { 0x13, "R", PRESSED, 'R' },
- { 0x14, "T", PRESSED, 'T' },
- { 0x15, "Y", PRESSED, 'Y' },
- { 0x16, "U", PRESSED, 'U' },
- { 0x17, "I", PRESSED, 'I' },
- { 0x18, "O", PRESSED, 'O' },
- { 0x19, "P", PRESSED, 'P' },
- { 0x1a, "{", PRESSED, '{' },
- { 0x1b, "}", PRESSED, '}' },
- { 0x1c, "Enter", PRESSED, '\n' },
- { 0x1d, "Control", PRESSED, 0 },
- { 0x1e, "A", PRESSED, 'A' },
- { 0x1f, "S", PRESSED, 'S' },
- { 0x20, "D", PRESSED, 'D' },
- { 0x21, "F", PRESSED, 'F' },
- { 0x22, "G", PRESSED, 'G' },
- { 0x23, "H", PRESSED, 'H' },
- { 0x24, "J", PRESSED, 'J' },
- { 0x25, "K", PRESSED, 'K' },
- { 0x26, "L", PRESSED, 'L' },
- { 0x27, ":", PRESSED, ':' },
- { 0x28, "\"", PRESSED, '"' },
- { 0x29, "~", PRESSED, '~' },
- { 0x2a, "Shift", PRESSED, 0 },
- { 0x2b, "|", PRESSED, '|' },
- { 0x2c, "Z", PRESSED, 'Z' },
- { 0x2d, "X", PRESSED, 'X' },
- { 0x2e, "C", PRESSED, 'C' },
- { 0x2f, "V", PRESSED, 'V' },
- { 0x30, "B", PRESSED, 'B' },
- { 0x31, "N", PRESSED, 'N' },
- { 0x32, "M", PRESSED, 'M' },
- { 0x33, "<", PRESSED, '<' },
- { 0x34, ">", PRESSED, '>' },
- { 0x35, "?", PRESSED, '?' },
- { 0x36, "Right Shift", PRESSED, 0 },
- { 0x37, "* (Keypad)", PRESSED, '*' },
- { 0x38, "Alt", PRESSED, 0 },
- { 0x39, "Space", PRESSED, ' ' },
- { 0x3a, "CapsLock", PRESSED, 0 },
- { 0x3b, "F1", PRESSED, 0 },
- { 0x3c, "F2", PRESSED, 0 },
- { 0x3d, "F3", PRESSED, 0 },
- { 0x3e, "F4", PRESSED, 0 },
- { 0x3f, "F5", PRESSED, 0 },
- { 0x40, "F6", PRESSED, 0 },
- { 0x41, "F7", PRESSED, 0 },
- { 0x42, "F8", PRESSED, 0 },
- { 0x43, "F9", PRESSED, 0 },
- { 0x44, "F10", PRESSED, 0 },
- { 0x45, "NumberLock", PRESSED, 0 },
- { 0x46, "ScrollLock", PRESSED, 0 },
- { 0x47, "7 (Keypad)", PRESSED, '7' },
- { 0x48, "8 (Keypad)", PRESSED, '8' },
- { 0x49, "9 (Keypad)", PRESSED, '9' },
- { 0x4a, "- (Keypad)", PRESSED, '-' },
- { 0x4b, "4 (Keypad)", PRESSED, '4' },
- { 0x4c, "5 (Keypad)", PRESSED, '5' },
- { 0x4d, "6 (Keypad)", PRESSED, '6' },
- { 0x4e, "+ (Keypad)", PRESSED, '+' },
- { 0x4f, "1 (Keypad)", PRESSED, '1' },
- { 0x50, "2 (Keypad)", PRESSED, '2' },
- { 0x51, "3 (Keypad)", PRESSED, '3' },
- { 0x52, "0 (Keypad)", PRESSED, '0' },
- { 0x53, ". (Keypad)", PRESSED, '.' },
- { 0x57, "F11", PRESSED, 0 },
- { 0x58, "F12", PRESSED, 0 },
- { 0x81, "Escape", RELEASED, 0 },
- { 0x82, "!", RELEASED, '!' },
- { 0x83, "@", RELEASED, '@' },
- { 0x84, "#", RELEASED, '#' },
- { 0x85, "$", RELEASED, '$' },
- { 0x86, "%", RELEASED, '%' },
- { 0x87, "^", RELEASED, '^' },
- { 0x88, "&", RELEASED, '&' },
- { 0x89, "*", RELEASED, '*' },
- { 0x8a, "(", RELEASED, '(' },
- { 0x8b, ")", RELEASED, ')' },
- { 0x8c, "_", RELEASED, '_' },
- { 0x8d, "+", RELEASED, '+' },
- { 0x8e, "Backspace", RELEASED, 0 },
- { 0x8f, "Tab", RELEASED, '\t' },
- { 0x90, "Q", RELEASED, 'Q' },
- { 0x91, "W", RELEASED, 'W' },
- { 0x92, "E", RELEASED, 'E' },
- { 0x93, "R", RELEASED, 'R' },
- { 0x94, "T", RELEASED, 'T' },
- { 0x95, "Y", RELEASED, 'Y' },
- { 0x96, "U", RELEASED, 'U' },
- { 0x97, "I", RELEASED, 'I' },
- { 0x98, "O", RELEASED, 'O' },
- { 0x99, "P", RELEASED, 'P' },
- { 0x9a, "[", RELEASED, '{' },
- { 0x9b, "]", RELEASED, '}' },
- { 0x9c, "Enter", RELEASED, '\n' },
- { 0x9d, "Control", RELEASED, 0 },
- { 0x9e, "A", RELEASED, 'A' },
- { 0x9f, "S", RELEASED, 'S' },
- { 0xa0, "D", RELEASED, 'D' },
- { 0xa1, "F", RELEASED, 'F' },
- { 0xa2, "G", RELEASED, 'G' },
- { 0xa3, "H", RELEASED, 'H' },
- { 0xa4, "J", RELEASED, 'J' },
- { 0xa5, "K", RELEASED, 'K' },
- { 0xa6, "L", RELEASED, 'L' },
- { 0xa7, ":", RELEASED, ':' },
- { 0xa8, "\"", RELEASED, '"' },
- { 0xa9, "~", RELEASED, '~' },
- { 0xaa, "Shift", RELEASED, 0 },
- { 0xab, "\\", RELEASED, '\\' },
- { 0xac, "Z", RELEASED, 'Z' },
- { 0xad, "X", RELEASED, 'X' },
- { 0xae, "C", RELEASED, 'C' },
- { 0xaf, "V", RELEASED, 'V' },
- { 0xb0, "B", RELEASED, 'B' },
- { 0xb1, "N", RELEASED, 'N' },
- { 0xb2, "M", RELEASED, 'M' },
- { 0xb3, "<", RELEASED, '<' },
- { 0xb4, ">", RELEASED, '>' },
- { 0xb5, "?", RELEASED, '?' },
- { 0xb6, "Right Shift", RELEASED, 0 },
- { 0xb7, "* (Keypad)", RELEASED, '*' },
- { 0xb8, "Alt", RELEASED, 0 },
- { 0xb9, "Space", RELEASED, ' ' },
- { 0xba, "CapsLock", RELEASED, 0 },
- { 0xbb, "F1", RELEASED, 0 },
- { 0xbc, "F2", RELEASED, 0 },
- { 0xbd, "F3", RELEASED, 0 },
- { 0xbe, "F4", RELEASED, 0 },
- { 0xbf, "F5", RELEASED, 0 },
- { 0xc0, "F6", RELEASED, 0 },
- { 0xc1, "F7", RELEASED, 0 },
- { 0xc2, "F8", RELEASED, 0 },
- { 0xc3, "F9", RELEASED, 0 },
- { 0xc4, "F10", RELEASED, 0 },
- { 0xc5, "NumberLock", RELEASED, 0 },
- { 0xc6, "ScrollLock", RELEASED, 0 },
- { 0xc7, "7 (Keypad)", RELEASED, '7' },
- { 0xc8, "8 (Keypad)", RELEASED, '8' },
- { 0xc9, "9 (Keypad)", RELEASED, '9' },
- { 0xca, "- (Keypad)", RELEASED, '-' },
- { 0xcb, "4 (Keypad)", RELEASED, '4' },
- { 0xcc, "5 (Keypad)", RELEASED, '5' },
- { 0xcd, "6 (Keypad)", RELEASED, '6' },
- { 0xce, "+ (Keypad)", RELEASED, '+' },
- { 0xcf, "1 (Keypad)", RELEASED, '1' },
- { 0xd0, "2 (Keypad)", RELEASED, '2' },
- { 0xd1, "3 (Keypad)", RELEASED, '4' },
- { 0xd2, "0 (Keypad)", RELEASED, '0' },
- { 0xd3, ". (Keypad)", RELEASED, '.' },
- { 0xd7, "F11", RELEASED, 0 },
- { 0xd8, "F12", RELEASED, 0 },
- { 0xe010, "Previous Track", PRESSED, 0 },
- { 0xe019, "Next Track", PRESSED, 0 },
- { 0xe01c, "Enter (Keypad)", PRESSED, '\n' },
- { 0xe01d, "Right Control", PRESSED, 0 },
- { 0xe020, "Mute", PRESSED, 0 },
- { 0xe021, "Calculator", PRESSED, 0 },
- { 0xe022, "Play", PRESSED, 0 },
- { 0xe024, "Stop", PRESSED, 0 },
- { 0xe02e, "Volume Down", PRESSED, 0 },
- { 0xe030, "Volume Up", PRESSED, 0 },
- { 0xe032, "Home", PRESSED, 0 },
- { 0xe035, "/ (Keypad)", PRESSED, '/' },
- { 0xe038, "AltGr", PRESSED, 0 },
- { 0xe047, "Home", PRESSED, 0 },
- { 0xe048, "Up", PRESSED, 0 },
- { 0xe049, "Page Up", PRESSED, 0 },
- { 0xe04b, "Left", PRESSED, 0 },
- { 0xe04d, "Right", PRESSED, 0 },
- { 0xe04f, "End", PRESSED, 0 },
- { 0xe050, "Down", PRESSED, 0 },
- { 0xe051, "Page Down", PRESSED, 0 },
- { 0xe052, "Insert", PRESSED, 0 },
- { 0xe053, "Delete", PRESSED, 0 },
- { 0xe05b, "Left GUI", PRESSED, 0 },
- { 0xe05c, "Right GUI", PRESSED, 0 },
- { 0xe05d, "\"Apps\"", PRESSED, 0 },
- { 0xe05e, "Power", PRESSED, 0 },
- { 0xe05f, "Sleep", PRESSED, 0 },
- { 0xe063, "Wake", PRESSED, 0 },
- { 0xe065, "Search", PRESSED, 0 },
- { 0xe066, "Favorites", PRESSED, 0 },
- { 0xe067, "Refresh", PRESSED, 0 },
- { 0xe068, "Stop", PRESSED, 0 },
- { 0xe069, "Forward", PRESSED, 0 },
- { 0xe06a, "Back", PRESSED, 0 },
- { 0xe06b, "My Computer", PRESSED, 0 },
- { 0xe06c, "Email", PRESSED, 0 },
- { 0xe06d, "Media Select", PRESSED, 0 },
- { 0xe090, "Previous Track", RELEASED, 0 },
- { 0xe099, "Next Track", RELEASED, 0 },
- { 0xe09c, "Enter", RELEASED, '\n' },
- { 0xe09d, "Right Control", RELEASED, 0 },
- { 0xe0a0, "Mute", RELEASED, 0 },
- { 0xe0a1, "Calculator", RELEASED, 0 },
- { 0xe0a2, "Play", RELEASED, 0 },
- { 0xe0a4, "Stop", RELEASED, 0 },
- { 0xe0ae, "Volume Down", RELEASED, 0 },
- { 0xe0b0, "Volume Up", RELEASED, 0 },
- { 0xe0b2, "Home", RELEASED, 0 },
- { 0xe0b5, "/ (Keypad)", RELEASED, '/' },
- { 0xe0b8, "AltGr", RELEASED, 0 },
- { 0xe0c7, "Home", RELEASED, 0 },
- { 0xe0c8, "Up", RELEASED, 0 },
- { 0xe0c9, "Page Up", RELEASED, 0 },
- { 0xe0cb, "Left", RELEASED, 0 },
- { 0xe0cd, "Right", RELEASED, 0 },
- { 0xe0cf, "End", RELEASED, 0 },
- { 0xe0d0, "Down", RELEASED, 0 },
- { 0xe0d1, "Page Down", RELEASED, 0 },
- { 0xe0d2, "Insert", RELEASED, 0 },
- { 0xe0d3, "Delete", RELEASED, 0 },
- { 0xe0db, "Left GUI", RELEASED, 0 },
- { 0xe0dc, "Right GUI", RELEASED, 0 },
- { 0xe0dd, "\"Apps\"", RELEASED, 0 },
- { 0xe0de, "Power", RELEASED, 0 },
- { 0xe0df, "Sleep", RELEASED, 0 },
- { 0xe0e3, "Wake", RELEASED, 0 },
- { 0xe0e5, "Search", RELEASED, 0 },
- { 0xe0e6, "Favorites", RELEASED, 0 },
- { 0xe0e7, "Refresh", RELEASED, 0 },
- { 0xe0e8, "Stop", RELEASED, 0 },
- { 0xe0e9, "Forward", RELEASED, 0 },
- { 0xe0ea, "Back", RELEASED, 0 },
- { 0xe0eb, "My Computer", RELEASED, 0 },
- { 0xe0ec, "Email", RELEASED, 0 },
- { 0xe0ed, "Media Select", RELEASED, 0 },
- { 0xe02ae037, "Print Screen", PRESSED, 0 },
- { 0xe0b7e0aa, "Print Screen", RELEASED, 0 },
- { 0xe11d45e19dc5, "Pause", PRESSED, 0 },
+ { 0x1, "Escape", PRESSED, 0 },
+ { 0x2, "!", PRESSED, '!' },
+ { 0x3, "@", PRESSED, '@' },
+ { 0x4, "#", PRESSED, '#' },
+ { 0x5, "$", PRESSED, '$' },
+ { 0x6, "%", PRESSED, '%' },
+ { 0x7, "^", PRESSED, '^' },
+ { 0x8, "&", PRESSED, '&' },
+ { 0x9, "*", PRESSED, '*' },
+ { 0xa, "(", PRESSED, '(' },
+ { 0xb, ")", PRESSED, ')' },
+ { 0xc, "_", PRESSED, '_' },
+ { 0xd, "+", PRESSED, '+' },
+ { 0xe, "Backspace", PRESSED, 0 },
+ { 0xf, "Tab", PRESSED, '\t' },
+ { 0x10, "Q", PRESSED, 'Q' },
+ { 0x11, "W", PRESSED, 'W' },
+ { 0x12, "E", PRESSED, 'E' },
+ { 0x13, "R", PRESSED, 'R' },
+ { 0x14, "T", PRESSED, 'T' },
+ { 0x15, "Y", PRESSED, 'Y' },
+ { 0x16, "U", PRESSED, 'U' },
+ { 0x17, "I", PRESSED, 'I' },
+ { 0x18, "O", PRESSED, 'O' },
+ { 0x19, "P", PRESSED, 'P' },
+ { 0x1a, "{", PRESSED, '{' },
+ { 0x1b, "}", PRESSED, '}' },
+ { 0x1c, "Enter", PRESSED, '\n' },
+ { 0x1d, "Control", PRESSED, 0 },
+ { 0x1e, "A", PRESSED, 'A' },
+ { 0x1f, "S", PRESSED, 'S' },
+ { 0x20, "D", PRESSED, 'D' },
+ { 0x21, "F", PRESSED, 'F' },
+ { 0x22, "G", PRESSED, 'G' },
+ { 0x23, "H", PRESSED, 'H' },
+ { 0x24, "J", PRESSED, 'J' },
+ { 0x25, "K", PRESSED, 'K' },
+ { 0x26, "L", PRESSED, 'L' },
+ { 0x27, ":", PRESSED, ':' },
+ { 0x28, "\"", PRESSED, '"' },
+ { 0x29, "~", PRESSED, '~' },
+ { 0x2a, "Shift", PRESSED, 0 },
+ { 0x2b, "|", PRESSED, '|' },
+ { 0x2c, "Z", PRESSED, 'Z' },
+ { 0x2d, "X", PRESSED, 'X' },
+ { 0x2e, "C", PRESSED, 'C' },
+ { 0x2f, "V", PRESSED, 'V' },
+ { 0x30, "B", PRESSED, 'B' },
+ { 0x31, "N", PRESSED, 'N' },
+ { 0x32, "M", PRESSED, 'M' },
+ { 0x33, "<", PRESSED, '<' },
+ { 0x34, ">", PRESSED, '>' },
+ { 0x35, "?", PRESSED, '?' },
+ { 0x36, "Right Shift", PRESSED, 0 },
+ { 0x37, "* (Keypad)", PRESSED, '*' },
+ { 0x38, "Alt", PRESSED, 0 },
+ { 0x39, "Space", PRESSED, ' ' },
+ { 0x3a, "CapsLock", PRESSED, 0 },
+ { 0x3b, "F1", PRESSED, 0 },
+ { 0x3c, "F2", PRESSED, 0 },
+ { 0x3d, "F3", PRESSED, 0 },
+ { 0x3e, "F4", PRESSED, 0 },
+ { 0x3f, "F5", PRESSED, 0 },
+ { 0x40, "F6", PRESSED, 0 },
+ { 0x41, "F7", PRESSED, 0 },
+ { 0x42, "F8", PRESSED, 0 },
+ { 0x43, "F9", PRESSED, 0 },
+ { 0x44, "F10", PRESSED, 0 },
+ { 0x45, "NumberLock", PRESSED, 0 },
+ { 0x46, "ScrollLock", PRESSED, 0 },
+ { 0x47, "7 (Keypad)", PRESSED, '7' },
+ { 0x48, "8 (Keypad)", PRESSED, '8' },
+ { 0x49, "9 (Keypad)", PRESSED, '9' },
+ { 0x4a, "- (Keypad)", PRESSED, '-' },
+ { 0x4b, "4 (Keypad)", PRESSED, '4' },
+ { 0x4c, "5 (Keypad)", PRESSED, '5' },
+ { 0x4d, "6 (Keypad)", PRESSED, '6' },
+ { 0x4e, "+ (Keypad)", PRESSED, '+' },
+ { 0x4f, "1 (Keypad)", PRESSED, '1' },
+ { 0x50, "2 (Keypad)", PRESSED, '2' },
+ { 0x51, "3 (Keypad)", PRESSED, '3' },
+ { 0x52, "0 (Keypad)", PRESSED, '0' },
+ { 0x53, ". (Keypad)", PRESSED, '.' },
+ { 0x57, "F11", PRESSED, 0 },
+ { 0x58, "F12", PRESSED, 0 },
+ { 0x81, "Escape", RELEASED, 0 },
+ { 0x82, "!", RELEASED, '!' },
+ { 0x83, "@", RELEASED, '@' },
+ { 0x84, "#", RELEASED, '#' },
+ { 0x85, "$", RELEASED, '$' },
+ { 0x86, "%", RELEASED, '%' },
+ { 0x87, "^", RELEASED, '^' },
+ { 0x88, "&", RELEASED, '&' },
+ { 0x89, "*", RELEASED, '*' },
+ { 0x8a, "(", RELEASED, '(' },
+ { 0x8b, ")", RELEASED, ')' },
+ { 0x8c, "_", RELEASED, '_' },
+ { 0x8d, "+", RELEASED, '+' },
+ { 0x8e, "Backspace", RELEASED, 0 },
+ { 0x8f, "Tab", RELEASED, '\t' },
+ { 0x90, "Q", RELEASED, 'Q' },
+ { 0x91, "W", RELEASED, 'W' },
+ { 0x92, "E", RELEASED, 'E' },
+ { 0x93, "R", RELEASED, 'R' },
+ { 0x94, "T", RELEASED, 'T' },
+ { 0x95, "Y", RELEASED, 'Y' },
+ { 0x96, "U", RELEASED, 'U' },
+ { 0x97, "I", RELEASED, 'I' },
+ { 0x98, "O", RELEASED, 'O' },
+ { 0x99, "P", RELEASED, 'P' },
+ { 0x9a, "[", RELEASED, '{' },
+ { 0x9b, "]", RELEASED, '}' },
+ { 0x9c, "Enter", RELEASED, '\n' },
+ { 0x9d, "Control", RELEASED, 0 },
+ { 0x9e, "A", RELEASED, 'A' },
+ { 0x9f, "S", RELEASED, 'S' },
+ { 0xa0, "D", RELEASED, 'D' },
+ { 0xa1, "F", RELEASED, 'F' },
+ { 0xa2, "G", RELEASED, 'G' },
+ { 0xa3, "H", RELEASED, 'H' },
+ { 0xa4, "J", RELEASED, 'J' },
+ { 0xa5, "K", RELEASED, 'K' },
+ { 0xa6, "L", RELEASED, 'L' },
+ { 0xa7, ":", RELEASED, ':' },
+ { 0xa8, "\"", RELEASED, '"' },
+ { 0xa9, "~", RELEASED, '~' },
+ { 0xaa, "Shift", RELEASED, 0 },
+ { 0xab, "\\", RELEASED, '\\' },
+ { 0xac, "Z", RELEASED, 'Z' },
+ { 0xad, "X", RELEASED, 'X' },
+ { 0xae, "C", RELEASED, 'C' },
+ { 0xaf, "V", RELEASED, 'V' },
+ { 0xb0, "B", RELEASED, 'B' },
+ { 0xb1, "N", RELEASED, 'N' },
+ { 0xb2, "M", RELEASED, 'M' },
+ { 0xb3, "<", RELEASED, '<' },
+ { 0xb4, ">", RELEASED, '>' },
+ { 0xb5, "?", RELEASED, '?' },
+ { 0xb6, "Right Shift", RELEASED, 0 },
+ { 0xb7, "* (Keypad)", RELEASED, '*' },
+ { 0xb8, "Alt", RELEASED, 0 },
+ { 0xb9, "Space", RELEASED, ' ' },
+ { 0xba, "CapsLock", RELEASED, 0 },
+ { 0xbb, "F1", RELEASED, 0 },
+ { 0xbc, "F2", RELEASED, 0 },
+ { 0xbd, "F3", RELEASED, 0 },
+ { 0xbe, "F4", RELEASED, 0 },
+ { 0xbf, "F5", RELEASED, 0 },
+ { 0xc0, "F6", RELEASED, 0 },
+ { 0xc1, "F7", RELEASED, 0 },
+ { 0xc2, "F8", RELEASED, 0 },
+ { 0xc3, "F9", RELEASED, 0 },
+ { 0xc4, "F10", RELEASED, 0 },
+ { 0xc5, "NumberLock", RELEASED, 0 },
+ { 0xc6, "ScrollLock", RELEASED, 0 },
+ { 0xc7, "7 (Keypad)", RELEASED, '7' },
+ { 0xc8, "8 (Keypad)", RELEASED, '8' },
+ { 0xc9, "9 (Keypad)", RELEASED, '9' },
+ { 0xca, "- (Keypad)", RELEASED, '-' },
+ { 0xcb, "4 (Keypad)", RELEASED, '4' },
+ { 0xcc, "5 (Keypad)", RELEASED, '5' },
+ { 0xcd, "6 (Keypad)", RELEASED, '6' },
+ { 0xce, "+ (Keypad)", RELEASED, '+' },
+ { 0xcf, "1 (Keypad)", RELEASED, '1' },
+ { 0xd0, "2 (Keypad)", RELEASED, '2' },
+ { 0xd1, "3 (Keypad)", RELEASED, '4' },
+ { 0xd2, "0 (Keypad)", RELEASED, '0' },
+ { 0xd3, ". (Keypad)", RELEASED, '.' },
+ { 0xd7, "F11", RELEASED, 0 },
+ { 0xd8, "F12", RELEASED, 0 },
+ { 0xe010, "Previous Track", PRESSED, 0 },
+ { 0xe019, "Next Track", PRESSED, 0 },
+ { 0xe01c, "Enter (Keypad)", PRESSED, '\n' },
+ { 0xe01d, "Right Control", PRESSED, 0 },
+ { 0xe020, "Mute", PRESSED, 0 },
+ { 0xe021, "Calculator", PRESSED, 0 },
+ { 0xe022, "Play", PRESSED, 0 },
+ { 0xe024, "Stop", PRESSED, 0 },
+ { 0xe02e, "Volume Down", PRESSED, 0 },
+ { 0xe030, "Volume Up", PRESSED, 0 },
+ { 0xe032, "Home", PRESSED, 0 },
+ { 0xe035, "/ (Keypad)", PRESSED, '/' },
+ { 0xe038, "AltGr", PRESSED, 0 },
+ { 0xe047, "Home", PRESSED, 0 },
+ { 0xe048, "Up", PRESSED, 0 },
+ { 0xe049, "Page Up", PRESSED, 0 },
+ { 0xe04b, "Left", PRESSED, 0 },
+ { 0xe04d, "Right", PRESSED, 0 },
+ { 0xe04f, "End", PRESSED, 0 },
+ { 0xe050, "Down", PRESSED, 0 },
+ { 0xe051, "Page Down", PRESSED, 0 },
+ { 0xe052, "Insert", PRESSED, 0 },
+ { 0xe053, "Delete", PRESSED, 0 },
+ { 0xe05b, "Left GUI", PRESSED, 0 },
+ { 0xe05c, "Right GUI", PRESSED, 0 },
+ { 0xe05d, "\"Apps\"", PRESSED, 0 },
+ { 0xe05e, "Power", PRESSED, 0 },
+ { 0xe05f, "Sleep", PRESSED, 0 },
+ { 0xe063, "Wake", PRESSED, 0 },
+ { 0xe065, "Search", PRESSED, 0 },
+ { 0xe066, "Favorites", PRESSED, 0 },
+ { 0xe067, "Refresh", PRESSED, 0 },
+ { 0xe068, "Stop", PRESSED, 0 },
+ { 0xe069, "Forward", PRESSED, 0 },
+ { 0xe06a, "Back", PRESSED, 0 },
+ { 0xe06b, "My Computer", PRESSED, 0 },
+ { 0xe06c, "Email", PRESSED, 0 },
+ { 0xe06d, "Media Select", PRESSED, 0 },
+ { 0xe090, "Previous Track", RELEASED, 0 },
+ { 0xe099, "Next Track", RELEASED, 0 },
+ { 0xe09c, "Enter", RELEASED, '\n' },
+ { 0xe09d, "Right Control", RELEASED, 0 },
+ { 0xe0a0, "Mute", RELEASED, 0 },
+ { 0xe0a1, "Calculator", RELEASED, 0 },
+ { 0xe0a2, "Play", RELEASED, 0 },
+ { 0xe0a4, "Stop", RELEASED, 0 },
+ { 0xe0ae, "Volume Down", RELEASED, 0 },
+ { 0xe0b0, "Volume Up", RELEASED, 0 },
+ { 0xe0b2, "Home", RELEASED, 0 },
+ { 0xe0b5, "/ (Keypad)", RELEASED, '/' },
+ { 0xe0b8, "AltGr", RELEASED, 0 },
+ { 0xe0c7, "Home", RELEASED, 0 },
+ { 0xe0c8, "Up", RELEASED, 0 },
+ { 0xe0c9, "Page Up", RELEASED, 0 },
+ { 0xe0cb, "Left", RELEASED, 0 },
+ { 0xe0cd, "Right", RELEASED, 0 },
+ { 0xe0cf, "End", RELEASED, 0 },
+ { 0xe0d0, "Down", RELEASED, 0 },
+ { 0xe0d1, "Page Down", RELEASED, 0 },
+ { 0xe0d2, "Insert", RELEASED, 0 },
+ { 0xe0d3, "Delete", RELEASED, 0 },
+ { 0xe0db, "Left GUI", RELEASED, 0 },
+ { 0xe0dc, "Right GUI", RELEASED, 0 },
+ { 0xe0dd, "\"Apps\"", RELEASED, 0 },
+ { 0xe0de, "Power", RELEASED, 0 },
+ { 0xe0df, "Sleep", RELEASED, 0 },
+ { 0xe0e3, "Wake", RELEASED, 0 },
+ { 0xe0e5, "Search", RELEASED, 0 },
+ { 0xe0e6, "Favorites", RELEASED, 0 },
+ { 0xe0e7, "Refresh", RELEASED, 0 },
+ { 0xe0e8, "Stop", RELEASED, 0 },
+ { 0xe0e9, "Forward", RELEASED, 0 },
+ { 0xe0ea, "Back", RELEASED, 0 },
+ { 0xe0eb, "My Computer", RELEASED, 0 },
+ { 0xe0ec, "Email", RELEASED, 0 },
+ { 0xe0ed, "Media Select", RELEASED, 0 },
+ { 0xe02ae037, "Print Screen", PRESSED, 0 },
+ { 0xe0b7e0aa, "Print Screen", RELEASED, 0 },
+ { 0xe11d45e19dc5, "Pause", PRESSED, 0 },
};
-struct KeyboardCaptureData find_key_from_code(uint64_t code, char is_shifted, char is_capslocked) {
- for (size_t i = 0; i < DICT_SIZE; i++) {
- if (KEY_DICTIONARY[i].code == code) {
- if (is_capslocked && is_shifted) {
- return KEY_DICTIONARY_SHIFTED[i];
- } else if (is_capslocked && !is_shifted) {
- if ((code >= 0x2 && code <= 0xd) || (code >= 0x82 && code <= 0x8d)) {
- return KEY_DICTIONARY[i];
- } else {
- return KEY_DICTIONARY_SHIFTED[i];
- }
- } else if (!is_capslocked && is_shifted) {
- return KEY_DICTIONARY_SHIFTED[i];
- } else {
- return KEY_DICTIONARY[i];
- }
- }
- }
- struct KeyboardCaptureData dummy = { 0, "", PRESSED, 0 };
- return dummy;
+struct KeyboardCaptureData find_key_from_code(uint64_t code, char is_shifted,
+ char is_capslocked)
+{
+ for (size_t i = 0; i < DICT_SIZE; i++) {
+ if (KEY_DICTIONARY[i].code == code) {
+ if (is_capslocked && is_shifted) {
+ return KEY_DICTIONARY_SHIFTED[i];
+ } else if (is_capslocked && !is_shifted) {
+ if ((code >= 0x2 && code <= 0xd) ||
+ (code >= 0x82 && code <= 0x8d)) {
+ return KEY_DICTIONARY[i];
+ } else {
+ return KEY_DICTIONARY_SHIFTED[i];
+ }
+ } else if (!is_capslocked && is_shifted) {
+ return KEY_DICTIONARY_SHIFTED[i];
+ } else {
+ return KEY_DICTIONARY[i];
+ }
+ }
+ }
+ struct KeyboardCaptureData dummy = { 0, "", PRESSED, 0 };
+ return dummy;
}
-void printk_key_event(struct KeyboardCaptureData key, struct timespec64 now) {
- char sec = (now.tv_sec - (sys_tz.tz_minuteswest * 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;
- printk(KERN_INFO "%02d:%02d:%02d \"%s\" ", hour, min, sec, key.key_name);
- if (key.ascii_value) {
- printk(KERN_CONT "(0x%02x) ", key.ascii_value);
- }
- if (key.state == PRESSED) {
- printk(KERN_CONT "PRESSED\n");
- } else {
- printk(KERN_CONT "RELEASED\n");
- }
+void printk_key_event(struct KeyboardCaptureData key, struct timespec64 now)
+{
+ char sec = (now.tv_sec - (sys_tz.tz_minuteswest * 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;
+ printk(KERN_INFO "%02d:%02d:%02d \"%s\" ", hour, min, sec,
+ key.key_name);
+ if (key.ascii_value) {
+ printk(KERN_CONT "(0x%02x) ", key.ascii_value);
+ }
+ if (key.state == PRESSED) {
+ printk(KERN_CONT "PRESSED\n");
+ } else {
+ printk(KERN_CONT "RELEASED\n");
+ }
}
-int append_node(struct list_head *list, struct KeyboardCaptureData key, struct timespec64 when) {
- struct linked_list_node *entry;
- entry = kmalloc(sizeof *entry, GFP_KERNEL);
- if (!entry)
- return -ENOMEM;
- entry->key = key;
- entry->when = when;
- calc_node_size(entry);
- INIT_LIST_HEAD(&entry->list);
- list_add_tail(&entry->list, list);
- return 0;
+int append_node(struct list_head *list, struct KeyboardCaptureData key,
+ struct timespec64 when)
+{
+ struct linked_list_node *entry;
+ entry = kmalloc(sizeof *entry, GFP_KERNEL);
+ if (!entry)
+ return -ENOMEM;
+ entry->key = key;
+ entry->when = when;
+ calc_node_size(entry);
+ INIT_LIST_HEAD(&entry->list);
+ list_add_tail(&entry->list, list);
+ return 0;
}
-irqreturn_t key_logger_isr(int i, void *dummy) {
- struct logger* key_logger = (struct logger *) dummy;
- uint64_t code = inb(0x60);
- mutex_lock(&lock);
- struct timespec64 now;
- ktime_get_real_ts64(&now);
- struct KeyboardCaptureData key = find_key_from_code(code, key_logger->shifted, key_logger->capslocked);
- if (!key.code) {
- return IRQ_NONE;
- }
- if (key.code == 0x2a || key.code == 0x36) {
- key_logger->shifted += 1;
- } else if (key.code == 0xaa || key.code == 0xb6) {
- key_logger->shifted -= 1;
- } else if (key.code == 0x3a) {
- key_logger->capslocked = 1;
- } else if (key.code == 0xba) {
- key_logger->capslocked = 0;
- }
- if (append_node(&keyboard_log, key, now)) {
- return IRQ_NONE;
- }
- printk_key_event(key, now);
- mutex_unlock(&lock);
- return IRQ_HANDLED;
+irqreturn_t key_logger_isr(int i, void *dummy)
+{
+ struct logger *key_logger = (struct logger *)dummy;
+ uint64_t code = inb(0x60);
+ mutex_lock(&lock);
+ struct timespec64 now;
+ ktime_get_real_ts64(&now);
+ struct KeyboardCaptureData key = find_key_from_code(
+ code, key_logger->shifted, key_logger->capslocked);
+ if (!key.code) {
+ return IRQ_NONE;
+ }
+ if (key.code == 0x2a || key.code == 0x36) {
+ key_logger->shifted += 1;
+ } else if (key.code == 0xaa || key.code == 0xb6) {
+ key_logger->shifted -= 1;
+ } else if (key.code == 0x3a) {
+ key_logger->capslocked = 1;
+ } else if (key.code == 0xba) {
+ key_logger->capslocked = 0;
+ }
+ if (append_node(&keyboard_log, key, now)) {
+ return IRQ_NONE;
+ }
+ printk_key_event(key, now);
+ mutex_unlock(&lock);
+ return IRQ_HANDLED;
}
-
-
diff --git a/src/main.c b/src/main.c
index 0aa36fb..d811a20 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,60 +12,62 @@
#define KEYBOARD_IRQ 1
static const struct file_operations fops = {
- .owner = THIS_MODULE,
- .read = read_keyboard_misc_device,
+ .owner = THIS_MODULE,
+ .read = read_keyboard_misc_device,
};
static struct miscdevice device = {
- .fops = &fops,
- .name = "drivers_and_interrupts",
- .minor = MISC_DYNAMIC_MINOR,
- .mode = 0444,
+ .fops = &fops,
+ .name = "drivers_and_interrupts",
+ .minor = MISC_DYNAMIC_MINOR,
+ .mode = 0444,
};
struct mutex lock = __MUTEX_INITIALIZER(lock);
-static struct logger key_logger = { 0, 0 };
+static struct logger key_logger = { 0, 0 };
-static int __init m_init(void) {
- struct linked_list_node *ptr, *tmp;
- int err = 0;
+static int __init m_init(void)
+{
+ struct linked_list_node *ptr, *tmp;
+ int err = 0;
printk(KERN_INFO "Drivers and Interrupts (init)\n");
- if (request_irq(1, key_logger_isr, IRQF_SHARED, "i8042", &key_logger)) {
- err = -EBUSY;
- goto err_free_linked_list;
- }
- if (misc_register(&device)) {
- err = -ENOMEM;
- goto err_free_keyboard_notifier;
+ if (request_irq(1, key_logger_isr, IRQF_SHARED, "i8042", &key_logger)) {
+ err = -EBUSY;
+ goto err_free_linked_list;
}
- mutex_init(&lock);
+ if (misc_register(&device)) {
+ err = -ENOMEM;
+ goto err_free_keyboard_notifier;
+ }
+ mutex_init(&lock);
return 0;
err_free_keyboard_notifier:
- free_irq(1, &key_logger);
+ free_irq(1, &key_logger);
err_free_linked_list:
- list_for_each_entry_safe(ptr, tmp, &keyboard_log, list) {
- list_del(&ptr->list);
- kfree(ptr);
- }
- return err;
+ list_for_each_entry_safe(ptr, tmp, &keyboard_log, list) {
+ list_del(&ptr->list);
+ kfree(ptr);
+ }
+ return err;
}
-static void __exit m_exit(void) {
- struct linked_list_node *ptr, *tmp;
+static void __exit m_exit(void)
+{
+ struct linked_list_node *ptr, *tmp;
- misc_deregister(&device);
- size_t len = 0;
+ misc_deregister(&device);
+ size_t len = 0;
- list_for_each_entry_safe(ptr, tmp, &keyboard_log, list){
- len++;
- list_del(&ptr->list);
- kfree(ptr);
- }
- printk(KERN_INFO "Captured %zu Keyboard inputs", len);
- free_irq(1,&key_logger);
- mutex_destroy(&lock);
+ list_for_each_entry_safe(ptr, tmp, &keyboard_log, list) {
+ len++;
+ list_del(&ptr->list);
+ kfree(ptr);
+ }
+ printk(KERN_INFO "Captured %zu Keyboard inputs", len);
+ free_irq(1, &key_logger);
+ mutex_destroy(&lock);
printk(KERN_INFO "Drivers and Interrupts (exit)\n");
}
diff --git a/src/misc_device_fops.c b/src/misc_device_fops.c
index d092531..f0dc168 100644
--- a/src/misc_device_fops.c
+++ b/src/misc_device_fops.c
@@ -4,72 +4,84 @@
#include "drivers_and_interrupts.h"
-size_t calc_node_size(struct linked_list_node *node) {
- size_t size = 14;
- if (node->key.state == PRESSED) {
- size += 7;
- } else {
- size += 8;
- }
- if (node->key.ascii_value) {
- size += 6;
- }
- size += strlen(node->key.key_name);
- node->size = size;
- return size;
+size_t calc_node_size(struct linked_list_node *node)
+{
+ size_t size = 14;
+ if (node->key.state == PRESSED) {
+ size += 7;
+ } else {
+ size += 8;
+ }
+ if (node->key.ascii_value) {
+ size += 6;
+ }
+ size += strlen(node->key.key_name);
+ node->size = size;
+ return size;
}
+ssize_t read_keyboard_misc_device(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct linked_list_node *tmp;
+ loff_t node_offset = *ppos;
-ssize_t read_keyboard_misc_device(struct file *file, char __user *buf, size_t count, loff_t *ppos) {
- struct linked_list_node *tmp;
- loff_t node_offset = *ppos;
+ mutex_lock(&lock);
+ list_for_each_entry(tmp, &keyboard_log, list) {
+ if (node_offset < tmp->size) {
+ break;
+ }
+ node_offset -= tmp->size;
+ }
+ if (node_offset > tmp->size) {
+ mutex_unlock(&lock);
+ return 0;
+ }
+ // if (count > len - *ppos) {
+ // count = len - *ppos;
+ // }
- mutex_lock(&lock);
- list_for_each_entry(tmp, &keyboard_log, list) {
- if (node_offset < tmp->size) {
- break;
- }
- node_offset -= tmp->size;
- }
- if (node_offset > tmp->size) {
- printk("early exit\n");
- return 0;
- }
-// if (count > len - *ppos) {
-// count = len - *ppos;
-// }
+ size_t user_offset = 0;
+ for (; !list_entry_is_head(tmp, &keyboard_log, list);
+ tmp = list_next_entry(tmp, list)) {
+ char sec =
+ (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) % 60;
+ char min = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) /
+ 60 % 60;
+ char hour = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) /
+ 60 / 60 % 24;
+ char *buffer = kmalloc(sizeof(char) * tmp->size, GFP_KERNEL);
+ if (!buffer) {
+ mutex_unlock(&lock);
+ return -ENOMEM;
+ }
+ memset(buffer, 0, tmp->size);
+ snprintf(buffer, tmp->size, "%02d:%02d:%02d \"%s\"", hour, min,
+ sec, tmp->key.key_name);
+ if (tmp->key.ascii_value) {
+ snprintf(buffer + strlen(buffer),
+ tmp->size - strlen(buffer), "(0x%02x) ",
+ tmp->key.ascii_value);
+ }
+ if (tmp->key.state == PRESSED) {
+ snprintf(buffer + strlen(buffer),
+ tmp->size - strlen(buffer), "PRESSED\n");
+ } else {
+ snprintf(buffer + strlen(buffer),
+ tmp->size - strlen(buffer), "RELEASED\n");
+ }
- size_t user_offset = 0;
- for (; !list_entry_is_head(tmp, &keyboard_log, list); tmp = list_next_entry(tmp, list)) {
- char sec = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) % 60;
- char min = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 % 60;
- char hour = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 / 60 % 24;
- char *buffer = kmalloc(sizeof(char) * tmp->size, GFP_KERNEL);
- if (!buffer) {
- mutex_unlock(&lock);
- return -ENOMEM;
- }
- memset(buffer, 0, tmp->size);
- snprintf(buffer, tmp->size, "%02d:%02d:%02d \"%s\"", hour, min, sec, tmp->key.key_name);
- if (tmp->key.ascii_value) {
- snprintf(buffer + strlen(buffer), tmp->size - strlen(buffer), "(0x%02x) ", tmp->key.ascii_value);
- }
- if (tmp->key.state == PRESSED) {
- snprintf(buffer + strlen(buffer), tmp->size - strlen(buffer), "PRESSED\n");
- } else {
- snprintf(buffer + strlen(buffer), tmp->size - strlen(buffer), "RELEASED\n");
- }
-
- if (copy_to_user(buf + user_offset, buffer + node_offset, tmp->size - node_offset)) {
- kfree(buffer);
- mutex_unlock(&lock);
- return -EFAULT;
- }
- kfree(buffer);
- user_offset += tmp->size - node_offset;
- node_offset = 0;
- }
- *ppos += (long long)user_offset;
- mutex_unlock(&lock);
- return (long long)user_offset;
-}
\ No newline at end of file
+ if (copy_to_user(buf + user_offset, buffer + node_offset,
+ tmp->size - node_offset)) {
+ kfree(buffer);
+ mutex_unlock(&lock);
+ return -EFAULT;
+ }
+ kfree(buffer);
+ user_offset += tmp->size - node_offset;
+ node_offset = 0;
+ }
+ *ppos += (long long)user_offset;
+ mutex_unlock(&lock);
+ return (long long)user_offset;
+}