Fix label truncation when strlen(hats) + 1 < strlen(buttons)

Hat labels reserve an extra character for the arrow, which partially
masked this error.  When used buttons requires more characters than (1
+ used hats), the buffer had insufficient space and the label was
truncated.
This commit is contained in:
Kp 2017-05-13 04:19:39 +00:00
parent 139ad58c72
commit 806c76ce02

View file

@ -155,7 +155,9 @@ extern joyaxis_text_t joyaxis_text;
#endif
#if DXX_MAX_BUTTONS_PER_JOYSTICK || DXX_MAX_HATS_PER_JOYSTICK
using joybutton_text_t = joystick_text_t<sizeof("J H ") + joystick_text_length<DXX_MAX_JOYSTICKS>::value + joystick_text_length<DXX_MAX_HATS_PER_JOYSTICK>::value>;
#define DXX_JOY_MAX(A,B) ((A) < (B) ? (B) : (A))
using joybutton_text_t = joystick_text_t<joystick_text_length<DXX_MAX_JOYSTICKS>::value + DXX_JOY_MAX(sizeof("J H ") + joystick_text_length<DXX_MAX_HATS_PER_JOYSTICK>::value, sizeof("J B") + joystick_text_length<DXX_MAX_BUTTONS_PER_JOYSTICK>::value)>;
#undef DXX_JOY_MAX
extern joybutton_text_t joybutton_text;
#endif