Ignore:
Timestamp:
Apr 8, 2013, 2:29:13 AM (10 years ago)
Author:
sam
Message:

input: activate SDL input with Emscripten.

Location:
trunk/src/platform/sdl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/sdl/sdlapp.cpp

    r2625 r2644  
    102102#   endif
    103103
    104 #   if !defined EMSCRIPTEN
    105104    new SdlInput();
    106 #   endif
    107105#endif
    108106}
  • trunk/src/platform/sdl/sdlinput.cpp

    r2610 r2644  
    99//
    1010
    11 #if defined HAVE_CONFIG_H
     11#if HAVE_CONFIG_H
    1212#   include "config.h"
    1313#endif
    1414
    15 #if defined USE_SDL
    16 #   if defined HAVE_SDL_SDL_H
     15#if USE_SDL
     16#   if HAVE_SDL_SDL_H
    1717#      include <SDL/SDL.h>
    1818#   else
     
    4343
    4444    static ivec2 GetMousePos();
    45 #if defined USE_SDL
     45#if USE_SDL
    4646    Array<SDL_Joystick *, Stick *> m_joysticks;
    4747#endif
     
    5555  : m_data(new SdlInputData())
    5656{
    57 #if defined USE_SDL
     57#if USE_SDL
    5858    /* Enable Unicode translation of keyboard events */
    5959    SDL_EnableUNICODE(1);
     
    6161    SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK);
    6262
    63 #   if SDL_FORCE_POLL_JOYSTICK
     63#   if !EMSCRIPTEN
     64#       if SDL_FORCE_POLL_JOYSTICK
    6465    SDL_JoystickEventState(SDL_QUERY);
    65 #   else
     66#       else
    6667    SDL_JoystickEventState(SDL_ENABLE);
    67 #   endif
     68#       endif
    6869
    6970    /* Register all the joysticks we can find, and let the input
     
    7980        char const *name = SDL_JoystickName(i);
    8081        if (strstr(name, "HDAPS")
    81 #   if defined USE_XINPUT
     82#       if USE_XINPUT
    8283             || strstr(name, "XBOX 360 For Windows")
    83 #   endif
     84#       endif
    8485             || false)
    8586        {
     
    9899        m_data->m_joysticks.Push(sdlstick, stick);
    99100    }
     101#   endif
    100102#endif
    101103
     
    105107SdlInput::~SdlInput()
    106108{
    107 #if defined USE_SDL
     109#if USE_SDL && !EMSCRIPTEN
    108110    /* Unregister all the joysticks we added */
    109111    while (m_data->m_joysticks.Count())
     
    121123    Entity::TickGame(seconds);
    122124
    123 #if !defined _WIN32
     125#if !_WIN32
    124126    m_data->Tick(seconds);
    125127#endif
     
    130132    Entity::TickDraw(seconds);
    131133
    132 #if defined _WIN32
     134#if _WIN32
    133135    m_data->Tick(seconds);
    134136#endif
     
    137139void SdlInputData::Tick(float seconds)
    138140{
    139 #if defined USE_SDL
     141#if USE_SDL
    140142    /* Handle mouse input */
    141143    ivec2 mouse = SdlInputData::GetMousePos();;
    142144    Input::SetMousePos(mouse);
    143145
    144 #   if SDL_FORCE_POLL_JOYSTICK
     146#   if SDL_FORCE_POLL_JOYSTICK && EMSCRIPTEN
    145147    /* Pump all joystick events because no event is coming to us. */
    146148    SDL_JoystickUpdate();
     
    211213    ivec2 ret(-1, -1);
    212214
    213 #if defined USE_SDL
     215#if USE_SDL
     216#   if !EMSCRIPTEN
    214217    if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
     218#   endif
    215219    {
    216220        SDL_GetMouseState(&ret.x, &ret.y);
Note: See TracChangeset for help on using the changeset viewer.