2
* Copyright (c) 1997 - 2001 Hansj�rg Malthaner
4
* This file is part of the Simutrans project under the artistic licence.
15
#include <SDL/SDL_syswm.h>
19
#include <sys/errno.h>
30
#define PATH_MAX (1024)
42
struct sys_event sys_event;
44
int dr_os_init(const int*)
46
// prepare for next event
47
sys_event.type = SIM_NOEVENT;
52
int dr_query_screen_width()
57
int dr_query_screen_height()
63
int dr_os_open(int, int, int, int)
75
int dr_textur_resize(unsigned short** textur, int, int, int)
81
// query home directory
82
char *dr_query_homedir(void)
84
static char buffer[PATH_MAX];
87
DWORD len=PATH_MAX-24;
89
if(RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 0, KEY_READ, &hHomeDir)==ERROR_SUCCESS) {
90
RegQueryValueExA(hHomeDir,"Personal",NULL,NULL,(BYTE *)buffer,&len);
91
strcat(buffer,"\\Simutrans");
92
CreateDirectoryA( buffer, NULL);
95
// create other subdirectories
96
sprintf(b2, "%ssave", buffer );
97
CreateDirectoryA( b2, NULL );
98
sprintf(b2, "%sscreenshot", buffer );
99
CreateDirectoryA( b2, NULL );
100
sprintf(b2, "%smaps", buffer );
101
CreateDirectoryA( b2, NULL );
108
sprintf( buffer, "%s/simutrans", getenv("HOME") );
110
sprintf( buffer, "%s/Documents/simutrans", getenv("HOME") );
112
int err = mkdir( buffer, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
113
if(err && err!=EEXIST) {
114
// could not create directory
115
// we assume success anyway
117
strcat( buffer, "/" );
118
sprintf( b2, "%smaps", buffer );
120
sprintf( b2, "%sscreenshot", buffer );
122
sprintf( b2, "%ssave", buffer );
128
unsigned short *dr_textur_init()
133
unsigned int get_system_color(unsigned int, unsigned int, unsigned int)
138
void dr_setRGB8multi(int, int, unsigned char*)
142
void dr_prepare_flush()
150
void dr_textur(int, int, int, int)
154
void move_pointer(int, int)
158
void set_pointer(int)
162
int dr_screenshot(const char *)
167
static inline unsigned int ModifierKeys(void)
176
void GetEventsNoWait(void)
180
void show_pointer(int)
184
void ex_ord_update_mx_my()
188
unsigned long dr_time(void)
193
void dr_sleep(uint32 usec)
195
timespec sleepfor, zero;
196
sleepfor.tv_sec = usec/1000;
198
sleepfor.tv_nsec = 1000 * usec;
199
nanosleep( &sleepfor, &zero);
202
bool dr_fatal_notify(const char* msg, int choices)
208
int main(int argc, char **argv)
211
# if defined __GLIBC__
212
/* glibc has a non-standard extension */
213
char* buffer2 = NULL;
215
char buffer2[PATH_MAX];
217
char buffer[PATH_MAX];
218
int length = readlink("/proc/self/exe", buffer, lengthof(buffer) - 1);
220
buffer[length] = '\0'; /* readlink() does not NUL-terminate */
223
// no process file system => need to parse argv[0]
224
/* should work on most unix or gnu systems */
225
argv[0] = realpath(argv[0], buffer2);
227
return simu_main(argc, argv);