Author Topic: ODK project set up: initial issues  (Read 28112 times)

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
ODK project set up: initial issues
« on: January 12, 2013, 05:05:19 PM »
I finished setting up the ODK project and ran some quick preliminary tests (I had to give up the TV so my son can get his fix of Zelda OOT, so I won't be able to test more extensively until after he goes to bed).

The most immediate problem is with input.  The app is detecting rapid-fire of a key (need to investigate which one), which prevents mapping buttons.  Additionally, in-game the input plug-in is detecting random analog input, making it impossible to navigate any N64 menus even with the controller touchpad.  So basically I can see Mario's head, and press start to get to the game selection screen, then I'm stuck.  I'll have to resolve this issue first before I can really tackle any other problems.  I'll take a look at the controller diagnostics once I get the TV back :)

Another immediate problem is with performance.  I couldn't get very far into the game because of the input issue, but I was getting steady audio skipping even in the game selection screen of Mario 64.  Side-loaded 1.9.2 runs full-speed, so not sure what the difference is.  At least I know it is possible to get great performance on the OUYA - just have to track down what is causing the slowness in the ODK build/ 2.0 vs. the 1.9.2 Android build.  There are quite a few differences between these versions, so lots of potential suspects to look at.  Will also be useful to look at Frame Skip settings, differences between the video plug-ins, and governor settings (in case you couldn't tell, the GS3 slowness issue is still fresh on my mind).
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #1 on: January 12, 2013, 05:21:28 PM »
Strange.  Hopefully the diagnostics screen will uncover what's going on.

My Nexus 7 runs pretty much the same hardware and OS as far as I know, and the out-of-box default settings are smooth as butter on Mario.  So if you have to fuss with settings to get good performance then something's wrong.

Watching this thread closely, excited to hear about the progress.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #2 on: January 12, 2013, 05:24:11 PM »
Regarding the governor, don't know much about it but makes me wonder what the API is for turning it off.  Since I guess there are some apps that will do it?  Wonder if/why SG3 doesn't have problems with other games.  Be nice if it's just a flag to set.  Wishful thinking...
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: ODK project set up: initial issues
« Reply #3 on: January 12, 2013, 05:37:39 PM »
Actually, thinking about the input thing, it probably isn't rapid-fire of a button at all.  Since the input mapper listens to axes and there is random axes input going on (visible by the hand moving around sporadically in the game selection screen for Mario 64), that would of course cause the listener to immediately close when I press a control to map.  Could be a dead-zone problem maybe.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #4 on: January 12, 2013, 05:42:32 PM »
The mapping listener has 50% deadzone built in.  Plus 10% hysteresis to keep the ui respnsive.  Strange...
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #5 on: January 12, 2013, 06:04:03 PM »
I bet I know what's going on.  Touchpad is probably bound to AXIS_X and AXIS_Y in the hardware (which is Android spec for pointing devices), with a range in each axis from 0 to a few hundred.  The left analog stick is also bound in hardware to those axes (also following spec).  The listener is expecting a range of -1 to 1, so deadzone is blown out of the water, and even a touch movement of 0.1 pixel (inevitable) sends a new signal to the listener.  Somehow we need to ignore input from that device.  The easy hack is to make the listener ignore anything larger than 1.  That would be done in LazyProvider.java, in onInput([],[])
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: ODK project set up: initial issues
« Reply #6 on: January 12, 2013, 06:05:39 PM »
Excellent!  I'll take a look at this now.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #7 on: January 12, 2013, 06:11:41 PM »
Actually, make the fix in AxisProvider.java, that will take care of the in-game problem as well.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #8 on: January 12, 2013, 06:16:16 PM »
The key piece is shown below.  But now that I look at it, I see I was already normalizing to [-1,1].  Unless the touchpad is faulty and providing the wrong values in motion.getRange().  Possible since it's still prototype hardware.  Nonetheless, you could add a sanity check at the very end of the block to set strengths(i) to zero if abs(strengths(i)) > 1.

Code: [Select]
        public boolean onGenericMotion( View v, MotionEvent event )
        {
            InputDevice device = event.getDevice();
           
            // Read all the requested axes
            float[] strengths = new float[mInputCodes.length];
            for( int i = 0; i < mInputCodes.length; i++ )
            {
                int inputCode = mInputCodes[i];
               
                // Compute the axis code from the input code
                int axisCode = inputToAxisCode( inputCode );
               
                // Get the analog value using the Android API
                float strength = event.getAxisValue( axisCode );
                MotionRange motionRange = device.getMotionRange( axisCode );
                if( motionRange != null )
                    strength = 2f * ( strength - motionRange.getMin() ) / motionRange.getRange() - 1f;
               
                // If the strength points in the correct direction, record it
                boolean direction1 = inputToAxisDirection( inputCode );
                boolean direction2 = strength > 0;
                if( direction1 == direction2 )
                    strengths[i] = Math.abs( strength );
                else
                    strengths[i] = 0;
            }
           
            // Notify listeners about new input data
            notifyListeners( mInputCodes, strengths, getHardwareId( event ) );
           
            return true;
        }
« Last Edit: January 12, 2013, 06:17:55 PM by littleguy »
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: ODK project set up: initial issues
« Reply #9 on: January 12, 2013, 11:57:55 PM »
Finally had a chance to run the input diagnostic, and getting the following output.  All numbers are stable except for the two I indicated below.  The controller is perfectly still - not touching or moving it.

Code: [Select]
MotionEvent:
Device: 2 (OUYA Game Controller)
Action: MOVE

AXIS_X: -1.52587.....E-5
AXIS_Y: -1.52587.....E-5
AXIS_PRESSURE: 0.0
AXIS_VSCROLL: 0.0
AXIS_X: -1.52587.....E-5
AXIS_Y: -1.52587.....E-5
AXIS_LTRIGGER: 0.0      <-----------Constant, rapid flashing between 0.0 and numbers in the range [0.10, 0.16]
AXIS_Z: 0.2###.....     <----------Changes periodically, sometimes flashes rapidly.  Stays in the range [0.23, 0.28]
AXIS_RZ: 0.0
AXIS_RTRIGGER: 0.0
AXIS_GENERIC_1: 0.0
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #10 on: January 13, 2013, 12:07:27 AM »
Strange.  Do the numbers settle down and track your motion when you pull the left trigger and move the right stick?  Wondering if it's as simple as a flaky controller.  How does the other controller respond?

Those flickering numbers are still small; they *should* fall inside the mapping listener's deadband and not mess up anything.

Do the digital buttons work fine in the diagnostics?
Do touchpad inputs show up on the diagnostics?  (I'm guessing they're the first four AXIS channels?)

As an aside, that mostly follows the PS3 bindings, so it's nice they stayed vanilla.  What does AXIS_GENERIC_1 refer to?
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: ODK project set up: initial issues
« Reply #11 on: January 13, 2013, 12:52:46 AM »
Do the numbers settle down and track your motion when you pull the left trigger and move the right stick?
Yes, when pulling the trigger, it goes to 1.0 with no problem, and when down or up on the right stick it goes to -1.0, 1.0 no problem.

Wondering if it's as simple as a flaky controller.  How does the other controller respond?
Both behave similarly.  It might possibly be a tad more stable (or I might just be imagining things).  And the Axis_X rows tends to stop on a number in the range [0.1, 0.2], but I can tap the left stick and they go back to -1.5...E-5.  I still can't map anything in the controller mapping screen, though.  The AXIS_Y (-), (axis up) control seems to be always highlighted blue.  I assume that means it thinks it is pressed, which is odd since it is showing virtually zero in the diagnostic screen.

Do the digital buttons work fine in the diagnostics?
Yes

Do touchpad inputs show up on the diagnostics?  (I'm guessing they're the first four AXIS channels?)
Correct, showing values in the hundreds I think, but changes so rapidly that it's hard to tell (just a blur of numbers)

What does AXIS_GENERIC_1 refer to?
Was wondering that myself.  It is always 0.0, can't get it to change by doing anything on the controller.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: ODK project set up: initial issues
« Reply #12 on: January 13, 2013, 12:56:17 AM »
Also, it is running quite smoothly now.  Not sure if the OUYA was busy doing something the first time I tested, but no audio skipping any more (for now at least!)
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #13 on: January 13, 2013, 10:35:12 AM »
When I get a chance today I'll post a new default keymapping that should allow your controllers to work out of the box.  Maybe not push to the main repo yet, but enough for you to test the controller in-game on a local build.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: ODK project set up: initial issues
« Reply #14 on: January 13, 2013, 02:44:26 PM »
I just pushed the input map for the OUYA controller.  Just go into preferences.xml and change line 147 from

Code: [Select]
android:defaultValue="@string/inputMap_defaultOn"
to

Code: [Select]
android:defaultValue="@string/inputMap_defaultOn_OUYA"
Similarly for lines 168, 174, 180.

Just be sure to reset preferences to their defaults in the settings menu.  This should allow you to test the controller in-game without having the mapping process get in the way.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version