//-------------------------------------------------------------------------------- // Constants //-------------------------------------------------------------------------------- // keep these in sync with the pickRemote label picker constant kPowerCD := 0; constant kSonyCD := 1; constant kTest := 2; constant kPlay:= 0; constant kStop := 1; constant kPause := 2; constant kFF := 3; constant kRew := 4; constant kNext := 5; constant kPrev := 6; //-------------------------------------------------------------------------------- // Philips RC-5 commands (PowerCD) //-------------------------------------------------------------------------------- rf := OpenResFileX(Home & "RC5.rsrc"); // RC-5 requires the Control bit to be toggled for each new command // so we have two commands, one with C set, and one with C clear rc5CDPlay0 := GetNamedResource("IRCD", "RC5Play0", 'resource); rc5CDPlay1 := GetNamedResource("IRCD", "RC5Play1", 'resource); rc5CDStop0 := GetNamedResource("IRCD", "RC5Stop0", 'resource); rc5CDstop1 := GetNamedResource("IRCD", "RC5Stop1", 'resource); rc5CDPause0 := GetNamedResource("IRCD", "RC5Pause0", 'resource); rc5CDPause1 := GetNamedResource("IRCD", "RC5Pause1", 'resource); rc5CDFF0 := GetNamedResource("IRCD", "RC5FF0", 'resource); rc5CDFF1 := GetNamedResource("IRCD", "RC5FF1", 'resource); rc5CDRew0 := GetNamedResource("IRCD", "RC5Rew0", 'resource); rc5CDRew1 := GetNamedResource("IRCD", "RC5Rew1", 'resource); rc5CDNext0 := GetNamedResource("IRCD", "RC5Next0", 'resource); rc5CDNext1 := GetNamedResource("IRCD", "RC5Next1", 'resource); rc5CDPrev0 := GetNamedResource("IRCD", "RC5Prev0", 'resource); rc5CDPrev1 := GetNamedResource("IRCD", "RC5Prev1", 'resource); CloseResFileX(rf); //-------------------------------------------------------------------------------- // Sony commands //-------------------------------------------------------------------------------- rf := OpenResFileX(Home & "Sony.rsrc"); sonyCDPlay := GetNamedResource("IRCD", "SonyCDPlay", 'resource); sonyCDStop := GetNamedResource("IRCD", "SonyCDStop", 'resource); sonyCDPause := GetNamedResource("IRCD", "SonyCDPause", 'resource); sonyCDFF := GetNamedResource("IRCD", "SonyCDFF", 'resource); sonyCDRew := GetNamedResource("IRCD", "SonyCDRew", 'resource); sonyCDNext := GetNamedResource("IRCD", "SonyCDTrackUp", 'resource); sonyCDPrev := GetNamedResource("IRCD", "SonyCDTrackDown", 'resource); CloseResFileX(rf); // ---- End Project Data ---- // ---- File main.t ---- remoteView := {viewBounds: {left: 1, top: 49, right: 128, bottom: 210}, data: nil, Toggle: nil, irCodes: { rc5c0CD: [rc5CDPlay0, rc5CDStop0, rc5CDPause0, rc5CDFF0, rc5CDRew0, rc5CDNext0, rc5CDPrev0], rc5c1CD: [rc5CDPlay1, rc5CDStop1, rc5CDPause1, rc5CDFF1, rc5CDRew1, rc5CDNext1, rc5CDPrev1], sonyCD: [sonyCDPlay, sonyCDStop, sonyCDPause, sonyCDFF, sonyCDRew, sonyCDNext, sonyCDPrev], }, viewSetupFormScript: func() begin data := :OpenRemoteControl(); end, viewQuitScript: func() begin :CloseRemoteControl(data); end, SendCode: func(code, toggle, count) begin local rsrc := nil; if remoteType = kPowerCD then begin if toggle then rsrc := irCodes.rc5c1CD[code]; else rsrc := irCodes.rc5c0CD[code]; end; else if remoteType = kSonyCD then begin rsrc := irCodes.sonyCD[code]; end; if rsrc then :SendRemoteControlCode(data, rsrc, count); end, remoteType: 0, title: "Application", OpenRemoteControl: kOpenRemoteControlFunc, CloseRemoteControl: kCloseRemoteControlFunc, SendRemoteControlCode: kSendRemoteControlCodeFunc, _proto: protoFloater, debug: "remoteView" }; closeBox := /* child of remoteView */ {_proto: protoClosebox, debug: "closeBox"} ; // View closeBox is declared to remoteView Thetitle := /* child of remoteView */ {text: "Remote Control", viewBounds: {left: 8, top: 8, right: 114, bottom: 22}, viewJustify: 8388610, _proto: protoStaticText, debug: "Thetitle" }; // View Thetitle is declared to remoteView PrevButton := /* child of remoteView */ {viewBounds: {left: 9, top: 52, right: 41, bottom: 84}, buttonPressedScript: func() begin // send "prev" command as long as the button is held down // note that we toggle each time so they get interpreted // as separate "next" commands // (c.f. FF and REW) :SendCode(kPrev, toggle, 1); toggle := not toggle; end, icon: GetPictAsBits("Prev", 1), viewFormat: 1, _proto: protoPictureButton, debug: "PrevButton" }; // View PrevButton is declared to remoteView PauseButton := /* child of remoteView */ {viewBounds: {left: 46, top: 89, right: 78, bottom: 121}, buttonClickScript: func() begin :SendCode(kPause, toggle, 3); toggle := not toggle; end, icon: GetPictAsBits("Pause", 1), viewFormat: 1, _proto: protoPictureButton, debug: "PauseButton" }; // View PauseButton is declared to remoteView NextButton := /* child of remoteView */ {viewBounds: {left: 83, top: 52, right: 115, bottom: 84}, buttonPressedScript: func() begin // send "next" command as long as the button is held down // note that we toggle each time so they get interpreted // as separate "next" commands // (c.f. FF and REW) :SendCode(kNext, toggle, 1); toggle := not toggle; end, icon: GetPictAsBits("Next", 1), viewFormat: 1, _proto: protoPictureButton, debug: "NextButton" }; // View NextButton is declared to remoteView RewButton := /* child of remoteView */ {viewBounds: {left: 9, top: 89, right: 41, bottom: 121}, buttonClickScript: func() begin // toggle the command bit only once per press // instead of once per send toggle := not toggle; end, buttonPressedScript: func() begin // keep sending the "REW" command as long as the button // is held down. // note that we are sending the same command over and // over (i.e., not toggling the Control bit) // also note that we are repeating the command 3x for each send :SendCode(kRew, toggle, 3); end, icon: GetPictAsBits("Rew", 1), viewFormat: 1, _proto: protoPictureButton, debug: "RewButton" }; // View RewButton is declared to remoteView PlayButton := /* child of remoteView */ {viewBounds: {left: 46, top: 52, right: 78, bottom: 84}, buttonClickScript: func() begin :SendCode(kPlay, toggle, 3); toggle := not toggle; end, icon: GetPictAsBits("Play", 1), viewFormat: 1, _proto: protoPictureButton, debug: "PlayButton" }; // View PlayButton is declared to remoteView FFButton := /* child of remoteView */ {viewBounds: {left: 83, top: 89, right: 115, bottom: 121}, buttonClickScript: func() begin // toggle the command bit only once per press // instead of once per send toggle := not toggle; end, buttonPressedScript: func() begin // keep sending the "FF" command as long as the button // is held down. // note that we are sending the same command over and // over (i.e., not toggling the Control bit) // also note that we are repeating the command 3x for each send :SendCode(kFF, toggle, 3); end, icon: GetPictAsBits("FF", 1), viewFormat: 1, _proto: protoPictureButton, debug: "FFButton" }; // View FFButton is declared to remoteView StopButton := /* child of remoteView */ {viewBounds: {left: 46, top: 126, right: 78, bottom: 158}, buttonClickScript: func() begin :SendCode(kStop, toggle, 3); toggle := not toggle; end, icon: GetPictAsBits("Stop", 1), viewFormat: 1, _proto: protoPictureButton, debug: "StopButton" }; // View StopButton is declared to remoteView pickRemote := /* child of remoteView */ {viewBounds: {left: 11, top: 28, right: 113, bottom: 44}, labelCommands: ["Power CD", "Sony CD"], labelActionScript: func(cmd) begin remoteType := cmd; end, _proto: protoLabelPicker, debug: "pickRemote" }; // View pickRemote is declared to remoteView // ---- Beginning of section for non used Layout files ---- // End of output