Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 12th July 2009, 17:55   #1
fleoparra
Junior Member
 
Join Date: Feb 2009
Posts: 6
Add Keyboard Accelerator - General purpose plugin

Hello.
I want to add a keyboard accelerator like ALT + A or A for my general purpose plugin.

I have tried some times but until this moment it haven't worked

The first form that I tried was with:

1. In the process WinampSubclassProc I added:
code:

LRESULT CALLBACK WinampSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_KEYDOWN:
if (LOWORD(wParam) == 65) //A
{
openPlugin();
}
break;
default:; // All other messages : pass to Winamp
}
return CallWindowProc(acl.lpWinampProc,hwnd,message,wParam,lParam);
}


But it only works when the screen is positioned over the main window of winamp.
It doesn't work when is opened other plugin or other window.

2. The second form was with a accelerator (Resources):
code:

LRESULT CALLBACK WinampSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_ACC_OPEN: //a
openPlugin();
break;
}
break;

default:; // All other messages : pass to Winamp
}

MSG msg; // application messages
BOOL bRet; // for return value of GetMessage
HACCEL haccel; // handle to accelerator table

haccel = LoadAccelerators(plugin.hDllInstance, MAKEINTRESOURCE(IDR_ACC_TABLE));

if (GetMessage(&msg, NULL, 0, 0)) //while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(plugin.hwndParent, haccel, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return CallWindowProc(acl.lpWinampProc,hwnd,message,wParam,lParam);
}


It worked well with the accelerator, but winamp began to be slow and it didn't answer to some requests. Beside it began to show mistakes.

3. The third form was:

I added soport for api_service and api_aplication
In the init:
code:

// go ahead and grab the wasabi service manager.
WASABI_API_SVC = (api_service *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0,

IPC_GET_API_SERVICE);

// get the application API
// we need this to get/set Winamp's current working directory
waServiceFactory *factory =

WASABI_API_SVC->service_getServiceByGuid(applicationApiServiceGuid);
if (factory)
WASABI_API_APP = (api_application *)factory->getInterface();



After this in:
code:

LRESULT CALLBACK WinampSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_ACC_OPEN: //a
openPlugin();
break;
}
break;

default:; // All other messages : pass to Winamp
}

MSG msg; // application messages
BOOL bRet; // for return value of GetMessage
HACCEL haccel; // handle to accelerator table

haccel = LoadAccelerators(plugin.hDllInstance, MAKEINTRESOURCE(IDR_ACC_TABLE));
HACCEL* phAccel = new HACCEL(haccel);

applicationApi->app_addAccelerators(plugin.hwndParent, phAccel, 0, 1);

return CallWindowProc(acl.lpWinampProc,hwnd,message,wParam,lParam);
}



but although it show "build succeded" and it started the plugin, In Execute time it show the mistake in "applicationApi->app_addAccelerators".
With this last form I was testing it but in internet I didn't find examples about it, how I should use it?.
I'm not sure if I doing it well and I would like knowing if you have some examples where it works for add a keyboard accelarator to a general purpose plugin.

Thanks for your attention.

Fabio
fleoparra is offline   Reply With Quote
Old 14th July 2009, 18:27   #2
griffins_Grader
Senior Member
 
Join Date: Aug 2008
Posts: 114
I dont know if wa_hotkeys.h will be appropriate
griffins_Grader is offline   Reply With Quote
Old 14th July 2009, 22:39   #3
DrO
-
 
DrO's Avatar
 
Join Date: Sep 2003
Location: UK
Posts: 22,278
as i don't have access to an code this is all going tobe going on my memory so if it's wrong then i apologise now.

wa_hotkeys.h won't be appropriate in this instance. i'll assume this is to have a means to toggle a window and if so then prior to 5.53 you're best using IPC_TRANSLATEACCEL (think that'st the right api) and from 5.53+ you will need to use the api_service method.

what has been pasted for the api_service implementation looks wrong as it's constantly trying to add the association on all messages through the window proceedure and should only be done once either in init(..) or on a delayed loading callback (custom WM_WA_IPC into a subclassed Winamp window proc via PostMessage(..) in init(..) ). once it's working then all you need to do is handle the respective WM_COMMAND message against the command id set (there's an api that will allocate you a value which shouldn't have been already used by Winamp added in 5.1x i think - is in wa_ipc.h near the bottom).

-daz
DrO is offline   Reply With Quote
Old 21st July 2009, 01:54   #4
fleoparra
Junior Member
 
Join Date: Feb 2009
Posts: 6
Thanks for your reply, unfortunately I have tried to find examples of code and how to do the verification with IPC_TRANSLATEACCELERATOR to add support to versions prior to 5.53 and the of use api_service for versions 5.33+ but I have not made progress.

After that I can upload accelerators, I know that can be handled with the respective WM_COMMAND message and this part I already have ready.

I have tried to look at the SDK and in the application code for winamp plugins that have code public, but none have used or IPC_TRANSLATEACCELERATOR nor api_service to load accelerators. I am very inexperienced in this subject, and the plugin that I have developed was the first I've done and I only need to correct this subject accelerated.

Regarding options that you mentioned to make calls in the init (..) or on a delayed loading callback, you could help me with some example code? or with a link to a plug-in with public code to see if I can guide me a little better.

Sorry for my english
fleoparra is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump