[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Adding new events
Hello Everybody,
I need to us 2 new sdl libraries with pygames and I was hoping someone could
tell me the best way to go about including them in pygame. The API looks
like this. This was not created by me, I just need to use it with the game I
developed in python.
/*
* SDL-oriented Zeekthing-Compass access routines.
*
* mrb / Mike Burke, 2006 November.
*/
#ifndef __SDL_COMPASS_H
#define __SDL_COMPASS_H
/*
* This SDL compass library interacts with the compass on the Zeekthing
board,
* by serial connection. To use it, first you have to call sdlcomp_open()
* which will return an SDL_COMPASS handle that you will use to get readings
* back from the compass.
*/
#include <SDL.h>
#include <SDL_thread.h>
#define COMPASS_EVENT (SDL_USEREVENT+2)
#define COMPASS_READDELAY 100 // ms: 100 ms = 10 readings per second
#define COMPASS_SERVFILE "/tmp/sermuxd.serv.C" // where to find the text
file indicating our service pty
struct SDL_COMPASS
{
SDL_Thread *thrd;
void *thrddata;
};
/*
* Open the compass at the specified location where -- a serial device or
pty.
* If that is NULL, the function tries to figure it out. Creates a separate
* thread to manage polling the compass.
*
* Pass in a pointer to a struct SDL_COMPASS that you have allocated memory
* for, that will be used for future calls to sdlcomp_* functions.
* sdlcomp_getAzimuth to get the reading in either case, and it can be called
* at any time without penalty)
* push_event: 1 if you want COMPASS_EVENT to be pushed onto the stack when
* a compass reading is available, 0 otherwise (you will need to call
* getAzimuth to get the reading back, however; it is not provided in the
* USEREVENT struct due to thread-unsafeness).
*
*
* Returns: 0 for success, -1 for error
*/
int sdlcomp_open(struct SDL_COMPASS *sdlcomp, char *where, int push_event);
/*
* Fetch a reading from the compass. Argument sdlcompass is the sdlcompass
* handle returned from a call to sdlcomp_open
*
* Returns a value < 0 in case of failure, else the azimuth in [0,360]
*/
double sdlcomp_getAzimuth(struct SDL_COMPASS *sdlcompass);
/*
* Gracefully stop the compass-polling thread. sdlcompass will no longer be
* meaningful and may be deleted by you after this call.
*/
void sdlcomp_close(struct SDL_COMPASS *sdlcompass);
#endif
So it adds stuff to the SDL event queue. So I am guessing I need to
recompile pygame so it knows about my 2 new sdl libraries. Do i have to also
tell it about the event type and define what is coming. Also, if anybody
knows is it difficult to recompile pymaomo, since I am actually using this
on the nokia 770.
Thanks for any help you can give me.
Ben Woodhead
_________________________________________________________________
Download now! Visit http://www.telusmobility.com/msnxbox/ to enter and see
how cool it is to get Messenger with you on your cell phone.
http://www.telusmobility.com/msnxbox/