From 95caca311f1047d5c6640e671bdd848cb58d8425 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Tue, 28 Jul 2015 17:21:43 +0200 Subject: [PATCH] Add debugging output specific to FF_CONSTANT to the dummy device. --- klgdff.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/klgdff.c b/klgdff.c index 52115f3..fc1c6c7 100644 --- a/klgdff.c +++ b/klgdff.c @@ -71,9 +71,27 @@ static int klgdff_er_stop(struct klgd_command_stream *s, const struct ff_effect static int klgdff_start(struct klgd_command_stream *s, const struct ff_effect *effect, const int repeat) { - char *text = kasprintf(GFP_KERNEL, "Playing effect, type %d, id %d, repeat %d", effect->type, effect->id, repeat); - size_t len = strlen(text); - struct klgd_command *c = klgd_alloc_cmd(len + 1); + char *text; + size_t len; + struct klgd_command *c; + + switch (effect->type) { + case FF_CONSTANT: + { + s32 x; + s32 y; + + ffpl_lvl_dir_to_x_y(effect->u.constant.level, effect->direction, &x, &y); + text = kasprintf(GFP_KERNEL, "Playing FF_CONSTANT, level: %d, dir: %u, X: %d, Y: %d", effect->u.constant.level, effect->direction, x, y); + break; + } + default: + text = kasprintf(GFP_KERNEL, "Playing effect, type %d, id %d, repeat %d", effect->type, effect->id, repeat); + break; + } + + len = strlen(text); + c = klgd_alloc_cmd(len + 1); if (!c) return -ENOMEM; @@ -99,9 +117,27 @@ static int klgdff_stop(struct klgd_command_stream *s, const struct ff_effect *ef static int klgdff_update(struct klgd_command_stream *s, const struct ff_effect *effect) { - char *text = kasprintf(GFP_KERNEL, "Updating effect, type %d, id %d", effect->type, effect->id); - size_t len = strlen(text); - struct klgd_command *c = klgd_alloc_cmd(len + 1); + char *text; + size_t len; + struct klgd_command *c; + + switch (effect->type) { + case FF_CONSTANT: + { + s32 x; + s32 y; + + ffpl_lvl_dir_to_x_y(effect->u.constant.level, effect->direction, &x, &y); + text = kasprintf(GFP_KERNEL, "Updating FF_CONSTANT, level: %d, dir: %u, X: %d, Y: %d", effect->u.constant.level, effect->direction, x, y); + break; + } + default: + text = kasprintf(GFP_KERNEL, "Updating, type %d, id %d", effect->type, effect->id); + break; + } + + len = strlen(text); + c = klgd_alloc_cmd(len + 1); if (!c) return -ENOMEM; @@ -127,9 +163,27 @@ static int klgdff_upload(struct klgd_command_stream *s, const struct ff_effect * static int klgdff_up_start(struct klgd_command_stream *s, const struct ff_effect *effect, const int repeat) { - char *text = kasprintf(GFP_KERNEL, "Uploading and starting effect, type %d, id %d, repeat %d", effect->type, effect->id, repeat); - size_t len = strlen(text); - struct klgd_command *c = klgd_alloc_cmd(len + 1); + char *text; + size_t len; + struct klgd_command *c; + + switch (effect->type) { + case FF_CONSTANT: + { + s32 x; + s32 y; + + ffpl_lvl_dir_to_x_y(effect->u.constant.level, effect->direction, &x, &y); + text = kasprintf(GFP_KERNEL, "Uploading and starting FF_CONSTANT, level: %d, dir: %u, X: %d, Y: %d", effect->u.constant.level, effect->direction, x, y); + break; + } + default: + text = kasprintf(GFP_KERNEL, "Uploading and starting effect, type %d, id %d, repeat %d", effect->type, effect->id, repeat); + break; + } + + len = strlen(text); + c = klgd_alloc_cmd(len + 1); if (!c) return -ENOMEM; -- 2.43.5