/*\r
- * (C) Gražvydas "notaz" Ignotas, 2006-2010\r
+ * (C) Gražvydas "notaz" Ignotas, 2006-2011\r
*\r
* This work is licensed under the terms of any of these licenses\r
* (at your option):\r
return ret;\r
}\r
\r
+static unsigned int me_read_onoff(const menu_entry *ent)\r
+{\r
+ // guess var size based on mask to avoid reading too much\r
+ if (ent->mask & 0xffff0000)\r
+ return *(unsigned int *)ent->var & ent->mask;\r
+ else if (ent->mask & 0xff00)\r
+ return *(unsigned short *)ent->var & ent->mask;\r
+ else\r
+ return *(unsigned char *)ent->var & ent->mask;\r
+}\r
+\r
+static void me_toggle_onoff(menu_entry *ent)\r
+{\r
+ // guess var size based on mask to avoid reading too much\r
+ if (ent->mask & 0xffff0000)\r
+ *(unsigned int *)ent->var ^= ent->mask;\r
+ else if (ent->mask & 0xff00)\r
+ *(unsigned short *)ent->var ^= ent->mask;\r
+ else\r
+ *(unsigned char *)ent->var ^= ent->mask;\r
+}\r
+\r
static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))\r
{\r
const menu_entry *ent, *ent_sel = entries;\r
case MB_NONE:\r
break;\r
case MB_OPT_ONOFF:\r
- text_out16(x + col2_offs, y, (*(int *)ent->var & ent->mask) ? "ON" : "OFF");\r
+ text_out16(x + col2_offs, y, me_read_onoff(ent) ? "ON" : "OFF");\r
break;\r
case MB_OPT_RANGE:\r
text_out16(x + col2_offs, y, "%i", *(int *)ent->var);\r
{\r
case MB_OPT_ONOFF:\r
case MB_OPT_CUSTONOFF:\r
- *(int *)entry->var ^= entry->mask;\r
+ me_toggle_onoff(entry);\r
return 1;\r
case MB_OPT_RANGE:\r
case MB_OPT_CUSTRANGE:\r