xbmc/xbmc — pull request #1170 by Memphiz (2012-07-16 19:00:21+00:00)
Title: Fix hold key presses in lists.

This fixes the issue where the lists are scrolled way to fast when holding down the cursor keys (thats also used when using remote controls most likly - at least on ios and with the nyxboard).

The code before assumed that the Action was called in time slices which are bigger then 1 sec. So it calcs the scrollspeed in itemsperframe by clamping it to a minimum of 1 item per frame. Our action handlers are called in timeslices around 30ms - so we are getting called about 300 times a sec. With the original code we would allways jump one item which leads to the fast scrolling.

The code maxes the speed so that each list is completly scrolled in 10 secs. (we should maybe rethink this - see below).

I have adapted the code so that we also throttle down if we are called really fast. Now we really get a 3 sec ramp up and then max speed so that the list is scrolled in 10 secs.

On homescreen where the horizontal list has only a hand full of items we would now need 10 secs to scroll these items from left to right while holding the key. Thats cause the max speed is dependend on the number of items in the list. I have hacked around it by setting max speed to 1sec/list if there are less then 10 items.

We should consider specifying a maxspeed independend of the list size and maybe calc the ramp up time based on the list length instead. (short list -> short rampup, long list -> long rampup).

Second problem was - the gui sound was played before the action even if the action isn't executed. That made a really bad feeling if the list is scrolled with throttle and the sounds are fireing as often as they can. So i handle it by playing the sound after the action when the action has a holdtime set.

Since we inject the remote on AppleTV1/2 via joystickevents i also had to do the same there. (don't like the doubled code though). There might be other places in the handlers which play gui sounds, where this would need to go too - not sure where. If so we could factore it out into its own method.

@jmarshallnz - what do you think?