Commit 8dc11a3a authored by Alexandre Julliard's avatar Alexandre Julliard

wineandroid: Add support for keyboard events.

parent db742a49
......@@ -4,6 +4,7 @@ IMPORTS = user32 gdi32 ntoskrnl
C_SRCS = \
device.c \
init.c \
keyboard.c \
window.c
IN_SRCS = \
......
......@@ -31,6 +31,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.TextureView;
......@@ -54,6 +55,7 @@ public class WineActivity extends Activity
public native void wine_desktop_changed( int width, int height );
public native void wine_surface_changed( int hwnd, Surface surface );
public native boolean wine_motion_event( int hwnd, int action, int x, int y, int state, int vscroll );
public native boolean wine_keyboard_event( int hwnd, int action, int keycode, int state );
private final String LOGTAG = "wine";
private ProgressDialog progress_dialog;
......@@ -389,6 +391,8 @@ public class WineActivity extends Activity
setSurfaceTextureListener( this );
setVisibility( VISIBLE );
setOpaque( false );
setFocusable( true );
setFocusableInTouchMode( true );
}
public WineWindow get_window()
......@@ -450,6 +454,17 @@ public class WineActivity extends Activity
return wine_motion_event( window.hwnd, event.getAction(), pos[0], pos[1],
event.getButtonState(), 0 );
}
public boolean dispatchKeyEvent( KeyEvent event )
{
Log.i( LOGTAG, String.format( "view key event win %08x action %d keycode %d (%s)",
window.hwnd, event.getAction(), event.getKeyCode(),
event.keyCodeToString( event.getKeyCode() )));;
boolean ret = wine_keyboard_event( window.hwnd, event.getAction(), event.getKeyCode(),
event.getMetaState() );
if (!ret) ret = super.dispatchKeyEvent(event);
return ret;
}
}
// The top-level desktop view group
......
......@@ -87,12 +87,15 @@ extern void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height )
extern void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface ) DECLSPEC_HIDDEN;
extern jboolean motion_event( JNIEnv *env, jobject obj, jint win, jint action,
jint x, jint y, jint state, jint vscroll ) DECLSPEC_HIDDEN;
extern jboolean keyboard_event( JNIEnv *env, jobject obj, jint win, jint action,
jint keycode, jint state ) DECLSPEC_HIDDEN;
enum event_type
{
DESKTOP_CHANGED,
SURFACE_CHANGED,
MOTION_EVENT,
KEYBOARD_EVENT,
};
union event_data
......@@ -118,6 +121,12 @@ union event_data
HWND hwnd;
INPUT input;
} motion;
struct
{
enum event_type type;
HWND hwnd;
INPUT input;
} kbd;
};
int send_event( const union event_data *data );
......
......@@ -392,6 +392,7 @@ static const JNINativeMethod methods[] =
{ "wine_desktop_changed", "(II)V", desktop_changed },
{ "wine_surface_changed", "(ILandroid/view/Surface;)V", surface_changed },
{ "wine_motion_event", "(IIIIII)Z", motion_event },
{ "wine_keyboard_event", "(IIII)Z", keyboard_event },
};
#define DECL_FUNCPTR(f) typeof(f) * p##f = NULL
......
......@@ -405,6 +405,9 @@ static int process_events( DWORD mask )
}
else if (mask & QS_MOUSEMOVE) break;
continue; /* skip it */
case KEYBOARD_EVENT:
if (mask & QS_KEY) break;
continue; /* skip it */
default:
if (mask & QS_SENDMESSAGE) break;
continue; /* skip it */
......@@ -470,6 +473,18 @@ static int process_events( DWORD mask )
}
break;
case KEYBOARD_EVENT:
if (event->data.kbd.input.u.ki.dwFlags & KEYEVENTF_KEYUP)
TRACE("KEYUP hwnd %p vkey %x '%c' scancode %x\n", event->data.kbd.hwnd,
event->data.kbd.input.u.ki.wVk, event->data.kbd.input.u.ki.wVk,
event->data.kbd.input.u.ki.wScan );
else
TRACE("KEYDOWN hwnd %p vkey %x '%c' scancode %x\n", event->data.kbd.hwnd,
event->data.kbd.input.u.ki.wVk, event->data.kbd.input.u.ki.wVk,
event->data.kbd.input.u.ki.wScan );
__wine_send_input( 0, &event->data.kbd.input );
break;
default:
FIXME( "got event %u\n", event->data.type );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment