[PATCH 1/2] joystick.cpl: First version of the joystick configuration applet (try 2)
Lucas Fialho Zawacki
lfzawacki at gmail.com
Tue Jun 5 10:01:37 CDT 2012
From: Lucas Fialho Zawacki <lfzawacki at gmail.com>
This adds a control panel applet to configure the joysticks. It is
a property sheet and has 3 pages:
* Joystick listing
* Axes and Button Testing
* Force Feedback testing
All the function are stubs at the moment, the panel has no icon too.
Changes since last version:
* Changed name to joy.cpl
* All code will go in the file main.c
* Only exporting CPLApplet in joy.cpl.spec
* Took off some exports from Makefile.in
---
configure.ac | 1 +
dlls/joy.cpl/Makefile.in | 10 +++
dlls/joy.cpl/joy.cpl.spec | 1 +
dlls/joy.cpl/joy.h | 60 +++++++++++++++
dlls/joy.cpl/joy.rc | 55 ++++++++++++++
dlls/joy.cpl/main.c | 182 +++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 309 insertions(+)
create mode 100644 dlls/joy.cpl/Makefile.in
create mode 100644 dlls/joy.cpl/joy.cpl.spec
create mode 100644 dlls/joy.cpl/joy.h
create mode 100644 dlls/joy.cpl/joy.rc
create mode 100644 dlls/joy.cpl/main.c
diff --git a/configure.ac b/configure.ac
index 85c8939..0879178 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2624,6 +2624,7 @@ WINE_CONFIG_TEST(dlls/iphlpapi/tests)
WINE_CONFIG_DLL(itircl)
WINE_CONFIG_DLL(itss)
WINE_CONFIG_TEST(dlls/itss/tests)
+WINE_CONFIG_DLL(joy.cpl,,[po])
WINE_CONFIG_DLL(jscript,,[po])
WINE_CONFIG_TEST(dlls/jscript/tests)
WINE_CONFIG_DLL(kernel32,,[implib,mc])
diff --git a/dlls/joy.cpl/Makefile.in b/dlls/joy.cpl/Makefile.in
new file mode 100644
index 0000000..c797216
--- /dev/null
+++ b/dlls/joy.cpl/Makefile.in
@@ -0,0 +1,10 @@
+MODULE = joy.cpl
+IMPORTS = comctl32 user32 dinput dinput8 dxguid ole32
+
+C_SRCS = \
+ main.c
+
+RC_SRCS = joy.rc
+PO_SRCS = joy.rc
+
+ at MAKE_DLL_RULES@
diff --git a/dlls/joy.cpl/joy.cpl.spec b/dlls/joy.cpl/joy.cpl.spec
new file mode 100644
index 0000000..df77a30
--- /dev/null
+++ b/dlls/joy.cpl/joy.cpl.spec
@@ -0,0 +1 @@
+@ stdcall CPlApplet(long long long long)
diff --git a/dlls/joy.cpl/joy.h b/dlls/joy.cpl/joy.h
new file mode 100644
index 0000000..5c60125
--- /dev/null
+++ b/dlls/joy.cpl/joy.h
@@ -0,0 +1,60 @@
+/*
+ * Joystick testing control panel applet resources and definitions
+ *
+ * Copyright 2012 Lucas Fialho Zawacki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#ifndef __WINE_JOYSTICKCPL__
+#define __WINE_JOYSTICKCPL__
+
+#include <winuser.h>
+#include <windef.h>
+#include <commctrl.h>
+#include <dinput.h>
+
+extern HMODULE hcpl;
+
+struct Joystick {
+ IDirectInputDevice8W *device;
+ DIDEVICEINSTANCEW instance;
+ int num_buttons;
+ int num_axes;
+};
+
+struct JoystickData {
+ IDirectInput8W *di;
+ struct Joystick *joysticks;
+ int num_joysticks;
+ int cur_joystick;
+ int chosen_joystick;
+};
+
+#define NUM_PROPERTY_PAGES 3
+
+/* strings */
+#define IDS_CPL_NAME 1
+#define IDS_CPL_INFO 2
+
+/* dialogs */
+#define IDC_STATIC -1
+
+#define IDD_LIST 1000
+#define IDD_TEST 1001
+#define IDD_FORCEFEEDBACK 1002
+
+#endif
diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc
new file mode 100644
index 0000000..b9e747e
--- /dev/null
+++ b/dlls/joy.cpl/joy.rc
@@ -0,0 +1,55 @@
+/*
+ * Joystick testing control panel applet resource file
+ *
+ * Copyright 2012 Lucas Fialho Zawacki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "joy.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE
+BEGIN
+ IDS_CPL_NAME "Configure Joysticks"
+END
+
+IDD_LIST DIALOG 0, 0, 250, 200
+STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
+CAPTION "Joysticks"
+FONT 8, "Ms Shell Dlg"
+{
+}
+
+IDD_TEST DIALOG 0, 0, 250, 200
+STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
+CAPTION "Test Joystick"
+FONT 8, "Ms Shell Dlg"
+{
+}
+
+IDD_FORCEFEEDBACK DIALOG 0, 0, 250, 200
+STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
+CAPTION "Test Forcefeedback"
+FONT 8, "Ms Shell Dlg"
+{
+}
+
+#define WINE_FILENAME_STR "joy.cpl"
+#define WINE_FILEDESCRIPTION_STR "Joystick Configuration Panel"
+
+#include "wine/wine_common_ver.rc"
diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c
new file mode 100644
index 0000000..caa6208
--- /dev/null
+++ b/dlls/joy.cpl/main.c
@@ -0,0 +1,182 @@
+/*
+ * Joystick testing control panel applet
+ *
+ * Copyright 2012 Lucas Fialho Zawacki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#define NONAMELESSUNION
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <commctrl.h>
+#include <cpl.h>
+#include "ole2.h"
+
+#include "wine/debug.h"
+#include "joy.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(joycpl);
+
+DECLSPEC_HIDDEN HMODULE hcpl;
+
+/*********************************************************************
+ * DllMain (joystickcpl.@)
+ */
+BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
+{
+ TRACE("(%p, %d, %p)\n", hdll, reason, reserved);
+
+ switch (reason)
+ {
+ case DLL_WINE_PREATTACH:
+ return FALSE; /* prefer native version */
+
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hdll);
+ hcpl = hdll;
+ }
+ return TRUE;
+}
+
+/******************************************************************************
+ * propsheet_callback [internal]
+ *
+ */
+static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
+{
+ TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
+ switch (msg)
+ {
+ case PSCB_INITIALIZED:
+ break;
+ }
+ return 0;
+}
+
+/******************************************************************************
+ * display_cpl_sheets [internal]
+ *
+ * Build and display the dialog with all control panel propertysheets
+ *
+ */
+static void display_cpl_sheets(HWND parent, struct JoystickData *data)
+{
+ INITCOMMONCONTROLSEX icex;
+ PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
+ PROPSHEETHEADERW psh;
+ DWORD id = 0;
+
+ OleInitialize(NULL);
+ /* Initialize common controls */
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ ZeroMemory(&psh, sizeof(psh));
+ ZeroMemory(psp, sizeof(psp));
+
+ /* Fill out all PROPSHEETPAGE */
+ psp[id].dwSize = sizeof (PROPSHEETPAGEW);
+ psp[id].hInstance = hcpl;
+ psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_LIST);
+ psp[id].pfnDlgProc = NULL;
+ psp[id].lParam = (INT_PTR) data;
+ id++;
+
+ psp[id].dwSize = sizeof (PROPSHEETPAGEW);
+ psp[id].hInstance = hcpl;
+ psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_TEST);
+ psp[id].pfnDlgProc = NULL;
+ psp[id].lParam = (INT_PTR) data;
+ id++;
+
+ psp[id].dwSize = sizeof (PROPSHEETPAGEW);
+ psp[id].hInstance = hcpl;
+ psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_FORCEFEEDBACK);
+ psp[id].pfnDlgProc = NULL;
+ psp[id].lParam = (INT_PTR) data;
+ id++;
+
+ /* Fill out the PROPSHEETHEADER */
+ psh.dwSize = sizeof (PROPSHEETHEADERW);
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
+ psh.hwndParent = parent;
+ psh.hInstance = hcpl;
+ psh.pszCaption = MAKEINTRESOURCEW(IDS_CPL_NAME);
+ psh.nPages = id;
+ psh.u3.ppsp = psp;
+ psh.pfnCallback = propsheet_callback;
+
+ /* display the dialog */
+ PropertySheetW(&psh);
+
+ OleUninitialize();
+}
+
+/*********************************************************************
+ * CPlApplet (joystickcpl.@)
+ *
+ * Control Panel entry point
+ *
+ * PARAMS
+ * hWnd [I] Handle for the Control Panel Window
+ * command [I] CPL_* Command
+ * lParam1 [I] first extra Parameter
+ * lParam2 [I] second extra Parameter
+ *
+ * RETURNS
+ * Depends on the command
+ *
+ */
+LONG CALLBACK CPlApplet(HWND hwnd, UINT command, LPARAM lParam1, LPARAM lParam2)
+{
+ static struct JoystickData data;
+ TRACE("(%p, %u, 0x%lx, 0x%lx)\n", hwnd, command, lParam1, lParam2);
+
+ switch (command)
+ {
+ case CPL_INIT:
+ return TRUE;
+
+ case CPL_GETCOUNT:
+ return 1;
+
+ case CPL_INQUIRE:
+ {
+ CPLINFO *appletInfo = (CPLINFO *) lParam2;
+
+ appletInfo->idName = IDS_CPL_NAME;
+ appletInfo->idInfo = IDS_CPL_INFO;
+ appletInfo->lData = 0;
+ return TRUE;
+ }
+
+ case CPL_DBLCLK:
+ display_cpl_sheets(hwnd, &data);
+ break;
+
+ case CPL_STOP:
+ break;
+ }
+
+ return FALSE;
+}
--
1.7.9.5
More information about the wine-patches
mailing list