Ejemplo n.º 1
0
void es_peepEvents(sdl_data *sd, int len, char *bp)
{
  SDL_Event events[256];
  int numevents, res;
  Uint32 mask;
  char *start;

  if (len == 0) {
    mask = SDL_ALLEVENTS;
    numevents = 16;
  } else {
    mask = * (Uint32 *) bp; bp += sizeof(Uint32);
    numevents = *bp++;
  }
  SDL_PumpEvents();
  res = SDL_PeepEvents(events, numevents, SDL_GETEVENT, mask);
  if (res > 0) {
    int sendlen, i;
    bp = start = sdl_get_temp_buff(sd, res*MAX_EVENT_SIZE);
    for (i = 0; i < res; i++) {
      bp = encode_event(&(events[i]), bp);
    }
    sendlen = bp - start;
    sdl_send(sd, sendlen);
  }
}
Ejemplo n.º 2
0
/* API */
void es_audioDriverName(sdl_data *sd, int len, char *bp)
{
  int sendlen = 0;
    
  bp = sdl_get_temp_buff(sd, 256);
  if (SDL_AudioDriverName(bp, 256) != NULL) {
      sendlen = (int) strlen(bp);
  }
  sdl_send(sd, sendlen);
}
Ejemplo n.º 3
0
void es_getAppState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 state;

   bp = start = sdl_get_temp_buff(sd, 1);
   state = SDL_GetAppState();
   put8(bp, state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 4
0
void es_getCursor(sdl_data *sd, int len,char *buff)
{
   char *bp, *start;
   SDL_Cursor *c;
   int sendlen;
   
   bp = start = sdl_get_temp_buff(sd, 8);
   c = SDL_GetCursor();
   PUSHGLPTR(c, bp);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 5
0
void es_numJoysticks(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int joys;

   bp = buff;
   bp = start = sdl_get_temp_buff(sd, 1);
   joys = SDL_NumJoysticks();
   put8(bp, joys);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 6
0
void es_showCursor(sdl_data *sd, int len, char *bp)
{
   int sendlen;
   char *start;
   Uint8 bool;

   bool = (Uint8) *bp;
   bool = SDL_ShowCursor(bool);
   bp = start = sdl_get_temp_buff(sd, 1);
   put8(bp, bool);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 7
0
void es_getModState(sdl_data *sd, int len,char *buff)
{
   Uint16 state;

   if ((state = SDL_GetModState()) != 0) {
     int sendlen;
     char *bp, *start;
     bp = start = sdl_get_temp_buff(sd, 2);
     put16be(bp, state);
     sendlen = bp - start;
     sdl_send(sd, sendlen);
   }
}
Ejemplo n.º 8
0
void es_getKeyState(sdl_data *sd, int len,char *buff)
{
   Uint8 * keys;
   char *bp, *start;
   int length, sendlen, i;

   keys = SDL_GetKeyState(&length);
   bp = start = sdl_get_temp_buff(sd, length);
   for(i=0; i<length; i++)
      put8(bp, keys[i]);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 9
0
void es_joystick_opened(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int index, bool;
   
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   bool = SDL_JoystickOpened(index);
   put8(bp, bool);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 10
0
void es_enableKeyRepeat(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint16 delay, intv, res;
   bp = buff;
   delay = get16be(bp);
   intv  = get16be(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   res = SDL_EnableKeyRepeat(delay, intv);
   put8(bp, res);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 11
0
void es_enableUNICODE(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 enable;

   bp = buff;
   enable = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   enable = SDL_EnableUNICODE(enable);
   put8(bp, enable);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 12
0
void es_joystick_eventState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int state;
   
   bp = buff;
   state = get32be(bp);
   bp = start = sdl_get_temp_buff(sd, 4);
   state = SDL_JoystickEventState(state);
   put32be(bp, state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 13
0
void es_waitEvent(sdl_data *sd, int len,char *buff)
{
    SDL_Event event;
    int sendlen;
    char *bp, *start;
    
    bp = start = sdl_get_temp_buff(sd, MAX_EVENT_SIZE);
    SDL_WaitEvent(&event);
    bp = encode_event(&event, bp);
    if (*start != SDL_NOEVENT) {
      sendlen = bp - start;
      sdl_send(sd, sendlen);
    }
}
Ejemplo n.º 14
0
void es_pollEvent(sdl_data *sd, int len, char *buff)
{
  SDL_Event event;
  
  if (SDL_PollEvent(&event)) {
    int sendlen;
    char *bp, *start;

    bp = start = sdl_get_temp_buff(sd, MAX_EVENT_SIZE);
    bp = encode_event(&event, bp);
    sendlen = bp - start;
    sdl_send(sd, sendlen);
  }
}
Ejemplo n.º 15
0
void es_eventState(sdl_data *sd, int len, char *bp) 
{
   Uint8 type, res;
   int sendlen, state;
   char *start;
    
   type  = get8(bp);
   state = get8(bp);

   res = SDL_EventState(type, state);
   bp = start = sdl_get_temp_buff(sd, 1);
   put8(bp, res);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 16
0
void es_getRelativeMouseState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 state;
   int x, y;

   bp = start = sdl_get_temp_buff(sd, 5);
   state = SDL_GetRelativeMouseState(&x, &y);
   put8(bp, state);
   put16be(bp, x);
   put16be(bp, y);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 17
0
void es_joystick_getAxis(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int state, axis;
   bp = buff;
   POPGLPTR(joy, bp);
   axis = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 4);
   state = SDL_JoystickGetAxis(joy, axis);
   put32be(bp, state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 18
0
void es_joystick_numButtons(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int buttons;

   bp = buff;
   POPGLPTR(joy, bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   buttons = SDL_JoystickNumButtons(joy);
   put8(bp,buttons);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 19
0
void es_joystick_index(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int index;

   bp = buff;
   POPGLPTR(joy, bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   index = SDL_JoystickIndex(joy);
   put8(bp,index);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 20
0
void es_joystick_getButton(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int state;
   Uint8 button;
   bp = buff;
   POPGLPTR(joy, bp);
   button = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   state = SDL_JoystickGetButton(joy, button);
   put8(bp,state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 21
0
void es_joystick_open(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int index;
   
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 8);
   if((joy = SDL_JoystickOpen(index)) != NULL) {
      PUSHGLPTR(joy, bp);
   }
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 22
0
void es_getKeyName(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start, *name;
   Uint16 key;
   
   bp = buff;
   key = get16be(bp);
   bp = start = sdl_get_temp_buff(sd, 128);
   name = SDL_GetKeyName(key);
   while(*name != '\0') {
      put8(bp, *name);
      name++;
   }
   
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 23
0
void es_joystick_name(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int index;
   const char * name;
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 256);
   name = SDL_JoystickName(index);
   index = 0;
   while(*name != '\0' && index++ < 256) {
      put8(bp, *name);
      name++;
   }
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 24
0
void es_joystick_getBall(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int dx, dy;
   Uint8 ball;
   
   bp = buff;
   POPGLPTR(joy, bp);
   ball = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 8);
   if(0 == SDL_JoystickGetBall(joy, ball, &dx, &dy)) {
      put32be(bp, dx);
      put32be(bp, dy);
   }
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Ejemplo n.º 25
0
void es_createCursor(sdl_data *sd, int len, char *bp)
{
  int sendlen;
  char *start;
  Uint8* data;
  Uint8* mask;
  int w,h, hotx, hoty, ds;
  SDL_Cursor* cursor;

  w = * (unsigned short *) bp; bp += sizeof(unsigned short);
  h = * (unsigned short *) bp; bp += sizeof(unsigned short);
  hotx = * (unsigned short *) bp; bp += sizeof(unsigned short);
  hoty = * (unsigned short *) bp; bp += sizeof(unsigned short);
  ds = * (unsigned short *) bp; bp += sizeof(unsigned short);
  data = (Uint8*) bp;
  mask = data + ds;
  cursor = SDL_CreateCursor(data, mask, w, h, hotx, hoty);
  bp = start = sdl_get_temp_buff(sd, 8);
  PUSHGLPTR(cursor, bp);
  sendlen = bp - start;
  sdl_send(sd, sendlen);
}
Ejemplo n.º 26
0
void es_loadWAV(sdl_data *sd, int len, char *bp)
{
    int sendlen;
    char *name, *start;
    SDL_AudioSpec obtained;
    Uint8 * ptr;
    Uint32 blen;

    name = bp;
    bp = start = sdl_get_temp_buff(sd, 28);
    if(NULL != SDL_LoadWAV(name, &obtained, &ptr, &blen)) {
       put32be(bp, obtained.freq);
       put16be(bp, obtained.format);
       put8(bp, obtained.channels);
       put8(bp, obtained.silence);
       put16be(bp, obtained.samples);
       put16be(bp, obtained.padding);
       put32be(bp, obtained.size);
       PUSHGLPTR(ptr, bp);
       put32be(bp, blen);
    }
    sendlen = (int) (bp - start);
    sdl_send(sd, sendlen);
}