Skip to content

Commit f1e7697

Browse files
committed
Date: Sat, 8 Sep 2001 04:42:23 +0200
From: Max Horn <[email protected]> Subject: SDL/OSX: Joystick; Better key handling I just finished implementing improved keyhandling for OS X (in fact the code should be easily ported to the "normal" MacOS part of SDL, I just had no chance yet). Works like this: First init the mapping table statically like before. Them, it queries the OS for the "official" key table, then iterates over all 127 scancode and gets the associates ascii code. It ignores everythng below 32 (has to, as it would lead to many problems if we did not... e.g. both ESC and NUM LOCk produce an ascii code 27 on my keyboard), and all stuff above 127 is mapped to SDLK_WORLD_* simply in the order it is encountered. In addition, caps lock is now working, too. The code work flawless for me, but since I only have one keyboard, I may have not encountered some serious problem... but I am pretty confident that it is better than the old code in most cases. The joystick driver works fine for me, too. I think it can be added to CVS already. It would simply be helpful if more people would test it. Hm, I wonder if Maelstrom or GLTron has Joystick support? That would be a wonderful test application :) I also took the liberty of modifying some text files like BUGS, README.CVS, README.MacOSX (which now contains the OS X docs I long promised)
1 parent c04171b commit f1e7697

13 files changed

+1197
-267
lines changed

BUGS

+2-4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ MacOS:
6868
Not all of the keys are properly recognized on the keyboard.
6969

7070
MacOS X:
71-
Joystick and CD-ROM functions are not implemented yet.
71+
CD-ROM functions are not implemented yet.
7272

73-
Window management buttons don't draw correctly.
73+
Joystick code is not extensively tested yet.
7474

7575
Window may not close when unsetting video mode and resetting.
7676

@@ -98,8 +98,6 @@ MacOS X:
9898
cursor in the center of the window/screen. Also, mouse moved events
9999
are not generated, and the keyboard cannot be grabbed.
100100

101-
Not all of the keys are properly recognized on the keyboard.
102-
103101
MacOS X seems to have a broken pthread_cancel() implementation.
104102

105103
FreeBSD:

README.CVS

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
The latest development version of SDL is available via CVS:
33

4-
cvs -d :pserver:guest@cvs.lokigames.com:/cvs login
5-
# use the password "guest"
6-
cvs -d :pserver:guest@cvs.lokigames.com:/cvs checkout SDL
4+
cvs -d :pserver:guest@libsdl.org:/home/slouken/libsdl.org/cvs login
5+
# No password, so just hit enter when prompted for a password
6+
cvs -d :pserver:guest@libsdl.org:/home/slouken/libsdl.org/cvs checkout SDL
77

88
When you check a fresh copy of SDL out of CVS, you need to generate
99
the files used by make by running the "autogen.sh" script, which will
1010
run aclocal, automake, autoconf and then run configure.
1111

12-
There is a web interface to cvs at http://cvs.lokigames.com/
12+
There is a web interface to cvs at http://www.libsdl.org/cgi/cvsweb.cgi
1313

README.MacOS

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ IV. Enjoy! :)
5252
If you have a project you'd like me to know about, or want to ask questions,
5353
go ahead and join the SDL developer's mailing list by sending e-mail to:
5454

55-
55+
5656

57-
and put the line "subscribe sdl" in the body of the message.
57+
and put "subscribe" into the subject of the message. Or alternatively you
58+
can use the web interface:
59+
60+
http://www.libsdl.org/mailman/listinfo/sdl
5861

5962
==============================================================================
6063

README.MacOSX

+75-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ process:
1818

1919
(You may need to create the subdirs of /usr/local manually.)
2020

21-
For some reason, libtool doesn't run ranlib properly, so do this
22-
manually:
23-
24-
ranlib /usr/local/lib/libSDL.a
25-
21+
/*
2622
To use the library once it's built, you need to use the "Carbon
2723
framework", which is the port of the old Mac Toolbox to OS X.
2824
To do this, use the -F and -framework arguments for compiling
@@ -33,6 +29,79 @@ and linking, respectively:
3329

3430
sdl-config knows about the linking path and -framework, so it's
3531
recommended to use it to fill in your Makefile variables.
32+
*/
33+
34+
To use the library once it's built, you essential have two possibilities:
35+
use the traditional autoconf/automake/make method, or use Apple's Project Builder.
36+
37+
==============================================================================
38+
Using the Simple DirectMedia Layer with a traditional Makefile
39+
==============================================================================
40+
41+
In the following, it will be mostly assumed that you are using autoconf and
42+
automake to setup your SDL project, and furthermore that you use the AM_PATH_SDL
43+
macro provided by SDL in sdl.m4. If you are not using these tools, you can
44+
still use SDL but it will be somewhat hard to get running.
45+
46+
Only step 1) is really required to get started, but for full OS X support you
47+
will want to do the other steps, too.
48+
49+
1) Update your acinclude.m4 file in case you have copied an older version of
50+
sdl.m4 into it. This is essential as AM_PATH_SDL now performs some additional
51+
tasks when used on MacOS X
52+
53+
Rationale: AM_PATH_SDL copies /usr/local/share/sdl/Info.plist and the folder
54+
/usr/local/share/sdl/SDLMain.nib/ into the directory where configure is invoked.
55+
This is essential for the configure script to be able to run the test code
56+
that detects SDL.
57+
58+
2) Copy SDL's Info.plist.in file (from src/main/macosx) into your project's main
59+
folder (the same spot that your configure.in sits), and edit it to suite your
60+
needs. Then add it to your AC_OUTPUT list in configure.in
61+
62+
Rationale: The Info.plist file can be used to specify an icon file for
63+
your app, and also to provide a human readable version/copyright string
64+
and other meta-information to the user via the Finder's Get Info dialog.
65+
66+
3) Add something like the following rule to your Makefile.am:
67+
68+
APP_NAME.app: EXE_NAME
69+
mkdir -p $@/Contents/MacOS
70+
mkdir -p $@/Contents/Resources
71+
mkdir -p $@/Contents/Resources/SDLMain.nib
72+
echo "APPL????" > $@/Contents/PkgInfo
73+
$(INSTALL_DATA) Info.plist $@/Contents/
74+
$(INSTALL_DATA) SDLMain.nib/*.nib $@/Contents/Resources/
75+
$(INSTALL_PROGRAM) $< $@/Contents/MacOS/
76+
77+
You should replace EXE_NAME with the name of the executable. APP_NAME is what
78+
will be visible to the user in the Finder. Usually it will be the same
79+
as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME
80+
usually is "TestGame"
81+
82+
If your project builds more than one application, you will have to do a bit more.
83+
For each of your target applications, you need a seperate rule. Furthermore, each
84+
needs its own Info.plist file, since that has to contain the exact name of the
85+
executable (i.e. EXE_NAME above). One way to do that is to use sed in your make rules
86+
and modify a single master Info.plist.
87+
88+
Rationale: on Mac OS X, executables have to be put into so-called "bundles".
89+
The make rule given above will construct such a bundle around the executable
90+
for you. You need to make a copy of it for each target application.
91+
92+
4) If you want the create bundles to be installed, you may want to add this
93+
rule to your Makefile.am:
94+
95+
install-exec-local: Exult.app
96+
mkdir -p /Applications/
97+
cp -r $< /Applications/
98+
99+
This rule takes the Bundle created by the rule from step 3 and installs them
100+
into /Applications/. An alternate installation place would be $HOME/Applications/
101+
102+
Again, if you want to install multiple applications, you will have to augment
103+
the make rule accordingly.
104+
36105

37106
==============================================================================
38107
Using the Simple DirectMedia Layer with Project Builder
@@ -122,3 +191,4 @@ following locations:
122191
but I expect that things will still work on older versions.
123192

124193
Known bugs are listed in the file "BUGS"
194+
LocalWords: Stuffit

configure.in

+4-2
Original file line numberDiff line numberDiff line change
@@ -2056,8 +2056,8 @@ case "$target" in
20562056
fi
20572057
# Set up files for the joystick library
20582058
if test x$enable_joystick = xyes; then
2059-
JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
2060-
JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
2059+
JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS darwin"
2060+
JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS darwin/libjoystick_darwin.la"
20612061
fi
20622062
# Set up files for the cdrom library
20632063
if test x$enable_cdrom = xyes; then
@@ -2192,6 +2192,7 @@ include/Makefile
21922192
src/Makefile
21932193
src/main/Makefile
21942194
src/main/macosx/Makefile
2195+
src/main/macosx/Info.plist
21952196
src/audio/Makefile
21962197
src/audio/alsa/Makefile
21972198
src/audio/arts/Makefile
@@ -2236,6 +2237,7 @@ src/events/Makefile
22362237
src/joystick/Makefile
22372238
src/joystick/amigaos/Makefile
22382239
src/joystick/beos/Makefile
2240+
src/joystick/darwin/Makefile
22392241
src/joystick/dummy/Makefile
22402242
src/joystick/linux/Makefile
22412243
src/joystick/macos/Makefile

sdl.m4

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run
3232
fi
3333
fi
3434
35+
AC_REQUIRE([AC_CANONICAL_TARGET])
3536
AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
3637
min_sdl_version=ifelse([$1], ,0.11.0,$1)
3738
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)

src/joystick/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libjoystick.la
55

66
# Define which subdirectories need to be built
77
SUBDIRS = @JOYSTICK_SUBDIRS@
8-
DIST_SUBDIRS = dummy amigaos beos linux macos win32
8+
DIST_SUBDIRS = dummy amigaos beos darwin linux macos win32
99

1010
DRIVERS = @JOYSTICK_DRIVERS@
1111

src/joystick/darwin/.cvsignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Makefile.in
2+
Makefile
3+
.libs
4+
*.o
5+
*.lo
6+
*.la

src/joystick/darwin/Makefile.am

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
## Makefile.am for the darwin/MacOS X joystick driver for SDL
3+
4+
noinst_LTLIBRARIES = libjoystick_darwin.la
5+
libjoystick_darwin_la_SOURCES = $(SRCS)
6+
7+
# The SDL joystick driver sources
8+
SRCS = SDL_sysjoystick.c

0 commit comments

Comments
 (0)