wadetb / shellspace

One tiny step towards the VR Desktop Operating System
GNU General Public License v2.0
42 stars 11 forks source link

Bluetooth mouse support #9

Open wadetb opened 9 years ago

wadetb commented 9 years ago

Using the Android Motion events:

http://developer.android.com/reference/android/view/MotionEvent.html

Have to plumb this through from the Java code:

// VRLib/src/com/oculusvr/vrlib/VrActivity.java:
public static native void nativeKeyEvent(long appPtr, int keyNum, boolean down, int repeatCount );

// VRLib/jni/App.cpp
void Java_com_oculusvr_vrlib_VrActivity_nativeKeyEvent( JNIEnv *jni, jclass clazz,
        jlong appPtr, jint key, jboolean down, jint repeatCount )
{
    AppLocal * local = ((AppLocal *)appPtr);
    // Suspend input until OneTimeInit() has finished to avoid overflowing the message queue on long loads.
    if ( local->OneTimeInitCalled )
    {
        local->GetMessageQueue().PostPrintf( "key %i %i %i", key, down, repeatCount );
    }
}

if ( MatchesHead( "key ", msg ) )
{
    int key, down, repeatCount;
    sscanf( msg, "key %i %i %i", &key, &down, &repeatCount );
    KeyEvent( key, down, repeatCount );
    return; 
}