mirror of
https://github.com/reactos/reactos.git
synced 2025-04-05 13:11:22 +00:00
[OSK] Implement "Use Click Sound" feature
- Implement the save/load handler for this feature - Check the "Use Click Sound" item state accordingly depending if it's enabled or disabled - Use PlaySoundW() to play the wave sound file from resource - Add the WAV sound click file. The work is made thanks to Midori Mizuno
This commit is contained in:
parent
1001e6089f
commit
d000a1e1c6
24 changed files with 94 additions and 22 deletions
|
@ -3,5 +3,5 @@ file(GLOB osk_rc_deps res/*.*)
|
|||
add_rc_deps(rsrc.rc ${osk_rc_deps})
|
||||
add_executable(osk main.c settings.c rsrc.rc)
|
||||
set_module_type(osk win32gui UNICODE)
|
||||
add_importlibs(osk comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32)
|
||||
add_importlibs(osk comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 winmm)
|
||||
add_cd_file(TARGET osk DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -271,7 +271,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -271,7 +271,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -272,7 +272,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -271,7 +271,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -271,7 +271,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -272,7 +272,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Sempre in primo piano", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Usa suono al click", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Usa suono al click", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Modalità di scrittura...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -271,7 +271,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Întotdeauna în sus", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Folosește sunetul de clic", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Folosește sunetul de clic", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Modalitatea de scriere...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -270,7 +270,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -273,7 +273,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -272,7 +272,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND, GRAYED
|
||||
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Typing Mode...", IDM_TYPE_MODE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -157,6 +157,12 @@ int OSK_DlgInitDialog(HWND hDlg)
|
|||
CheckMenuItem(GetMenu(hDlg), IDM_ENHANCED_KB, MF_BYCOMMAND | MF_UNCHECKED);
|
||||
}
|
||||
|
||||
/* Check if the "Click Sound" option was chosen before (and if so, then tick the menu item) */
|
||||
if (Globals.bSoundClick)
|
||||
{
|
||||
CheckMenuItem(GetMenu(hDlg), IDM_CLICK_SOUND, MF_BYCOMMAND | MF_CHECKED);
|
||||
}
|
||||
|
||||
/* Set the application's icon */
|
||||
hIcon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE);
|
||||
hIconSm = CopyImage(hIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_COPYFROMRESOURCE);
|
||||
|
@ -347,6 +353,12 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
|||
SendInput(1, &Input, sizeof(Input));
|
||||
}
|
||||
|
||||
/* Play the sound during clicking event (only if "Use Click Sound" menu option is ticked) */
|
||||
if (Globals.bSoundClick)
|
||||
{
|
||||
PlaySoundW(MAKEINTRESOURCEW(IDI_SOUNDCLICK), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -498,6 +510,26 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
|
||||
case IDM_CLICK_SOUND:
|
||||
{
|
||||
/*
|
||||
This case is triggered when the user attempts to click on the menu item. Before doing anything,
|
||||
we must check the condition state of such menu item so that we can tick/untick the menu item accordingly.
|
||||
*/
|
||||
if (!Globals.bSoundClick)
|
||||
{
|
||||
Globals.bSoundClick = TRUE;
|
||||
CheckMenuItem(GetMenu(hDlg), IDM_CLICK_SOUND, MF_BYCOMMAND | MF_CHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.bSoundClick = FALSE;
|
||||
CheckMenuItem(GetMenu(hDlg), IDM_CLICK_SOUND, MF_BYCOMMAND | MF_UNCHECKED);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case IDM_ABOUT:
|
||||
{
|
||||
OSK_About();
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef struct
|
|||
HWND hActiveWnd;
|
||||
BOOL bShowWarning;
|
||||
BOOL bIsEnhancedKeyboard;
|
||||
BOOL bSoundClick;
|
||||
} OSK_GLOBALS;
|
||||
|
||||
/* DEFINES ********************************************************************/
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#define MAIN_DIALOG_ENHANCED_KB 2000
|
||||
#define MAIN_DIALOG_STANDARD_KB 2001
|
||||
|
||||
#define IDI_SOUNDCLICK 50
|
||||
|
||||
#define IDC_LED_NUM 100
|
||||
#define IDC_LED_CAPS 101
|
||||
#define IDC_LED_SCROLL 102
|
||||
|
|
BIN
base/applications/osk/res/click.wav
Normal file
BIN
base/applications/osk/res/click.wav
Normal file
Binary file not shown.
|
@ -21,7 +21,8 @@
|
|||
|
||||
#include <reactos/version.rc>
|
||||
|
||||
IDI_OSK ICON "res/osk.ico"
|
||||
IDI_OSK ICON "res/osk.ico"
|
||||
IDI_SOUNDCLICK WAVE "res/click.wav"
|
||||
|
||||
|
||||
IDI_BACK ICON "res/back.ico"
|
||||
|
|
|
@ -16,12 +16,13 @@ BOOL LoadDataFromRegistry()
|
|||
{
|
||||
HKEY hKey;
|
||||
LONG lResult;
|
||||
DWORD dwShowWarningData, dwLayout;
|
||||
DWORD dwShowWarningData, dwLayout, dwSoundOnClick;
|
||||
DWORD cbData = sizeof(DWORD);
|
||||
|
||||
/* Set the structure members to TRUE */
|
||||
/* Set the structure members to TRUE (and the bSoundClick member to FALSE) */
|
||||
Globals.bShowWarning = TRUE;
|
||||
Globals.bIsEnhancedKeyboard = TRUE;
|
||||
Globals.bSoundClick = FALSE;
|
||||
|
||||
/* Open the key, so that we can query it */
|
||||
lResult = RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
|
@ -71,6 +72,24 @@ BOOL LoadDataFromRegistry()
|
|||
|
||||
/* Load the dialog layout value */
|
||||
Globals.bIsEnhancedKeyboard = (dwLayout != 0);
|
||||
|
||||
/* Query the key */
|
||||
lResult = RegQueryValueExW(hKey,
|
||||
L"OnSoundClick",
|
||||
0,
|
||||
0,
|
||||
(BYTE *)&dwSoundOnClick,
|
||||
&cbData);
|
||||
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
/* Bail out and return FALSE if we fail */
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Load the sound on click value event */
|
||||
Globals.bSoundClick = (dwSoundOnClick != 0);
|
||||
|
||||
/* If we're here then we succeed, close the key and return TRUE */
|
||||
RegCloseKey(hKey);
|
||||
|
@ -81,7 +100,7 @@ BOOL SaveDataToRegistry()
|
|||
{
|
||||
HKEY hKey;
|
||||
LONG lResult;
|
||||
DWORD dwShowWarningData, dwLayout;
|
||||
DWORD dwShowWarningData, dwLayout, dwSoundOnClick;
|
||||
|
||||
/* If no key has been made, create one */
|
||||
lResult = RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||
|
@ -134,6 +153,23 @@ BOOL SaveDataToRegistry()
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* The value will be appended to the sound on click event */
|
||||
dwSoundOnClick = Globals.bSoundClick;
|
||||
|
||||
lResult = RegSetValueExW(hKey,
|
||||
L"OnSoundClick",
|
||||
0,
|
||||
REG_DWORD,
|
||||
(BYTE *)&dwSoundOnClick,
|
||||
sizeof(dwSoundOnClick));
|
||||
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
/* Bail out and return FALSE if we fail */
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we're here then we succeed, close the key and return TRUE */
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue