Opened 14 months ago

Last modified 2 months ago

#99 accepted defect

Strange set key behavior

Reported by: HoraK-FDF@… Owned by: Thomas Bernard
Priority: major Milestone: 2.8
Component: GrafX2 Version: 2.6
Keywords: Cc:

Description

Hi,

the version I'm using is grafx2-win32-2.6.2475-win32.zip from the download page.

If i try to set keys it displays a wrong key but the desired key works as intended for example:

if press Up it shows Shift+PgDn?, that kind of behavior is true for many other keys:
Left -> Alt+Shift+' '
Right -> Alt+Shift+PgDn?

... greetings HoraK-FDF

Change History (13)

comment:1 Changed 14 months ago by Thomas Bernard

thanks for the report, I will check that.

comment:2 Changed 14 months ago by Thomas Bernard

Owner: changed from pulkomandy to Thomas Bernard
Status: newaccepted

comment:3 Changed 14 months ago by HoraK-FDF@…

It does not happen with grafx2-sdl-2.6.2475-win32.zip

comment:4 Changed 14 months ago by Thomas Bernard

OK I think that is because we use MOD_SHIFT/MOD_ALT_/MOD_CTRL which are defined in WinUser.h :

#define MOD_ALT         0x0001
#define MOD_CONTROL     0x0002
#define MOD_SHIFT       0x0004

it conflicts with our own definitions in global.h

Up has win32 keycode 0x26 which is 0x4 (SHIFT) + 0x22 (Page Down)

comment:6 Changed 14 months ago by Thomas Bernard

safe and long term solution is to rename MOD_SHIFT, etc. to a private name such as GFX2_MOD_SHIFT, etc.

comment:7 Changed 14 months ago by yrizoud@…

<windows.h> pollutes the global namespace a lot, I think it would be better to minimize the number of .C files that include it.

comment:8 Changed 14 months ago by Thomas Bernard

@yrizoud: here is what I propose to do :

  1. merge https://gitlab.com/GrafX2/grafX2/merge_requests/168 as a quick fix for v2.6
  1. wait v2.7wip to apply the patch https://gitlab.com/miniupnp/grafX2/commit/a29e2c0bda7a60fcd85091c722ef5f181d567de3

which rename MOD_* to GFX2_MOD_* so there is no more clash

comment:9 Changed 14 months ago by yrizoud@…

Yes I agree with both changes as a short- and long-term fix for these modifiers. But I still think that (microsoft's) windows.h is going to collide with more stuff in the future.
The current coding conventions helps avoid a lot of conflicts (T_Struct for most structs, capitalized Function() etc. but (from a quick look at MS docs in search of examples) you can easily collide common names such as #define INPUT (reserved by a typdefed struct) or if you try to call a parameter or local variable "mouse_event" (reserved by an obsolete function)

comment:10 Changed 14 months ago by PulkoMandy

For Haiku I moved all the platform specific code to haiku.cpp as it is written in C++.
I would recommend doing the same for other platform specific parts: define our API, and move its implementation to a specific file. This would avoid including windows.h anywhere outside this specific file.

comment:11 Changed 14 months ago by Thomas Bernard

I have created a specific ticket for <windows.h> name pollution :
http://pulkomandy.tk/projects/GrafX2/ticket/105

comment:12 Changed 14 months ago by Thomas Bernard

comment:13 Changed 2 months ago by PulkoMandy

Milestone: 2.8
Note: See TracTickets for help on using tickets.