Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Proof of concept done - Win32 GDI implementation mostly complete.
  • Loading branch information
slouken committed Jul 6, 2006
1 parent f167e55 commit 0d18b5a
Show file tree
Hide file tree
Showing 34 changed files with 2,927 additions and 295 deletions.
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -2347,7 +2347,7 @@ case "$host" in
have_loadso=yes
fi
# Set up the system libraries we need
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
# The Win32 platform requires special setup
SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
Expand Down
6 changes: 6 additions & 0 deletions include/SDL_compat.h
Expand Up @@ -57,6 +57,12 @@ extern "C" {
#define SDL_ACTIVEEVENT SDL_EVENT_RESERVED1
#define SDL_VIDEORESIZE SDL_EVENT_RESERVED2
#define SDL_VIDEOEXPOSE SDL_EVENT_RESERVED3
#define SDL_ACTIVEEVENTMASK SDL_EVENTMASK(SDL_ACTIVEEVENT)
#define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
#define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)

#define SDL_BUTTON_WHEELUP 4
#define SDL_BUTTON_WHEELDOWN 5

typedef struct SDL_VideoInfo
{
Expand Down
33 changes: 28 additions & 5 deletions include/SDL_events.h
Expand Up @@ -60,9 +60,11 @@ typedef enum
SDL_WINDOWEVENT, /**< Window state change */
SDL_KEYDOWN, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */
SDL_TEXTINPUT, /**< Keyboard text input */
SDL_MOUSEMOTION, /**< Mouse moved */
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
SDL_MOUSEBUTTONUP, /**< Mouse button released */
SDL_MOUSEWHEEL, /**< Mouse wheel motion */
SDL_JOYAXISMOTION, /**< Joystick axis motion */
SDL_JOYBALLMOTION, /**< Joystick trackball motion */
SDL_JOYHATMOTION, /**< Joystick hat position change */
Expand Down Expand Up @@ -93,9 +95,11 @@ typedef enum
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
Expand Down Expand Up @@ -141,17 +145,17 @@ typedef struct SDL_KeyboardEvent
} SDL_KeyboardEvent;

/**
* \struct SDL_CharEvent
* \struct SDL_TextInputEvent
*
* \brief Keyboard input event structure
* \brief Keyboard text input event structure
*/
typedef struct SDL_CharEvent
typedef struct SDL_TextInputEvent
{
Uint8 type; /**< SDL_CHARINPUT (FIXME: NYI) */
Uint8 type; /**< SDL_TEXTINPUT */
Uint8 which; /**< The keyboard device index */
char text[32]; /**< The input text */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
} SDL_CharEvent;
} SDL_TextInputEvent;

/**
* \struct SDL_MouseMotionEvent
Expand Down Expand Up @@ -186,6 +190,19 @@ typedef struct SDL_MouseButtonEvent
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseButtonEvent;

/**
* \struct SDL_MouseWheelEvent
*
* \brief Mouse wheel event structure
*/
typedef struct SDL_MouseWheelEvent
{
Uint8 type; /**< SDL_MOUSEWHEEL */
Uint8 which; /**< The mouse device index */
int motion; /**< The direction and distance scrolled */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseWheelEvent;

/**
* \struct SDL_JoyAxisEvent
*
Expand Down Expand Up @@ -306,8 +323,10 @@ typedef union SDL_Event
Uint8 type; /**< Event type, shared with all events */
SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
SDL_JoyBallEvent jball; /**< Joystick ball event data */
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
Expand Down Expand Up @@ -353,6 +372,10 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
SDL_eventaction action,
Uint32 mask);

/* Checks to see if certain event types are in the event queue.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);

/* Polls for currently pending events, and returns 1 if there are any pending
events, or 0 if there are none available. If 'event' is not NULL, the next
event is removed from the queue and stored in that area.
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_keyboard.h
Expand Up @@ -52,7 +52,7 @@ typedef struct SDL_keysym
Uint8 padding[3]; /**< alignment padding */
Uint16 sym; /**< SDL virtual keysym */
Uint16 mod; /**< current key modifiers */
Uint32 unicode; /**< OBSOLETE, use SDL_CharEvent instead */
Uint32 unicode; /**< OBSOLETE, use SDL_TextInputEvent instead */
} SDL_keysym;

/* Function prototypes */
Expand Down
4 changes: 0 additions & 4 deletions include/SDL_mouse.h
Expand Up @@ -202,15 +202,11 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
Button 1: Left mouse button
Button 2: Middle mouse button
Button 3: Right mouse button
Button 4: Mouse wheel up (may also be a real button)
Button 5: Mouse wheel down (may also be a real button)
*/
#define SDL_BUTTON(X) (1 << ((X)-1))
#define SDL_BUTTON_LEFT 1
#define SDL_BUTTON_MIDDLE 2
#define SDL_BUTTON_RIGHT 3
#define SDL_BUTTON_WHEELUP 4
#define SDL_BUTTON_WHEELDOWN 5
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
Expand Down
9 changes: 9 additions & 0 deletions include/SDL_video.h
Expand Up @@ -148,6 +148,7 @@ typedef enum
SDL_WINDOWEVENT_NONE, /**< Never used */
SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be redrawn */
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1,data2 */
SDL_WINDOWEVENT_RESIZED, /**< Window size changed to data1xdata2 */
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
Expand All @@ -157,6 +158,7 @@ typedef enum
SDL_WINDOWEVENT_LEAVE, /**< The window has lost mouse focus */
SDL_WINDOWEVENT_FOCUS_GAINED, /**< The window has gained keyboard focus */
SDL_WINDOWEVENT_FOCUS_LOST, /**< The window has lost keyboard focus */
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
} SDL_WindowEventID;

/**
Expand Down Expand Up @@ -1419,6 +1421,13 @@ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
*/
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);

/*
* Calculate the intersection of two rectangles
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
const SDL_Rect * B,
SDL_Rect * intersection);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
Expand Down
46 changes: 45 additions & 1 deletion src/SDL_compat.c
Expand Up @@ -164,6 +164,12 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
switch (event->type) {
case SDL_WINDOWEVENT:
switch (event->window.event) {
case SDL_WINDOWEVENT_EXPOSED:
if (!SDL_HasEvent(SDL_VIDEOEXPOSEMASK)) {
fake.type = SDL_VIDEOEXPOSE;
SDL_PushEvent(&fake);
}
break;
case SDL_WINDOWEVENT_RESIZED:
fake.type = SDL_VIDEORESIZE;
fake.resize.w = event->window.data1;
Expand Down Expand Up @@ -206,6 +212,10 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
fake.active.state = SDL_APPINPUTFOCUS;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_CLOSE:
fake.type = SDL_QUIT;
SDL_PushEvent(&fake);
break;
}
case SDL_KEYDOWN:
case SDL_KEYUP:
Expand All @@ -226,6 +236,38 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
}
break;
}
case SDL_MOUSEWHEEL:
{
Uint8 button;
int selected;
int x, y;

selected = SDL_SelectMouse(event->wheel.which);
SDL_GetMouseState(&x, &y);
SDL_SelectMouse(selected);

if (event->wheel.motion > 0) {
button = SDL_BUTTON_WHEELUP;
} else {
button = SDL_BUTTON_WHEELDOWN;
}

fake.button.which = event->wheel.windowID;
fake.button.button = button;
fake.button.x = x;
fake.button.y = y;
fake.button.windowID = event->wheel.windowID;

fake.type = SDL_MOUSEBUTTONDOWN;
fake.button.state = SDL_PRESSED;
SDL_PushEvent(&fake);

fake.type = SDL_MOUSEBUTTONUP;
fake.button.state = SDL_RELEASED;
SDL_PushEvent(&fake);
break;
}

}
if (orig_eventfilter) {
return orig_eventfilter(orig_eventfilterparam, event);
Expand Down Expand Up @@ -304,7 +346,9 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
window_flags |= SDL_WINDOW_BORDERLESS;
}
SDL_VideoWindow =
SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags);
SDL_CreateWindow(wm_title, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, width, height,
window_flags);
if (!SDL_VideoWindow) {
return NULL;
}
Expand Down
8 changes: 7 additions & 1 deletion src/events/SDL_events.c
Expand Up @@ -373,6 +373,12 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
return (used);
}

SDL_bool
SDL_HasEvent(Uint32 mask)
{
return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, mask) > 0);
}

/* Run the system dependent event loops */
void
SDL_PumpEvents(void)
Expand Down Expand Up @@ -520,7 +526,7 @@ SDL_EventState(Uint8 type, int state)
/* This is a generic event handler.
*/
int
SDL_PrivateSysWMEvent(SDL_SysWMmsg * message)
SDL_SendSysWMEvent(SDL_SysWMmsg * message)
{
int posted;

Expand Down
3 changes: 3 additions & 0 deletions src/events/SDL_events_c.h
Expand Up @@ -25,6 +25,7 @@
#include "SDL_events.h"
#include "SDL_mouse_c.h"
#include "SDL_keyboard_c.h"
#include "SDL_windowevents_c.h"

/* Start and stop the event processing loop */
extern int SDL_StartEventLoop(Uint32 flags);
Expand All @@ -35,6 +36,8 @@ extern void SDL_Lock_EventThread(void);
extern void SDL_Unlock_EventThread(void);
extern Uint32 SDL_EventThreadID(void);

extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);

extern int SDL_QuitInit(void);
extern int SDL_SendQuit(void);
extern void SDL_QuitQuit(void);
Expand Down

0 comments on commit 0d18b5a

Please sign in to comment.