diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c index e27e0be464..b5193152a2 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c | |||
@@ -110,6 +110,19 @@ static struct ft_state_machine { | |||
110 | int cur_x, cur_y; | 110 | int cur_x, cur_y; |
111 | } fsm; | 111 | } fsm; |
112 | 112 | ||
113 | /* coordinates below this are the left hand buttons, | ||
114 | * coordinates above this are part of the scrollbar */ | ||
115 | #define SCROLLSTRIP_LEFT_X 80 | ||
116 | |||
117 | /* top and bottom cutoffs for the center of the strip, | ||
118 | * divides it into top/middle/bottom zones */ | ||
119 | #define SCROLLSTRIP_TOP_Y 105 | ||
120 | #define SCROLLSTRIP_BOT_Y 185 | ||
121 | |||
122 | /* cutoffs for the menu/left button zones */ | ||
123 | #define MENUBUTTON_Y 80 | ||
124 | #define LEFTBUTTON_Y 190 | ||
125 | |||
113 | static int touch_to_button(int x, int y) | 126 | static int touch_to_button(int x, int y) |
114 | { | 127 | { |
115 | if(x == 900) { | 128 | if(x == 900) { |
@@ -120,19 +133,19 @@ static int touch_to_button(int x, int y) | |||
120 | return BUTTON_RIGHT; | 133 | return BUTTON_RIGHT; |
121 | else | 134 | else |
122 | return 0; | 135 | return 0; |
123 | } else if(x < 80) { | 136 | } else if(x < SCROLLSTRIP_LEFT_X) { |
124 | /* Left strip */ | 137 | /* Left strip */ |
125 | if(y < 80) | 138 | if(y < MENUBUTTON_Y) |
126 | return BUTTON_MENU; | 139 | return BUTTON_MENU; |
127 | else if(y > 190) | 140 | else if(y > LEFTBUTTON_Y) |
128 | return BUTTON_LEFT; | 141 | return BUTTON_LEFT; |
129 | else | 142 | else |
130 | return 0; | 143 | return 0; |
131 | } else { | 144 | } else { |
132 | /* Middle strip */ | 145 | /* Middle strip */ |
133 | if(y < 100) | 146 | if(y < SCROLLSTRIP_TOP_Y) |
134 | return BUTTON_UP; | 147 | return BUTTON_UP; |
135 | else if(y > 220) | 148 | else if(y > SCROLLSTRIP_BOT_Y) |
136 | return BUTTON_DOWN; | 149 | return BUTTON_DOWN; |
137 | else | 150 | else |
138 | return BUTTON_SELECT; | 151 | return BUTTON_SELECT; |
@@ -489,6 +502,24 @@ bool dbg_fiiom3k_touchpad(void) | |||
489 | "IDLE", "PRESS", "REPORT", "SCROLL_PRESS", "SCROLLING" | 502 | "IDLE", "PRESS", "REPORT", "SCROLL_PRESS", "SCROLLING" |
490 | }; | 503 | }; |
491 | 504 | ||
505 | /* definition of box used to represent the touchpad */ | ||
506 | const int pad_w = LCD_WIDTH; | ||
507 | const int pad_h = LCD_HEIGHT; | ||
508 | const int box_h = pad_h - SYSFONT_HEIGHT*5; | ||
509 | const int box_w = pad_w * box_h / pad_h; | ||
510 | const int box_x = (LCD_WIDTH - box_w) / 2; | ||
511 | const int box_y = SYSFONT_HEIGHT * 9 / 2; | ||
512 | |||
513 | /* cutoffs converted to box coordinates */ | ||
514 | const int ss_left_x = box_x + SCROLLSTRIP_LEFT_X * box_w / pad_w; | ||
515 | const int ss_top_y = box_y + SCROLLSTRIP_TOP_Y * box_h / pad_h; | ||
516 | const int ss_bot_y = box_y + SCROLLSTRIP_BOT_Y * box_h / pad_h; | ||
517 | const int menubtn_y = box_y + MENUBUTTON_Y * box_h / pad_h; | ||
518 | const int leftbtn_y = box_y + LEFTBUTTON_Y * box_h / pad_h; | ||
519 | |||
520 | bool draw_areas = true; | ||
521 | bool draw_border = true; | ||
522 | |||
492 | do { | 523 | do { |
493 | int line = 0; | 524 | int line = 0; |
494 | lcd_clear_display(); | 525 | lcd_clear_display(); |
@@ -496,6 +527,26 @@ bool dbg_fiiom3k_touchpad(void) | |||
496 | lcd_putsf(0, line++, "button: %08x", fsm.buttons); | 527 | lcd_putsf(0, line++, "button: %08x", fsm.buttons); |
497 | lcd_putsf(0, line++, "pos x: %4d orig x: %4d", fsm.cur_x, fsm.orig_x); | 528 | lcd_putsf(0, line++, "pos x: %4d orig x: %4d", fsm.cur_x, fsm.orig_x); |
498 | lcd_putsf(0, line++, "pos y: %4d orig y: %4d", fsm.cur_y, fsm.orig_y); | 529 | lcd_putsf(0, line++, "pos y: %4d orig y: %4d", fsm.cur_y, fsm.orig_y); |
530 | |||
531 | /* draw touchpad box borders */ | ||
532 | if(draw_border) | ||
533 | lcd_drawrect(box_x, box_y, box_w, box_h); | ||
534 | |||
535 | /* draw crosshair */ | ||
536 | int tx = box_x + fsm.cur_x * box_w / pad_w; | ||
537 | int ty = box_y + fsm.cur_y * box_h / pad_h; | ||
538 | lcd_hline(tx-2, tx+2, ty); | ||
539 | lcd_vline(tx, ty-2, ty+2); | ||
540 | |||
541 | /* draw the button areas */ | ||
542 | if(draw_areas) { | ||
543 | lcd_vline(ss_left_x, box_y, box_y+box_h); | ||
544 | lcd_hline(ss_left_x, box_x+box_w, ss_top_y); | ||
545 | lcd_hline(ss_left_x, box_x+box_w, ss_bot_y); | ||
546 | lcd_hline(box_x, ss_left_x, menubtn_y); | ||
547 | lcd_hline(box_x, ss_left_x, leftbtn_y); | ||
548 | } | ||
549 | |||
499 | lcd_update(); | 550 | lcd_update(); |
500 | } while(getbtn() != BUTTON_POWER); | 551 | } while(getbtn() != BUTTON_POWER); |
501 | return false; | 552 | return false; |