Change application selection in configure. Make android raaa compile.
[kugel-rb.git] / firmware / target / hosted / android / button-android.c
blob67e8ca1f895714364c94903c9546d36d2ddd52c0
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"
28 #include "touchscreen.h"
30 static long last_touch;
31 static int last_y, last_x;
33 static enum {
34 STATE_UNKNOWN,
35 STATE_UP,
36 STATE_DOWN,
37 } last_state = STATE_UNKNOWN;
41 * this writes in an interrupt-like fashion the last pixel coordinates
42 * that the user pressed on the screen */
43 JNIEXPORT void JNICALL
44 Java_org_rockbox_RockboxFramebuffer_pixelHandler(JNIEnv*env, jobject this,
45 int x, int y)
47 (void)env;
48 (void)this;
49 last_x = x;
50 last_y = y;
51 last_touch = current_tick;
55 * this notifies us in an interrupt-like fashion whether the user just
56 * began or stopped the touch action */
57 JNIEXPORT void JNICALL
58 Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
59 int down)
61 (void)env;
62 (void)this;
63 if (down)
64 last_state = STATE_DOWN;
65 else
66 last_state = STATE_UP;
69 void button_init_device(void)
71 last_touch = current_tick;
74 int button_read_device(int *data)
76 /* get grid button/coordinates based on the current touchscreen mode */
77 int btn = touchscreen_to_pixels(last_x, last_y, data);
78 if (last_state == STATE_DOWN)
80 return btn;
82 else
84 *data = last_x = last_y = 0;
85 return 0;