diff --git a/src/modules/espresso/Espresso/Espresso.rc b/src/modules/espresso/Espresso/Espresso.rc index af288a92d3..fc17ffa577 100644 --- a/src/modules/espresso/Espresso/Espresso.rc +++ b/src/modules/espresso/Espresso/Espresso.rc @@ -1,3 +1,18 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + 1 VERSIONINFO FILEVERSION 0,1,0,0 PRODUCTVERSION 0,1,0,0 @@ -29,4 +44,56 @@ BEGIN BEGIN VALUE "Translation", 0x409, 1200 END -END \ No newline at end of file +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_ESPRESSO_NAME "Espresso" +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/modules/espresso/Espresso/Espresso.vcxproj b/src/modules/espresso/Espresso/Espresso.vcxproj index 7a45469124..db8b101340 100644 --- a/src/modules/espresso/Espresso/Espresso.vcxproj +++ b/src/modules/espresso/Espresso/Espresso.vcxproj @@ -22,7 +22,6 @@ DynamicLibrary true - v142 Unicode @@ -58,7 +57,7 @@ Level3 Disabled true - _DEBUG;EXAMPLEPOWERTOY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EXAMPLEPOWERTOY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true pch.h MultiThreadedDebug @@ -94,10 +93,12 @@ - $(SolutionDir)src\;$(SolutionDir)src\modules;$(SolutionDir)src\common\Telemetry;%(AdditionalIncludeDirectories) + ..\..\..\common\Telemetry;..\..\;..\..\..\;%(AdditionalIncludeDirectories) + false + @@ -113,8 +114,11 @@ - - {74485049-c722-400f-abe5-86ac52d929b3} + + {d9b8fc84-322a-4f9f-bbb9-20915c47ddfd} + + + {6955446d-23f7-4023-9bb3-8657f904af99} diff --git a/src/modules/espresso/Espresso/Espresso.vcxproj.filters b/src/modules/espresso/Espresso/Espresso.vcxproj.filters new file mode 100644 index 0000000000..5c1e6e58b0 --- /dev/null +++ b/src/modules/espresso/Espresso/Espresso.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + + + + + + + Header Files + + + Header Files + + + Generated Files + + + + + {e8ef1c4e-cc50-4ce5-b00d-4e3ac5c1a7db} + + + {fbd9cdd2-e7d5-4417-9b52-25e345ae9562} + + + {c2a23a2b-5846-440f-b29e-eea748dba12d} + + + + + Generated Files + + + \ No newline at end of file diff --git a/src/modules/espresso/Espresso/EspressoConstants.h b/src/modules/espresso/Espresso/EspressoConstants.h new file mode 100644 index 0000000000..6b97fe7021 --- /dev/null +++ b/src/modules/espresso/Espresso/EspressoConstants.h @@ -0,0 +1,7 @@ +#include + +namespace EspressoConstants +{ + // Name of the powertoy module. + inline const std::wstring ModuleKey = L"Espresso"; +} \ No newline at end of file diff --git a/src/modules/espresso/Espresso/dllmain.cpp b/src/modules/espresso/Espresso/dllmain.cpp index be128ce14b..c48c2024cc 100644 --- a/src/modules/espresso/Espresso/dllmain.cpp +++ b/src/modules/espresso/Espresso/dllmain.cpp @@ -1,9 +1,22 @@ #include "pch.h" -#include -#include -#include -#include +#include "resource.h" #include "trace.h" +#include "EspressoConstants.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -24,8 +37,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv return TRUE; } + + // The PowerToy name that will be shown in the settings. -const static wchar_t* MODULE_NAME = L"$projectname$"; +const static wchar_t* MODULE_NAME = L"Espresso"; // Add a description that will we shown in the module settings page. const static wchar_t* MODULE_DESC = L""; @@ -46,8 +61,12 @@ struct ModuleSettings } g_settings; // Implement the PowerToy Module Interface and all the required methods. -class $safeprojectname$ : public PowertoyModuleIface +class Espresso : public PowertoyModuleIface { + std::wstring app_name; + //contains the non localized key of the powertoy + std::wstring app_key; + private: // The PowerToy state. bool m_enabled = false; @@ -57,8 +76,10 @@ private: public: // Constructor - $safeprojectname$() + Espresso() { + app_name = GET_RESOURCE_STRING(IDS_ESPRESSO_NAME); + app_key = EspressoConstants::ModuleKey; init_settings(); }; @@ -74,22 +95,22 @@ public: return MODULE_NAME; } - // Return array of the names of all events that this powertoy listens for, with - // nullptr as the last element of the array. Nullptr can also be retured for empty - // list. - virtual const wchar_t** get_events() override - { - static const wchar_t* events[] = { nullptr }; - // Available events: - // - ll_keyboard - // - win_hook_event - // - // static const wchar_t* events[] = { ll_keyboard, - // win_hook_event, - // nullptr }; + //// Return array of the names of all events that this powertoy listens for, with + //// nullptr as the last element of the array. Nullptr can also be retured for empty + //// list. + //virtual const wchar_t** get_events() override + //{ + // static const wchar_t* events[] = { nullptr }; + // // Available events: + // // - ll_keyboard + // // - win_hook_event + // // + // // static const wchar_t* events[] = { ll_keyboard, + // // win_hook_event, + // // nullptr }; - return events; - } + // return events; + //} // Return JSON with the configuration options. virtual bool get_config(wchar_t* buffer, int* buffer_size) override @@ -149,6 +170,12 @@ public: return settings.serialize_to_buffer(buffer, buffer_size); } + // Return the non localized key of the powertoy, this will be cached by the runner + virtual const wchar_t* get_key() override + { + return app_key.c_str(); + } + // Signal from the Settings editor to call a custom action. // This can be used to spawn more complex editors. virtual void call_custom_action(const wchar_t* action) override @@ -177,7 +204,7 @@ public: { // Parse the input JSON string. PowerToysSettings::PowerToyValues values = - PowerToysSettings::PowerToyValues::from_json_string(config); + PowerToysSettings::PowerToyValues::from_json_string(config, get_key()); // Update a bool property. //if (auto v = values.get_bool_value(L"bool_toggle_1")) { @@ -229,43 +256,43 @@ public: return m_enabled; } - // Handle incoming event, data is event-specific - virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override - { - if (wcscmp(name, ll_keyboard) == 0) - { - auto& event = *(reinterpret_cast(data)); - // Return 1 if the keypress is to be suppressed (not forwarded to Windows), - // otherwise return 0. - return 0; - } - else if (wcscmp(name, win_hook_event) == 0) - { - auto& event = *(reinterpret_cast(data)); - // Return value is ignored - return 0; - } - return 0; - } + //// Handle incoming event, data is event-specific + //virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override + //{ + // if (wcscmp(name, ll_keyboard) == 0) + // { + // auto& event = *(reinterpret_cast(data)); + // // Return 1 if the keypress is to be suppressed (not forwarded to Windows), + // // otherwise return 0. + // return 0; + // } + // else if (wcscmp(name, win_hook_event) == 0) + // { + // auto& event = *(reinterpret_cast(data)); + // // Return value is ignored + // return 0; + // } + // return 0; + //} - // This methods are part of an experimental features not fully supported yet - virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override - { - } + //// This methods are part of an experimental features not fully supported yet + //virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override + //{ + //} - virtual void signal_system_menu_action(const wchar_t* name) override - { - } + //virtual void signal_system_menu_action(const wchar_t* name) override + //{ + //} }; // Load the settings file. -void $safeprojectname$::init_settings() +void Espresso::init_settings() { try { // Load and parse the settings file for this PowerToy. PowerToysSettings::PowerToyValues settings = - PowerToysSettings::PowerToyValues::load_from_settings_file($safeprojectname$::get_name()); + PowerToysSettings::PowerToyValues::load_from_settings_file(Espresso::get_name()); // Load a bool property. //if (auto v = settings.get_bool_value(L"bool_toggle_1")) { @@ -334,5 +361,5 @@ void $safeprojectname$::init_settings() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() { - return new $safeprojectname$(); + return new Espresso(); } \ No newline at end of file diff --git a/src/modules/espresso/Espresso/pch.h b/src/modules/espresso/Espresso/pch.h index 769a37b377..46fc911b44 100644 --- a/src/modules/espresso/Espresso/pch.h +++ b/src/modules/espresso/Espresso/pch.h @@ -1,5 +1,8 @@ #pragma once #define WIN32_LEAN_AND_MEAN #include -#include -#include \ No newline at end of file +#include +#include +#include +#include +#include \ No newline at end of file diff --git a/src/modules/espresso/Espresso/resource.h b/src/modules/espresso/Espresso/resource.h index e69de29bb2..e2a786bc46 100644 --- a/src/modules/espresso/Espresso/resource.h +++ b/src/modules/espresso/Espresso/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Espresso.rc +// +#define IDS_ESPRESSO_NAME 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif