forked from len0rd/rockbox
Add support multimedia keys/buttons to the core, and adapt Rockbox on android for it (multimedia buttons are found on wired headsets and the lock screen in cyanogenmod).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28421 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dbe2ac1ec6
commit
49f1ec8e8a
13 changed files with 300 additions and 17 deletions
|
@ -16,10 +16,21 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service android:name=".RockboxService"/>
|
<service android:name=".RockboxService"/>
|
||||||
|
<receiver android:name=".Helper.MediaButtonReceiver$MediaReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<activity android:name="KeyboardActivity"></activity>
|
<activity android:name="KeyboardActivity"></activity>
|
||||||
<activity android:name="YesnoActivity"></activity>
|
<activity android:name="YesnoActivity"></activity>
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="4" />
|
<uses-sdk android:minSdkVersion="4" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
164
android/src/org/rockbox/Helper/MediaButtonReceiver.java
Normal file
164
android/src/org/rockbox/Helper/MediaButtonReceiver.java
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Thomas Martitz
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
package org.rockbox.Helper;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.rockbox.RockboxService;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
|
public class MediaButtonReceiver
|
||||||
|
{
|
||||||
|
/* A note on the API being used. 2.2 introduces a new and sane API
|
||||||
|
* for handling multimedia button presses
|
||||||
|
* http://android-developers.blogspot.com/2010/06/allowing-applications-to-play-nicer.html
|
||||||
|
*
|
||||||
|
* the old API is flawed. It doesn't have management for
|
||||||
|
* concurrent media apps
|
||||||
|
*
|
||||||
|
* if multiple media apps are running
|
||||||
|
* probably all of them want to respond to media keys
|
||||||
|
*
|
||||||
|
* it's not clear which app wins, it depends on the
|
||||||
|
* priority set for the IntentFilter (see below)
|
||||||
|
*
|
||||||
|
* so this all might or might not work on < 2.2 */
|
||||||
|
|
||||||
|
IMultiMediaReceiver api;
|
||||||
|
|
||||||
|
public MediaButtonReceiver(Context c)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
api = new NewApi(c);
|
||||||
|
} catch (Exception e) {
|
||||||
|
api = new OldApi(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register()
|
||||||
|
{
|
||||||
|
api.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister()
|
||||||
|
{
|
||||||
|
api.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* helper class for the manifest */
|
||||||
|
public static class MediaReceiver extends BroadcastReceiver
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent)
|
||||||
|
{
|
||||||
|
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()))
|
||||||
|
{
|
||||||
|
KeyEvent key = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
|
||||||
|
if (key.getAction() == KeyEvent.ACTION_UP)
|
||||||
|
{ /* pass the pressed key to Rockbox */
|
||||||
|
if (RockboxService.get_instance().get_fb().dispatchKeyEvent(key))
|
||||||
|
abortBroadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface IMultiMediaReceiver
|
||||||
|
{
|
||||||
|
void register();
|
||||||
|
void unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class NewApi implements IMultiMediaReceiver
|
||||||
|
{
|
||||||
|
private Method register_method;
|
||||||
|
private Method unregister_method;
|
||||||
|
private AudioManager audio_manager;
|
||||||
|
private ComponentName receiver_name;
|
||||||
|
/* the constructor gets the methods through reflection so that
|
||||||
|
* this compiles on pre-2.2 devices */
|
||||||
|
NewApi(Context c) throws SecurityException, NoSuchMethodException
|
||||||
|
{
|
||||||
|
register_method = AudioManager.class.getMethod(
|
||||||
|
"registerMediaButtonEventReceiver",
|
||||||
|
new Class[] { ComponentName.class } );
|
||||||
|
unregister_method = AudioManager.class.getMethod(
|
||||||
|
"unregisterMediaButtonEventReceiver",
|
||||||
|
new Class[] { ComponentName.class } );
|
||||||
|
|
||||||
|
audio_manager = (AudioManager)c.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
receiver_name = new ComponentName(c, MediaReceiver.class);
|
||||||
|
}
|
||||||
|
public void register()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
register_method.invoke(audio_manager, receiver_name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Nothing
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
unregister_method.invoke(audio_manager, receiver_name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Nothing
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OldApi implements IMultiMediaReceiver
|
||||||
|
{
|
||||||
|
private static final IntentFilter filter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
|
||||||
|
private MediaReceiver receiver;
|
||||||
|
private Context context;
|
||||||
|
OldApi(Context c)
|
||||||
|
{
|
||||||
|
filter.setPriority(1); /* 1 higher than the built-in media player */
|
||||||
|
receiver = new MediaReceiver();
|
||||||
|
context = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register()
|
||||||
|
{
|
||||||
|
context.registerReceiver(receiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister()
|
||||||
|
{
|
||||||
|
context.unregisterReceiver(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,8 @@ package org.rockbox;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import org.rockbox.Helper.MediaButtonReceiver;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -35,6 +37,7 @@ public class RockboxFramebuffer extends View
|
||||||
{
|
{
|
||||||
private Bitmap btm;
|
private Bitmap btm;
|
||||||
private ByteBuffer native_buf;
|
private ByteBuffer native_buf;
|
||||||
|
private MediaButtonReceiver media_monitor;
|
||||||
|
|
||||||
public RockboxFramebuffer(Context c, int lcd_width,
|
public RockboxFramebuffer(Context c, int lcd_width,
|
||||||
int lcd_height, ByteBuffer native_fb)
|
int lcd_height, ByteBuffer native_fb)
|
||||||
|
@ -47,6 +50,8 @@ public class RockboxFramebuffer extends View
|
||||||
btm = Bitmap.createBitmap(lcd_width, lcd_height, Bitmap.Config.RGB_565);
|
btm = Bitmap.createBitmap(lcd_width, lcd_height, Bitmap.Config.RGB_565);
|
||||||
native_buf = native_fb;
|
native_buf = native_fb;
|
||||||
requestFocus();
|
requestFocus();
|
||||||
|
media_monitor = new MediaButtonReceiver(c);
|
||||||
|
media_monitor.register();
|
||||||
/* the service needs to know the about us */
|
/* the service needs to know the about us */
|
||||||
((RockboxService)c).set_fb(this);
|
((RockboxService)c).set_fb(this);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +127,12 @@ public class RockboxFramebuffer extends View
|
||||||
set_lcd_active(1);
|
set_lcd_active(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroy()
|
||||||
|
{
|
||||||
|
suspend();
|
||||||
|
media_monitor.unregister();
|
||||||
|
}
|
||||||
|
|
||||||
public native void set_lcd_active(int active);
|
public native void set_lcd_active(int active);
|
||||||
public native void touchHandler(boolean down, int x, int y);
|
public native void touchHandler(boolean down, int x, int y);
|
||||||
public native boolean buttonHandler(int keycode, boolean state);
|
public native boolean buttonHandler(int keycode, boolean state);
|
||||||
|
|
|
@ -139,6 +139,7 @@ public class RockboxService extends Service
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
LOG("main");
|
||||||
/* the following block unzips libmisc.so, which contains the files
|
/* the following block unzips libmisc.so, which contains the files
|
||||||
* we ship, such as themes. It's needed to put it into a .so file
|
* we ship, such as themes. It's needed to put it into a .so file
|
||||||
* because there's no other way to ship files and have access
|
* because there's no other way to ship files and have access
|
||||||
|
@ -276,6 +277,7 @@ public class RockboxService extends Service
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
fb.destroy();
|
||||||
/* Make sure our notification is gone. */
|
/* Make sure our notification is gone. */
|
||||||
stopForeground();
|
stopForeground();
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,8 +183,9 @@ static int get_action_worker(int context, int timeout,
|
||||||
else
|
else
|
||||||
button = button_get_w_tmo(timeout);
|
button = button_get_w_tmo(timeout);
|
||||||
|
|
||||||
/* Data from sys events can be pulled with button_get_data */
|
/* Data from sys events can be pulled with button_get_data
|
||||||
if (button == BUTTON_NONE || button & SYS_EVENT)
|
* multimedia button presses don't go through the action system */
|
||||||
|
if (button == BUTTON_NONE || button & (SYS_EVENT|BUTTON_MULTIMEDIA))
|
||||||
return button;
|
return button;
|
||||||
/* Don't send any buttons through untill we see the release event */
|
/* Don't send any buttons through untill we see the release event */
|
||||||
if (wait_for_release)
|
if (wait_for_release)
|
||||||
|
|
|
@ -1045,18 +1045,18 @@ long gui_wps_show(void)
|
||||||
exit = true;
|
exit = true;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case SYS_POWEROFF:
|
|
||||||
default_event_handler(SYS_POWEROFF);
|
|
||||||
break;
|
|
||||||
case ACTION_WPS_VIEW_PLAYLIST:
|
case ACTION_WPS_VIEW_PLAYLIST:
|
||||||
gwps_leave_wps();
|
gwps_leave_wps();
|
||||||
return GO_TO_PLAYLIST_VIEWER;
|
return GO_TO_PLAYLIST_VIEWER;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
switch(default_event_handler(button))
|
||||||
{
|
{ /* music has been stopped by the default handler */
|
||||||
gwps_leave_wps();
|
case SYS_USB_CONNECTED:
|
||||||
return GO_TO_ROOT;
|
case SYS_CALL_INCOMING:
|
||||||
|
case BUTTON_MULTIMEDIA_STOP:
|
||||||
|
gwps_leave_wps();
|
||||||
|
return GO_TO_ROOT;
|
||||||
}
|
}
|
||||||
update = true;
|
update = true;
|
||||||
break;
|
break;
|
||||||
|
|
16
apps/menu.c
16
apps/menu.c
|
@ -650,10 +650,20 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(default_event_handler(action) == SYS_USB_CONNECTED)
|
else
|
||||||
{
|
{
|
||||||
ret = MENU_ATTACHED_USB;
|
switch(default_event_handler(action))
|
||||||
done = true;
|
{
|
||||||
|
case SYS_USB_CONNECTED:
|
||||||
|
ret = MENU_ATTACHED_USB;
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
case SYS_CALL_HUNG_UP:
|
||||||
|
case BUTTON_MULTIMEDIA_PLAYPAUSE:
|
||||||
|
/* remove splash from playlist_resume() */
|
||||||
|
redraw_lists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_lists && !done)
|
if (redraw_lists && !done)
|
||||||
|
|
37
apps/misc.c
37
apps/misc.c
|
@ -529,6 +529,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
||||||
#if CONFIG_PLATFORM & PLATFORM_ANDROID
|
#if CONFIG_PLATFORM & PLATFORM_ANDROID
|
||||||
static bool resume = false;
|
static bool resume = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case SYS_BATTERY_UPDATE:
|
case SYS_BATTERY_UPDATE:
|
||||||
|
@ -629,10 +630,44 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
||||||
if (resume && playlist_resume() != -1)
|
if (resume && playlist_resume() != -1)
|
||||||
{
|
{
|
||||||
playlist_start(global_status.resume_index,
|
playlist_start(global_status.resume_index,
|
||||||
global_status.resume_offset);
|
global_status.resume_offset);
|
||||||
}
|
}
|
||||||
resume = false;
|
resume = false;
|
||||||
return SYS_CALL_HUNG_UP;
|
return SYS_CALL_HUNG_UP;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MULTIMEDIA_KEYS
|
||||||
|
/* multimedia keys on keyboards, headsets */
|
||||||
|
case BUTTON_MULTIMEDIA_PLAYPAUSE:
|
||||||
|
{
|
||||||
|
int status = audio_status();
|
||||||
|
if (status & AUDIO_STATUS_PLAY)
|
||||||
|
{
|
||||||
|
if (status & AUDIO_STATUS_PAUSE)
|
||||||
|
audio_resume();
|
||||||
|
else
|
||||||
|
audio_pause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (playlist_resume() != -1)
|
||||||
|
{
|
||||||
|
playlist_start(global_status.resume_index,
|
||||||
|
global_status.resume_offset);
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
case BUTTON_MULTIMEDIA_NEXT:
|
||||||
|
audio_next();
|
||||||
|
return event;
|
||||||
|
case BUTTON_MULTIMEDIA_PREV:
|
||||||
|
audio_prev();
|
||||||
|
return event;
|
||||||
|
case BUTTON_MULTIMEDIA_STOP:
|
||||||
|
list_stop_handler();
|
||||||
|
return event;
|
||||||
|
case BUTTON_MULTIMEDIA_REW:
|
||||||
|
case BUTTON_MULTIMEDIA_FFWD:
|
||||||
|
/* not supported yet, needs to be done in the WPS */
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -69,6 +69,21 @@ int button_apply_acceleration(const unsigned int data);
|
||||||
#define BUTTON_REL 0x02000000
|
#define BUTTON_REL 0x02000000
|
||||||
#define BUTTON_REPEAT 0x04000000
|
#define BUTTON_REPEAT 0x04000000
|
||||||
#define BUTTON_TOUCHSCREEN 0x08000000
|
#define BUTTON_TOUCHSCREEN 0x08000000
|
||||||
|
#define BUTTON_MULTIMEDIA 0x10000000
|
||||||
|
|
||||||
|
#define BUTTON_MULTIMEDIA_PLAYPAUSE (BUTTON_MULTIMEDIA|0x01)
|
||||||
|
#define BUTTON_MULTIMEDIA_STOP (BUTTON_MULTIMEDIA|0x02)
|
||||||
|
#define BUTTON_MULTIMEDIA_PREV (BUTTON_MULTIMEDIA|0x04)
|
||||||
|
#define BUTTON_MULTIMEDIA_NEXT (BUTTON_MULTIMEDIA|0x08)
|
||||||
|
#define BUTTON_MULTIMEDIA_REW (BUTTON_MULTIMEDIA|0x10)
|
||||||
|
#define BUTTON_MULTIMEDIA_FFWD (BUTTON_MULTIMEDIA|0x20)
|
||||||
|
|
||||||
|
#define BUTTON_MULTIMEDIA_ALL (BUTTON_MULTIMEDIA_PLAYPAUSE| \
|
||||||
|
BUTTON_MULTIMEDIA_STOP| \
|
||||||
|
BUTTON_MULTIMEDIA_PREV| \
|
||||||
|
BUTTON_MULTIMEDIA_NEXT| \
|
||||||
|
BUTTON_MULTIMEDIA_REW | \
|
||||||
|
BUTTON_MULTIMEDIA_FFWD)
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
int touchscreen_last_touch(void);
|
int touchscreen_last_touch(void);
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
|
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
|
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
|
||||||
#define CONFIG_KEYPAD ANDROID_PAD
|
#define CONFIG_KEYPAD ANDROID_PAD
|
||||||
|
#define HAVE_MULTIMEDIA_KEYS
|
||||||
#elif (CONFIG_PLATFORM & PLATFORM_SDL)
|
#elif (CONFIG_PLATFORM & PLATFORM_SDL)
|
||||||
#define HAVE_SCROLLWHEEL
|
#define HAVE_SCROLLWHEEL
|
||||||
#define CONFIG_KEYPAD SDL_PAD
|
#define CONFIG_KEYPAD SDL_PAD
|
||||||
|
|
|
@ -45,3 +45,24 @@ int key_to_button(int keyboard_key)
|
||||||
return BUTTON_MENU;
|
return BUTTON_MENU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned multimedia_to_button(int keyboard_key)
|
||||||
|
{
|
||||||
|
switch (keyboard_key)
|
||||||
|
{
|
||||||
|
case KEYCODE_MEDIA_PLAY_PAUSE:
|
||||||
|
return BUTTON_MULTIMEDIA_PLAYPAUSE;
|
||||||
|
case KEYCODE_MEDIA_STOP:
|
||||||
|
return BUTTON_MULTIMEDIA_STOP;
|
||||||
|
case KEYCODE_MEDIA_NEXT:
|
||||||
|
return BUTTON_MULTIMEDIA_NEXT;
|
||||||
|
case KEYCODE_MEDIA_PREVIOUS:
|
||||||
|
return BUTTON_MULTIMEDIA_PREV;
|
||||||
|
case KEYCODE_MEDIA_REWIND:
|
||||||
|
return BUTTON_MULTIMEDIA_REW;
|
||||||
|
case KEYCODE_MEDIA_FAST_FORWARD:
|
||||||
|
return BUTTON_MULTIMEDIA_FFWD;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#undef button_init_device
|
#undef button_init_device
|
||||||
void button_init_device(void);
|
void button_init_device(void);
|
||||||
int button_read_device(int *data);
|
int button_read_device(int *data);
|
||||||
|
unsigned multimedia_to_button(int keyboard_key);
|
||||||
|
|
||||||
/* Main unit's buttons */
|
/* Main unit's buttons */
|
||||||
#define BUTTON_MENU 0x00000001
|
#define BUTTON_MENU 0x00000001
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "touchscreen.h"
|
#include "touchscreen.h"
|
||||||
|
#include "debug.h"
|
||||||
static int last_y, last_x;
|
static int last_y, last_x;
|
||||||
static int last_btns;
|
static int last_btns;
|
||||||
static long last_button_tick;
|
static long last_button_tick;
|
||||||
|
@ -44,7 +44,7 @@ static enum {
|
||||||
* began or stopped the touch action + where (pixel coordinates) */
|
* began or stopped the touch action + where (pixel coordinates) */
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
|
Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
|
||||||
bool down, int x, int y)
|
jboolean down, jint x, jint y)
|
||||||
{
|
{
|
||||||
(void)env;
|
(void)env;
|
||||||
(void)this;
|
(void)this;
|
||||||
|
@ -63,12 +63,23 @@ Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
|
||||||
* generated by pressing/releasing them to a variable */
|
* generated by pressing/releasing them to a variable */
|
||||||
JNIEXPORT bool JNICALL
|
JNIEXPORT bool JNICALL
|
||||||
Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this,
|
Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this,
|
||||||
int keycode, bool state)
|
jint keycode, jboolean state)
|
||||||
{
|
{
|
||||||
(void)env;
|
(void)env;
|
||||||
(void)this;
|
(void)this;
|
||||||
|
|
||||||
int button = key_to_button(keycode);
|
unsigned button = 0;
|
||||||
|
|
||||||
|
if (!state)
|
||||||
|
button = multimedia_to_button((int)keycode);
|
||||||
|
|
||||||
|
if (button)
|
||||||
|
{ /* multimeida buttons are handled differently */
|
||||||
|
queue_post(&button_queue, button, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
button = key_to_button(keycode);
|
||||||
|
|
||||||
if (button == BUTTON_NONE)
|
if (button == BUTTON_NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue