Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fc944144
Commit
fc944144
authored
Aug 13, 2012
by
Lucas Zawacki
Committed by
Alexandre Julliard
Aug 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
joy.cpl: Correct misplaced elements when using high DPIs.
parent
028f3be0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
46 deletions
+78
-46
joy.h
dlls/joy.cpl/joy.h
+27
-26
main.c
dlls/joy.cpl/main.c
+51
-20
No files found.
dlls/joy.cpl/joy.h
View file @
fc944144
...
@@ -50,6 +50,13 @@ struct Joystick {
...
@@ -50,6 +50,13 @@ struct Joystick {
#define TEST_MAX_BUTTONS 32
#define TEST_MAX_BUTTONS 32
#define TEST_MAX_AXES 4
#define TEST_MAX_AXES 4
struct
Graphics
{
HWND
hwnd
;
HWND
buttons
[
TEST_MAX_BUTTONS
];
HWND
axes
[
TEST_MAX_AXES
];
HWND
ff_axis
;
};
struct
JoystickData
{
struct
JoystickData
{
IDirectInput8W
*
di
;
IDirectInput8W
*
di
;
struct
Joystick
*
joysticks
;
struct
Joystick
*
joysticks
;
...
@@ -57,9 +64,7 @@ struct JoystickData {
...
@@ -57,9 +64,7 @@ struct JoystickData {
int
num_ff
;
int
num_ff
;
int
cur_joystick
;
int
cur_joystick
;
int
chosen_joystick
;
int
chosen_joystick
;
HWND
buttons
[
TEST_MAX_BUTTONS
];
struct
Graphics
graphics
;
HWND
axes
[
TEST_MAX_AXES
];
HWND
ff_axis
;
BOOL
stop
;
BOOL
stop
;
};
};
...
@@ -86,36 +91,32 @@ struct JoystickData {
...
@@ -86,36 +91,32 @@ struct JoystickData {
#define IDC_TESTGROUPZRZ 2007
#define IDC_TESTGROUPZRZ 2007
#define IDC_TESTGROUPPOV 2008
#define IDC_TESTGROUPPOV 2008
#define IDC_JOYSTICKBUTTON 3000
#define IDC_JOYSTICKAXES 4000
#define IDC_FFSELECTCOMBO 2009
#define IDC_FFSELECTCOMBO 2009
#define IDC_FFEFFECTLIST 2010
#define IDC_FFEFFECTLIST 2010
#define IDC_FFAXIS 2011
/* constants */
/* constants */
#define TEST_POLL_TIME 100
#define TEST_POLL_TIME 100
#define TEST_BUTTON_COL_MAX 8
#define TEST_BUTTON_COL_MAX 8
#define TEST_BUTTON_X
15
#define TEST_BUTTON_X
8
#define TEST_BUTTON_Y
200
#define TEST_BUTTON_Y
122
#define TEST_NEXT_BUTTON_X
45
#define TEST_NEXT_BUTTON_X
30
#define TEST_NEXT_BUTTON_Y
40
#define TEST_NEXT_BUTTON_Y
25
#define TEST_BUTTON_SIZE_X
3
0
#define TEST_BUTTON_SIZE_X
2
0
#define TEST_BUTTON_SIZE_Y
25
#define TEST_BUTTON_SIZE_Y
18
#define TEST_AXIS_X
65
#define TEST_AXIS_X
43
#define TEST_AXIS_Y
98
#define TEST_AXIS_Y
60
#define TEST_NEXT_AXIS_X
115
#define TEST_NEXT_AXIS_X
77
#define TEST_AXIS_SIZE_X
5
#define TEST_AXIS_SIZE_X
3
#define TEST_AXIS_SIZE_Y
5
#define TEST_AXIS_SIZE_Y
3
#define TEST_AXIS_MIN -
40
#define TEST_AXIS_MIN -
25
#define TEST_AXIS_MAX
40
#define TEST_AXIS_MAX
25
#define FF_AXIS_X
373
#define FF_AXIS_X
248
#define FF_AXIS_Y
98
#define FF_AXIS_Y
60
#define FF_AXIS_SIZE_X
5
#define FF_AXIS_SIZE_X
3
#define FF_AXIS_SIZE_Y
5
#define FF_AXIS_SIZE_Y
3
#define FF_PLAY_TIME 2*DI_SECONDS
#define FF_PLAY_TIME 2*DI_SECONDS
#define FF_PERIOD_TIME FF_PLAY_TIME/4
#define FF_PERIOD_TIME FF_PLAY_TIME/4
...
...
dlls/joy.cpl/main.c
View file @
fc944144
...
@@ -166,6 +166,9 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
...
@@ -166,6 +166,9 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
SendDlgItemMessageW
(
hwnd
,
IDC_JOYSTICKLIST
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
joy
->
instance
.
tszInstanceName
);
SendDlgItemMessageW
(
hwnd
,
IDC_JOYSTICKLIST
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
joy
->
instance
.
tszInstanceName
);
}
}
/* Store the hwnd to be used with MapDialogRect for unit conversions */
data
->
graphics
.
hwnd
=
hwnd
;
return
TRUE
;
return
TRUE
;
}
}
...
@@ -260,7 +263,7 @@ static DWORD WINAPI input_thread(void *param)
...
@@ -260,7 +263,7 @@ static DWORD WINAPI input_thread(void *param)
/* Indicate pressed buttons */
/* Indicate pressed buttons */
for
(
i
=
0
;
i
<
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
;
i
++
)
for
(
i
=
0
;
i
<
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
;
i
++
)
if
(
state
.
rgbButtons
[
i
])
if
(
state
.
rgbButtons
[
i
])
SendMessageW
(
data
->
buttons
[
i
],
BM_SETSTATE
,
TRUE
,
0
);
SendMessageW
(
data
->
graphics
.
buttons
[
i
],
BM_SETSTATE
,
TRUE
,
0
);
/* Indicate axis positions, axes showing are hardcoded for now */
/* Indicate axis positions, axes showing are hardcoded for now */
axes_pos
[
0
][
0
]
=
state
.
lX
;
axes_pos
[
0
][
0
]
=
state
.
lX
;
...
@@ -281,16 +284,21 @@ static DWORD WINAPI input_thread(void *param)
...
@@ -281,16 +284,21 @@ static DWORD WINAPI input_thread(void *param)
}
}
for
(
i
=
0
;
i
<
TEST_MAX_AXES
;
i
++
)
for
(
i
=
0
;
i
<
TEST_MAX_AXES
;
i
++
)
SetWindowPos
(
data
->
axes
[
i
],
0
,
{
TEST_AXIS_X
+
TEST_NEXT_AXIS_X
*
i
+
axes_pos
[
i
][
0
],
RECT
r
;
TEST_AXIS_Y
+
axes_pos
[
i
][
1
],
0
,
0
,
SWP_NOZORDER
|
SWP_NOSIZE
);
r
.
left
=
(
TEST_AXIS_X
+
TEST_NEXT_AXIS_X
*
i
+
axes_pos
[
i
][
0
]);
r
.
top
=
(
TEST_AXIS_Y
+
axes_pos
[
i
][
1
]);
MapDialogRect
(
data
->
graphics
.
hwnd
,
&
r
);
SetWindowPos
(
data
->
graphics
.
axes
[
i
],
0
,
r
.
left
,
r
.
top
,
0
,
0
,
SWP_NOZORDER
|
SWP_NOSIZE
);
}
Sleep
(
TEST_POLL_TIME
);
Sleep
(
TEST_POLL_TIME
);
/* Reset button state */
/* Reset button state */
for
(
i
=
0
;
i
<
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
;
i
++
)
for
(
i
=
0
;
i
<
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
;
i
++
)
SendMessageW
(
data
->
buttons
[
i
],
BM_SETSTATE
,
FALSE
,
0
);
SendMessageW
(
data
->
graphics
.
buttons
[
i
],
BM_SETSTATE
,
FALSE
,
0
);
}
}
return
0
;
return
0
;
...
@@ -306,7 +314,7 @@ static void test_handle_joychange(HWND hwnd, struct JoystickData *data)
...
@@ -306,7 +314,7 @@ static void test_handle_joychange(HWND hwnd, struct JoystickData *data)
/* Enable only buttons present in the device */
/* Enable only buttons present in the device */
for
(
i
=
0
;
i
<
TEST_MAX_BUTTONS
;
i
++
)
for
(
i
=
0
;
i
<
TEST_MAX_BUTTONS
;
i
++
)
ShowWindow
(
data
->
buttons
[
i
],
i
<=
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
);
ShowWindow
(
data
->
graphics
.
buttons
[
i
],
i
<=
data
->
joysticks
[
data
->
chosen_joystick
].
num_buttons
);
}
}
/*********************************************************************
/*********************************************************************
...
@@ -331,17 +339,24 @@ static void draw_joystick_buttons(HWND hwnd, struct JoystickData* data)
...
@@ -331,17 +339,24 @@ static void draw_joystick_buttons(HWND hwnd, struct JoystickData* data)
for
(
i
=
0
;
i
<
TEST_MAX_BUTTONS
;
i
++
)
for
(
i
=
0
;
i
<
TEST_MAX_BUTTONS
;
i
++
)
{
{
RECT
r
;
if
((
i
%
TEST_BUTTON_COL_MAX
)
==
0
&&
i
!=
0
)
if
((
i
%
TEST_BUTTON_COL_MAX
)
==
0
&&
i
!=
0
)
{
{
row
+=
1
;
row
+=
1
;
col
=
0
;
col
=
0
;
}
}
r
.
left
=
(
TEST_BUTTON_X
+
TEST_NEXT_BUTTON_X
*
col
);
r
.
top
=
(
TEST_BUTTON_Y
+
TEST_NEXT_BUTTON_Y
*
row
);
r
.
right
=
r
.
left
+
TEST_BUTTON_SIZE_X
;
r
.
bottom
=
r
.
top
+
TEST_BUTTON_SIZE_Y
;
MapDialogRect
(
hwnd
,
&
r
);
button_number_to_wchar
(
i
+
1
,
button_label
);
button_number_to_wchar
(
i
+
1
,
button_label
);
data
->
buttons
[
i
]
=
CreateWindowW
(
button_class
,
button_label
,
WS_CHILD
,
data
->
graphics
.
buttons
[
i
]
=
CreateWindowW
(
button_class
,
button_label
,
WS_CHILD
,
TEST_BUTTON_X
+
TEST_NEXT_BUTTON_X
*
col
,
TEST_BUTTON_Y
+
TEST_NEXT_BUTTON_Y
*
row
,
r
.
left
,
r
.
top
,
r
.
right
-
r
.
left
,
r
.
bottom
-
r
.
top
,
TEST_BUTTON_SIZE_X
,
TEST_BUTTON_SIZE_Y
,
hwnd
,
NULL
,
NULL
,
hinst
);
hwnd
,
NULL
,
NULL
,
hinst
);
col
+=
1
;
col
+=
1
;
...
@@ -360,13 +375,19 @@ static void draw_joystick_axes(HWND hwnd, struct JoystickData* data)
...
@@ -360,13 +375,19 @@ static void draw_joystick_axes(HWND hwnd, struct JoystickData* data)
for
(
i
=
0
;
i
<
TEST_MAX_AXES
;
i
++
)
for
(
i
=
0
;
i
<
TEST_MAX_AXES
;
i
++
)
{
{
RECT
r
;
/* Set axis box name */
/* Set axis box name */
SetWindowTextW
(
GetDlgItem
(
hwnd
,
axes_idc
[
i
]),
axes_names
[
i
]);
SetWindowTextW
(
GetDlgItem
(
hwnd
,
axes_idc
[
i
]),
axes_names
[
i
]);
data
->
axes
[
i
]
=
CreateWindowW
(
button_class
,
NULL
,
WS_CHILD
|
WS_VISIBLE
,
r
.
left
=
(
TEST_AXIS_X
+
TEST_NEXT_AXIS_X
*
i
);
TEST_AXIS_X
+
TEST_NEXT_AXIS_X
*
i
,
TEST_AXIS_Y
,
r
.
top
=
TEST_AXIS_Y
;
TEST_AXIS_SIZE_X
,
TEST_AXIS_SIZE_Y
,
r
.
right
=
r
.
left
+
TEST_AXIS_SIZE_X
;
hwnd
,
(
HMENU
)
IDC_JOYSTICKAXES
+
i
,
NULL
,
hinst
);
r
.
bottom
=
r
.
top
+
TEST_AXIS_SIZE_Y
;
MapDialogRect
(
hwnd
,
&
r
);
data
->
graphics
.
axes
[
i
]
=
CreateWindowW
(
button_class
,
NULL
,
WS_CHILD
|
WS_VISIBLE
,
r
.
left
,
r
.
top
,
r
.
right
-
r
.
left
,
r
.
bottom
-
r
.
top
,
hwnd
,
NULL
,
NULL
,
hinst
);
}
}
}
}
...
@@ -452,12 +473,18 @@ static void draw_ff_axis(HWND hwnd, struct JoystickData *data)
...
@@ -452,12 +473,18 @@ static void draw_ff_axis(HWND hwnd, struct JoystickData *data)
{
{
HINSTANCE
hinst
=
(
HINSTANCE
)
GetWindowLongPtrW
(
hwnd
,
GWLP_HINSTANCE
);
HINSTANCE
hinst
=
(
HINSTANCE
)
GetWindowLongPtrW
(
hwnd
,
GWLP_HINSTANCE
);
static
WCHAR
button_class
[]
=
{
'B'
,
'u'
,
't'
,
't'
,
'o'
,
'n'
,
'\0'
};
static
WCHAR
button_class
[]
=
{
'B'
,
'u'
,
't'
,
't'
,
'o'
,
'n'
,
'\0'
};
RECT
r
;
r
.
left
=
FF_AXIS_X
;
r
.
top
=
FF_AXIS_Y
;
r
.
right
=
r
.
left
+
FF_AXIS_SIZE_X
;
r
.
bottom
=
r
.
top
+
FF_AXIS_SIZE_Y
;
MapDialogRect
(
hwnd
,
&
r
);
/* Draw direction axis */
/* Draw direction axis */
data
->
ff_axis
=
CreateWindowW
(
button_class
,
NULL
,
WS_CHILD
|
WS_VISIBLE
,
data
->
graphics
.
ff_axis
=
CreateWindowW
(
button_class
,
NULL
,
WS_CHILD
|
WS_VISIBLE
,
FF_AXIS_X
,
FF_AXIS_Y
,
r
.
left
,
r
.
top
,
r
.
right
-
r
.
left
,
r
.
bottom
-
r
.
top
,
FF_AXIS_SIZE_X
,
FF_AXIS_SIZE_Y
,
hwnd
,
NULL
,
NULL
,
hinst
);
hwnd
,
(
HMENU
)
IDC_FFAXIS
,
NULL
,
hinst
);
}
}
static
void
initialize_effects_list
(
HWND
hwnd
,
struct
Joystick
*
joy
)
static
void
initialize_effects_list
(
HWND
hwnd
,
struct
Joystick
*
joy
)
...
@@ -508,6 +535,7 @@ static DWORD WINAPI ff_input_thread(void *param)
...
@@ -508,6 +535,7 @@ static DWORD WINAPI ff_input_thread(void *param)
int
chosen_effect
=
joy
->
chosen_effect
;
int
chosen_effect
=
joy
->
chosen_effect
;
DIEFFECT
*
dieffect
;
DIEFFECT
*
dieffect
;
DWORD
flags
=
DIEP_AXES
|
DIEP_DIRECTION
|
DIEP_NORESTART
;
DWORD
flags
=
DIEP_AXES
|
DIEP_DIRECTION
|
DIEP_NORESTART
;
RECT
r
;
/* Skip this if we have no effects */
/* Skip this if we have no effects */
if
(
joy
->
num_effects
==
0
||
chosen_effect
<
0
)
continue
;
if
(
joy
->
num_effects
==
0
||
chosen_effect
<
0
)
continue
;
...
@@ -519,8 +547,11 @@ static DWORD WINAPI ff_input_thread(void *param)
...
@@ -519,8 +547,11 @@ static DWORD WINAPI ff_input_thread(void *param)
dieffect
->
rgdwAxes
[
0
]
=
state
.
lX
;
dieffect
->
rgdwAxes
[
0
]
=
state
.
lX
;
dieffect
->
rgdwAxes
[
1
]
=
state
.
lY
;
dieffect
->
rgdwAxes
[
1
]
=
state
.
lY
;
SetWindowPos
(
data
->
ff_axis
,
0
,
FF_AXIS_X
+
state
.
lX
,
FF_AXIS_Y
+
state
.
lY
,
r
.
left
=
FF_AXIS_X
+
state
.
lX
;
0
,
0
,
SWP_NOZORDER
|
SWP_NOSIZE
);
r
.
top
=
FF_AXIS_Y
+
state
.
lY
;
MapDialogRect
(
data
->
graphics
.
hwnd
,
&
r
);
SetWindowPos
(
data
->
graphics
.
ff_axis
,
0
,
r
.
left
,
r
.
top
,
0
,
0
,
SWP_NOZORDER
|
SWP_NOSIZE
);
for
(
i
=
0
;
i
<
joy
->
num_buttons
;
i
++
)
for
(
i
=
0
;
i
<
joy
->
num_buttons
;
i
++
)
if
(
state
.
rgbButtons
[
i
])
if
(
state
.
rgbButtons
[
i
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment