From d8e16a2b4f53f49ad7c66919bef05cdc03c06d4c Mon Sep 17 00:00:00 2001 From: pelya Date: Wed, 1 Feb 2012 12:53:25 +0200 Subject: [PATCH] Fixed hardware mouse detection, fixed Ballfield example --- project/java/Video.java | 23 +++++++++++++++++-- .../jni/application/ballfield/ballfield.cpp | 21 ++++++++--------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/project/java/Video.java b/project/java/Video.java index c7b7c4711..54102b956 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -226,8 +226,27 @@ abstract class DifferentTouchInput if( touchEvents[id].down ) action = Mouse.SDL_FINGER_MOVE; else - action = Mouse.SDL_FINGER_HOVER; //action = Mouse.SDL_FINGER_DOWN; - //touchEvents[id].down = true; + action = Mouse.SDL_FINGER_HOVER; + if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1 ) + { + // Noneycomb has no excuse for sending such hackish mouse events, it has a dedicated ACTION_HOVER_MOVE event + action = Mouse.SDL_FINGER_DOWN; + touchEvents[id].down = true; + } + else + { + // Beagleboard with Android 2.3.3 sends ACTION_MOVE for USB mouse movements, without sending ACTION_DOWN first + // So we're guessing if we have Android 2.X and USB mouse, if there are no other fingers touching the screen + for( int iii = 0; iii < touchEventMax; iii++ ) + { + if( touchEvents[iii].down ) + { + action = Mouse.SDL_FINGER_DOWN; + touchEvents[id].down = true; + break; + } + } + } touchEvents[id].x = (int)event.getX(ii); touchEvents[id].y = (int)event.getY(ii); touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0); diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index fc6cc8d61..8509dd0fe 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -569,6 +569,7 @@ int main(int argc, char* argv[]) // UNALIGNED MEMORY ACCESS HERE! However all the devices that I have won't report it and won't send a signal or write to the /proc/kmsg, // despite the /proc/cpu/alignment flag set. +/* unsigned * ptr = (unsigned *)(data); unaligned_test(ptr, &val0); * ((unsigned *)&ptr) += 1; @@ -579,7 +580,9 @@ int main(int argc, char* argv[]) unaligned_test(ptr, &val3); * ((unsigned *)&ptr) += 1; unaligned_test(ptr, &val4); +*/ } +/* print_num(screen, font, screen->w-37, screen->h-12, fps); print_num_hex(screen, font_hex, 0, 40, val0); print_num_hex(screen, font_hex, 0, 60, val1); @@ -587,7 +590,7 @@ int main(int argc, char* argv[]) print_num_hex(screen, font_hex, 0, 100, val3); print_num_hex(screen, font_hex, 0, 120, val4); print_num_hex(screen, font_hex, 0, 180, 0x12345678); - +*/ ++fps_count; for(i=0; i 0xff ) - color = 0xff; - color = color + color * 0x100 + color * 0x10000; - SDL_FillRect(screen, &r, color); + SDL_FillRect(screen, &r, 0xaaaaaa); print_num(screen, font, r.x, r.y, i+1); } int mx, my; @@ -664,14 +663,14 @@ int main(int argc, char* argv[]) */ if( evt.type == SDL_JOYAXISMOTION ) { - if( evt.jaxis.which == 0 ) + if( evt.jaxis.which == 0 ) // 0 = The accelerometer continue; int joyid = evt.jaxis.which - 1; - touchPointers[joyid][evt.jaxis.axis] = evt.jaxis.value; + touchPointers[joyid][evt.jaxis.axis] = evt.jaxis.value; // Axis 0 and 1 are coordinates, 2 and 3 are pressure and touch point radius } if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP ) { - if( evt.jbutton.which == 0 ) + if( evt.jbutton.which == 0 ) // 0 = The accelerometer continue; int joyid = evt.jbutton.which - 1; touchPointers[joyid][PTR_PRESSED] = (evt.jbutton.state == SDL_PRESSED);