Try and make the ifdefs more sane

This commit is contained in:
ahal 2011-04-15 10:11:34 -07:00
Родитель a9b62dc262
Коммит 9edf535176
7 изменённых файлов: 50 добавлений и 47 удалений

11
common/common_utils.h Normal file
Просмотреть файл

@ -0,0 +1,11 @@
#ifndef __COMMON_UTILS_H
#define __COMMON_UTILS_H
typedef struct {
unsigned int shift;
unsigned int ctrl;
unsigned int meta;
unsigned int alt;
unsigned int access;
} modifiers;
#endif // header guard

Просмотреть файл

@ -1,4 +1,4 @@
#include "../native_events.h"
#include "linux_events.h"
#include <stdlib.h>
// Creates a key event

Просмотреть файл

@ -2,18 +2,11 @@
#define __LINUX_NATIVE_UTILS_H
#include <gdk/gdk.h>
typedef struct {
unsigned int shift;
unsigned int ctrl;
unsigned int meta;
unsigned int alt;
unsigned int access;
} modifiers;
#include "../common/common_utils.h"
// Utility methods for linux events
GdkDevice* getSomeDevice();
GdkWindow* getActiveWindow();
guint32 getTimestamp();
guint getModifierState(modifiers *mods);
#endif
#endif // header guard

Просмотреть файл

@ -1,22 +1,13 @@
#include "native_events.h"
// We need to talk about this interface. This isn't going to work
#ifdef __linux
guint click(gint x, gint y, guint button) {
libexport uint click(int x, int y, uint button) {
return _click(x, y, button);
}
guint keypress(guint32 val, modifiers mods) {
libexport uint keypress(uint32 val, modifiers mods) {
return _keypress(val, &mods);
}
guint sendKeys(char *val, modifiers mods) {
libexport uint sendKeys(char *val, modifiers mods) {
return _sendKeys(val, &mods);
}
#endif
#ifdef __WIN32
#define DllExport __declspec( dllexport )
DllExport unsigned int click(int x, int y, char flags[32], int button) {
return _click(x, y, flags, button);
}
#endif

Просмотреть файл

@ -1,35 +1,30 @@
#ifndef __SEND_EVENT_H
#define __SEND_EVENT_H
#ifdef __cplusplus
#define ext extern "C"
#else
#define ext
#endif
#include "common/common_utils.h"
#ifdef __linux
#include <gdk/gdk.h>
#include "linux/linux_events.h"
#include "linux/linux_utils.h"
#ifdef __cplusplus
// Define C++ 'private' methods here
guint createKeyEvent(GdkEventType type, char c, guint state);
guint createModifierEvents(GdkEventType type, modifiers *mods);
#else
// Define C shim methods here (this is the API exposed to the user)
guint click(gint x, gint y, guint button);
guint sendKeys(char *val, modifiers mods);
guint keypress(guint32 val, modifiers mods);
#endif
// Define C++ method implementations here
ext guint _click(gint x, gint y, guint button);
ext guint _sendKeys(char *val, modifiers *mods);
ext guint _keypress(guint32 val, modifiers *mods);
#define libexport
// Type definitions
#define uint guint
#define uint32 guint32
#define int gint
#endif // linux
#ifdef __WIN32
ext unsigned int _click(int x, int y, char flags[32], int button);
#include "windows/windows_events.h"
#define libexport __declspec( dllexport )
// Type definitions
#define uint unsigned int
#define uint32 unsigned int // TODO Make this whatever the windows equivalent is
#endif // windows
// Define C shim methods here (this is the API exposed to the user)
uint click(int x, int y, uint button);
uint sendKeys(char *val, modifiers mods);
uint keypress(uint32 val, modifiers mods);
#endif // header guard

Просмотреть файл

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "../native_events.h"
#include "windows_events.h"
extern "C" unsigned int _click(int x, int y, char flags[32], int button){
extern "C" unsigned int _click(int x, int y, unsigned int button){
printf("Hello world\n");
return 0;
}

13
windows/windows_events.h Normal file
Просмотреть файл

@ -0,0 +1,13 @@
#ifndef __WINDOWS_EVENTS_H
#define __WINDOWS_EVENTS_H
#ifdef __cplusplus
#define ext extern "C"
// Define C++ 'private' methods here
#else
#define ext
#endif
// Define C++ implementation methods here
ext unsigned int _click(int x, int y, unsigned int button);
#endif