From 141c6073ca39f0d59c67ebef89b094395b903a4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Feb 2019 15:14:51 +1100 Subject: WM: Event simulation support for Python This feature is intended only for testing, to automate simulating user input. - Enabled by '--enable-event-simulate'. - Disables handling all real input events. - Access by calling `Window.event_simulate(..)` - Disabling `bpy.app.use_event_simulate` to allow handling real events (can only disable). Currently only mouse & keyboard events work well, NDOF, IME... etc could be added as needed. See D4286 for example usage. --- source/creator/creator_args.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/creator/creator_args.c') diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 294944f0d8d..4040b09f618 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -565,6 +565,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo BLI_argsPrintArgDoc(ba, "--app-template"); BLI_argsPrintArgDoc(ba, "--factory-startup"); BLI_argsPrintArgDoc(ba, "--enable-static-override"); + BLI_argsPrintArgDoc(ba, "--enable-event-simulate"); printf("\n"); BLI_argsPrintArgDoc(ba, "--env-system-datafiles"); BLI_argsPrintArgDoc(ba, "--env-system-scripts"); @@ -1016,6 +1017,15 @@ static int arg_handle_enable_static_override(int UNUSED(argc), const char **UNUS return 0; } +static const char arg_handle_enable_event_simulate_doc[] = +"\n\tEnable event simulation testing feature 'bpy.types.Window.event_simulate'." +; +static int arg_handle_enable_event_simulate(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + G.f |= G_FLAG_EVENT_SIMULATE; + return 0; +} + static const char arg_handle_env_system_set_doc_datafiles[] = "\n\tSet the "STRINGIFY_ARG (BLENDER_SYSTEM_DATAFILES)" environment variable."; static const char arg_handle_env_system_set_doc_scripts[] = @@ -1950,6 +1960,7 @@ void main_args_setup(bContext *C, bArgs *ba) BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL); BLI_argsAdd(ba, 1, NULL, "--enable-static-override", CB(arg_handle_enable_static_override), NULL); + BLI_argsAdd(ba, 1, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL); /* TODO, add user env vars? */ BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), NULL); -- cgit v1.2.3