1
diff --exclude='*.wanjet' --exclude='.??*' --exclude=config.h --exclude='*.orig' --exclude=Makefile --exclude='*.o' --exclude=Doxyfile --exclude='*.a' --exclude=config.log --exclude=config.status --exclude='init-*' -Nuarp server/menu.c server.HKEY/menu.c
2
--- server/menu.c 2006-01-26 19:47:59.000000000 -0800
3
+++ server.HKEY/menu.c 2006-02-21 09:21:25.000000000 -0800
8
+#ifndef HKEY //hybrid keys
9
+#include "shared/configfile.h"
11
+extern int hybrid_left_key;
12
+extern int hybrid_right_key;
15
/** Basicly a patched version of LL_GetByIndex() that ignores hidden
16
* entries completely. (But it takes a menu as an argument.) */
18
@@ -559,12 +566,86 @@ MenuResult menu_process_input(Menu *menu
19
return MENURESULT_ERROR;
22
+ case MENUTOKEN_LEFT:
24
+ return MENURESULT_NONE;
25
+#ifndef HKEY //hybrid key left
27
+ * hybrid left key just fall through to menu key
29
+ if (!hybrid_left_key) {
30
+ subitem = menu_get_subitem (menu, menu->data.menu.selector_pos);
31
+ if (subitem == NULL)
33
+ switch (subitem->type) {
34
+ case MENUITEM_CHECKBOX:
35
+ /* note: this dangerous looking code works since
36
+ * CheckboxValue is an enum >= 0. */
37
+ if (subitem->data.checkbox.allow_gray) {
38
+ subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 3;
41
+ subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 2;
43
+ if (subitem->event_func)
44
+ subitem->event_func (subitem, MENUEVENT_UPDATE);
45
+ return MENURESULT_NONE;
47
+ /* ring: jump to the end if beginning is reached */
48
+ subitem->data.ring.value = (subitem->data.ring.value < 1)
49
+ ? LL_Length (subitem->data.ring.strings) - 1
50
+ : (subitem->data.ring.value - 1) % LL_Length (subitem->data.ring.strings);
51
+ if (subitem->event_func)
52
+ subitem->event_func (subitem, MENUEVENT_UPDATE);
53
+ return MENURESULT_NONE;
57
+ return MENURESULT_NONE;
61
subitem = menu_get_item_for_predecessor_check(menu);
63
return MENURESULT_ERROR;
64
return menuitem_predecessor2menuresult(
65
subitem->predecessor_id, MENURESULT_CLOSE);
66
+ case MENUTOKEN_RIGHT:
67
+#ifndef HKEY //hybrid key right
69
+ * hybrid right key just fall through to enter key
71
+ if (!hybrid_right_key) {
72
+ if (!extended) /* Can you get a MENUTOKEN_RIGHT w/o a RightKey defined, this code maybe be unecessary */
73
+ return MENURESULT_NONE;
75
+ subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
76
+ if (subitem == NULL)
78
+ switch (subitem->type) {
79
+ case MENUITEM_CHECKBOX:
80
+ if (subitem->data.checkbox.allow_gray) {
81
+ subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 3;
84
+ subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2;
86
+ if (subitem->event_func)
87
+ subitem->event_func (subitem, MENUEVENT_UPDATE);
88
+ return MENURESULT_NONE;
90
+ subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length (subitem->data.ring.strings);
91
+ if (subitem->event_func)
92
+ subitem->event_func (subitem, MENUEVENT_UPDATE);
93
+ return MENURESULT_NONE;
95
+ return MENURESULT_ENTER;
99
+ return MENURESULT_NONE;
102
case MENUTOKEN_ENTER:
103
subitem = menu_get_subitem (menu, menu->data.menu.selector_pos);
105
@@ -609,6 +690,18 @@ MenuResult menu_process_input(Menu *menu
106
menu->data.menu.scroll --;
108
else if (menu->data.menu.selector_pos == 0) {
109
+#ifndef HKEY //hybrid key left
110
+ if ( hybrid_left_key ) {
112
+ * If this menu has only checkbox's and/or rings
113
+ * need a key to get back from this menu on a 4 key pad
115
+ subitem = menu_get_item_for_predecessor_check(menu);
116
+ if ( subitem && ((subitem->type == MENUITEM_CHECKBOX) || (subitem->type == MENUITEM_RING)))
117
+ return menuitem_predecessor2menuresult(
118
+ subitem->predecessor_id, MENURESULT_CLOSE);
121
// wrap around to last menu entry
122
menu->data.menu.selector_pos = menu_visible_item_count(menu) - 1;
123
menu->data.menu.scroll = menu->data.menu.selector_pos + 2 - display_props->height;
124
@@ -626,67 +719,6 @@ MenuResult menu_process_input(Menu *menu
125
menu->data.menu.scroll = 0;
127
return MENURESULT_NONE;
128
- case MENUTOKEN_LEFT:
130
- return MENURESULT_NONE;
132
- subitem = menu_get_subitem (menu, menu->data.menu.selector_pos);
133
- if (subitem == NULL)
135
- switch (subitem->type) {
136
- case MENUITEM_CHECKBOX:
137
- /* note: this dangerous looking code works since
138
- * CheckboxValue is an enum >= 0. */
139
- if (subitem->data.checkbox.allow_gray) {
140
- subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 3;
143
- subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 2;
145
- if (subitem->event_func)
146
- subitem->event_func (subitem, MENUEVENT_UPDATE);
147
- return MENURESULT_NONE;
148
- case MENUITEM_RING:
149
- /* ring: jump to the end if beginning is reached */
150
- subitem->data.ring.value = (subitem->data.ring.value < 1)
151
- ? LL_Length (subitem->data.ring.strings) - 1
152
- : (subitem->data.ring.value - 1) % LL_Length (subitem->data.ring.strings);
153
- if (subitem->event_func)
154
- subitem->event_func (subitem, MENUEVENT_UPDATE);
155
- return MENURESULT_NONE;
159
- return MENURESULT_NONE;
160
- case MENUTOKEN_RIGHT:
162
- return MENURESULT_NONE;
164
- subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
165
- if (subitem == NULL)
167
- switch (subitem->type) {
168
- case MENUITEM_CHECKBOX:
169
- if (subitem->data.checkbox.allow_gray) {
170
- subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 3;
173
- subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2;
175
- if (subitem->event_func)
176
- subitem->event_func (subitem, MENUEVENT_UPDATE);
177
- return MENURESULT_NONE;
178
- case MENUITEM_RING:
179
- subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length (subitem->data.ring.strings);
180
- if (subitem->event_func)
181
- subitem->event_func (subitem, MENUEVENT_UPDATE);
182
- return MENURESULT_NONE;
183
- case MENUITEM_MENU:
184
- return MENURESULT_ENTER;
188
- return MENURESULT_NONE;
189
case MENUTOKEN_OTHER:
190
/* TODO: move to the selected number and enter it */
191
return MENURESULT_NONE;
192
diff --exclude='*.wanjet' --exclude='.??*' --exclude=config.h --exclude='*.orig' --exclude=Makefile --exclude='*.o' --exclude=Doxyfile --exclude='*.a' --exclude=config.log --exclude=config.status --exclude='init-*' -Nuarp server/menuitem.c server.HKEY/menuitem.c
193
--- server/menuitem.c 2006-01-26 19:47:59.000000000 -0800
194
+++ server.HKEY/menuitem.c 2006-02-21 09:22:53.000000000 -0800
195
@@ -84,6 +84,10 @@ const IpSstringProperties IPinfo[] = {
196
{ 39, ':', 16, 4, 65535, { 4096, 256, 16, 1, 0 }, "%04x", verify_ipv6, "0:0:0:0:0:0:0:0" }
199
+#ifndef HKEY // hybrid keys
200
+extern int hybrid_left_key;
201
+extern int hybrid_right_key;
204
/******** MENU UTILITY FUNCTIONS ********/
206
@@ -983,26 +987,38 @@ MenuResult menuitem_process_input_slider
207
return MENURESULT_ERROR;
210
- case MENUTOKEN_MENU:
211
- return menuitem_predecessor2menuresult(
212
- item->predecessor_id, MENURESULT_CLOSE);
213
- case MENUTOKEN_ENTER:
214
- return menuitem_successor2menuresult(
215
- item->successor_id, MENURESULT_CLOSE);
217
case MENUTOKEN_RIGHT:
218
- item->data.slider.value = min (item->data.slider.maxvalue,
219
+#ifndef HKEY //hybrid key right
220
+ if ( !hybrid_right_key || token == MENUTOKEN_UP ) {
222
+ item->data.slider.value = min (item->data.slider.maxvalue,
223
item->data.slider.value + item->data.slider.stepsize);
224
- if (item->event_func)
225
- item->event_func (item, MENUEVENT_PLUS);
226
- return MENURESULT_NONE;
227
+ if (item->event_func)
228
+ item->event_func (item, MENUEVENT_PLUS);
229
+ return MENURESULT_NONE;
230
+#ifndef HKEY //hybrid key right
231
+ } /* hybrid right key fall through to enter */
233
+ case MENUTOKEN_ENTER:
234
+ return menuitem_successor2menuresult(
235
+ item->successor_id, MENURESULT_CLOSE);
238
- item->data.slider.value = max (item->data.slider.minvalue,
239
+#ifndef HKEY //hybrid key left
240
+ if ( !hybrid_left_key || token == MENUTOKEN_DOWN ) {
242
+ item->data.slider.value = max (item->data.slider.minvalue,
243
item->data.slider.value - item->data.slider.stepsize);
244
- if (item->event_func)
245
- item->event_func (item, MENUEVENT_MINUS);
246
- return MENURESULT_NONE;
247
+ if (item->event_func)
248
+ item->event_func (item, MENUEVENT_MINUS);
249
+ return MENURESULT_NONE;
250
+#ifndef HKEY //hybrid key left
251
+ } /* hybrid left key fall through to menu */
253
+ case MENUTOKEN_MENU:
254
+ return menuitem_predecessor2menuresult(
255
+ item->predecessor_id, MENURESULT_CLOSE);
256
case MENUTOKEN_OTHER:
259
@@ -1037,6 +1053,21 @@ MenuResult menuitem_process_input_numeri
260
item->data.numeric.error_code = 0;
263
+ case MENUTOKEN_LEFT:
264
+ /* The user wants to go to back a digit */
266
+ item->data.numeric.edit_pos--;
267
+ if (item->data.numeric.edit_offs > item->data.numeric.edit_pos)
268
+ item->data.numeric.edit_offs = item->data.numeric.edit_pos;
269
+#ifndef HKEY //hybrid key left
270
+ if( hybrid_left_key ) return MENURESULT_NONE;
272
+ if( !hybrid_left_key ) return MENURESULT_NONE;
273
+ /* fall through to MENU */
276
+ return MENURESULT_NONE;
280
return menuitem_predecessor2menuresult(
281
@@ -1047,6 +1078,21 @@ MenuResult menuitem_process_input_numeri
282
menuitem_reset_numeric(item);
284
return MENURESULT_NONE;
285
+ case MENUTOKEN_RIGHT:
286
+ /* The user wants to go to next digit */
287
+ if (str[pos] != '\0' && pos < max_len) {
288
+ item->data.numeric.edit_pos++;
289
+ if (pos >= display_props->width - 2)
290
+ item->data.numeric.edit_offs++;
291
+#ifndef HKEY //hybrid key right
292
+ if( hybrid_right_key ) return MENURESULT_NONE;
294
+ if( !hybrid_right_key ) return MENURESULT_NONE;
295
+ /* fall through to ENTER */
298
+ return MENURESULT_NONE;
300
case MENUTOKEN_ENTER:
301
if ((extended) || (str[pos] == '\0')) {
303
@@ -1131,22 +1177,6 @@ MenuResult menuitem_process_input_numeri
306
return MENURESULT_NONE;
307
- case MENUTOKEN_RIGHT:
308
- /* The user wants to go to next digit */
309
- if (str[pos] != '\0' && pos < max_len) {
310
- item->data.numeric.edit_pos++;
311
- if (pos >= display_props->width - 2)
312
- item->data.numeric.edit_offs++;
314
- return MENURESULT_NONE;
315
- case MENUTOKEN_LEFT:
316
- /* The user wants to go to back a digit */
318
- item->data.numeric.edit_pos--;
319
- if (item->data.numeric.edit_offs > item->data.numeric.edit_pos)
320
- item->data.numeric.edit_offs = item->data.numeric.edit_pos;
322
- return MENURESULT_NONE;
323
case MENUTOKEN_OTHER:
324
if (pos >= max_len) {
325
/* We're not allowed to add anything anymore */
326
@@ -1196,6 +1226,21 @@ MenuResult menuitem_process_input_alpha
327
item->data.alpha.error_code = 0;
330
+ case MENUTOKEN_LEFT:
331
+ /* The user wants to go to back a digit */
333
+ item->data.alpha.edit_pos--;
334
+ if (item->data.alpha.edit_offs > item->data.alpha.edit_pos)
335
+ item->data.alpha.edit_offs = item->data.alpha.edit_pos;
336
+#ifndef HKEY //hybrid key left
337
+ if( hybrid_left_key ) return MENURESULT_NONE;
339
+ if( !hybrid_left_key ) return MENURESULT_NONE;
340
+ /* fall through to MENU */
343
+ return MENURESULT_NONE;
347
return menuitem_predecessor2menuresult(
348
@@ -1206,6 +1251,22 @@ MenuResult menuitem_process_input_alpha
349
menuitem_reset_alpha(item);
351
return MENURESULT_NONE;
352
+ case MENUTOKEN_RIGHT:
353
+ /* The user wants to go to next digit */
354
+ if (str[item->data.alpha.edit_pos] != '\0' &&
355
+ pos < item->data.alpha.maxlength - 1) {
356
+ item->data.alpha.edit_pos++;
357
+ if (pos >= display_props->width - 2)
358
+ item->data.alpha.edit_offs++;
359
+#ifndef HKEY //hybrid key right
360
+ if( hybrid_right_key ) return MENURESULT_NONE;
362
+ if( !hybrid_right_key ) return MENURESULT_NONE;
363
+ /* fall through to ENTER */
366
+ return MENURESULT_NONE;
368
case MENUTOKEN_ENTER:
369
if ((extended) || (str[item->data.alpha.edit_pos] == '\0')) {
370
/* The user completed his input */
371
@@ -1278,23 +1339,6 @@ MenuResult menuitem_process_input_alpha
374
return MENURESULT_NONE;
375
- case MENUTOKEN_RIGHT:
376
- /* The user wants to go to next digit */
377
- if (str[item->data.alpha.edit_pos] != '\0' &&
378
- pos < item->data.alpha.maxlength - 1) {
379
- item->data.alpha.edit_pos++;
380
- if (pos >= display_props->width - 2)
381
- item->data.alpha.edit_offs++;
383
- return MENURESULT_NONE;
384
- case MENUTOKEN_LEFT:
385
- /* The user wants to go to back a digit */
387
- item->data.alpha.edit_pos--;
388
- if (item->data.alpha.edit_offs > item->data.alpha.edit_pos)
389
- item->data.alpha.edit_offs = item->data.alpha.edit_pos;
391
- return MENURESULT_NONE;
392
case MENUTOKEN_OTHER:
393
if (pos >= item->data.alpha.maxlength) {
394
/* We're not allowed to add anything anymore */
395
@@ -1333,7 +1377,24 @@ MenuResult menuitem_process_input_ip (Me
396
item->data.ip.error_code = 0;
399
- case MENUTOKEN_MENU:
400
+ case MENUTOKEN_LEFT:
401
+ /* The user wants to go to back a digit */
403
+ item->data.ip.edit_pos--;
404
+ if (str[item->data.ip.edit_pos] == ipinfo->sep)
405
+ item->data.ip.edit_pos--;
406
+ if (item->data.ip.edit_offs > item->data.ip.edit_pos)
407
+ item->data.ip.edit_offs = item->data.ip.edit_pos;
408
+#ifndef HKEY //hybrid key left
409
+ if( hybrid_left_key ) return MENURESULT_NONE;
411
+ if( !hybrid_left_key ) return MENURESULT_NONE;
412
+ /* fall through to MENU */
415
+ return MENURESULT_NONE;
417
+ case MENUTOKEN_MENU:
419
return menuitem_predecessor2menuresult(
420
item->predecessor_id, MENURESULT_CLOSE);
421
@@ -1343,6 +1404,22 @@ MenuResult menuitem_process_input_ip (Me
422
menuitem_reset_ip(item);
424
return MENURESULT_NONE;
425
+ case MENUTOKEN_RIGHT:
426
+ if (pos < item->data.ip.maxlength - 1) {
427
+ item->data.ip.edit_pos++;
428
+ if (str[item->data.ip.edit_pos] == ipinfo->sep)
429
+ item->data.ip.edit_pos++;
430
+ while (item->data.ip.edit_pos - item->data.ip.edit_offs > display_props->width - 2)
431
+ item->data.ip.edit_offs++;
432
+#ifndef HKEY //hybrid key right
433
+ if( hybrid_right_key ) return MENURESULT_NONE;
435
+ if( !hybrid_right_key ) return MENURESULT_NONE;
436
+ /* fall through to ENTER */
439
+ return MENURESULT_NONE;
441
case MENUTOKEN_ENTER:
442
if (extended || (pos >= item->data.ip.maxlength - 1)) {
443
// remove the leading spaces/zeros in each octet-representing string
444
@@ -1409,25 +1486,6 @@ MenuResult menuitem_process_input_ip (Me
445
snprintf(numstr, 5, ipinfo->format, num);
446
memcpy(&str[pos - (pos % (ipinfo->width + 1))], numstr, ipinfo->width);
447
return MENURESULT_NONE;
448
- case MENUTOKEN_RIGHT:
449
- if (pos < item->data.ip.maxlength - 1) {
450
- item->data.ip.edit_pos++;
451
- if (str[item->data.ip.edit_pos] == ipinfo->sep)
452
- item->data.ip.edit_pos++;
453
- while (item->data.ip.edit_pos - item->data.ip.edit_offs > display_props->width - 2)
454
- item->data.ip.edit_offs++;
456
- return MENURESULT_NONE;
457
- case MENUTOKEN_LEFT:
458
- /* The user wants to go to back a digit */
460
- item->data.ip.edit_pos--;
461
- if (str[item->data.ip.edit_pos] == ipinfo->sep)
462
- item->data.ip.edit_pos--;
463
- if (item->data.ip.edit_offs > item->data.ip.edit_pos)
464
- item->data.ip.edit_offs = item->data.ip.edit_pos;
466
- return MENURESULT_NONE;
467
case MENUTOKEN_OTHER:
468
/* process other keys */
469
if ((strlen(key) == 1) &&
470
diff --exclude='*.wanjet' --exclude='.??*' --exclude=config.h --exclude='*.orig' --exclude=Makefile --exclude='*.o' --exclude=Doxyfile --exclude='*.a' --exclude=config.log --exclude=config.status --exclude='init-*' -Nuarp server/menuscreens.c server.HKEY/menuscreens.c
471
--- server/menuscreens.c 2006-01-26 19:47:59.000000000 -0800
472
+++ server.HKEY/menuscreens.c 2006-02-21 09:33:21.000000000 -0800
473
@@ -48,6 +48,15 @@ char * down_key;
477
+#ifndef HKEY //hybrid keys
479
+ * hybrid left becomes menu key at left edge of screen
480
+ * hybrid right becomes enter key at right edge of screen
482
+int hybrid_left_key = 0;
483
+int hybrid_right_key = 0;
486
Screen * menuscreen = NULL;
487
MenuItem * active_menuitem = NULL;
488
/** the "real" main_menu */
489
@@ -91,6 +100,11 @@ int menuscreens_init()
491
right_key = strdup(tmp);
493
+#ifndef HKEY //get hybrid keys from config file
494
+ hybrid_right_key = config_get_bool ("menu", "HybridRightKey", 0, 0);
495
+ hybrid_left_key = config_get_bool ("menu", "HybridLeftKey", 0, 0);
499
/* Now reserve keys */
500
input_reserve_key (menu_key, true, NULL);
501
@@ -186,6 +200,11 @@ void menuscreen_inform_item_modified (Me
503
bool is_menu_key (char * key)
505
+#ifndef HKEY //hybrid keys, any key wake-up menus
506
+ /* any key wakes up menus */
507
+ if (key && ( hybrid_left_key || hybrid_right_key ))
510
if (menu_key && key && strcmp (key, menu_key) == 0)
513
@@ -466,28 +485,28 @@ void menuscreen_create_menu ()
514
menu_add_item (options_menu, driver_menu);
515
if (contrast_avail) {
516
int contrast = driver->get_contrast(driver);
519
/* menu's client is NULL since we're in the server */
520
slider = menuitem_create_slider ("contrast", contrast_handler, "Contrast",
521
- NULL, "min", "max", 0, 1000, 25, contrast);
522
+ NULL, "min", "max", 0, 1000, 25, contrast);
523
menu_add_item (driver_menu, slider);
525
if (brightness_avail) {
526
int onbrightness = driver->get_brightness (driver, BACKLIGHT_ON);
527
int offbrightness = driver->get_brightness (driver, BACKLIGHT_OFF);
530
slider = menuitem_create_slider ("onbrightness", brightness_handler, "On Brightness",
531
- NULL, "min", "max", 0, 1000, 25, onbrightness);
532
+ NULL, "min", "max", 0, 1000, 25, onbrightness);
533
menu_add_item (driver_menu, slider);
535
slider = menuitem_create_slider ("offbrightness", brightness_handler, "Off Brightness",
536
- NULL, "min", "max", 0, 1000, 25, offbrightness);
537
+ NULL, "min", "max", 0, 1000, 25, offbrightness);
538
menu_add_item (driver_menu, slider);
543
-#ifdef LCDPROC_TESTMENUS
544
+#ifdef LCDPROC_TESTMENUS
545
test_menu = menu_create ("test", NULL, "Test menu", NULL);
546
menu_add_item (main_menu, test_menu);