Apple remote broken on leopard


#1

Hi,

I was trying the apple remote feature in the juce demo app but it always receives the same id (switched).

I remember having tried when i was running tiger and it was working ok but since i’m on leopard it’s not working any more.

I’m currently trying to figure out what’s happening but as i’m new to mac dev, it can take some time!

cheers

Rimshot


#2

That’d odd, but I’ve not actually tried it myself since I upgraded to leopard, so I’ll have a go. Thanks for pointing it out.


#3

Hi Guys,

I’ve just checked and have also the problem.

I found a piece of code where the guy makes a difference between tiger and leopard.

Here is the link to his file:
tonelli.sns.it/pub/mplayer/svn/mplayer/input/ar.c

He is checking for the osx version and set a is_leopard variable.

I cannot find the official button patterns (where the F*** are they??) from Apple but the guy gives those:

/* On tiger, 5 always follows 6; on leopard, 18 always follows 19.

  • On leopard, there seems to be no cookie value of 5 or 6.

  • Following is the shortened cookie sequence list

  • keycode cookies_on_tiger ///// cookies_on_leopard *down_state

  • AR_PREV_HOLD 14+6+3+2 ///// 31+19+3+2 yes

  • AR_NEXT_HOLD 14+6+4+2 ///// 31+19+4+2 yes

  • AR_MENU_HOLD 14+6+14+6 ///// 31+19+31+19

  • AR_VUP 14+12+11+6 ///// 31+29+28+19 yes

  • AR_VDOWN 14+13+11+6 ///// 31+30+28+19 yes

  • AR_MENU 14+7+6+14+7+6 ///// 31+20+19+31+20+19

  • AR_PLAY 14+8+6+14+8+6 ///// 31+21+19+31+21+19

  • AR_NEXT 14+9+6+14+9+6 ///// 31+22+19+31+22+19

  • AR_PREV 14+10+6+14+10+6 ///// 31+23+19+31+23+19

  • AR_PLAY_HOLD 18+14+6+18+14+6 /////35+31+19+35+31+19

  • *down_state: A button with this feature has a pressed event and

  • a released event, with which we can trace the state of the button.

  • A button without this feature will only return one release event.

  • hidden keys currently not implemented:

  • hold for 5 secs

  • MENU_NEXT_HOLD 15+14+6+15+14+6

  • MENU_PREV_HOLD 16+14+6+16+14+6

  • MENU_VUP_HOLD 20+14+6+20+14+6

  • MENU_VDOWN_HOLD 19+14+6+19+14+6

  • It seems that pressing ‘menu’ and ‘play’ on the Apple Remote for

  • 5 seconds will trigger the make-pair function of the remote.

  • MENU_PLAY_HOLD 21+15+14+6+15+14+6
    */

Also when i’m debugging the juce demo; if i press the next button i get the following sequence:
22 19 18 31 22 19 18
which seem to correspond to wha the guy gives but what about the start of the pattern(22 19 18 )?
I can’t understand where does that 22 comes from …

the 19 bring us in the buttonpressed(switched)
what does the “swiched” mean? do it just mean a button has been pressed?

Hope that helps,

Pit


#4

Hi Jules,

I 've tried some stuff in the juce mac windowing and i managed to get the remote working on leopard.

First to get the osx version, i use (in the consructor of appleRemoteDevice with is_leopard a member of appleRemoteDevice)
if (floor(NSAppKitVersionNumber) <= 824 /*NSAppKitVersionNumber10_4 */)
is_leopard = 0;
else
is_leopard = 1;

with NSAppKitVersionNumber declared as extern out of the juce namespace

extern const double NSAppKitVersionNumber;

BEGIN_JUCE_NAMESPACE

you then have to link with the AppKit framework for NSAppKitVersionNumber

Finally, in AppleRemoteDevice::handleCallbackInternal()

static const char buttonPatterns_Tiger[] =
{
14, 7, 6, 5, 14, 7, 6, 5, 0,
14, 8, 6, 5, 14, 8, 6, 5, 0,
14, 12, 11, 6, 5, 0,
14, 13, 11, 6, 5, 0,
14, 9, 6, 5, 14, 9, 6, 5, 0,
14, 10, 6, 5, 14, 10, 6, 5, 0,
14, 6, 5, 4, 2, 0,
14, 6, 5, 3, 2, 0,
14, 6, 5, 14, 6, 5, 0,
18, 14, 6, 5, 18, 14, 6, 5, 0,
19, 0
};

static const char buttonPatterns_Leopard[] =
{
    31, 20, 18, 31, 20, 18, 0,
    31, 21, 18, 31, 21, 18, 0,
    31, 29, 28, 18, 31, 29, 28 ,18,0,
    31, 30, 28, 18, 31, 30, 28 ,18,0,
    31, 22, 18, 31, 22, 18, 0,
    31, 23, 18, 31, 23, 18, 0,
    31, 18, 4, 2, 31, 18, 4,2,0,
	31, 18, 3, 2, 31, 18, 3,2,0,
    31,18,31,18,0,
    35,31,18,35,31,18, 0,
    19, 0
};

const char * buttonPatterns;
if(is_leopard)
	buttonPatterns  = buttonPatterns_Leopard;
else
	buttonPatterns  = buttonPatterns_Tiger;
		
int buttonNum = (int) menuButton;
int i = 0;

while (i < numElementsInArray (buttonPatterns_Tiger))
{

	if (strcmp (cookies, buttonPatterns + i) == 0)
	{
		buttonPressed ((ButtonType) buttonNum, totalValues > 0);
		break;
	}
		
	i += strlen (buttonPatterns + i) + 1;
    ++buttonNum;
}

This work ok execpt for 4 buttons : plus,minus, long right, long left.

I’ve seen those buttons can have a “down state” so the cookie is different of the one i 've put but i cannot find any good documentation from Apple or other about their message format.

Do somebody know where to find the infos?

Cheers,

Pit


#5

Hello Pit,
hello Jules,

I’ve stumbled over the same problem with the AR demo.
After some searching I’ve found a program, which gives some output of AR events; see
http://www.osxbook.com/software/iremoted/download/iremoted.c
: short-plus and short-minus give other codes as all other keys, so we probably have two more…

Don’t have the energy to dig deeper here, but it may help to solve the problem.

Regards,
Stephan