summaryrefslogtreecommitdiff
path: root/plugins/mRadio/i_hotkey.inc
blob: d3f739d84493ebd8297a1f9074466970f7732713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{}
const
  hRadioHotkey:THANDLE=0;
const
  MS_RADIO_HOTKEY:PAnsiChar  = 'mRadio/Hotkey';

  HKN_PLAYPAUSE  :PAnsiChar = 'mRadio_PlayPause';
  HKN_STOP       :PAnsiChar = 'mRadio_Stop';
  HKN_MUTE       :PAnsiChar = 'mRadio_Mute';
  HKN_RECORD     :PAnsiChar = 'mRadio_Record';

  DefRadioKeyRecord = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('R');
  DefRadioKeyMute   = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('M');
  DefRadioKeyPlay   = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('P');
  DefRadioKeyStop   = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('S');

function mRadio_Hotkey(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
begin
  if lParam=MRC_MUTE then
    result:=Service_RadioMute(0,0)
  else
    result:=CallService(MS_RADIO_COMMAND,lParam,0);
end;

procedure RegisterHotKey;
var
  hkrec:THOTKEYDESC;
begin
  hRadioHotkey:=CreateServiceFunction(MS_RADIO_HOTKEY,@mRadio_Hotkey);

  FillChar(hkrec,SizeOf(hkrec),0);

  hkrec.pszSection.a    := PluginName;
  hkrec.pszService      := MS_RADIO_HOTKEY;

  hkrec.DefHotKey       := DefRadioKeyPlay;
  hkrec.pszName         := HKN_PLAYPAUSE;
  hkrec.pszDescription.a:= 'Play/Pause';
  hkrec.lParam          := MRC_PAUSE;
  Hotkey_Register(@hkrec);

  hkrec.DefHotKey       := DefRadioKeyStop;
  hkrec.pszName         := HKN_STOP;
  hkrec.pszDescription.a:= 'Stop';
  hkrec.lParam          := MRC_STOP;
  Hotkey_Register(@hkrec);

  hkrec.DefHotKey       := DefRadioKeyMute;
  hkrec.pszName         := HKN_MUTE;
  hkrec.pszDescription.a:= 'Mute';
  hkrec.lParam          := MRC_MUTE;
  Hotkey_Register(@hkrec);

  hkrec.DefHotKey       := DefRadioKeyRecord;
  hkrec.pszName         := HKN_RECORD;
  hkrec.pszDescription.a:= 'Start/Stop Record';
  hkrec.lParam          := MRC_RECORD;
  Hotkey_Register(@hkrec);
end;

procedure UnregisterHotKey;
begin
  DestroyServiceFunction(hRadioHotkey);
end;