[PATCH 1/2] joystick.cpl: First version of the joystick configuration applet
Lucas Fialho Zawacki
lfzawacki at gmail.com
Sun Jun 3 23:19:52 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.
---
configure.ac | 1 +
dlls/joystick.cpl/Makefile.in | 14 +++
dlls/joystick.cpl/forcefeedback.c | 60 +++++++++++
dlls/joystick.cpl/joystick.cpl.spec | 3 +
dlls/joystick.cpl/joystick.h | 63 ++++++++++++
dlls/joystick.cpl/joystick.rc | 55 ++++++++++
dlls/joystick.cpl/list.c | 57 +++++++++++
dlls/joystick.cpl/main.c | 191 +++++++++++++++++++++++++++++++++++
dlls/joystick.cpl/test.c | 60 +++++++++++
9 files changed, 504 insertions(+)
create mode 100644 dlls/joystick.cpl/Makefile.in
create mode 100644 dlls/joystick.cpl/forcefeedback.c
create mode 100644 dlls/joystick.cpl/joystick.cpl.spec
create mode 100644 dlls/joystick.cpl/joystick.h
create mode 100644 dlls/joystick.cpl/joystick.rc
create mode 100644 dlls/joystick.cpl/list.c
create mode 100644 dlls/joystick.cpl/main.c
create mode 100644 dlls/joystick.cpl/test.c
diff --git a/configure.ac b/configure.ac
index 85c8939..4681c98 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(joystick.cpl,,[po])
WINE_CONFIG_DLL(jscript,,[po])
WINE_CONFIG_TEST(dlls/jscript/tests)
WINE_CONFIG_DLL(kernel32,,[implib,mc])
diff --git a/dlls/joystick.cpl/Makefile.in b/dlls/joystick.cpl/Makefile.in
new file mode 100644
index 0000000..b3cab48
--- /dev/null
+++ b/dlls/joystick.cpl/Makefile.in
@@ -0,0 +1,14 @@
+MODULE = joystick.cpl
+IMPORTS = comctl32 shlwapi user32 advapi32 dinput dinput8 dxguid
+DELAYIMPORTS = ole32
+
+C_SRCS = \
+ main.c \
+ list.c \
+ test.c \
+ forcefeedback.c
+
+RC_SRCS = joystick.rc
+PO_SRCS = joystick.rc
+
+ at MAKE_DLL_RULES@
diff --git a/dlls/joystick.cpl/forcefeedback.c b/dlls/joystick.cpl/forcefeedback.c
new file mode 100644
index 0000000..b86912d
--- /dev/null
+++ b/dlls/joystick.cpl/forcefeedback.c
@@ -0,0 +1,60 @@
+/*
+ * Joystick testing control panel applet: Joystick force feedback testing propsheet
+ *
+ * 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
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <wininet.h>
+#include <winreg.h>
+#include <shlwapi.h>
+#include <prsht.h>
+
+#include "wine/debug.h"
+#include "joystick.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(joystickcpl);
+
+/*********************************************************************
+ * forcefeedback_dlgproc [internal]
+ *
+ */
+INT_PTR CALLBACK forcefeedback_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ return TRUE;
+
+ case WM_NOTIFY:
+ return TRUE;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
diff --git a/dlls/joystick.cpl/joystick.cpl.spec b/dlls/joystick.cpl/joystick.cpl.spec
new file mode 100644
index 0000000..7b1f97d
--- /dev/null
+++ b/dlls/joystick.cpl/joystick.cpl.spec
@@ -0,0 +1,3 @@
+@ stdcall CPlApplet(long long long long)
+@ stub DisplayPopupWindowManagementDialog
+@ stdcall -private DllInstall(long wstr)
diff --git a/dlls/joystick.cpl/joystick.h b/dlls/joystick.cpl/joystick.h
new file mode 100644
index 0000000..52f6b72
--- /dev/null
+++ b/dlls/joystick.cpl/joystick.h
@@ -0,0 +1,63 @@
+/*
+ * 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;
+INT_PTR CALLBACK list_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
+INT_PTR CALLBACK test_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
+INT_PTR CALLBACK forcefeedback_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
+
+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/joystick.cpl/joystick.rc b/dlls/joystick.cpl/joystick.rc
new file mode 100644
index 0000000..cce2e30
--- /dev/null
+++ b/dlls/joystick.cpl/joystick.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 "joystick.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 "joystick.cpl"
+#define WINE_FILEDESCRIPTION_STR "Joystick Configuration Panel"
+
+#include "wine/wine_common_ver.rc"
diff --git a/dlls/joystick.cpl/list.c b/dlls/joystick.cpl/list.c
new file mode 100644
index 0000000..5883faa
--- /dev/null
+++ b/dlls/joystick.cpl/list.c
@@ -0,0 +1,57 @@
+/*
+ * Joystick testing control panel applet: Joystick listing propsheet
+ *
+ * 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
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <shlwapi.h>
+#include <prsht.h>
+
+#include "wine/debug.h"
+#include "joystick.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(joystickcpl);
+
+/*********************************************************************
+ * list_dlgproc [internal]
+ *
+ */
+INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ return TRUE;
+
+ case WM_NOTIFY:
+ return TRUE;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
diff --git a/dlls/joystick.cpl/main.c b/dlls/joystick.cpl/main.c
new file mode 100644
index 0000000..55e9a4e
--- /dev/null
+++ b/dlls/joystick.cpl/main.c
@@ -0,0 +1,191 @@
+/*
+ * 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 "joystick.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(joystickcpl);
+
+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;
+}
+
+/***********************************************************************
+ * DllInstall (joystickcpl.@)
+ */
+HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
+{
+ FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
+ return S_OK;
+}
+
+/******************************************************************************
+ * 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 = list_dlgproc;
+ 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 = test_dlgproc;
+ 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 = forcefeedback_dlgproc;
+ 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;
+}
diff --git a/dlls/joystick.cpl/test.c b/dlls/joystick.cpl/test.c
new file mode 100644
index 0000000..0db4108
--- /dev/null
+++ b/dlls/joystick.cpl/test.c
@@ -0,0 +1,60 @@
+/*
+ * Joystick testing control panel applet: Joystick testing propsheet
+ *
+ * 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
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <wininet.h>
+#include <winreg.h>
+#include <shlwapi.h>
+#include <prsht.h>
+
+#include "wine/debug.h"
+#include "joystick.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(joystickcpl);
+
+/*********************************************************************
+ * test_dlgproc [internal]
+ *
+ */
+INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ return TRUE;
+
+ case WM_NOTIFY:
+ return TRUE;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
--
1.7.9.5
More information about the wine-patches
mailing list