summaryrefslogtreecommitdiff
path: root/firmware/target/arm/olympus/mrobe-100/button-mr100.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-100/button-mr100.c')
-rw-r--r--firmware/target/arm/olympus/mrobe-100/button-mr100.c95
1 files changed, 26 insertions, 69 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c
index 130c32739a..d4479278ef 100644
--- a/firmware/target/arm/olympus/mrobe-100/button-mr100.c
+++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c
@@ -28,10 +28,6 @@
28#define LOGF_ENABLE 28#define LOGF_ENABLE
29#include "logf.h" 29#include "logf.h"
30 30
31#define MEP_BUTTON_HEADER 0x1a
32#define MEP_BUTTON_ID 0x9
33#define MEP_ABSOLUTE_HEADER 0x0b
34
35static int int_btn = BUTTON_NONE; 31static int int_btn = BUTTON_NONE;
36 32
37#ifndef BOOTLOADER 33#ifndef BOOTLOADER
@@ -56,9 +52,9 @@ void button_init_device(void)
56 GPIOD_OUTPUT_EN |= 0x4; /* DATA */ 52 GPIOD_OUTPUT_EN |= 0x4; /* DATA */
57 GPIOD_OUTPUT_VAL |= 0x4; /* high */ 53 GPIOD_OUTPUT_VAL |= 0x4; /* high */
58 54
59 if (!syn_init()) 55 if (!touchpad_init())
60 { 56 {
61 logf("button_init_dev: touchpad not ready"); 57 logf("touchpad not ready");
62 } 58 }
63} 59}
64 60
@@ -67,73 +63,34 @@ void button_init_device(void)
67 */ 63 */
68void button_int(void) 64void button_int(void)
69{ 65{
70 int data[4]; 66 char data[4];
71 int val, id; 67 int val;
72 68
73 int_btn = BUTTON_NONE; 69 int_btn = BUTTON_NONE;
74 70
75 if (syn_get_status()) 71 val = touchpad_read_device(data, 4);
72
73 if (val == MEP_BUTTON_HEADER)
74 {
75 /* Buttons packet - touched one of the 5 "buttons" */
76 if (data[1] & 0x1) int_btn |= BUTTON_PLAY;
77 if (data[1] & 0x2) int_btn |= BUTTON_MENU;
78 if (data[1] & 0x4) int_btn |= BUTTON_LEFT;
79 if (data[1] & 0x8) int_btn |= BUTTON_DISPLAY;
80 if (data[2] & 0x1) int_btn |= BUTTON_RIGHT;
81 }
82 else if (val == MEP_ABSOLUTE_HEADER)
76 { 83 {
77 /* disable interrupt while we read the touchpad */ 84 /* Absolute packet - the finger is on the vertical strip.
78 syn_int_enable(false); 85 Position ranges from 1-4095, with 1 at the bottom. */
79 86 val = ((data[1] >> 4) << 8) | data[2]; /* position */
80 val = syn_read(data, 4); 87
81 if (val > 0) 88 if ((val > 0) && (val <= 1365))
82 { 89 int_btn |= BUTTON_DOWN;
83 val = data[0] & 0xff; /* packet header */ 90 else if ((val > 1365) && (val <= 2730))
84 id = (data[1] >> 4) & 0xf; /* packet id */ 91 int_btn |= BUTTON_SELECT;
85 92 else if ((val > 2730) && (val <= 4095))
86 logf("button_read_device..."); 93 int_btn |= BUTTON_UP;
87 logf(" data[0] = 0x%08x", data[0]);
88 logf(" data[1] = 0x%08x", data[1]);
89 logf(" data[2] = 0x%08x", data[2]);
90 logf(" data[3] = 0x%08x", data[3]);
91
92 if ((val == MEP_BUTTON_HEADER) && (id == MEP_BUTTON_ID))
93 {
94 /* Buttons packet - touched one of the 5 "buttons" */
95 if (data[1] & 0x1)
96 int_btn |= BUTTON_PLAY;
97 if (data[1] & 0x2)
98 int_btn |= BUTTON_MENU;
99 if (data[1] & 0x4)
100 int_btn |= BUTTON_LEFT;
101 if (data[1] & 0x8)
102 int_btn |= BUTTON_DISPLAY;
103 if (data[2] & 0x1)
104 int_btn |= BUTTON_RIGHT;
105
106 /* An Absolute packet should follow which we ignore */
107 val = syn_read(data, 4);
108
109 logf(" int_btn = 0x%04x", int_btn);
110 }
111 else if (val == MEP_ABSOLUTE_HEADER)
112 {
113 /* Absolute packet - the finger is on the vertical strip.
114 Position ranges from 1-4095, with 1 at the bottom. */
115 val = ((data[1] >> 4) << 8) | data[2]; /* position */
116
117 logf(" pos %d", val);
118 logf(" z %d", data[3]);
119 logf(" finger %d", data[1] & 0x1);
120 logf(" gesture %d", data[1] & 0x2);
121 logf(" RelPosVld %d", data[1] & 0x4);
122
123 if(data[1] & 0x1) /* if finger on touch strip */
124 {
125 if ((val > 0) && (val <= 1365))
126 int_btn |= BUTTON_DOWN;
127 else if ((val > 1365) && (val <= 2730))
128 int_btn |= BUTTON_SELECT;
129 else if ((val > 2730) && (val <= 4095))
130 int_btn |= BUTTON_UP;
131 }
132 }
133 }
134
135 /* re-enable interrupts */
136 syn_int_enable(true);
137 } 94 }
138} 95}
139#else 96#else