1
0
Fork 0

Allow application to provide separate user input events when key is pressed/typed/released.

This commit is contained in:
hpi1 2019-04-05 18:34:04 +03:00
parent f1390c99f5
commit 4d45011536
5 changed files with 49 additions and 9 deletions

View File

@ -1,5 +1,6 @@
2019-??-??: Version 1.2.0
- Add functions to list and read BD-ROM files.
- Add support for separate key pressed / typed / released user input events.
2019-06-07: Version 1.1.2
- Add libxml version to pkg-config Requires.private.

View File

@ -702,7 +702,7 @@ public class Libbluray {
break;
case BDJ_EVENT_VK_KEY:
switch (param) {
switch (param & 0xffff) {
case 0: key = KeyEvent.VK_0; break;
case 1: key = KeyEvent.VK_1; break;
case 2: key = KeyEvent.VK_2; break;
@ -733,9 +733,16 @@ public class Libbluray {
break;
}
if (key > 0) {
boolean r1 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_PRESSED, 0, key);
boolean r2 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_TYPED, 0, key);
boolean r3 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_RELEASED, 0, key);
boolean r1 = false, r2 = false, r3 = false;
if ((param & 0x80000000) != 0) {
r1 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_PRESSED, 0, key);
}
if ((param & 0x40000000) != 0) {
r2 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_TYPED, 0, key);
}
if ((param & 0x20000000) != 0) {
r3 = EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_RELEASED, 0, key);
}
result = r1 || r2 || r3;
}
break;

View File

@ -3654,12 +3654,21 @@ int bd_mouse_select(BLURAY *bd, int64_t pts, uint16_t x, uint16_t y)
return result;
}
#define BD_VK_FLAGS_MASK (BD_VK_KEY_PRESSED | BD_VK_KEY_TYPED | BD_VK_KEY_RELEASED)
#define BD_VK_KEY(k) ((k) & ~(BD_VK_FLAGS_MASK))
#define BD_VK_FLAGS(k) ((k) & BD_VK_FLAGS_MASK)
/* HDMV: key is triggered when pressed down */
#define BD_KEY_TYPED(k) (!((k) & (BD_VK_KEY_TYPED | BD_VK_KEY_RELEASED)))
int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key)
{
int result = -1;
if (key == BD_VK_ROOT_MENU) {
return bd_menu_call(bd, pts);
if (BD_VK_KEY(key) == BD_VK_ROOT_MENU) {
if (BD_KEY_TYPED(key)) {
return bd_menu_call(bd, pts);
}
return 0;
}
bd_mutex_lock(&bd->mutex);
@ -3667,8 +3676,17 @@ int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key)
_set_scr(bd, pts);
if (bd->title_type == title_hdmv) {
result = _run_gc(bd, GC_CTRL_VK_KEY, key);
if (BD_KEY_TYPED(key)) {
result = _run_gc(bd, GC_CTRL_VK_KEY, BD_VK_KEY(key));
} else {
result = 0;
}
} else if (bd->title_type == title_bdj) {
if (!BD_VK_FLAGS(key)) {
/* No flags --> single key press event */
key |= BD_VK_KEY_PRESSED | BD_VK_KEY_TYPED | BD_VK_KEY_RELEASED;
}
result = _bdj_event(bd, BDJ_EVENT_VK_KEY, key);
}

View File

@ -1013,9 +1013,14 @@ int bd_set_rate(BLURAY *bd, uint32_t rate);
* Pass user input to graphics controller or BD-J.
* Keys are defined in libbluray/keys.h.
*
* Two user input models are supported:
* - Single event when a key is typed once.
* - Separate events when key is pressed and released.
* VD_VK_KEY_PRESSED, BD_VK_TYPED and BD_VK_KEY_RELEASED are or'd with the key.
*
* @param bd BLURAY object
* @param pts current playback position (1/90000s) or -1
* @param key input key
* @param key input key (@see keys.h)
* @return <0 on error, 0 on success, >0 if selection/activation changed
*/
int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key);

View File

@ -1,6 +1,6 @@
/*
* This file is part of libbluray
* Copyright (C) 2010 hpi1
* Copyright (C) 2010-2019 Petri Hintukainen <phintuka@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -61,4 +61,13 @@ typedef enum {
} bd_vk_key_e;
/*
* Application may optionally provide KEY_PRESSED, KEY_TYPED and KEY_RELEASED events.
* These masks are OR'd with the key code when calling bd_user_input().
*/
#define BD_VK_KEY_PRESSED 0x80000000 /* Key was pressed down */
#define BD_VK_KEY_TYPED 0x40000000 /* Key was typed */
#define BD_VK_KEY_RELEASED 0x20000000 /* Key was released */
#endif // _BD_KEYS_H_