summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsungmin ha <sungmin82.ha@samsung.com>2015-04-28 22:24:45 +0900
committersungmin ha <sungmin82.ha@samsung.com>2015-04-28 22:32:50 +0900
commit1a4656cf25b8eed9f9f7400a9558a0d446905852 (patch)
treeb0bc19c1f463a7336f8ffd31ca63baa7c1434b92
parentfc2cea975e2ede057afe8f66c471e131a35a5af0 (diff)
downloademulator-kernel-1a4656cf25b8eed9f9f7400a9558a0d446905852.tar.gz
emulator-kernel-1a4656cf25b8eed9f9f7400a9558a0d446905852.tar.bz2
emulator-kernel-1a4656cf25b8eed9f9f7400a9558a0d446905852.zip
rotary: modified for rapidly pass through multiple detents
Change-Id: I42a85b7136b0170cfd89463d771bc1f26f429a84 Signed-off-by: sungmin ha <sungmin82.ha@samsung.com>
-rwxr-xr-xdrivers/maru/maru_virtio_rotary.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/maru/maru_virtio_rotary.c b/drivers/maru/maru_virtio_rotary.c
index bc5cc5f37777..b8f3f69fb721 100755
--- a/drivers/maru/maru_virtio_rotary.c
+++ b/drivers/maru/maru_virtio_rotary.c
@@ -95,7 +95,9 @@ static void vq_rotary_handler(struct virtqueue *vq)
void *data;
struct rotary_event event;
+ int i = 0;
int pos = 0;
+ int value = 0;
data = virtqueue_get_buf(vq, &len);
if (!data) {
@@ -104,7 +106,8 @@ static void vq_rotary_handler(struct virtqueue *vq)
}
while (1) {
- memcpy(&event, &vrtr->event[vqidx], sizeof(struct rotary_event));
+ memcpy(&event, &vrtr->event[vqidx],
+ sizeof(struct rotary_event));
event.delta %= 360;
if (event.delta == 0) {
@@ -117,26 +120,34 @@ static void vq_rotary_handler(struct virtqueue *vq)
"rotary event: vqidx(%d), event.delta(%d), pos(%d)\n",
vqidx, event.delta, pos);
- if ((pos % DETENT_UNIT) == 0) {
- input_report_rel(vrtr->idev, REL_WHEEL, 1);
- if (get_rotary_pos(pos) != last_detent) {
- last_detent = get_rotary_pos(pos);
- if (event.delta > 0) {
- input_report_rel(vrtr->idev, REL_WHEEL, 2);
+ for (i = 1; i <= abs(event.delta); i++) {
+ value = (event.delta > 0) ? last_pos + i : last_pos - i;
+ if ((value % DETENT_UNIT) == 0) {
+ input_report_rel(vrtr->idev, REL_WHEEL, 1);
+ if (get_rotary_pos(value) != last_detent) {
+ last_detent = get_rotary_pos(value);
+ if (event.delta > 0) { /* CW */
+ input_report_rel(vrtr->idev,
+ REL_WHEEL, 2);
+ } else { /* CCW */
+ input_report_rel(vrtr->idev,
+ REL_WHEEL, -2);
+ }
} else {
- input_report_rel(vrtr->idev, REL_WHEEL, -2);
+ input_report_rel(vrtr->idev,
+ REL_WHEEL, -1);
}
- } else {
- input_report_rel(vrtr->idev, REL_WHEEL, -1);
- }
- input_sync(vrtr->idev);
+ input_sync(vrtr->idev);
- VR_LOG(KERN_INFO, "event: delta(%d), detent(%d)\n", event.delta, last_detent);
+ VR_LOG(KERN_INFO, "event: delta(%d),detent(%d)\n",
+ event.delta, last_detent);
+ }
}
last_pos = pos;
- memset(&vrtr->event[vqidx], 0x00, sizeof(struct rotary_event));
+ memset(&vrtr->event[vqidx], 0x00,
+ sizeof(struct rotary_event));
vqidx++;
if (vqidx == ROTARY_BUF_SIZE) {
vqidx = 0;