RockboxBootloader => Rockbox
[kugel-rb.git] / firmware / target / hosted / android / button-android.c
blob2176d8a3ace4eadfab22b106554b657dc5b8eaa6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2010 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include <jni.h>
24 #include <stdbool.h>
25 #include "config.h"
26 #include "kernel.h"
27 #include "system.h"
30 extern jclass Framebuffer_class;
31 extern jobject Framebuffer_instance;
35 static long last_touch;
36 static int last_y, last_x;
37 static enum {
38 STATE_UNKNOWN,
39 STATE_UP,
40 STATE_DOWN,
41 } last_state = STATE_UNKNOWN;
43 JNIEXPORT void JNICALL Java_org_rockbox_RockboxFramebuffer_pixelHandler(JNIEnv*env, jobject this, int x, int y)
46 LOG("%s(): %d:%d\n", __func__, x, y);
48 last_x = x;
49 last_y = y;
50 last_touch = current_tick;
53 JNIEXPORT void JNICALL Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, int down)
55 if (down)
56 last_state = STATE_DOWN;
57 else
58 last_state = STATE_UP;
61 void button_init_device(void)
63 last_touch = current_tick;
66 int button_read_device(int *data)
68 int btn = touchscreen_to_pixels(last_x, last_y, data);
69 if (last_state == STATE_DOWN)
71 return btn;
73 else
75 *data = last_x = last_y = 0;
76 return 0;