lib/input.h was old+bad code. fixed in_add_handler return type to enum; renamed EV_PASS to IN_PASS; no longer include sdl.h from other code (instead rely on input.h)
This was SVN commit r2975.
This commit is contained in:
parent
39060e7900
commit
bed9363bfe
@ -31,7 +31,6 @@
|
||||
#include "Model.h"
|
||||
#include "Projectile.h"
|
||||
|
||||
#include "sdl.h"
|
||||
#include "input.h"
|
||||
#include "lib.h"
|
||||
#include "timer.h"
|
||||
@ -580,19 +579,19 @@ void CGameView::PopCameraTarget()
|
||||
m_CameraTargets.pop_back();
|
||||
}
|
||||
|
||||
int game_view_handler(const SDL_Event* ev)
|
||||
InEventReaction game_view_handler(const SDL_Event* ev)
|
||||
{
|
||||
// put any events that must be processed even if inactive here
|
||||
|
||||
if(!g_active || !g_Game)
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
CGameView *pView=g_Game->GetView();
|
||||
|
||||
return pView->HandleEvent(ev);
|
||||
}
|
||||
|
||||
int CGameView::HandleEvent(const SDL_Event* ev)
|
||||
InEventReaction CGameView::HandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
switch(ev->type)
|
||||
{
|
||||
@ -606,30 +605,30 @@ int CGameView::HandleEvent(const SDL_Event* ev)
|
||||
} else {
|
||||
g_Renderer.SetTerrainRenderMode(WIREFRAME);
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
case HOTKEY_CAMERA_RESET_ORIGIN:
|
||||
ResetCamera();
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
case HOTKEY_CAMERA_RESET:
|
||||
ResetCameraOrientation();
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
case HOTKEY_CAMERA_ROTATE_ABOUT_TARGET:
|
||||
RotateAboutTarget();
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
// Mouse wheel must be treated using events instead of polling,
|
||||
// because SDL auto-generates a sequence of mousedown/mouseup events
|
||||
// and we never get to see the "down" state inside Update().
|
||||
case HOTKEY_CAMERA_ZOOM_WHEEL_IN:
|
||||
m_ZoomDelta += m_ViewZoomSensitivityWheel;
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
case HOTKEY_CAMERA_ZOOM_WHEEL_OUT:
|
||||
m_ZoomDelta -= m_ViewZoomSensitivityWheel;
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
|
||||
default:
|
||||
|
||||
@ -657,7 +656,7 @@ int CGameView::HandleEvent(const SDL_Event* ev)
|
||||
if( bookmarkInUse[id] )
|
||||
SetCameraTarget( cameraBookmarks[id] );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
}
|
||||
case SDL_HOTKEYUP:
|
||||
@ -669,12 +668,12 @@ int CGameView::HandleEvent(const SDL_Event* ev)
|
||||
currentBookmark = -1;
|
||||
break;
|
||||
default:
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
}
|
||||
|
||||
bool CGameView::JSI_StartCustomSelection(
|
||||
|
@ -11,10 +11,7 @@ extern float g_YMinOffset;
|
||||
|
||||
#include "scripting/ScriptableObject.h"
|
||||
|
||||
// note: cannot forward declare SDL_Event since it is a nameless union
|
||||
// in the standard SDL library and a nameless struct in wsdl, so
|
||||
// include the full SDL header instead.
|
||||
#include "sdl.h"
|
||||
#include "lib/input.h"
|
||||
|
||||
class CGame;
|
||||
class CGameAttributes;
|
||||
@ -96,7 +93,7 @@ public:
|
||||
// Render: Render the World
|
||||
void Render();
|
||||
|
||||
int HandleEvent(const SDL_Event* ev);
|
||||
InEventReaction HandleEvent(const SDL_Event* ev);
|
||||
|
||||
//Keep the camera in between boundaries/smooth camera scrolling/translating
|
||||
//Should call this whenever moving (translating) the camera
|
||||
@ -119,6 +116,6 @@ public:
|
||||
inline CCamera *GetCamera()
|
||||
{ return &m_Camera; }
|
||||
};
|
||||
extern int game_view_handler(const SDL_Event* ev);
|
||||
extern InEventReaction game_view_handler(const SDL_Event* ev);
|
||||
|
||||
#endif
|
||||
|
@ -181,7 +181,7 @@ void CDropDown::HandleMessage(const SGUIMessage &Message)
|
||||
CList::HandleMessage(Message);
|
||||
}
|
||||
|
||||
int CDropDown::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
InEventReaction CDropDown::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
int szChar = ev->key.keysym.sym;
|
||||
bool update_highlight = false;
|
||||
@ -199,7 +199,7 @@ int CDropDown::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
case SDLK_PAGEUP:
|
||||
case SDLK_PAGEDOWN:
|
||||
if (!m_Open)
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
// Set current selected item to highlighted, before
|
||||
// then really processing these in CList::ManuallyHandleEvent()
|
||||
GUI<int>::SetSetting(this, "selected", m_ElementHighlight);
|
||||
@ -215,7 +215,7 @@ int CDropDown::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
if (update_highlight)
|
||||
GUI<int>::GetSetting(this, "selected", m_ElementHighlight);
|
||||
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
}
|
||||
|
||||
void CDropDown::SetupListRect()
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/**
|
||||
* Handle events manually to catch keyboard inputting.
|
||||
*/
|
||||
virtual int ManuallyHandleEvent(const SDL_Event* ev);
|
||||
virtual InEventReaction ManuallyHandleEvent(const SDL_Event* ev);
|
||||
|
||||
/**
|
||||
* Draws the Button
|
||||
|
@ -60,14 +60,14 @@ JSClass GUIClass = {
|
||||
// event is passed to other handlers if false is returned.
|
||||
// trampoline: we don't want to make the implementation (in CGUI) static
|
||||
//-------------------------------------------------------------------
|
||||
int gui_handler(const SDL_Event* ev)
|
||||
InEventReaction gui_handler(const SDL_Event* ev)
|
||||
{
|
||||
return g_GUI.HandleEvent(ev);
|
||||
}
|
||||
|
||||
int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
InEventReaction CGUI::HandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
int ret = EV_PASS;
|
||||
InEventReaction ret = IN_PASS;
|
||||
|
||||
if (ev->type == SDL_GUIHOTKEYPRESS)
|
||||
{
|
||||
@ -87,7 +87,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
else if (ev->type == SDL_MOUSEMOTION)
|
||||
{
|
||||
// Yes the mouse position is stored as float to avoid
|
||||
// constant conversations when operating in a
|
||||
// constant conversions when operating in a
|
||||
// float-based environment.
|
||||
m_MousePos = CPos((float)ev->motion.x, (float)ev->motion.y);
|
||||
|
||||
@ -152,7 +152,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
pNearest->ScriptEvent("mouseleftpress");
|
||||
|
||||
// Block event, so things on the map (behind the GUI) won't be pressed
|
||||
ret = EV_HANDLED;
|
||||
ret = IN_HANDLED;
|
||||
}
|
||||
else if (m_FocusedObject)
|
||||
{
|
||||
@ -168,7 +168,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
pNearest->HandleMessage(SGUIMessage(GUIM_MOUSE_WHEEL_DOWN));
|
||||
pNearest->ScriptEvent("mousewheeldown");
|
||||
|
||||
ret = EV_HANDLED;
|
||||
ret = IN_HANDLED;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -178,7 +178,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
pNearest->HandleMessage(SGUIMessage(GUIM_MOUSE_WHEEL_UP));
|
||||
pNearest->ScriptEvent("mousewheelup");
|
||||
|
||||
ret = EV_HANDLED;
|
||||
ret = IN_HANDLED;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -197,7 +197,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
pNearest->HandleMessage(SGUIMessage(GUIM_MOUSE_RELEASE_LEFT));
|
||||
pNearest->ScriptEvent("mouseleftrelease");
|
||||
|
||||
ret = EV_HANDLED;
|
||||
ret = IN_HANDLED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -250,7 +250,7 @@ int CGUI::HandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
ret = GetFocusedObject()->ManuallyHandleEvent(ev);
|
||||
}
|
||||
// else will return EV_PASS because we never used the button.
|
||||
// else will return IN_PASS because we never used the button.
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -32,7 +32,7 @@ ERROR_TYPE(GUI, JSOpenFailed);
|
||||
|
||||
#include "XML/Xeromyces.h"
|
||||
|
||||
extern int gui_handler(const SDL_Event* ev);
|
||||
extern InEventReaction gui_handler(const SDL_Event* ev);
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Macros
|
||||
@ -146,7 +146,7 @@ public:
|
||||
*
|
||||
* @param ev SDL Event, like mouse/keyboard input
|
||||
*/
|
||||
int HandleEvent(const SDL_Event* ev);
|
||||
InEventReaction HandleEvent(const SDL_Event* ev);
|
||||
|
||||
/**
|
||||
* Load a GUI XML file into the GUI.
|
||||
|
@ -54,7 +54,7 @@ CInput::~CInput()
|
||||
{
|
||||
}
|
||||
|
||||
int CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
InEventReaction CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
debug_assert(m_iBufferPos != -1);
|
||||
|
||||
@ -83,7 +83,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
clipboard_free(text);
|
||||
}
|
||||
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
}
|
||||
}
|
||||
else if (ev->type == SDL_KEYDOWN)
|
||||
@ -414,7 +414,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
// If there's a selection, delete if first.
|
||||
if (cooked == 0)
|
||||
return EV_PASS; // Important, because we didn't use any key
|
||||
return IN_PASS; // Important, because we didn't use any key
|
||||
|
||||
// check max length
|
||||
int max_length;
|
||||
@ -444,7 +444,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
}
|
||||
}
|
||||
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
}
|
||||
|
||||
void CInput::HandleMessage(const SGUIMessage &Message)
|
||||
|
@ -80,7 +80,7 @@ protected:
|
||||
/**
|
||||
* Handle events manually to catch keyboard inputting.
|
||||
*/
|
||||
virtual int ManuallyHandleEvent(const SDL_Event* ev);
|
||||
virtual InEventReaction ManuallyHandleEvent(const SDL_Event* ev);
|
||||
|
||||
// void InsertMessage(const wchar_t* szMessage, ...);
|
||||
// void InsertChar(const int szChar, const wchar_t cooked);
|
||||
|
@ -251,7 +251,7 @@ void CList::HandleMessage(const SGUIMessage &Message)
|
||||
IGUITextOwner::HandleMessage(Message);
|
||||
}
|
||||
|
||||
int CList::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
InEventReaction CList::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
int szChar = ev->key.keysym.sym;
|
||||
|
||||
@ -289,7 +289,7 @@ int CList::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
break;
|
||||
}
|
||||
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
}
|
||||
|
||||
void CList::Draw()
|
||||
|
@ -84,7 +84,7 @@ protected:
|
||||
/**
|
||||
* Handle events manually to catch keyboard inputting.
|
||||
*/
|
||||
virtual int ManuallyHandleEvent(const SDL_Event* ev);
|
||||
virtual InEventReaction ManuallyHandleEvent(const SDL_Event* ev);
|
||||
|
||||
/**
|
||||
* Draws the List box
|
||||
|
@ -35,7 +35,7 @@ gee@pyro.nu
|
||||
#include "GUItext.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "lib/input.h" // just for EV_PASS
|
||||
#include "lib/input.h" // just for IN_PASS
|
||||
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
|
||||
@ -336,11 +336,11 @@ protected:
|
||||
*
|
||||
* Only the object with focus will have this function called.
|
||||
*
|
||||
* Returns either EV_PASS or EV_HANDLED. If EV_HANDLED, then
|
||||
* Returns either IN_PASS or IN_HANDLED. If IN_HANDLED, then
|
||||
* the key won't be passed on and processed by other handlers.
|
||||
* This is used for keys that the GUI uses.
|
||||
*/
|
||||
virtual int ManuallyHandleEvent(const SDL_Event* UNUSED(ev)) { return EV_PASS; }
|
||||
virtual InEventReaction ManuallyHandleEvent(const SDL_Event* UNUSED(ev)) { return IN_PASS; }
|
||||
|
||||
/**
|
||||
* Loads a style.
|
||||
|
@ -20,9 +20,8 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "sdl.h"
|
||||
#include "lib.h"
|
||||
#include "input.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -30,22 +29,21 @@
|
||||
|
||||
#define MAX_HANDLERS 8
|
||||
|
||||
static EventHandler handler_stack[MAX_HANDLERS];
|
||||
static InEventHandler handler_stack[MAX_HANDLERS];
|
||||
static int handler_stack_top = 0;
|
||||
|
||||
|
||||
int in_add_handler(EventHandler handler)
|
||||
void in_add_handler(InEventHandler handler)
|
||||
{
|
||||
debug_assert(handler);
|
||||
|
||||
if(handler_stack_top >= MAX_HANDLERS)
|
||||
{
|
||||
debug_warn("increase MAX_HANDLERS");
|
||||
return -1;
|
||||
// return -1;
|
||||
}
|
||||
|
||||
handler_stack[handler_stack_top++] = handler;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -56,10 +54,10 @@ void dispatch_event(const SDL_Event* event)
|
||||
{
|
||||
int ret = handler_stack[i](event);
|
||||
// .. done, return
|
||||
if(ret == EV_HANDLED)
|
||||
if(ret == IN_HANDLED)
|
||||
return;
|
||||
// .. next handler
|
||||
else if(ret == EV_PASS)
|
||||
else if(ret == IN_PASS)
|
||||
continue;
|
||||
// .. invalid return value
|
||||
else
|
||||
|
@ -1,26 +1,25 @@
|
||||
/*
|
||||
* input layer (dispatch events to multiple handlers; record/playback events)
|
||||
*
|
||||
* Copyright (c) 2002 Jan Wassenberg
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* Contact info:
|
||||
* Jan.Wassenberg@stud.uni-karlsruhe.de
|
||||
* http://www.stud.uni-karlsruhe.de/~urkt/
|
||||
*/
|
||||
// input layer (dispatch events to multiple handlers; record/playback events)
|
||||
//
|
||||
// Copyright (c) 2002 Jan Wassenberg
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// Contact info:
|
||||
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
||||
// http://www.stud.uni-karlsruhe.de/~urkt/
|
||||
|
||||
#ifndef INPUT_H__
|
||||
#define INPUT_H__
|
||||
|
||||
// note: cannot forward-declare SDL_Event since it is a nameless union.
|
||||
#include "sdl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -28,26 +27,34 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// event handler return value defs (int).
|
||||
// don't require an enum type - simplifies user function decl;
|
||||
// the dispatcher makes sure each return value is correct.
|
||||
enum
|
||||
// event handler return values.
|
||||
enum InEventReaction
|
||||
{
|
||||
// (the handlers' return values are checked and these
|
||||
// 'strange' values might bring errors to light)
|
||||
|
||||
// pass the event to the next handler in the chain
|
||||
EV_PASS = 4,
|
||||
IN_PASS = 4,
|
||||
|
||||
// we've handled it; no other handlers will receive this event.
|
||||
EV_HANDLED = 2
|
||||
IN_HANDLED = 2
|
||||
};
|
||||
|
||||
// declare functions to take SDL_Event*; in_add_handler converts to void*
|
||||
// (avoids header dependency on SDL)
|
||||
typedef int (*EventHandler)(const SDL_Event*);
|
||||
typedef InEventReaction (*InEventHandler)(const SDL_Event*);
|
||||
|
||||
enum InEventOrder
|
||||
{
|
||||
// this handler will be added to the front of the queue -
|
||||
// it'll be called first (unless another IN_FIRST is registered).
|
||||
IN_FIRST,
|
||||
|
||||
IN_LAST
|
||||
};
|
||||
|
||||
|
||||
// register an input handler, which will receive all subsequent events first.
|
||||
// events are passed to other handlers if handler returns EV_PASS.
|
||||
extern int in_add_handler(EventHandler handler);
|
||||
// events are passed to other handlers if handler returns IN_PASS.
|
||||
extern void in_add_handler(InEventHandler handler);
|
||||
|
||||
// send event to each handler (newest first) until one returns true
|
||||
extern void in_dispatch_event(const SDL_Event* event);
|
||||
|
@ -45,7 +45,7 @@ void kill_mainloop();
|
||||
|
||||
|
||||
// main app message handler
|
||||
static int MainInputHandler(const SDL_Event* ev)
|
||||
static InEventReaction MainInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
switch(ev->type)
|
||||
{
|
||||
@ -58,11 +58,11 @@ static int MainInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
case HOTKEY_EXIT:
|
||||
kill_mainloop();
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
|
||||
case HOTKEY_SCREENSHOT:
|
||||
WriteScreenshot("png");
|
||||
return EV_HANDLED;
|
||||
return IN_HANDLED;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -70,7 +70,7 @@ static int MainInputHandler(const SDL_Event* ev)
|
||||
break;
|
||||
}
|
||||
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "Pyrogenesis.h"
|
||||
#include "sysdep/sysdep.h"
|
||||
#include "input.h"
|
||||
#include "Hotkey.h"
|
||||
#include "scripting/ScriptingHost.h"
|
||||
#include "MathUtil.h"
|
||||
@ -627,20 +626,18 @@ void CConsole::ReceivedChatMessage(const wchar_t *szSender, const wchar_t *szMes
|
||||
InsertMessage(L"%ls: %ls", szSender, szMessage);
|
||||
}
|
||||
|
||||
#include "sdl.h"
|
||||
|
||||
extern CConsole* g_Console;
|
||||
|
||||
extern void Die(int err, const wchar_t* fmt, ...);
|
||||
|
||||
int conInputHandler(const SDL_Event* ev)
|
||||
InEventReaction conInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
if( ev->type == SDL_HOTKEYDOWN )
|
||||
{
|
||||
if( ev->user.code == HOTKEY_CONSOLE_TOGGLE )
|
||||
{
|
||||
g_Console->ToggleVisible();
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
else if( ev->user.code == HOTKEY_CONSOLE_COPY )
|
||||
{
|
||||
@ -660,12 +657,12 @@ int conInputHandler(const SDL_Event* ev)
|
||||
}
|
||||
|
||||
if( ev->type != SDL_KEYDOWN)
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
SDLKey sym = ev->key.keysym.sym;
|
||||
|
||||
if(!g_Console->IsActive())
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
// Stop unprintable characters (ctrl+, alt+ and escape),
|
||||
// also prevent ` and/or ~ appearing in console every time it's toggled.
|
||||
@ -679,5 +676,5 @@ int conInputHandler(const SDL_Event* ev)
|
||||
!hotkeys[HOTKEY_CONSOLE_TOGGLE] )
|
||||
g_Console->InsertChar(sym, (wchar_t)ev->key.keysym.unicode );
|
||||
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
}
|
||||
|
@ -18,13 +18,9 @@
|
||||
#include "lib/res/graphics/unifont.h"
|
||||
#include "ogl.h"
|
||||
#include "lib.h"
|
||||
#include "sdl.h"
|
||||
#include "CStr.h"
|
||||
|
||||
// note: cannot forward declare SDL_Event since it is a nameless union
|
||||
// in the standard SDL library and a nameless struct in wsdl, so
|
||||
// include the full SDL header instead.
|
||||
#include "lib/sdl.h"
|
||||
#include "lib/input.h"
|
||||
|
||||
#ifndef CCONSOLE_H
|
||||
#define CCONSOLE_H
|
||||
@ -122,6 +118,6 @@ public:
|
||||
|
||||
extern CConsole* g_Console;
|
||||
|
||||
extern int conInputHandler(const SDL_Event* ev);
|
||||
extern InEventReaction conInputHandler(const SDL_Event* ev);
|
||||
|
||||
#endif
|
||||
|
@ -950,7 +950,7 @@ void Init(int argc, char* argv[], bool setup_videomode, bool setup_gui)
|
||||
// Check for heap corruption after every allocation. Very, very slowly.
|
||||
// (And it highlights the allocation just after the one you care about,
|
||||
// so you need to run it again and tell it to break on the one before.)
|
||||
// debug_heap_enable(DEBUG_HEAP_ALL);
|
||||
//debug_heap_enable(DEBUG_HEAP_ALL);
|
||||
|
||||
InitInput();
|
||||
|
||||
|
@ -15,7 +15,7 @@ bool g_mouse_buttons[5];
|
||||
|
||||
|
||||
// updates the state of the above; never swallows messages.
|
||||
int GlobalsInputHandler(const SDL_Event* ev)
|
||||
InEventReaction GlobalsInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -23,12 +23,12 @@ int GlobalsInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
g_active = (ev->active.gain != 0);
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
g_mouse_x = ev->motion.x;
|
||||
g_mouse_y = ev->motion.y;
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
@ -41,7 +41,7 @@ int GlobalsInputHandler(const SDL_Event* ev)
|
||||
// spoofs keys (it assigns values starting from SDLK_LAST)
|
||||
//debug_warn("invalid key");
|
||||
}
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
@ -50,10 +50,10 @@ int GlobalsInputHandler(const SDL_Event* ev)
|
||||
g_mouse_buttons[c] = (ev->type == SDL_MOUSEBUTTONDOWN);
|
||||
else
|
||||
debug_warn("invalid mouse button");
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
default:
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
}
|
||||
|
||||
UNREACHABLE;
|
||||
|
@ -7,4 +7,4 @@ extern int g_mouse_x, g_mouse_y;
|
||||
// (order is given by SDL_BUTTON_* constants).
|
||||
extern bool g_mouse_buttons[5];
|
||||
|
||||
extern int GlobalsInputHandler(const SDL_Event* ev);
|
||||
extern InEventReaction GlobalsInputHandler(const SDL_Event* ev);
|
||||
|
@ -309,7 +309,7 @@ void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName )
|
||||
boundTo.push_back( objName );
|
||||
}
|
||||
|
||||
int hotkeyInputHandler( const SDL_Event* ev )
|
||||
InEventReaction hotkeyInputHandler( const SDL_Event* ev )
|
||||
{
|
||||
int keycode;
|
||||
|
||||
@ -324,7 +324,7 @@ int hotkeyInputHandler( const SDL_Event* ev )
|
||||
keycode = SDLK_LAST + (int)ev->button.button;
|
||||
break;
|
||||
default:
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
|
||||
// Somewhat hackish:
|
||||
@ -580,7 +580,7 @@ int hotkeyInputHandler( const SDL_Event* ev )
|
||||
}
|
||||
}
|
||||
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
// - Add some bindings to the config file.
|
||||
|
||||
#include "precompiled.h"
|
||||
#include "sdl.h"
|
||||
#include "CStr.h"
|
||||
#include "lib/input.h"
|
||||
|
||||
const int SDL_HOTKEYDOWN = SDL_USEREVENT;
|
||||
const int SDL_HOTKEYUP = SDL_USEREVENT + 1;
|
||||
@ -103,7 +103,7 @@ enum
|
||||
};
|
||||
|
||||
void loadHotkeys();
|
||||
int hotkeyInputHandler( const SDL_Event* ev );
|
||||
InEventReaction hotkeyInputHandler( const SDL_Event* ev );
|
||||
void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName );
|
||||
|
||||
void initKeyNameMap();
|
||||
|
@ -825,10 +825,10 @@ void MouseButtonUpHandler(const SDL_Event *ev, int clicks)
|
||||
}
|
||||
}
|
||||
|
||||
int interactInputHandler( const SDL_Event* ev )
|
||||
InEventReaction interactInputHandler( const SDL_Event* ev )
|
||||
{
|
||||
if (!g_active || !g_Game)
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
CGameView *pView=g_Game->GetView();
|
||||
//CCamera *pCamera=pView->GetCamera();
|
||||
@ -853,7 +853,7 @@ int interactInputHandler( const SDL_Event* ev )
|
||||
static bool right_button_down = false;
|
||||
|
||||
if (customSelectionMode && ev->type != SDL_MOUSEBUTTONUP)
|
||||
return EV_PASS;
|
||||
return IN_PASS;
|
||||
|
||||
switch( ev->type )
|
||||
{
|
||||
@ -895,12 +895,12 @@ int interactInputHandler( const SDL_Event* ev )
|
||||
else
|
||||
g_Selection.loadGroup( id );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
case SDL_HOTKEYUP:
|
||||
switch( ev->user.code )
|
||||
{
|
||||
@ -912,9 +912,9 @@ int interactInputHandler( const SDL_Event* ev )
|
||||
g_Mouseover.m_viewall = false;
|
||||
break;
|
||||
default:
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
int button = SDL_BUTTON_TO_INDEX(ev->button.button);
|
||||
@ -971,7 +971,7 @@ int interactInputHandler( const SDL_Event* ev )
|
||||
}
|
||||
break;
|
||||
}
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
|
||||
bool isOnScreen( CEntity* ev, void* UNUSED(userdata) )
|
||||
|
@ -150,7 +150,7 @@ bool isOnScreen( CEntity* ev, void* userdata );
|
||||
void StartCustomSelection();
|
||||
void ResetInteraction();
|
||||
|
||||
int interactInputHandler( const SDL_Event* ev );
|
||||
InEventReaction interactInputHandler( const SDL_Event* ev );
|
||||
|
||||
#define g_Selection CSelectedEntities::GetSingleton()
|
||||
#define g_Mouseover CMouseoverEntities::GetSingleton()
|
||||
|
@ -164,7 +164,7 @@ void RenderProfile()
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
int profilehandler( const SDL_Event* ev )
|
||||
InEventReaction profilehandler( const SDL_Event* ev )
|
||||
{
|
||||
switch( ev->type )
|
||||
{
|
||||
@ -186,15 +186,15 @@ int profilehandler( const SDL_Event* ev )
|
||||
if( (*it)->CanExpand() && !k )
|
||||
{
|
||||
currentNode = (*it);
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
for( it = currentNode->GetScriptChildren()->begin(); it != currentNode->GetScriptChildren()->end(); it++, k-- )
|
||||
if( (*it)->CanExpand() && !k )
|
||||
{
|
||||
currentNode = (*it);
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -203,9 +203,9 @@ int profilehandler( const SDL_Event* ev )
|
||||
if( ev->user.code == HOTKEY_PROFILE_TOGGLE )
|
||||
{
|
||||
profileVisible = !profileVisible;
|
||||
return( EV_HANDLED );
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return( EV_PASS );
|
||||
return( IN_PASS );
|
||||
}
|
||||
|
@ -9,6 +9,6 @@
|
||||
|
||||
void ResetProfileViewer();
|
||||
void RenderProfile();
|
||||
int profilehandler( const SDL_Event* ev );
|
||||
InEventReaction profilehandler( const SDL_Event* ev );
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user