https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d000a1e1c6506da7c67d1…
commit d000a1e1c6506da7c67d16133867fd9b1825d85a
Author: Bișoc George <fraizeraust99(a)gmail.com>
AuthorDate: Sun Feb 24 16:40:02 2019 +0100
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Mar 1 00:13:47 2019 +0100
[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
---
base/applications/osk/CMakeLists.txt | 2 +-
base/applications/osk/lang/ar-DZ.rc | 2 +-
base/applications/osk/lang/cs-CZ.rc | 2 +-
base/applications/osk/lang/de-DE.rc | 2 +-
base/applications/osk/lang/en-GB.rc | 2 +-
base/applications/osk/lang/en-US.rc | 2 +-
base/applications/osk/lang/es-ES.rc | 2 +-
base/applications/osk/lang/et-EE.rc | 2 +-
base/applications/osk/lang/fr-CA.rc | 2 +-
base/applications/osk/lang/fr-FR.rc | 2 +-
base/applications/osk/lang/he-IL.rc | 2 +-
base/applications/osk/lang/it-IT.rc | 2 +-
base/applications/osk/lang/pl-PL.rc | 2 +-
base/applications/osk/lang/ro-RO.rc | 2 +-
base/applications/osk/lang/ru-RU.rc | 2 +-
base/applications/osk/lang/tr-TR.rc | 2 +-
base/applications/osk/lang/zh-CN.rc | 2 +-
base/applications/osk/lang/zh-TW.rc | 2 +-
base/applications/osk/main.c | 32 ++++++++++++++++++++++++++
base/applications/osk/main.h | 1 +
base/applications/osk/osk_res.h | 2 ++
base/applications/osk/res/click.wav | Bin 0 -> 20856 bytes
base/applications/osk/rsrc.rc | 3 ++-
base/applications/osk/settings.c | 42 ++++++++++++++++++++++++++++++++---
24 files changed, 94 insertions(+), 22 deletions(-)
diff --git a/base/applications/osk/CMakeLists.txt b/base/applications/osk/CMakeLists.txt
index 51ff4f3a42..5d5ddf76f9 100644
--- a/base/applications/osk/CMakeLists.txt
+++ b/base/applications/osk/CMakeLists.txt
@@ -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)
diff --git a/base/applications/osk/lang/ar-DZ.rc b/base/applications/osk/lang/ar-DZ.rc
index 3bf1192f0a..edd4536dd6 100644
--- a/base/applications/osk/lang/ar-DZ.rc
+++ b/base/applications/osk/lang/ar-DZ.rc
@@ -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
diff --git a/base/applications/osk/lang/cs-CZ.rc b/base/applications/osk/lang/cs-CZ.rc
index 3d35fa2b47..5360c7075d 100644
--- a/base/applications/osk/lang/cs-CZ.rc
+++ b/base/applications/osk/lang/cs-CZ.rc
@@ -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
diff --git a/base/applications/osk/lang/de-DE.rc b/base/applications/osk/lang/de-DE.rc
index 6748444650..dba2dc1788 100644
--- a/base/applications/osk/lang/de-DE.rc
+++ b/base/applications/osk/lang/de-DE.rc
@@ -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
diff --git a/base/applications/osk/lang/en-GB.rc b/base/applications/osk/lang/en-GB.rc
index 11f91b9b2f..ab04edc3a3 100644
--- a/base/applications/osk/lang/en-GB.rc
+++ b/base/applications/osk/lang/en-GB.rc
@@ -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
diff --git a/base/applications/osk/lang/en-US.rc b/base/applications/osk/lang/en-US.rc
index cabdadbc6a..d955621f20 100644
--- a/base/applications/osk/lang/en-US.rc
+++ b/base/applications/osk/lang/en-US.rc
@@ -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
diff --git a/base/applications/osk/lang/es-ES.rc b/base/applications/osk/lang/es-ES.rc
index 4fc2284830..319fe387d0 100644
--- a/base/applications/osk/lang/es-ES.rc
+++ b/base/applications/osk/lang/es-ES.rc
@@ -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
diff --git a/base/applications/osk/lang/et-EE.rc b/base/applications/osk/lang/et-EE.rc
index 4de3166e29..c527e7e449 100644
--- a/base/applications/osk/lang/et-EE.rc
+++ b/base/applications/osk/lang/et-EE.rc
@@ -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
diff --git a/base/applications/osk/lang/fr-CA.rc b/base/applications/osk/lang/fr-CA.rc
index 27c2cc78fb..18636d9614 100644
--- a/base/applications/osk/lang/fr-CA.rc
+++ b/base/applications/osk/lang/fr-CA.rc
@@ -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
diff --git a/base/applications/osk/lang/fr-FR.rc b/base/applications/osk/lang/fr-FR.rc
index eef680d01b..ba05f9f195 100644
--- a/base/applications/osk/lang/fr-FR.rc
+++ b/base/applications/osk/lang/fr-FR.rc
@@ -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
diff --git a/base/applications/osk/lang/he-IL.rc b/base/applications/osk/lang/he-IL.rc
index 5f1fa891c3..fb7977d847 100644
--- a/base/applications/osk/lang/he-IL.rc
+++ b/base/applications/osk/lang/he-IL.rc
@@ -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
diff --git a/base/applications/osk/lang/it-IT.rc b/base/applications/osk/lang/it-IT.rc
index 965a73af5c..b4ba448adf 100644
--- a/base/applications/osk/lang/it-IT.rc
+++ b/base/applications/osk/lang/it-IT.rc
@@ -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
diff --git a/base/applications/osk/lang/pl-PL.rc b/base/applications/osk/lang/pl-PL.rc
index d5f7e2d30b..7e845c8cf7 100644
--- a/base/applications/osk/lang/pl-PL.rc
+++ b/base/applications/osk/lang/pl-PL.rc
@@ -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
diff --git a/base/applications/osk/lang/ro-RO.rc b/base/applications/osk/lang/ro-RO.rc
index 405a163a28..f47416acbf 100644
--- a/base/applications/osk/lang/ro-RO.rc
+++ b/base/applications/osk/lang/ro-RO.rc
@@ -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
diff --git a/base/applications/osk/lang/ru-RU.rc b/base/applications/osk/lang/ru-RU.rc
index cbaafcf41b..42f6b43e35 100644
--- a/base/applications/osk/lang/ru-RU.rc
+++ b/base/applications/osk/lang/ru-RU.rc
@@ -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
diff --git a/base/applications/osk/lang/tr-TR.rc b/base/applications/osk/lang/tr-TR.rc
index 3ccca25ba1..fb40d8c76b 100644
--- a/base/applications/osk/lang/tr-TR.rc
+++ b/base/applications/osk/lang/tr-TR.rc
@@ -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
diff --git a/base/applications/osk/lang/zh-CN.rc b/base/applications/osk/lang/zh-CN.rc
index da381ed815..5f8b49ec04 100644
--- a/base/applications/osk/lang/zh-CN.rc
+++ b/base/applications/osk/lang/zh-CN.rc
@@ -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
diff --git a/base/applications/osk/lang/zh-TW.rc b/base/applications/osk/lang/zh-TW.rc
index 3ea417a631..fbb62ff79f 100644
--- a/base/applications/osk/lang/zh-TW.rc
+++ b/base/applications/osk/lang/zh-TW.rc
@@ -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
diff --git a/base/applications/osk/main.c b/base/applications/osk/main.c
index 72cee21f30..972f8c8e9b 100644
--- a/base/applications/osk/main.c
+++ b/base/applications/osk/main.c
@@ -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();
diff --git a/base/applications/osk/main.h b/base/applications/osk/main.h
index a399abadd2..137cf5b2ca 100644
--- a/base/applications/osk/main.h
+++ b/base/applications/osk/main.h
@@ -25,6 +25,7 @@ typedef struct
HWND hActiveWnd;
BOOL bShowWarning;
BOOL bIsEnhancedKeyboard;
+ BOOL bSoundClick;
} OSK_GLOBALS;
/* DEFINES ********************************************************************/
diff --git a/base/applications/osk/osk_res.h b/base/applications/osk/osk_res.h
index 03fdffc9a7..04dd6e2b88 100644
--- a/base/applications/osk/osk_res.h
+++ b/base/applications/osk/osk_res.h
@@ -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
diff --git a/base/applications/osk/res/click.wav b/base/applications/osk/res/click.wav
new file mode 100644
index 0000000000..fd5402fe6b
Binary files /dev/null and b/base/applications/osk/res/click.wav differ
diff --git a/base/applications/osk/rsrc.rc b/base/applications/osk/rsrc.rc
index 44bcd0d34c..51b4534c5a 100644
--- a/base/applications/osk/rsrc.rc
+++ b/base/applications/osk/rsrc.rc
@@ -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"
diff --git a/base/applications/osk/settings.c b/base/applications/osk/settings.c
index fa21d67d3a..03eb18f62e 100644
--- a/base/applications/osk/settings.c
+++ b/base/applications/osk/settings.c
@@ -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;