From cac7702565b560d5a16bc82bf553d1a4c08297e1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Sep 2012 14:00:08 +0200 Subject: commands: handle property stepping in a generic way Instead of forcing each property implementation implement its own logic for M_PROPERTY_STEP_UP/M_PROPERTY_STEP_DOWN, handle it in the generic property code. Rename the M_PROPERTY_STEP_UP command to M_PROPERTY_SWITCH (the other property command, M_PROPERTY_STEP_DOWN, isn't needed anymore: stepping downwards is done by passing a negative argument). Always use double as argument type; it makes the code easier, and covers all property types. Move the code which does the actual type-specific value stepping to m_option.c (the idea is that m_option handles types). Some properties still have custom handlers implemented with M_PROPERTY_SWITCH. They can't be mapped to the generic mechanism, because their value range is dynamic or entirely unknown. For some properties, the default step stride is changed to 1. This is no issue, because the default bindings in input.conf all use an explicit stride in the affected cases. --- m_option.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'm_option.h') diff --git a/m_option.h b/m_option.h index 73752e7a56..75f9ee5925 100644 --- a/m_option.h +++ b/m_option.h @@ -222,6 +222,11 @@ struct m_option_type { * set to NULL. */ void (*free)(void *dst); + + // Add the value add to the value in val. For types that are not numeric, + // add gives merely the direction. The wrap parameter determines whether + // the value is clipped, or wraps around to the opposite max/min. + void (*add)(const m_option_t *opt, void *val, double add, bool wrap); }; // Option description -- cgit v1.2.3