Fixed hardware mouse detection, fixed Ballfield example
This commit is contained in:
@@ -226,8 +226,27 @@ abstract class DifferentTouchInput
|
|||||||
if( touchEvents[id].down )
|
if( touchEvents[id].down )
|
||||||
action = Mouse.SDL_FINGER_MOVE;
|
action = Mouse.SDL_FINGER_MOVE;
|
||||||
else
|
else
|
||||||
action = Mouse.SDL_FINGER_HOVER; //action = Mouse.SDL_FINGER_DOWN;
|
action = Mouse.SDL_FINGER_HOVER;
|
||||||
//touchEvents[id].down = true;
|
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].x = (int)event.getX(ii);
|
||||||
touchEvents[id].y = (int)event.getY(ii);
|
touchEvents[id].y = (int)event.getY(ii);
|
||||||
touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0);
|
touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0);
|
||||||
|
|||||||
@@ -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,
|
// 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.
|
// despite the /proc/cpu/alignment flag set.
|
||||||
|
/*
|
||||||
unsigned * ptr = (unsigned *)(data);
|
unsigned * ptr = (unsigned *)(data);
|
||||||
unaligned_test(ptr, &val0);
|
unaligned_test(ptr, &val0);
|
||||||
* ((unsigned *)&ptr) += 1;
|
* ((unsigned *)&ptr) += 1;
|
||||||
@@ -579,7 +580,9 @@ int main(int argc, char* argv[])
|
|||||||
unaligned_test(ptr, &val3);
|
unaligned_test(ptr, &val3);
|
||||||
* ((unsigned *)&ptr) += 1;
|
* ((unsigned *)&ptr) += 1;
|
||||||
unaligned_test(ptr, &val4);
|
unaligned_test(ptr, &val4);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
print_num(screen, font, screen->w-37, screen->h-12, fps);
|
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, 40, val0);
|
||||||
print_num_hex(screen, font_hex, 0, 60, val1);
|
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, 100, val3);
|
||||||
print_num_hex(screen, font_hex, 0, 120, val4);
|
print_num_hex(screen, font_hex, 0, 120, val4);
|
||||||
print_num_hex(screen, font_hex, 0, 180, 0x12345678);
|
print_num_hex(screen, font_hex, 0, 180, 0x12345678);
|
||||||
|
*/
|
||||||
++fps_count;
|
++fps_count;
|
||||||
|
|
||||||
for(i=0; i<MAX_POINTERS; i++)
|
for(i=0; i<MAX_POINTERS; i++)
|
||||||
@@ -596,15 +599,11 @@ int main(int argc, char* argv[])
|
|||||||
continue;
|
continue;
|
||||||
r.x = touchPointers[i][0];
|
r.x = touchPointers[i][0];
|
||||||
r.y = touchPointers[i][1];
|
r.y = touchPointers[i][1];
|
||||||
r.w = 50 + touchPointers[i][3] / 10;
|
r.w = 80 + touchPointers[i][2] / 10; // Pressure
|
||||||
r.h = 50 + touchPointers[i][3] / 10;
|
r.h = 80 + touchPointers[i][3] / 10; // Touch point size
|
||||||
r.x -= r.w/2;
|
r.x -= r.w/2;
|
||||||
r.y -= r.h/2;
|
r.y -= r.h/2;
|
||||||
Uint32 color = touchPointers[i][3] / 5 + 0x7f;
|
SDL_FillRect(screen, &r, 0xaaaaaa);
|
||||||
if( color > 0xff )
|
|
||||||
color = 0xff;
|
|
||||||
color = color + color * 0x100 + color * 0x10000;
|
|
||||||
SDL_FillRect(screen, &r, color);
|
|
||||||
print_num(screen, font, r.x, r.y, i+1);
|
print_num(screen, font, r.x, r.y, i+1);
|
||||||
}
|
}
|
||||||
int mx, my;
|
int mx, my;
|
||||||
@@ -664,14 +663,14 @@ int main(int argc, char* argv[])
|
|||||||
*/
|
*/
|
||||||
if( evt.type == SDL_JOYAXISMOTION )
|
if( evt.type == SDL_JOYAXISMOTION )
|
||||||
{
|
{
|
||||||
if( evt.jaxis.which == 0 )
|
if( evt.jaxis.which == 0 ) // 0 = The accelerometer
|
||||||
continue;
|
continue;
|
||||||
int joyid = evt.jaxis.which - 1;
|
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.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
|
||||||
{
|
{
|
||||||
if( evt.jbutton.which == 0 )
|
if( evt.jbutton.which == 0 ) // 0 = The accelerometer
|
||||||
continue;
|
continue;
|
||||||
int joyid = evt.jbutton.which - 1;
|
int joyid = evt.jbutton.which - 1;
|
||||||
touchPointers[joyid][PTR_PRESSED] = (evt.jbutton.state == SDL_PRESSED);
|
touchPointers[joyid][PTR_PRESSED] = (evt.jbutton.state == SDL_PRESSED);
|
||||||
|
|||||||
Reference in New Issue
Block a user