From 5be0e3430d13341feddee739997130239daf71d5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Mar 2020 17:24:12 +1100 Subject: GHOST/Keymap: support for detecting repeat events - Keymap items now have 'repeat' boolean which can be set to make keymap items respond to key repeat events or not. - Support for X11 & WIN32 (not macOS currently). This allows for the possibility to perform actions while a key is held and finish the action upon release. Thanks to @Severin for review and WIN32 support. --- source/blender/makesrna/intern/rna_wm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/blender/makesrna/intern/rna_wm.c') diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index bf3c562f95f..929540f10ac 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -652,6 +652,12 @@ static int rna_Event_unicode_length(PointerRNA *ptr) } } +static bool rna_Event_is_repeat_get(PointerRNA *ptr) +{ + const wmEvent *event = ptr->data; + return event->is_repeat; +} + static float rna_Event_pressure_get(PointerRNA *ptr) { const wmEvent *event = ptr->data; @@ -2131,6 +2137,12 @@ static void rna_def_event(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", ""); + /* keyboard */ + prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Event_is_repeat_get", NULL); + RNA_def_property_ui_text(prop, "Is Repeat", "The event is generated by holding a key down"); + /* mouse */ prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "x"); @@ -2728,6 +2740,12 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier"); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); + prop = RNA_def_property(srna, "repeat", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_REPEAT_IGNORE); + RNA_def_property_ui_text(prop, "Repeat", "Active on key-repeat events (when a key is held)"); + RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED); -- cgit v1.2.3