Beginnings of baselayer.cpp/.h refactor. This is 99.9% renames.

git-svn-id: https://svn.eduke32.com/eduke32@6827 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-04-12 21:02:31 +00:00
parent f41dc7b9c4
commit ee63d2c070
25 changed files with 641 additions and 708 deletions

View file

@ -51,8 +51,6 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx);
#ifdef USE_OPENGL
extern int32_t (*baselayer_osdcmd_vidmode_func)(osdfuncparm_t const * const parm);
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f);
extern int32_t osdcmd_glinfo(osdfuncparm_t const * const parm);
struct glinfo_t {
@ -89,40 +87,60 @@ struct glinfo_t {
extern struct glinfo_t glinfo;
#endif
extern int32_t setvsync(int32_t newSync);
extern vec2_t const g_defaultVideoModes[];
extern char inputdevices;
// keys
#define NUMKEYS 256
#define KEYSTATUSSIZ 256
#define KEYFIFOSIZ 64
extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ];
extern uint8_t keyasciififoplc, keyasciififoend, keyfifoplc, keyfifoend;
extern char scantoasc[128], keyremap[KEYSTATUSSIZ], key_names[NUMKEYS][24];
extern int32_t keyremapinit;
extern char const g_keyAsciiTable[128];
extern int32_t defaultres[][2];
extern char keystatus[NUMKEYS];
extern char g_keyFIFO[KEYFIFOSIZ];
extern char g_keyAsciiFIFO[KEYFIFOSIZ];
extern uint8_t g_keyAsciiPos;
extern uint8_t g_keyAsciiEnd;
extern uint8_t g_keyFIFOend;
extern char g_keyRemapTable[NUMKEYS];
extern char g_keyNameTable[NUMKEYS][24];
extern int32_t GetKey(int32_t key);
extern void SetKey(int32_t key, int32_t state);
extern int32_t keyGetState(int32_t key);
extern void keySetState(int32_t key, int32_t state);
// mouse
extern int32_t mousex, mousey, mouseb;
extern vec2_t mouseabs;
extern uint8_t mousepressstate;
extern uint8_t mousegrab, moustat, mouseinwindow, AppMouseGrab;
extern vec2_t g_mousePos;
extern vec2_t g_mouseAbs;
extern int32_t g_mouseBits;
extern uint8_t g_mouseClickState;
extern bool g_mouseGrabbed;
extern bool g_mouseEnabled;
extern bool g_mouseInsideWindow;
extern bool g_mouseLockedToWindow;
enum
{
Mouse_Idle = 0,
Mouse_Pressed = 1,
Mouse_Held = 2,
Mouse_Released = 3,
MOUSE_IDLE = 0,
MOUSE_PRESSED,
MOUSE_HELD,
MOUSE_RELEASED,
};
extern int32_t mousepressstateadvance(void);
extern int32_t mouseAdvanceClickState(void);
// joystick
extern int32_t *joyaxis, *joyhat, joyb;
extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats;
extern int32_t joyaxespresent;
typedef struct
{
int32_t *pAxis;
int32_t *pHat;
void (*pCallback)(int32_t, int32_t);
int32_t bits;
int32_t numAxes;
int32_t numButtons;
int32_t numHats;
} controllerinput_t;
extern controllerinput_t joystick;
extern int32_t qsetmode;
@ -132,7 +150,7 @@ int32_t initsystem(void);
void uninitsystem(void);
void system_getcvars(void);
extern int32_t flushlogwindow;
extern int32_t g_logFlushWindow;
void initputs(const char *);
#define buildputs initputs
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
@ -143,44 +161,43 @@ int32_t handleevents(void);
int32_t handleevents_peekkeys(void);
extern void (*keypresscallback)(int32_t,int32_t);
extern void (*mousepresscallback)(int32_t,int32_t);
extern void (*joypresscallback)(int32_t,int32_t);
extern void (*g_mouseCallback)(int32_t,int32_t);
int32_t initinput(void);
void uninitinput(void);
void releaseallbuttons(void);
void setkeypresscallback(void (*callback)(int32_t,int32_t));
void setmousepresscallback(void (*callback)(int32_t,int32_t));
void setjoypresscallback(void (*callback)(int32_t,int32_t));
const char *getkeyname(int32_t num);
const char *getjoyname(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
void keySetCallback(void (*callback)(int32_t,int32_t));
void mouseSetCallback(void (*callback)(int32_t,int32_t));
void joySetCallback(void (*callback)(int32_t,int32_t));
const char *keyGetName(int32_t num);
const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
char bgetchar(void);
#define bkbhit() (keyasciififoplc != keyasciififoend)
char keyGetChar(void);
#define keyBufferWaiting() (g_keyAsciiPos != g_keyAsciiEnd)
static FORCE_INLINE int keyascfifo_isfull(void)
static FORCE_INLINE int keyBufferFull(void)
{
return ((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc;
return ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)) == g_keyAsciiPos;
}
static FORCE_INLINE void keyascfifo_insert(char code)
static FORCE_INLINE void keyBufferInsert(char code)
{
keyasciififo[keyasciififoend] = code;
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
g_keyAsciiFIFO[g_keyAsciiEnd] = code;
g_keyAsciiEnd = ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1));
}
void bflushchars(void);
void keyFlushChars(void);
int32_t initmouse(void);
void uninitmouse(void);
void grabmouse(char a);
void AppGrabMouse(char a);
void readmousexy(int32_t *x, int32_t *y);
int32_t readmouseabsxy(vec2_t * const destination, vec2_t const * const source);
void readmousebstatus(int32_t *b);
void readjoybstatus(int32_t *b);
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur);
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur);
int32_t mouseInit(void);
void mouseUninit(void);
void mouseGrabInput(char a);
void mouseLockToWindow(char a);
void mouseReadPos(int32_t *x, int32_t *y);
int32_t mouseReadAbs(vec2_t * const destination, vec2_t const * const source);
void mouseReadButtons(int32_t *b);
void joyReadButtons(int32_t *b);
void joySetDeadZone(int32_t axis, uint16_t dead, uint16_t satur);
void joyGetDeadZone(int32_t axis, uint16_t *dead, uint16_t *satur);
extern int32_t inputchecked;
int32_t inittimer(int32_t);

View file

@ -1054,18 +1054,7 @@ int32_t qloadkvx(int32_t voxindex, const char *filename);
void vox_undefine(int32_t const);
intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
//void setvgapalette(void);
void setbasepal(int32_t id, uint8_t const *table);
void removebasepal(int32_t id);
void setblendtab(int32_t blend, const char *tab);
void removeblendtab(int32_t blend);
int32_t setpalookup(int32_t palnum, const uint8_t *shtab);
void removepalookup(int32_t palnum);
void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset);
void squarerotatetile(int16_t tilenume);
void fade_screen_black(int32_t moreopaquep);
int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp);
void nextpage(void);

View file

@ -36,7 +36,19 @@ typedef struct {
uint8_t r, g, b;
} rgb24_t;
extern palette_t curpalette[256], curpalettefaded[256], palfadergb;
extern char palfadedelta;
extern void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f);
extern void fade_screen_black(int32_t moreopaquep);
void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
void setbasepal(int32_t id, uint8_t const *table);
void removebasepal(int32_t id);
void setblendtab(int32_t blend, const char *tab);
void removeblendtab(int32_t blend);
int32_t setpalookup(int32_t palnum, const uint8_t *shtab);
void removepalookup(int32_t palnum);
void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset);
extern int32_t realmaxshade;
extern float frealmaxshade;

View file

@ -9,6 +9,7 @@
#include "polymost.h"
#include "cache1d.h"
// video
#ifdef _WIN32
extern "C"
{
@ -17,145 +18,131 @@ extern "C"
}
#endif // _WIN32
vec2_t const g_defaultVideoModes[]
= { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 },
{ 1600, 1200 }, { 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 },
{ 1024, 768 }, { 1024, 600 }, { 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 },
{ 400, 300 }, { 320, 240 }, { 320, 200 }, { 0, 0 } };
// input
char inputdevices=0;
char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ];
uint8_t keyfifoplc, keyfifoend, keyasciififoplc, keyasciififoend;
char keyremap[KEYSTATUSSIZ];
int32_t keyremapinit=0;
char key_names[NUMKEYS][24];
int32_t mousex=0,mousey=0,mouseb=0;
vec2_t mouseabs;
uint8_t mousepressstate;
uint8_t moustat = 0, mousegrab = 0, mouseinwindow = 1, AppMouseGrab = 1;
char inputdevices = 0;
int32_t mousepressstateadvance(void)
{
if (mousepressstate == Mouse_Pressed)
{
mousepressstate = Mouse_Held;
return 1;
}
else if (mousepressstate == Mouse_Released)
{
mousepressstate = Mouse_Idle;
return 1;
}
else if (mousepressstate == Mouse_Held)
return 1;
char keystatus[NUMKEYS];
char g_keyFIFO[KEYFIFOSIZ];
char g_keyAsciiFIFO[KEYFIFOSIZ];
uint8_t g_keyFIFOend;
uint8_t g_keyAsciiPos;
uint8_t g_keyAsciiEnd;
char g_keyRemapTable[NUMKEYS];
char g_keyNameTable[NUMKEYS][24];
return 0;
}
void (*keypresscallback)(int32_t, int32_t);
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;
char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0;
int32_t joyaxespresent=0;
void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
void(*keypresscallback)(int32_t,int32_t) = 0;
void(*mousepresscallback)(int32_t,int32_t) = 0;
void(*joypresscallback)(int32_t,int32_t) = 0;
extern int16_t brightness;
//
// set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed
//
void setkeypresscallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
void setmousepresscallback(void (*callback)(int32_t, int32_t)) { mousepresscallback = callback; }
void setjoypresscallback(void (*callback)(int32_t, int32_t)) { joypresscallback = callback; }
char scantoasc[128] = {
0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
char const g_keyAsciiTable[128] = {
0 , 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
'[', ']', 0, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', 0, 92, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
'.', '/', 0, '*', 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6',
'+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
int32_t defaultres[][2]
= { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 }, { 1600, 1200 },
{ 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 }, { 1024, 768 }, { 1024, 600 },
{ 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 }, { 400, 300 }, { 320, 240 }, { 320, 200 },
{ 0, 0 } };
int32_t keyGetState(int32_t key) { return keystatus[g_keyRemapTable[key]]; }
int32_t GetKey(int32_t key)
void keySetState(int32_t key, int32_t state)
{
return keystatus[keyremap[key]];
}
void SetKey(int32_t key, int32_t state)
{
keystatus[keyremap[key]] = state;
keystatus[g_keyRemapTable[key]] = state;
if (state)
{
keyfifo[keyfifoend] = keyremap[key];
keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state;
keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1));
g_keyFIFO[g_keyFIFOend] = g_keyRemapTable[key];
g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state;
g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1));
}
}
//
// bgetchar, bflushchars -- character-based input functions
// character-based input functions
//
char bgetchar(void)
char keyGetChar(void)
{
if (keyasciififoplc == keyasciififoend)
if (g_keyAsciiPos == g_keyAsciiEnd)
return 0;
char const c = g_keyAsciiFIFO[g_keyAsciiPos];
g_keyAsciiPos = ((g_keyAsciiPos + 1) & (KEYFIFOSIZ - 1));
return c;
}
void keyFlushChars(void)
{
Bmemset(&g_keyAsciiFIFO,0,sizeof(g_keyAsciiFIFO));
g_keyAsciiPos = g_keyAsciiEnd = 0;
}
const char *keyGetName(int32_t num) { return ((unsigned)num >= NUMKEYS) ? NULL : g_keyNameTable[num]; }
vec2_t g_mousePos;
vec2_t g_mouseAbs;
int32_t g_mouseBits;
uint8_t g_mouseClickState;
bool g_mouseEnabled;
bool g_mouseGrabbed;
bool g_mouseInsideWindow = 1;
bool g_mouseLockedToWindow = 1;
void (*g_mouseCallback)(int32_t, int32_t);
void mouseSetCallback(void(*callback)(int32_t, int32_t)) { g_mouseCallback = callback; }
int32_t mouseAdvanceClickState(void)
{
switch (g_mouseClickState)
{
char c = keyasciififo[keyasciififoplc];
keyasciififoplc = ((keyasciififoplc+1)&(KEYFIFOSIZ-1));
return c;
case MOUSE_PRESSED: g_mouseClickState = MOUSE_HELD; return 1;
case MOUSE_RELEASED: g_mouseClickState = MOUSE_IDLE; return 1;
case MOUSE_HELD: return 1;
}
return 0;
}
void bflushchars(void)
void mouseReadPos(int32_t *x, int32_t *y)
{
Bmemset(&keyasciififo,0,sizeof(keyasciififo));
keyasciififoplc = keyasciififoend = 0;
if (!g_mouseEnabled || !g_mouseGrabbed || !appactive)
{
*x = *y = 0;
return;
}
*x = g_mousePos.x;
*y = g_mousePos.y;
g_mousePos.x = g_mousePos.y = 0;
}
const char *getkeyname(int32_t num)
int32_t mouseReadAbs(vec2_t * const pResult, vec2_t const * const pInput)
{
return ((unsigned)num >= 256) ? NULL : key_names[num];
}
void readmousexy(int32_t *x, int32_t *y)
{
if (!moustat || !mousegrab || !appactive) { *x = *y = 0; return; }
*x = mousex;
*y = mousey;
mousex = mousey = 0;
}
int32_t readmouseabsxy(vec2_t * const destination, vec2_t const * const source)
{
int32_t xwidth;
if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE))
if (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE))
return 0;
xwidth = max(scale(240<<16, xdim, ydim), 320<<16);
int32_t const xwidth = max(scale(240<<16, xdim, ydim), 320<<16);
destination->x = scale(source->x, xwidth, xdim) - ((xwidth>>1) - (320<<15));
destination->y = scale(source->y, 200<<16, ydim);
pResult->x = scale(pInput->x, xwidth, xdim) - ((xwidth>>1) - (320<<15));
pResult->y = scale(pInput->y, 200<<16, ydim);
return 1;
}
void readmousebstatus(int32_t *b)
void mouseReadButtons(int32_t *pResult)
{
if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE)) { *b = 0; return; }
*b = mouseb;
*pResult = (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) ? 0 : g_mouseBits;
}
void readjoybstatus(int32_t *b)
{
if (!appactive) { *b = 0; return; }
*b = joyb;
}
controllerinput_t joystick;
void joySetCallback(void (*callback)(int32_t, int32_t)) { joystick.pCallback = callback; }
void joyReadButtons(int32_t *pResult) { *pResult = appactive ? joystick.bits : 0; }
#if defined __linux || defined EDUKE32_BSD || defined __APPLE__
# include <sys/mman.h>
@ -259,41 +246,9 @@ void makeasmwriteable(void)
}
int32_t vsync=0;
int32_t g_logFlushWindow = 1;
#ifdef USE_OPENGL
extern int32_t nofog;
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_TEXTURE_2D);
polymost_setFogEnabled(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4ub(r, g, b, f);
polymost_useColorOnly(true);
glBegin(GL_TRIANGLES);
glVertex2f(-2.5f, 1.f);
glVertex2f(2.5f, 1.f);
glVertex2f(.0f, -2.5f);
glEnd();
polymost_useColorOnly(false);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
struct glinfo_t glinfo =
{
"Unknown", // vendor
@ -325,11 +280,7 @@ struct glinfo_t glinfo =
0, // Sync
0, // GL info dumped
};
#endif
int32_t flushlogwindow = 1;
#ifdef USE_OPENGL
// Used to register the game's / editor's osdcmd_vidmode() functions here.
int32_t (*baselayer_osdcmd_vidmode_func)(osdfuncparm_t const * const parm);
@ -393,7 +344,7 @@ static int32_t osdfunc_setrendermode(osdfuncparm_t const * const parm)
return OSDCMD_OK;
}
#if defined(USE_OPENGL)
#ifdef DEBUGGINGAIDS
static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm)
{
@ -416,8 +367,6 @@ static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm)
int32_t osdcmd_glinfo(osdfuncparm_t const * const UNUSED(parm))
{
char *s,*t,*u,i;
UNREFERENCED_CONST_PARAMETER(parm);
if (bpp == 8)
@ -432,83 +381,41 @@ int32_t osdcmd_glinfo(osdfuncparm_t const * const UNUSED(parm))
if (!glinfo.dumped)
return OSDCMD_OK;
initprintf(
" BGRA textures: %s\n"
" Non-power-of-2 textures: %s\n"
" Clamp-to-edge: %s\n"
" Multitexturing: %s\n"
" Frame Buffer Objects: %s\n"
#ifndef EDUKE32_GLES
" Texture compression: %s\n"
" Multisampling: %s\n"
" NVIDIA multisample hint: %s\n"
" ARBfp fragment programs: %s\n"
" Depth textures: %s\n"
" Shadow textures: %s\n"
" Rectangle textures: %s\n"
" env_combine: %s\n"
" Vertex Buffer Objects: %s\n"
" Shader Model 4: %s\n"
" Occlusion queries: %s\n"
" GLSL: %s\n"
" Debug Output: %s\n"
" Buffer Storage: %s\n"
" Sync: %s\n"
#endif
" Maximum anisotropy: %.1f%s\n"
" Extensions:\n",
glinfo.bgra ? "supported": "not supported",
glinfo.texnpot ? "supported": "not supported",
glinfo.clamptoedge ? "supported": "not supported",
glinfo.multitex ? "supported": "not supported",
glinfo.fbos ? "supported": "not supported",
#ifndef EDUKE32_GLES
glinfo.texcompr ? "supported": "not supported",
glinfo.multisample ? "supported": "not supported",
glinfo.nvmultisamplehint ? "supported": "not supported",
glinfo.arbfp ? "supported": "not supported",
glinfo.depthtex ? "supported": "not supported",
glinfo.shadow ? "supported": "not supported",
glinfo.rect ? "supported": "not supported",
glinfo.envcombine ? "supported": "not supported",
glinfo.vbos ? "supported": "not supported",
glinfo.sm4 ? "supported": "not supported",
glinfo.occlusionqueries ? "supported": "not supported",
glinfo.glsl ? "supported": "not supported",
glinfo.debugoutput ? "supported": "not supported",
glinfo.bufferstorage ? "supported" : "not supported",
glinfo.sync ? "supported" : "not supported",
#endif
glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)"
);
char const *s[] = { "supported", "not supported" };
s = Bstrdup(glinfo.extensions);
if (!s) initprintf("%s", glinfo.extensions);
else
{
i = 0; t = u = s;
while (*t)
{
if (*t == ' ')
{
if (i&1)
{
*t = 0;
initprintf(" %s\n",u);
u = t+1;
}
i++;
}
t++;
}
if (i&1) initprintf(" %s\n",u);
Bfree(s);
}
#define SUPPORTED(x) (x ? s[0] : s[1])
initprintf(" BGRA textures: %s\n", SUPPORTED(glinfo.bgra));
initprintf(" Non-power-of-2 textures: %s\n", SUPPORTED(glinfo.texnpot));
initprintf(" Clamp-to-edge: %s\n", SUPPORTED(glinfo.clamptoedge));
initprintf(" Multi-texturing: %s\n", SUPPORTED(glinfo.multitex));
initprintf(" Framebuffer objects: %s\n", SUPPORTED(glinfo.fbos));
#ifndef EDUKE32_GLES
initprintf(" Texture compression: %s\n", SUPPORTED(glinfo.texcompr));
initprintf(" Multi-sampling: %s\n", SUPPORTED(glinfo.multisample));
initprintf(" NVIDIA multisample hint: %s\n", SUPPORTED(glinfo.nvmultisamplehint));
initprintf(" ARBfp fragment programs: %s\n", SUPPORTED(glinfo.arbfp));
initprintf(" Depth textures: %s\n", SUPPORTED(glinfo.depthtex));
initprintf(" Shadow textures: %s\n", SUPPORTED(glinfo.shadow));
initprintf(" Rectangle textures: %s\n", SUPPORTED(glinfo.rect));
initprintf(" env_combine: %s\n", SUPPORTED(glinfo.envcombine));
initprintf(" Vertex buffer objects: %s\n", SUPPORTED(glinfo.vbos));
initprintf(" Shader model 4: %s\n", SUPPORTED(glinfo.sm4));
initprintf(" Occlusion queries: %s\n", SUPPORTED(glinfo.occlusionqueries));
initprintf(" GLSL: %s\n", SUPPORTED(glinfo.glsl));
initprintf(" Debug output: %s\n", SUPPORTED(glinfo.debugoutput));
initprintf(" Buffer storage: %s\n", SUPPORTED(glinfo.bufferstorage));
initprintf(" Sync: %s\n", SUPPORTED(glinfo.sync));
#endif
initprintf(" Maximum anisotropy: %.1f%s\n", glinfo.maxanisotropy, glinfo.maxanisotropy > 1.0 ? "" : " (no anisotropic filtering)");
#undef SUPPORTED
initprintf(" Extensions:\n%s", glinfo.extensions);
return OSDCMD_OK;
}
#endif
#endif
static int32_t osdcmd_cvar_set_baselayer(osdfuncparm_t const * const parm)
{
@ -528,7 +435,6 @@ static int32_t osdcmd_cvar_set_baselayer(osdfuncparm_t const * const parm)
int32_t baselayer_init(void)
{
uint32_t i;
#ifdef _WIN32
// on Windows, don't save the "r_screenaspect" cvar because the physical screen size is
// determined at startup
@ -560,7 +466,7 @@ int32_t baselayer_init(void)
#endif
};
for (i=0; i<ARRAY_SIZE(cvars_engine); i++)
for (native_t i=0; i<ARRAY_SIZE(cvars_engine); i++)
OSD_RegisterCvar(&cvars_engine[i], (cvars_engine[i].flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
#ifdef USE_OPENGL
@ -583,6 +489,8 @@ int32_t baselayer_init(void)
polymost_initosdfuncs();
#endif
for (native_t i = 0; i < NUMKEYS; i++) g_keyRemapTable[i] = i;
return 0;
}
@ -592,20 +500,19 @@ void maybe_redirect_outputs(void)
char *argp;
// pipe standard outputs to files
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
if (!Bstrcasecmp(argp, "TRUE"))
{
FILE *fp = freopen("stdout.txt", "w", stdout);
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) == NULL || Bstrcasecmp(argp, "TRUE"))
return;
if (!fp)
fp = fopen("stdout.txt", "w");
FILE *fp = freopen("stdout.txt", "w", stdout);
if (fp)
{
setvbuf(fp, 0, _IONBF, 0);
*stdout = *fp;
*stderr = *fp;
}
}
if (!fp)
fp = fopen("stdout.txt", "w");
if (fp)
{
setvbuf(fp, 0, _IONBF, 0);
*stdout = *fp;
*stderr = *fp;
}
#endif
}

View file

@ -563,7 +563,7 @@ void M32_DrawRoomsAndMasks(void)
void M32_OnShowOSD(int32_t shown)
{
AppGrabMouse((!shown) + 2);
mouseLockToWindow((!shown) + 2);
}
static void M32_FatalEngineError(void)
@ -672,7 +672,7 @@ int app_main(int argc, char const * const * argv)
if (initinput()) return -1;
initmouse();
mouseInit();
inittimer(TIMERINTSPERSECOND);
installusertimercallback(keytimerstuff);
@ -756,7 +756,7 @@ int app_main(int argc, char const * const * argv)
updatesector(pos.x,pos.y,&cursectnum);
setkeypresscallback(&m32_keypresscallback);
keySetCallback(&m32_keypresscallback);
M32_OnShowOSD(0); // make sure the desktop's mouse cursor is hidden
if (cursectnum == -1)
@ -4283,7 +4283,7 @@ rotate_hlsect_out:
if (!smoothRotation || manualAngle)
keystatus[0x33] = keystatus[0x34] = 0;
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
bstatus &= ~(16|32);
}
else
@ -4299,7 +4299,7 @@ rotate_hlsect_out:
keystatus[0x33] = keystatus[0x34] = 0;
}
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
bstatus &= ~(16|32);
}
}
@ -5918,7 +5918,7 @@ end_point_dragging:
if (circlepoints > 1)
circlepoints--;
keystatus[0x4a] = 0;
mouseb &= ~32;
g_mouseBits &= ~32;
bstatus &= ~32;
}
if (circlewall != -1 && (keystatus[0x4e] || ((bstatus&16) && !eitherCTRL))) // +, mousewheel up
@ -5926,7 +5926,7 @@ end_point_dragging:
if (circlepoints < 63)
circlepoints++;
keystatus[0x4e] = 0;
mouseb &= ~16;
g_mouseBits &= ~16;
bstatus &= ~16;
}
@ -7976,7 +7976,7 @@ CANCEL:
printext16(16*8, ydim-STATUS2DSIZ2-12, editorcolors[15], -1, GetSaveBoardFilename(NULL), 0);
showframe(1);
bflushchars();
keyFlushChars();
bad = 1;
while (bad == 1)
{
@ -7989,7 +7989,7 @@ CANCEL:
}
idle();
ch = bgetchar();
ch = keyGetChar();
if (keystatus[1])
{
@ -8114,7 +8114,7 @@ CANCEL:
i -= 4;
boardfilename[i] = 0;
bflushchars();
keyFlushChars();
while (bad == 0)
{
_printmessage16("%sSave as: ^011%s%s", corrupt>=4?"(map corrupt) ":"",
@ -8126,7 +8126,7 @@ CANCEL:
idle();
ch = bgetchar();
ch = keyGetChar();
if (keystatus[1]) bad = 1;
else if (ch == 13) bad = 2;
@ -8293,7 +8293,7 @@ int32_t ask_if_sure(const char *query, uint32_t flags)
else
_printmessage16("%s", query);
showframe(1);
bflushchars();
keyFlushChars();
while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1)
{
@ -8309,7 +8309,7 @@ int32_t ask_if_sure(const char *query, uint32_t flags)
}
idle();
ch = bgetchar();
ch = keyGetChar();
if (ch == 'y' || ch == 'Y')
ret = 1;
@ -8334,7 +8334,7 @@ int32_t editor_ask_function(const char *question, const char *dachars, int32_t n
_printmessage16("%s", question);
showframe(1);
bflushchars();
keyFlushChars();
// 'c' is cancel too, but can be overridden
while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1)
@ -8343,7 +8343,7 @@ int32_t editor_ask_function(const char *question, const char *dachars, int32_t n
quitevent = 0;
idle();
ch = bgetchar();
ch = keyGetChar();
for (i=0; i<numchars; i++)
if (ch==Btolower(dachars[i]) || ch==Btoupper(dachars[i]))
@ -8549,7 +8549,7 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line, int8_t
if (numwalls == 0)
return -1;
if (mouseb & 1 || searchlock)
if (g_mouseBits & 1 || searchlock)
return line;
if (!ignore_pointhighlight && (pointhighlight&0xc000) == 16384)
@ -8624,7 +8624,7 @@ int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
if (numwalls == 0)
return -1;
if (mouseb & 1 || searchlock)
if (g_mouseBits & 1 || searchlock)
return point;
if (grid < 1)
@ -9316,14 +9316,14 @@ int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char
// ("^011", max. string length of an int32, "_ ")
Bstrncpyz(ournamestart, namestart, sizeof(ournamestart));
bflushchars();
keyFlushChars();
while (keystatus[0x1] == 0)
{
if (handleevents())
quitevent = 0;
idle();
ch = bgetchar();
ch = keyGetChar();
Bsprintf(buffer, "%s^011%d", ournamestart, danum);
n = Bstrlen(buffer); // maximum is 62+4+11 == 77
@ -9387,7 +9387,7 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha
// (max. string length of an int32, "_ ")
Bstrncpyz(ournamestart, namestart, sizeof(ournamestart));
bflushchars();
keyFlushChars();
while (keystatus[0x1] == 0)
{
if (handleevents())
@ -9396,12 +9396,12 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha
if ((flags&8)==0)
M32_DrawRoomsAndMasks();
ch = bgetchar();
ch = keyGetChar();
if (keystatus[0x1])
break;
clearkeys();
mouseb = 0;
g_mouseBits = 0;
searchx = osearchx;
searchy = osearchy;
@ -9457,7 +9457,7 @@ const char *getstring_simple(const char *querystr, const char *defaultstr, int32
int32_t ei=0, qrylen=0, maxidx, havecompl=0;
char ch;
bflushchars();
keyFlushChars();
clearkeys();
Bmemset(buf, 0, sizeof(buf));
@ -9498,7 +9498,7 @@ const char *getstring_simple(const char *querystr, const char *defaultstr, int32
quitevent = 0;
idle();
ch = bgetchar();
ch = keyGetChar();
if (ch==13)
{
@ -9818,7 +9818,7 @@ static int32_t menuselect(void)
idle();
ch = bgetchar();
ch = keyGetChar();
{
// JBF 20040208: seek to first name matching pressed character
@ -10998,7 +10998,7 @@ void test_map(int32_t mode)
OSD_Printf("...as `%s'\n", fullparam);
showframe(1);
uninitmouse();
mouseUninit();
#ifdef _WIN32
{
STARTUPINFO si;
@ -11023,7 +11023,7 @@ void test_map(int32_t mode)
else system(fullparam);
#endif
printmessage16("Game process exited");
initmouse();
mouseInit();
clearkeys();
Bfree(fullparam);

View file

@ -258,10 +258,6 @@ int32_t loadsetup(const char *fn)
if (readconfig(fp, "osdtryscript", val, VL) > 0) m32_osd_tryscript = !!atoi_safe(val);
for (i=0; i<256; i++)
keyremap[i]=i;
keyremapinit=1;
if (readconfig(fp, "remap", val, VL) > 0)
{
char *p=val; int32_t v1,v2;
@ -271,7 +267,7 @@ int32_t loadsetup(const char *fn)
if ((p=strchr(p,'-'))==0)break;
p++;
if (!sscanf(p,"%x",&v2))break;
keyremap[v1]=v2;
g_keyRemapTable[v1]=v2;
initprintf("Remap %X key to %X\n",v1,v2);
if ((p=strchr(p,','))==0)break;
p++;
@ -673,9 +669,9 @@ int32_t writesetup(const char *fn)
);
for (i=0; i<256; i++)
if (keyremap[i]!=i)
if (g_keyRemapTable[i]!=i)
{
Bfprintf(fp,first?"%02X-%02X":",%02X-%02X",i,keyremap[i]);
Bfprintf(fp,first?"%02X-%02X":",%02X-%02X",i,g_keyRemapTable[i]);
first=0;
}
Bfprintf(fp,"\n\n");

View file

@ -155,9 +155,9 @@ static void defsparser_include(const char *fn, const scriptfile *script, const c
{
if (!cmdtokptr)
{
flushlogwindow = 1;
g_logFlushWindow = 1;
initprintf("Loading module \"%s\"\n",fn);
flushlogwindow = 0;
g_logFlushWindow = 0;
}
defsparser(included);
@ -410,9 +410,9 @@ static int32_t defsparser(scriptfile *script)
#ifdef USE_DEF_PROGRESS
if (++iter >= 50)
{
flushlogwindow = 1;
g_logFlushWindow = 1;
initprintf(".");
flushlogwindow = 0;
g_logFlushWindow = 0;
iter = 0;
}
#endif
@ -3633,15 +3633,15 @@ static int32_t defsparser(scriptfile *script)
int32_t loaddefinitionsfile(const char *fn)
{
scriptfile *script;
int32_t f = flushlogwindow;
int32_t f = g_logFlushWindow;
script = scriptfile_fromfile(fn);
if (script)
{
flushlogwindow = 1;
g_logFlushWindow = 1;
initprintf("Loading \"%s\"\n",fn);
flushlogwindow = 0;
g_logFlushWindow = 0;
defsparser(script);
}
@ -3649,7 +3649,7 @@ int32_t loaddefinitionsfile(const char *fn)
for (char const * m : g_defModules)
defsparser_include(m, NULL, NULL);
flushlogwindow = f;
g_logFlushWindow = f;
if (script)
scriptfile_close(script);

View file

@ -11514,8 +11514,8 @@ void rotatepoint(vec2_t const pivot, vec2_t p, int16_t daang, vec2_t *p2)
void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus)
{
readmousexy(mousx,mousy);
readmousebstatus(bstatus);
mouseReadPos(mousx,mousy);
mouseReadButtons(bstatus);
}

View file

@ -1439,13 +1439,10 @@ void OSD_CaptureInput(int32_t cap)
{
osd->flags = (osd->flags & ~(OSD_CAPTURE|OSD_CTRL|OSD_SHIFT)) | (-cap & OSD_CAPTURE);
grabmouse(cap == 0 ? AppMouseGrab : 0);
mouseGrabInput(cap == 0 ? g_mouseLockedToWindow : 0);
onshowosd(cap);
if (cap)
releaseallbuttons();
bflushchars();
keyFlushChars();
}

View file

@ -36,6 +36,39 @@ int32_t curbrightness = 0, gammabrightness = 0;
static void setpalettefade_calc(uint8_t offset);
#ifdef USE_OPENGL
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_TEXTURE_2D);
polymost_setFogEnabled(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4ub(r, g, b, f);
polymost_useColorOnly(true);
glBegin(GL_TRIANGLES);
glVertex2f(-2.5f, 1.f);
glVertex2f(2.5f, 1.f);
glVertex2f(.0f, -2.5f);
glEnd();
polymost_useColorOnly(false);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
#endif
void fade_screen_black(int32_t moreopaquep)
{
#ifdef USE_OPENGL

View file

@ -10,8 +10,8 @@
static BOOL rawinput_started = 0;
static uint8_t KeyboardState[256] = {0}; // VKeys
extern uint8_t moustat, mousegrab;
extern void SetKey(int32_t key, int32_t state);
extern uint8_t g_mouseEnabled, g_mouseGrabbed;
extern void keySetState(int32_t key, int32_t state);
//#define MASK_DOWN (1<<(i<<1))
//#define MASK_UP (MASK_DOWN<<1)
@ -24,11 +24,11 @@ static inline void RI_ProcessMouse(const RAWMOUSE *rmouse)
int32_t i, mask;
int8_t MWheel = 0;
if (!mousegrab || !appactive)
if (!g_mouseGrabbed || !appactive)
return;
mousex += rmouse->lLastX;
mousey += rmouse->lLastY;
g_mousePos.x += rmouse->lLastX;
g_mousePos.y += rmouse->lLastY;
if (rmouse->usFlags & MOUSE_MOVE_ABSOLUTE)
{
@ -37,8 +37,8 @@ static inline void RI_ProcessMouse(const RAWMOUSE *rmouse)
ClientToScreen((HWND)win_gethwnd(), &pos);
mousex -= pos.x;
mousey -= pos.y;
g_mousePos.x -= pos.x;
g_mousePos.y -= pos.y;
}
for (i = 0, mask = (1<<0); mask <= (1<<8); i++, mask<<=2)
@ -56,15 +56,15 @@ static inline void RI_ProcessMouse(const RAWMOUSE *rmouse)
if (rmouse->usButtonFlags & mask) // button down
{
if (mousepresscallback)
mousepresscallback(i+1, 1);
mouseb |= 1<<i;
if (g_mouseCallback)
g_mouseCallback(i+1, 1);
g_mouseBits |= 1<<i;
}
else if (rmouse->usButtonFlags & (mask<<1)) // button up
{
if (mousepresscallback)
mousepresscallback(i+1, 0);
mouseb &= ~(1<<i);
if (g_mouseCallback)
g_mouseCallback(i+1, 0);
g_mouseBits &= ~(1<<i);
}
}
@ -72,13 +72,13 @@ static inline void RI_ProcessMouse(const RAWMOUSE *rmouse)
if (MWheel > 0) // wheel up
{
mouseb |= 16;
if (mousepresscallback) mousepresscallback(5, 1);
g_mouseBits |= 16;
if (g_mouseCallback) g_mouseCallback(5, 1);
}
else if (MWheel < 0) // wheel down
{
mouseb |= 32;
if (mousepresscallback) mousepresscallback(6, 1);
g_mouseBits |= 32;
if (g_mouseCallback) g_mouseCallback(6, 1);
}
}
@ -166,7 +166,7 @@ static inline void RI_ProcessKeyboard(const RAWKEYBOARD *rkbd)
if (rkbd->Flags & RI_KEY_BREAK)
return;
SetKey(sc_Pause, 1);
keySetState(sc_Pause, 1);
if (keypresscallback)
keypresscallback(sc_Pause, 1);
@ -178,25 +178,25 @@ static inline void RI_ProcessKeyboard(const RAWKEYBOARD *rkbd)
if (OSD_HandleScanCode(key, KeyboardState[VKey] > 0))
{
SetKey(key, KeyboardState[VKey] != 0);
keySetState(key, KeyboardState[VKey] != 0);
if (keypresscallback)
keypresscallback(key, KeyboardState[VKey] != 0);
}
if (rkbd->Flags & RI_KEY_BREAK) return;
if (((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc) return;
if ((keyasciififoend - keyasciififoplc) > 0) return;
if (((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)) == g_keyAsciiPos) return;
if ((g_keyAsciiEnd - g_keyAsciiPos) > 0) return;
{
uint8_t buf[2];
if (ToAscii(VKey, key, &KeyboardState[0], (LPWORD)&buf[0], 0) != 1) return;
if ((OSD_OSDKey() < 128) && (Btolower(scantoasc[OSD_OSDKey()]) == Btolower(buf[0]))) return;
if ((OSD_OSDKey() < 128) && (Btolower(g_keyAsciiTable[OSD_OSDKey()]) == Btolower(buf[0]))) return;
if (OSD_HandleChar(buf[0]) == 0) return;
keyasciififo[keyasciififoend] = buf[0];
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
g_keyAsciiFIFO[g_keyAsciiEnd] = buf[0];
g_keyAsciiEnd = ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1));
}
}
@ -215,7 +215,7 @@ BOOL RI_CaptureInput(BOOL grab, HWND target)
raw[1].dwFlags = 0;
raw[1].hwndTarget = target;
mousegrab = grab;
g_mouseGrabbed = grab;
return (RegisterRawInputDevices(raw, 2, sizeof(raw[0])) == FALSE);
}
@ -252,14 +252,14 @@ void RI_PollDevices(BOOL loop)
if (inputchecked)
{
if (mousepresscallback)
if (g_mouseCallback)
{
if (mouseb & 16)
mousepresscallback(5, 0);
if (mouseb & 32)
mousepresscallback(6, 0);
if (g_mouseBits & 16)
g_mouseCallback(5, 0);
if (g_mouseBits & 32)
g_mouseCallback(6, 0);
}
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
}
// snapshot the whole keyboard state so we can translate key presses into ascii later
@ -269,7 +269,7 @@ void RI_PollDevices(BOOL loop)
while (loop && PeekMessage(&msg, 0, WM_INPUT, WM_INPUT, PM_REMOVE | PM_QS_INPUT))
RI_ProcessMessage(&msg);
if (mousegrab && appactive)
if (g_mouseGrabbed && appactive)
{
// center the cursor in the window
POINT pt = { xdim>>1, ydim>>1 };
@ -279,27 +279,27 @@ void RI_PollDevices(BOOL loop)
}
}
int32_t initmouse(void)
int32_t mouseInit(void)
{
if (moustat) return 0;
grabmouse(moustat = AppMouseGrab);
if (g_mouseEnabled) return 0;
mouseGrabInput(g_mouseEnabled = g_mouseLockedToWindow);
return 0;
}
void uninitmouse(void)
void mouseUninit(void)
{
if (!moustat) return;
grabmouse(moustat = 0);
if (!g_mouseEnabled) return;
mouseGrabInput(g_mouseEnabled = 0);
}
void grabmouse(char a)
void mouseGrabInput(char a)
{
static POINT pos;
static int32_t d = 0;
if (!moustat) return;
if (!g_mouseEnabled) return;
if (!mousegrab || !d)
if (!g_mouseGrabbed || !d)
{
GetCursorPos(&pos);
d++;
@ -310,7 +310,7 @@ void grabmouse(char a)
SetCursorPos(pos.x, pos.y);
}
void AppGrabMouse(char a)
void mouseLockToWindow(char a)
{
UNREFERENCED_PARAMETER(a);
}

View file

@ -732,7 +732,7 @@ void initputs(const char *buf)
Bstrcat(dabuf,buf);
if (flushlogwindow || Bstrlen(dabuf) > 768)
if (g_logFlushWindow || Bstrlen(dabuf) > 768)
{
startwin_puts(dabuf);
#ifndef _WIN32
@ -794,14 +794,10 @@ int32_t initinput(void)
putenv(sdl_has3buttonmouse);
#endif
if (!keyremapinit)
for (i = 0; i < 256; i++) keyremap[i] = i;
keyremapinit = 1;
inputdevices = 1 | 2; // keyboard (1) and mouse (2)
mousegrab = 0;
g_mouseGrabbed = 0;
memset(key_names, 0, sizeof(key_names));
memset(g_keyNameTable, 0, sizeof(g_keyNameTable));
#if SDL_MAJOR_VERSION == 1
#define SDL_SCANCODE_TO_KEYCODE(x) (SDLKey)(x)
@ -817,7 +813,7 @@ int32_t initinput(void)
if (!keytranslation[i])
continue;
Bstrncpyz(key_names[keytranslation[i]], SDL_GetKeyName(SDL_SCANCODE_TO_KEYCODE(i)), sizeof(key_names[i]));
Bstrncpyz(g_keyNameTable[keytranslation[i]], SDL_GetKeyName(SDL_SCANCODE_TO_KEYCODE(i)), sizeof(g_keyNameTable[i]));
}
if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK))
@ -836,20 +832,20 @@ int32_t initinput(void)
inputdevices |= 4;
// KEEPINSYNC duke3d/src/gamedefs.h, mact/include/_control.h
joynumaxes = min(9, SDL_JoystickNumAxes(joydev));
joynumbuttons = min(32, SDL_JoystickNumButtons(joydev));
joynumhats = min((36-joynumbuttons)/4,SDL_JoystickNumHats(joydev));
initprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n", joynumaxes, joynumbuttons, joynumhats);
joystick.numAxes = min(9, SDL_JoystickNumAxes(joydev));
joystick.numButtons = min(32, SDL_JoystickNumButtons(joydev));
joystick.numHats = min((36-joystick.numButtons)/4,SDL_JoystickNumHats(joydev));
initprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n", joystick.numAxes, joystick.numButtons, joystick.numHats);
joyaxis = (int32_t *)Bcalloc(joynumaxes, sizeof(int32_t));
joystick.pAxis = (int32_t *)Bcalloc(joystick.numAxes, sizeof(int32_t));
if (joynumhats)
joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t));
if (joystick.numHats)
joystick.pHat = (int32_t *)Bcalloc(joystick.numHats, sizeof(int32_t));
for (i = 0; i < joynumhats; i++) joyhat[i] = -1; // centre
for (i = 0; i < joystick.numHats; i++) joystick.pHat[i] = -1; // centre
joydead = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
joysatur = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
joydead = (uint16_t *)Bcalloc(joystick.numAxes, sizeof(uint16_t));
joysatur = (uint16_t *)Bcalloc(joystick.numAxes, sizeof(uint16_t));
}
}
@ -864,7 +860,7 @@ void uninitinput(void)
#ifdef _WIN32
Win_SetKeyboardLayoutUS(0);
#endif
uninitmouse();
mouseUninit();
if (joydev)
{
@ -874,26 +870,26 @@ void uninitinput(void)
}
#ifndef GEKKO
const char *getjoyname(int32_t what, int32_t num)
const char *joyGetName(int32_t what, int32_t num)
{
static char tmp[64];
switch (what)
{
case 0: // axis
if ((unsigned)num > (unsigned)joynumaxes)
if ((unsigned)num > (unsigned)joystick.numAxes)
return NULL;
Bsprintf(tmp, "Axis %d", num);
return (char *)tmp;
case 1: // button
if ((unsigned)num > (unsigned)joynumbuttons)
if ((unsigned)num > (unsigned)joystick.numButtons)
return NULL;
Bsprintf(tmp, "Button %d", num);
return (char *)tmp;
case 2: // hat
if ((unsigned)num > (unsigned)joynumhats)
if ((unsigned)num > (unsigned)joystick.numHats)
return NULL;
Bsprintf(tmp, "Hat %d", num);
return (char *)tmp;
@ -907,20 +903,20 @@ const char *getjoyname(int32_t what, int32_t num)
//
// initmouse() -- init mouse input
//
int32_t initmouse(void)
int32_t mouseInit(void)
{
moustat=AppMouseGrab;
grabmouse(AppMouseGrab); // FIXME - SA
g_mouseEnabled=g_mouseLockedToWindow;
mouseGrabInput(g_mouseLockedToWindow); // FIXME - SA
return 0;
}
//
// uninitmouse() -- uninit mouse input
//
void uninitmouse(void)
void mouseUninit(void)
{
grabmouse(0);
moustat = 0;
mouseGrabInput(0);
g_mouseEnabled = 0;
}
@ -948,27 +944,27 @@ static inline char grabmouse_low(char a)
//
// grabmouse() -- show/hide mouse cursor
//
void grabmouse(char a)
void mouseGrabInput(char a)
{
if (appactive && moustat)
if (appactive && g_mouseEnabled)
{
#if !defined EDUKE32_TOUCH_DEVICES
if ((a != mousegrab) && !grabmouse_low(a))
if ((a != g_mouseGrabbed) && !grabmouse_low(a))
#endif
mousegrab = a;
g_mouseGrabbed = a;
}
else
mousegrab = a;
g_mouseGrabbed = a;
mousex = mousey = 0;
g_mousePos.x = g_mousePos.y = 0;
}
void AppGrabMouse(char a)
void mouseLockToWindow(char a)
{
if (!(a & 2))
{
grabmouse(a);
AppMouseGrab = mousegrab;
mouseGrabInput(a);
g_mouseLockedToWindow = g_mouseGrabbed;
}
SDL_ShowCursor((osd && osd->flags & OSD_CAPTURE) ? SDL_ENABLE : SDL_DISABLE);
@ -977,7 +973,7 @@ void AppGrabMouse(char a)
//
// setjoydeadzone() -- sets the dead and saturation zones for the joystick
//
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
void joySetDeadZone(int32_t axis, uint16_t dead, uint16_t satur)
{
joydead[axis] = dead;
joysatur[axis] = satur;
@ -987,20 +983,13 @@ void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
//
// getjoydeadzone() -- gets the dead and saturation zones for the joystick
//
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur)
void joyGetDeadZone(int32_t axis, uint16_t *dead, uint16_t *satur)
{
*dead = joydead[axis];
*satur = joysatur[axis];
}
//
// releaseallbuttons()
//
void releaseallbuttons(void)
{}
//
//
// ---------------------------------------
@ -1200,19 +1189,19 @@ void getvalidmodes(void)
SDL_CHECKFSMODES(maxx, maxy);
// add windowed modes next
for (i = 0; defaultres[i][0]; i++)
for (i = 0; g_defaultVideoModes[i].x; i++)
{
if (!SDL_CHECKMODE(defaultres[i][0], defaultres[i][1]))
if (!SDL_CHECKMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y))
continue;
// HACK: 8-bit == Software, 32-bit == OpenGL
SDL_ADDMODE(defaultres[i][0], defaultres[i][1], 8, 0);
SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, 8, 0);
#ifdef USE_OPENGL
if (nogl)
continue;
SDL_ADDMODE(defaultres[i][0], defaultres[i][1], 32, 0);
SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, 32, 0);
#endif
}
@ -1453,10 +1442,10 @@ int32_t setvideomode_sdlcommon(int32_t *x, int32_t *y, int32_t c, int32_t fs, in
startwin_close();
if (mousegrab)
if (g_mouseGrabbed)
{
*regrab = 1;
grabmouse(0);
mouseGrabInput(0);
}
while (lockcount) enddrawing();
@ -1514,7 +1503,7 @@ void setvideomode_sdlcommonpost(int32_t x, int32_t y, int32_t c, int32_t fs, int
setpalettefade(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
if (regrab)
grabmouse(AppMouseGrab);
mouseGrabInput(g_mouseLockedToWindow);
}
#if SDL_MAJOR_VERSION!=1
@ -1988,7 +1977,7 @@ int32_t handleevents_peekkeys(void)
void handleevents_updatemousestate(uint8_t state)
{
mousepressstate = state == SDL_RELEASED ? Mouse_Released : Mouse_Pressed;
g_mouseClickState = state == SDL_RELEASED ? MOUSE_RELEASED : MOUSE_PRESSED;
}
@ -2004,21 +1993,21 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
#if !defined EDUKE32_IOS
case SDL_MOUSEMOTION:
#ifndef GEKKO
mouseabs.x = ev->motion.x;
mouseabs.y = ev->motion.y;
g_mouseAbs.x = ev->motion.x;
g_mouseAbs.y = ev->motion.y;
#endif
// SDL <VER> doesn't handle relative mouse movement correctly yet as the cursor still clips to the
// screen edges
// so, we call SDL_WarpMouse() to center the cursor and ignore the resulting motion event that occurs
// <VER> is 1.3 for PK, 1.2 for tueidj
if (appactive && mousegrab)
if (appactive && g_mouseGrabbed)
{
# if SDL_MAJOR_VERSION==1
if (ev->motion.x != xdim >> 1 || ev->motion.y != ydim >> 1)
# endif
{
mousex += ev->motion.xrel;
mousey += ev->motion.yrel;
g_mousePos.x += ev->motion.xrel;
g_mousePos.y += ev->motion.yrel;
# if SDL_MAJOR_VERSION==1
SDL_WarpMouse(xdim>>1, ydim>>1);
# endif
@ -2062,44 +2051,44 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
break;
if (ev->button.state == SDL_PRESSED)
mouseb |= (1 << j);
g_mouseBits |= (1 << j);
else
#if SDL_MAJOR_VERSION==1
if (j != SDL_BUTTON_WHEELUP && j != SDL_BUTTON_WHEELDOWN)
#endif
mouseb &= ~(1 << j);
g_mouseBits &= ~(1 << j);
if (mousepresscallback)
mousepresscallback(j+1, ev->button.state == SDL_PRESSED);
if (g_mouseCallback)
g_mouseCallback(j+1, ev->button.state == SDL_PRESSED);
break;
}
#else
# if SDL_MAJOR_VERSION != 1
case SDL_FINGERUP:
mousepressstate = Mouse_Released;
g_mouseClickState = MOUSE_RELEASED;
break;
case SDL_FINGERDOWN:
mousepressstate = Mouse_Pressed;
g_mouseClickState = MOUSE_PRESSED;
case SDL_FINGERMOTION:
mouseabs.x = Blrintf(ev->tfinger.x * xdim);
mouseabs.y = Blrintf(ev->tfinger.y * ydim);
g_mouseAbs.x = Blrintf(ev->tfinger.x * xdim);
g_mouseAbs.y = Blrintf(ev->tfinger.y * ydim);
break;
# endif
#endif
case SDL_JOYAXISMOTION:
if (appactive && ev->jaxis.axis < joynumaxes)
if (appactive && ev->jaxis.axis < joystick.numAxes)
{
joyaxis[ev->jaxis.axis] = ev->jaxis.value * 10000 / 32767;
if ((joyaxis[ev->jaxis.axis] < joydead[ev->jaxis.axis]) &&
(joyaxis[ev->jaxis.axis] > -joydead[ev->jaxis.axis]))
joyaxis[ev->jaxis.axis] = 0;
else if (joyaxis[ev->jaxis.axis] >= joysatur[ev->jaxis.axis])
joyaxis[ev->jaxis.axis] = 10000;
else if (joyaxis[ev->jaxis.axis] <= -joysatur[ev->jaxis.axis])
joyaxis[ev->jaxis.axis] = -10000;
joystick.pAxis[ev->jaxis.axis] = ev->jaxis.value * 10000 / 32767;
if ((joystick.pAxis[ev->jaxis.axis] < joydead[ev->jaxis.axis]) &&
(joystick.pAxis[ev->jaxis.axis] > -joydead[ev->jaxis.axis]))
joystick.pAxis[ev->jaxis.axis] = 0;
else if (joystick.pAxis[ev->jaxis.axis] >= joysatur[ev->jaxis.axis])
joystick.pAxis[ev->jaxis.axis] = 10000;
else if (joystick.pAxis[ev->jaxis.axis] <= -joysatur[ev->jaxis.axis])
joystick.pAxis[ev->jaxis.axis] = -10000;
else
joyaxis[ev->jaxis.axis] = joyaxis[ev->jaxis.axis] * 10000 / joysatur[ev->jaxis.axis];
joystick.pAxis[ev->jaxis.axis] = joystick.pAxis[ev->jaxis.axis] * 10000 / joysatur[ev->jaxis.axis];
}
break;
@ -2123,19 +2112,19 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
-1, // left+down+right!! 14
-1, // left+down+right+up!! 15
};
if (appactive && ev->jhat.hat < joynumhats)
joyhat[ev->jhat.hat] = hatvals[ev->jhat.value & 15];
if (appactive && ev->jhat.hat < joystick.numHats)
joystick.pHat[ev->jhat.hat] = hatvals[ev->jhat.value & 15];
break;
}
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
if (appactive && ev->jbutton.button < joynumbuttons)
if (appactive && ev->jbutton.button < joystick.numButtons)
{
if (ev->jbutton.state == SDL_PRESSED)
joyb |= 1 << ev->jbutton.button;
joystick.bits |= 1 << ev->jbutton.button;
else
joyb &= ~(1 << ev->jbutton.button);
joystick.bits &= ~(1 << ev->jbutton.button);
#ifdef GEKKO
if (ev->jbutton.button == 0) // WII_A
@ -2170,10 +2159,10 @@ int32_t handleevents_pollsdl(void)
{
code = ev.text.text[j];
if (code != scantoasc[OSD_OSDKey()] && !keyascfifo_isfull())
if (code != g_keyAsciiTable[OSD_OSDKey()] && !keyBufferFull())
{
if (OSD_HandleChar(code))
keyascfifo_insert(code);
keyBufferInsert(code);
}
} while (j < SDL_TEXTINPUTEVENT_TEXT_SIZE && ev.text.text[++j]);
break;
@ -2191,7 +2180,7 @@ int32_t handleevents_pollsdl(void)
KMOD_LALT|KMOD_RALT|KMOD_LGUI|KMOD_RGUI;
// XXX: see osd.c, OSD_HandleChar(), there are more...
if (ev.key.type == SDL_KEYDOWN && !keyascfifo_isfull() &&
if (ev.key.type == SDL_KEYDOWN && !keyBufferFull() &&
(sc == SDL_SCANCODE_RETURN || sc == SDL_SCANCODE_KP_ENTER ||
sc == SDL_SCANCODE_ESCAPE ||
sc == SDL_SCANCODE_BACKSPACE ||
@ -2209,10 +2198,10 @@ int32_t handleevents_pollsdl(void)
default: keyvalue = sc - SDL_SCANCODE_A + 1; break; // Ctrl+A --> 1, etc.
}
if (OSD_HandleChar(keyvalue))
keyascfifo_insert(keyvalue);
keyBufferInsert(keyvalue);
}
else if (ev.key.type == SDL_KEYDOWN &&
ev.key.keysym.sym != scantoasc[OSD_OSDKey()] && !keyascfifo_isfull() &&
ev.key.keysym.sym != g_keyAsciiTable[OSD_OSDKey()] && !keyBufferFull() &&
!SDL_IsTextInputActive())
{
/*
@ -2288,7 +2277,7 @@ int32_t handleevents_pollsdl(void)
if ((unsigned)keyvalue <= 0x7Fu)
{
if (OSD_HandleChar(keyvalue))
keyascfifo_insert(keyvalue);
keyBufferInsert(keyvalue);
}
}
@ -2298,10 +2287,10 @@ int32_t handleevents_pollsdl(void)
if ((j = OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN))) <= 0)
{
if (j == -1) // osdkey
for (j = 0; j < KEYSTATUSSIZ; ++j)
if (GetKey(j))
for (j = 0; j < NUMKEYS; ++j)
if (keyGetState(j))
{
SetKey(j, 0);
keySetState(j, 0);
if (keypresscallback)
keypresscallback(j, 0);
}
@ -2310,9 +2299,9 @@ int32_t handleevents_pollsdl(void)
if (ev.key.type == SDL_KEYDOWN)
{
if (!GetKey(code))
if (!keyGetState(code))
{
SetKey(code, 1);
keySetState(code, 1);
if (keypresscallback)
keypresscallback(code, 1);
}
@ -2326,7 +2315,7 @@ int32_t handleevents_pollsdl(void)
if (code == 0x59) // pause
break;
# endif
SetKey(code, 0);
keySetState(code, 0);
if (keypresscallback)
keypresscallback(code, 0);
}
@ -2337,15 +2326,15 @@ int32_t handleevents_pollsdl(void)
// initprintf("wheel y %d\n",ev.wheel.y);
if (ev.wheel.y > 0)
{
mouseb |= 16;
if (mousepresscallback)
mousepresscallback(5, 1);
g_mouseBits |= 16;
if (g_mouseCallback)
g_mouseCallback(5, 1);
}
if (ev.wheel.y < 0)
{
mouseb |= 32;
if (mousepresscallback)
mousepresscallback(6, 1);
g_mouseBits |= 32;
if (g_mouseCallback)
g_mouseCallback(6, 1);
}
break;
@ -2355,7 +2344,7 @@ int32_t handleevents_pollsdl(void)
case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_FOCUS_LOST:
appactive = (ev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED);
if (mousegrab && moustat)
if (g_mouseGrabbed && g_mouseEnabled)
grabmouse_low(appactive);
#ifdef _WIN32
// Win_SetKeyboardLayoutUS(appactive);
@ -2373,10 +2362,10 @@ int32_t handleevents_pollsdl(void)
}
break;
case SDL_WINDOWEVENT_ENTER:
mouseinwindow = 1;
g_mouseInsideWindow = 1;
break;
case SDL_WINDOWEVENT_LEAVE:
mouseinwindow = 0;
g_mouseInsideWindow = 0;
break;
}
break;
@ -2399,16 +2388,16 @@ int32_t handleevents(void)
int32_t rv;
if (inputchecked && moustat)
if (inputchecked && g_mouseEnabled)
{
if (mousepresscallback)
if (g_mouseCallback)
{
if (mouseb & 16)
mousepresscallback(5, 0);
if (mouseb & 32)
mousepresscallback(6, 0);
if (g_mouseBits & 16)
g_mouseCallback(5, 0);
if (g_mouseBits & 32)
g_mouseCallback(6, 0);
}
mouseb &= ~(16 | 32);
g_mouseBits &= ~(16 | 32);
}
rv = handleevents_pollsdl();

View file

@ -135,20 +135,20 @@ static const char *joynames[3][15] = {
"Hat 11", "Hat 12", "Hat 13", "Hat 14", "Hat 15",
}
};
const char *getjoyname(int32_t what, int32_t num)
const char *joyGetName(int32_t what, int32_t num)
{
switch (what)
{
case 0: // axis
if ((unsigned)num > (unsigned)joynumaxes) return NULL;
if ((unsigned)num > (unsigned)joystick.numAxes) return NULL;
return joynames[0][num];
case 1: // button
if ((unsigned)num > (unsigned)joynumbuttons) return NULL;
if ((unsigned)num > (unsigned)joystick.numButtons) return NULL;
return joynames[1][num];
case 2: // hat
if ((unsigned)num > (unsigned)joynumhats) return NULL;
if ((unsigned)num > (unsigned)joystick.numHats) return NULL;
return joynames[2][num];
default:
@ -267,8 +267,8 @@ void getvalidmodes(void)
if (modes == (SDL_Rect **)-1)
{
for (i = 0; defaultres[i][0]; i++)
SDL_ADDMODE(defaultres[i][0], defaultres[i][1], cdepths[j], 1);
for (i = 0; g_defaultVideoModes[i].x; i++)
SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, cdepths[j], 1);
}
else
{
@ -300,12 +300,12 @@ void getvalidmodes(void)
if (cdepths[j] < 0)
continue;
for (i = 0; defaultres[i][0]; i++)
for (i = 0; g_defaultVideoModes[i].x; i++)
{
if (!SDL_CHECKMODE(defaultres[i][0], defaultres[i][1]))
if (!SDL_CHECKMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y))
continue;
SDL_ADDMODE(defaultres[i][0], defaultres[i][1], cdepths[j], 0);
SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, cdepths[j], 0);
}
}
@ -484,14 +484,14 @@ int32_t handleevents_pollsdl(void)
case SDL_KEYUP:
code = keytranslation[ev.key.keysym.sym];
#ifdef KEY_PRINT_DEBUG
printf("keytranslation[%d] = %s (%d) %s\n", ev.key.keysym.sym, key_names[code], code,
printf("keytranslation[%d] = %s (%d) %s\n", ev.key.keysym.sym, g_keyNameTable[code], code,
ev.key.type == SDL_KEYDOWN ? "DOWN" : "UP");
#endif
if (code != OSD_OSDKey() && ev.key.keysym.unicode != 0 && ev.key.type == SDL_KEYDOWN &&
(ev.key.keysym.unicode & 0xff80) == 0 && !keyascfifo_isfull())
(ev.key.keysym.unicode & 0xff80) == 0 && !keyBufferFull())
{
if (OSD_HandleChar(ev.key.keysym.unicode & 0x7f))
keyascfifo_insert(ev.key.keysym.unicode & 0x7f);
keyBufferInsert(ev.key.keysym.unicode & 0x7f);
}
// hook in the osd
@ -499,11 +499,11 @@ int32_t handleevents_pollsdl(void)
{
if (j == -1) // osdkey
{
for (j = 0; j < KEYSTATUSSIZ; ++j)
for (j = 0; j < NUMKEYS; ++j)
{
if (GetKey(j))
if (keyGetState(j))
{
SetKey(j, 0);
keySetState(j, 0);
if (keypresscallback)
keypresscallback(j, 0);
}
@ -514,9 +514,9 @@ int32_t handleevents_pollsdl(void)
if (ev.key.type == SDL_KEYDOWN)
{
if (!GetKey(code))
if (!keyGetState(code))
{
SetKey(code, 1);
keySetState(code, 1);
if (keypresscallback)
keypresscallback(code, 1);
}
@ -527,7 +527,7 @@ int32_t handleevents_pollsdl(void)
if (code == 0x59) // pause
break;
#endif
SetKey(code, 0);
keySetState(code, 0);
if (keypresscallback)
keypresscallback(code, 0);
}
@ -537,7 +537,7 @@ int32_t handleevents_pollsdl(void)
if (ev.active.state & SDL_APPINPUTFOCUS)
{
appactive = ev.active.gain;
if (mousegrab && moustat)
if (g_mouseGrabbed && g_mouseEnabled)
grabmouse_low(!!appactive);
# ifdef _WIN32
// Win_SetKeyboardLayoutUS(appactive);
@ -549,7 +549,7 @@ int32_t handleevents_pollsdl(void)
rv = -1;
if (ev.active.state & SDL_APPMOUSEFOCUS)
mouseinwindow = ev.active.gain;
g_mouseInsideWindow = ev.active.gain;
}
break;
@ -560,8 +560,8 @@ int32_t handleevents_pollsdl(void)
if (ev.motion.state & SDL_BUTTON_X2MASK)
{
// the absolute values are used to draw the crosshair
mouseabs.x = ev.motion.x;
mouseabs.y = ev.motion.y;
g_mouseAbs.x = ev.motion.x;
g_mouseAbs.y = ev.motion.y;
// hack: reduce the scale of the "relative" motions
// to make it act more like a real mouse
ev.motion.xrel /= 16;

View file

@ -597,7 +597,7 @@ void initputs(const char *buf)
Bstrcat(dabuf,buf);
if (flushlogwindow || Bstrlen(dabuf) > 768)
if (g_logFlushWindow || Bstrlen(dabuf) > 768)
{
startwin_puts(dabuf);
handleevents();
@ -691,19 +691,13 @@ int32_t initinput(void)
Win_GetOriginalLayoutName();
Win_SetKeyboardLayoutUS(1);
moustat=0;
g_mouseEnabled=0;
memset(keystatus, 0, sizeof(keystatus));
if (!keyremapinit)
for (i=0; i<256; i++)
keyremap[i]=i;
keyremapinit=1;
keyfifoplc = keyfifoend = 0;
keyasciififoplc = keyasciififoend = 0;
g_keyFIFOend = g_keyAsciiPos = g_keyAsciiEnd = 0;
inputdevices = 1|2;
joyisgamepad = joynumaxes = joynumbuttons = joynumhats=0;
joystick.numAxes = joystick.numButtons = joystick.numHats=0;
GetKeyNames();
InitDirectInput();
@ -719,7 +713,7 @@ void uninitinput(void)
{
Win_SetKeyboardLayoutUS(0);
uninitmouse();
mouseUninit();
UninitDirectInput();
}
@ -751,7 +745,7 @@ void idle_waitevent_timeout(uint32_t timeout)
//
// setjoydeadzone() -- sets the dead and saturation zones for the joystick
//
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
void joySetDeadZone(int32_t axis, uint16_t dead, uint16_t satur)
{
DIPROPDWORD dipdw;
HRESULT result;
@ -761,7 +755,7 @@ void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
if (dead > 10000) dead = 10000;
if (satur > 10000) satur = 10000;
if (dead >= satur) dead = satur-100;
if (axis >= joynumaxes) return;
if (axis >= joystick.numAxes) return;
memset(&dipdw, 0, sizeof(dipdw));
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
@ -801,14 +795,14 @@ void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
//
// getjoydeadzone() -- gets the dead and saturation zones for the joystick
//
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur)
void joyGetDeadZone(int32_t axis, uint16_t *dead, uint16_t *satur)
{
DIPROPDWORD dipdw;
HRESULT result;
if (!dead || !satur) return;
if (!lpDID) { *dead = *satur = 0; return; }
if (axis >= joynumaxes) { *dead = *satur = 0; return; }
if (axis >= joystick.numAxes) { *dead = *satur = 0; return; }
memset(&dipdw, 0, sizeof(dipdw));
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
@ -845,41 +839,41 @@ void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur)
*satur = dipdw.dwData;
}
#if 0
void releaseallbuttons(void)
{
int32_t i;
if (mousepresscallback)
if (g_mouseCallback)
{
if (mouseb & 1) mousepresscallback(1, 0);
if (mouseb & 2) mousepresscallback(2, 0);
if (mouseb & 4) mousepresscallback(3, 0);
if (mouseb & 8) mousepresscallback(4, 0);
if (mouseb & 16) mousepresscallback(5, 0);
if (mouseb & 32) mousepresscallback(6, 0);
if (mouseb & 64) mousepresscallback(7, 0);
if (g_mouseBits & 1) g_mouseCallback(1, 0);
if (g_mouseBits & 2) g_mouseCallback(2, 0);
if (g_mouseBits & 4) g_mouseCallback(3, 0);
if (g_mouseBits & 8) g_mouseCallback(4, 0);
if (g_mouseBits & 16) g_mouseCallback(5, 0);
if (g_mouseBits & 32) g_mouseCallback(6, 0);
if (g_mouseBits & 64) g_mouseCallback(7, 0);
}
mouseb = 0;
g_mouseBits = 0;
if (joypresscallback)
if (joystick.pCallback)
{
for (i=0; i<32; i++)
if (joyb & (1<<i)) joypresscallback(i+1, 0);
if (joystick.bits & (1<<i)) joystick.pCallback(i+1, 0);
}
joyb = joyblast = 0;
joystick.bits = joyblast = 0;
for (i=0; i<KEYSTATUSSIZ; i++)
for (i=0; i<NUMKEYS; i++)
{
//if (!keystatus[i]) continue;
//if (OSD_HandleKey(i, 0) != 0) {
OSD_HandleScanCode(i, 0);
SetKey(i, 0);
keySetState(i, 0);
if (keypresscallback) keypresscallback(i, 0);
//}
}
}
#endif
//
// InitDirectInput() -- get DirectInput started
@ -896,8 +890,7 @@ static BOOL CALLBACK InitDirectInput_enum(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRe
return DIENUM_CONTINUE;
inputdevices |= 4;
joyisgamepad = ((lpddi->dwDevType & (DIDEVTYPEJOYSTICK_GAMEPAD<<8)) != 0);
d = joyisgamepad ? "GAMEPAD" : "JOYSTICK";
d = "CONTROLLER"
Bmemcpy(&guidDevs, &lpddi->guidInstance, sizeof(GUID));
initprintf(" * %s: %s\n", d, lpddi->tszProductName);
@ -1043,19 +1036,19 @@ static BOOL InitDirectInput(void)
if (FAILED(result)) { IDirectInputDevice7_Release(dev2); HorribleDInputDeath("Failed getting controller capabilities", result); }
else if (result != DI_OK) initprintf(" Fetched controller capabilities with warning: %s\n",GetDInputError(result));
joynumaxes = (uint8_t)didc.dwAxes;
joynumbuttons = min(32,(uint8_t)didc.dwButtons);
joynumhats = (uint8_t)didc.dwPOVs;
initprintf("Controller has %d axes, %d buttons, and %d hat(s).\n",joynumaxes,joynumbuttons,joynumhats);
joystick.numAxes = (uint8_t)didc.dwAxes;
joystick.numButtons = min(32,(uint8_t)didc.dwButtons);
joystick.numHats = (uint8_t)didc.dwPOVs;
initprintf("Controller has %d axes, %d buttons, and %d hat(s).\n",joystick.numAxes,joystick.numButtons,joystick.numHats);
axisdefs = (struct _joydef *)Bcalloc(didc.dwAxes, sizeof(struct _joydef));
buttondefs = (struct _joydef *)Bcalloc(didc.dwButtons, sizeof(struct _joydef));
if (didc.dwPOVs)
hatdefs = (struct _joydef *)Bcalloc(didc.dwPOVs, sizeof(struct _joydef));
joyaxis = (int32_t *)Bcalloc(didc.dwAxes, sizeof(int32_t));
joystick.pAxis = (int32_t *)Bcalloc(didc.dwAxes, sizeof(int32_t));
if (didc.dwPOVs)
joyhat = (int32_t *)Bcalloc(didc.dwPOVs, sizeof(int32_t));
joystick.pHat = (int32_t *)Bcalloc(didc.dwPOVs, sizeof(int32_t));
result = IDirectInputDevice7_EnumObjects(dev2, InitDirectInput_enumobjects, (LPVOID)typecounts, DIDFT_ALL);
if (FAILED(result)) { IDirectInputDevice7_Release(dev2); HorribleDInputDeath("Failed getting controller features", result); }
@ -1083,17 +1076,17 @@ static void UninitDirectInput(void)
if (axisdefs)
{
for (i=joynumaxes-1; i>=0; i--) Bfree(axisdefs[i].name);
for (i=joystick.numAxes-1; i>=0; i--) Bfree(axisdefs[i].name);
DO_FREE_AND_NULL(axisdefs);
}
if (buttondefs)
{
for (i=joynumbuttons-1; i>=0; i--) Bfree(buttondefs[i].name);
for (i=joystick.numButtons-1; i>=0; i--) Bfree(buttondefs[i].name);
DO_FREE_AND_NULL(buttondefs);
}
if (hatdefs)
{
for (i=joynumhats-1; i>=0; i--) Bfree(hatdefs[i].name);
for (i=joystick.numHats-1; i>=0; i--) Bfree(hatdefs[i].name);
DO_FREE_AND_NULL(hatdefs);
}
@ -1131,29 +1124,29 @@ static void GetKeyNames(void)
int32_t i;
char tbuf[MAX_PATH], *cp;
memset(key_names,0,sizeof(key_names));
memset(g_keyNameTable,0,sizeof(g_keyNameTable));
for (i=0; i<256; i++)
{
tbuf[0] = 0;
GetKeyNameText((i>128?(i+128):i)<<16, tbuf, sizeof(key_names[i])-1);
Bstrncpy(&key_names[i][0], tbuf, sizeof(key_names[i])-1);
for (cp=key_names[i]; *cp; cp++)
GetKeyNameText((i>128?(i+128):i)<<16, tbuf, sizeof(g_keyNameTable[i])-1);
Bstrncpy(&g_keyNameTable[i][0], tbuf, sizeof(g_keyNameTable[i])-1);
for (cp=g_keyNameTable[i]; *cp; cp++)
if (!(*cp>=32 && *cp<127))
*cp = '?';
}
}
const char *getjoyname(int32_t what, int32_t num)
const char *joyGetName(int32_t what, int32_t num)
{
switch (what)
{
case 0: // axis
return ((unsigned)num > (unsigned)joynumaxes) ? NULL : (char *)axisdefs[num].name;
return ((unsigned)num > (unsigned)joystick.numAxes) ? NULL : (char *)axisdefs[num].name;
case 1: // button
return ((unsigned)num > (unsigned)joynumbuttons) ? NULL : (char *)buttondefs[num].name;
return ((unsigned)num > (unsigned)joystick.numButtons) ? NULL : (char *)buttondefs[num].name;
case 2: // hat
return ((unsigned)num > (unsigned)joynumhats) ? NULL : (char *)hatdefs[num].name;
return ((unsigned)num > (unsigned)joystick.numHats) ? NULL : (char *)hatdefs[num].name;
default:
return NULL;
}
@ -1195,7 +1188,7 @@ static void AcquireInputDevices(char acquire)
di_devacquired = 0;
releaseallbuttons();
// releaseallbuttons();
if (! *devicedef.did) return;
@ -1250,31 +1243,31 @@ static inline void DI_PollJoysticks(void)
int32_t j;
// check axes
for (j=0; j<joynumaxes; j++)
for (j=0; j<joystick.numAxes; j++)
{
if (axisdefs[j].ofs != didod[i].dwOfs) continue;
joyaxis[j] = didod[i].dwData - 32767;
joystick.pAxis[j] = didod[i].dwData - 32767;
break;
}
if (j<joynumaxes) continue;
if (j<joystick.numAxes) continue;
// check buttons
for (j=0; j<joynumbuttons; j++)
for (j=0; j<joystick.numButtons; j++)
{
if (buttondefs[j].ofs != didod[i].dwOfs) continue;
if (didod[i].dwData & 0x80) joyb |= (1<<j);
else joyb &= ~(1<<j);
if (joypresscallback)
joypresscallback(j+1, (didod[i].dwData & 0x80)==0x80);
if (didod[i].dwData & 0x80) joystick.bits |= (1<<j);
else joystick.bits &= ~(1<<j);
if (joystick.pCallback)
joystick.pCallback(j+1, (didod[i].dwData & 0x80)==0x80);
break;
}
if (j<joynumbuttons) continue;
if (j<joystick.numButtons) continue;
// check hats
for (j=0; j<joynumhats; j++)
for (j=0; j<joystick.numHats; j++)
{
if (hatdefs[j].ofs != didod[i].dwOfs) continue;
joyhat[j] = didod[i].dwData;
joystick.pHat[j] = didod[i].dwData;
break;
}
}
@ -1800,8 +1793,8 @@ void getvalidmodes(void)
for (j=0; j < 2; j++)
{
if (cdepths[j] == 0) continue;
for (i=0; defaultres[i][0]; i++)
ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1,-1)
for (i=0; g_defaultVideoModes[i].x; i++)
ADDMODE(g_defaultVideoModes[i].x,g_defaultVideoModes[i].y,cdepths[j],1,-1)
}
}
}
@ -1817,9 +1810,9 @@ void getvalidmodes(void)
for (j=0; j < 2; j++)
{
if (cdepths[j] == 0) continue;
for (i=0; defaultres[i][0]; i++)
CHECK(defaultres[i][0],defaultres[i][1])
ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0,-1)
for (i=0; g_defaultVideoModes[i].x; i++)
CHECK(g_defaultVideoModes[i].x,g_defaultVideoModes[i].y)
ADDMODE(g_defaultVideoModes[i].x,g_defaultVideoModes[i].y,cdepths[j],0,-1)
}
qsort((void *)validmode, validmodecnt, sizeof(struct validmode_t), &sortmodes);
@ -3515,9 +3508,9 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
{
if (!appactive && fullscreen)
{
if (mousegrab)
if (g_mouseGrabbed)
{
grabmouse(0);
mouseGrabInput(0);
regrabmouse = 1;
}
realfs = fullscreen;
@ -3529,7 +3522,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
{
if (regrabmouse)
{
grabmouse(AppMouseGrab);
mouseGrabInput(g_mouseLockedToWindow);
regrabmouse = 0;
}
ShowWindow(hWindow, SW_RESTORE);

View file

@ -1499,7 +1499,7 @@ static void IntegratedHelp(void)
for (i=0; i<IHELP_PATLEN+1; i++) pattern[i]=0;
i=0;
bflushchars();
keyFlushChars();
while (bad == 0)
{
_printmessage16("Search: %s_", pattern);
@ -1510,7 +1510,7 @@ static void IntegratedHelp(void)
if (handleevents())
quitevent = 0;
ch = bgetchar();
ch = keyGetChar();
if (keystatus[1]) bad = 1;
else if (ch == 13) bad = 2;
@ -1971,14 +1971,14 @@ static void SoundDisplay(void)
showframe(1);
i=0;
bflushchars();
keyFlushChars();
while (bad == 0)
{
idle_waitevent();
if (handleevents())
quitevent = 0;
ch = bgetchar();
ch = keyGetChar();
if (keystatus[1]) bad = 1;
@ -2743,12 +2743,12 @@ static int32_t m32gettile(int32_t idInitialTile)
scrollmode = !(eitherCTRL^revertCTRL);
if (bstatus&16 && scrollmode && iTopLeftTile > 0)
{
mouseb &= ~16;
g_mouseBits &= ~16;
iTopLeftTile -= (nXTiles*scrollamount);
}
else if (bstatus&32 && scrollmode && iTopLeftTile < localartlookupnum-nDisplayedTiles-1)
{
mouseb &= ~32;
g_mouseBits &= ~32;
iTopLeftTile += (nXTiles*scrollamount);
}
@ -2769,7 +2769,7 @@ static int32_t m32gettile(int32_t idInitialTile)
{
if (PRESSED_KEYSC(gSLASH) || (!scrollmode && bstatus&16))
{
mouseb &= ~16;
g_mouseBits &= ~16;
bstatus &= ~16;
// Watch out : If editor window is small, then the next zoom level
@ -2783,7 +2783,7 @@ static int32_t m32gettile(int32_t idInitialTile)
else
{
keystatus[KEYSC_gSTAR] = 0;
mouseb &= ~32;
g_mouseBits &= ~32;
bstatus &= ~32;
s_Zoom--;
}
@ -2966,7 +2966,7 @@ static int32_t m32gettile(int32_t idInitialTile)
}
}
mousex = mousey = mouseb = 0;
g_mousePos.x = g_mousePos.y = g_mouseBits = 0;
}
//
@ -3269,7 +3269,7 @@ static int32_t OnSelectTile(int32_t tileNum)
SelectAllTiles(tileNum);
bflushchars();
keyFlushChars();
setpolymost2dview();
#ifdef USE_OPENGL
@ -3314,7 +3314,7 @@ static int32_t OnSelectTile(int32_t tileNum)
}
showframe(1);
ch = bgetchar();
ch = keyGetChar();
for (i = 0; i < tile_groups; i++)
{
@ -3575,7 +3575,7 @@ restart:
tilescreen_drawrest(iSelected, showmsg);
k = (mousex || mousey || mouseb);
k = (g_mousePos.x || g_mousePos.y || g_mouseBits);
if (!k)
for (i=0; i<(signed)ARRAY_SIZE(keystatus); i++)
if (keystatus[i])
@ -3758,7 +3758,7 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int
}
oldnum = danum;
bflushchars();
keyFlushChars();
while (keystatus[0x1] == 0)
{
if (handleevents())
@ -3766,13 +3766,13 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int
M32_DrawRoomsAndMasks();
ch = bgetchar();
ch = keyGetChar();
if (keystatus[0x1]) break;
clearkeys();
mouseb = 0;
g_mouseBits = 0;
searchx = osearchx;
searchy = osearchy;
@ -3921,7 +3921,7 @@ ENDFOR1:
sp->pal = 0;
sp->cstat = 18;
bflushchars();
keyFlushChars();
while (keystatus[0x1] == 0)
{
if (handleevents())
@ -3960,13 +3960,13 @@ ENDFOR1:
M32_DrawRoomsAndMasks();
ch = bgetchar();
ch = keyGetChar();
if (keystatus[0x1]) break;
clearkeys();
mouseb = 0;
g_mouseBits = 0;
searchx = osearchx;
searchy = osearchy;
@ -5011,7 +5011,7 @@ static void Keys3d(void)
if (tsign)
{
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
bstatus &= ~(16|32);
if (eitherALT) //ALT
@ -5143,7 +5143,7 @@ static void Keys3d(void)
asksave = 1;
}
keystatus[KEYSC_DASH] = keystatus[KEYSC_EQUAL] = 0;
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
}
if (PRESSED_KEYSC(E)) // E (expand)
@ -5244,10 +5244,10 @@ static void Keys3d(void)
mouseaction=0;
if (eitherALT && (bstatus&1))
{
mousex=0; mskip=1;
if (mousey!=0)
g_mousePos.x=0; mskip=1;
if (g_mousePos.y!=0)
{
updownunits=klabs(mousey*128);
updownunits=klabs(g_mousePos.y*128);
mouseaction=1;
}
}
@ -5257,8 +5257,8 @@ static void Keys3d(void)
if (ASSERT_AIMING)
{
// PK: PGUP/PGDN, rmb only & mwheel
tsign -= (PRESSED_KEYSC(PGUP) || (mouseaction && mousey<0) || ((bstatus&(16|2|1))==(16|2)));
tsign += (PRESSED_KEYSC(PGDN) || (mouseaction && mousey>0) || ((bstatus&(32|2|1))==(32|2)));
tsign -= (PRESSED_KEYSC(PGUP) || (mouseaction && g_mousePos.y<0) || ((bstatus&(16|2|1))==(16|2)));
tsign += (PRESSED_KEYSC(PGDN) || (mouseaction && g_mousePos.y>0) || ((bstatus&(32|2|1))==(32|2)));
}
if (tsign)
@ -5424,7 +5424,7 @@ static void Keys3d(void)
}
asksave = 1;
mouseb &= ~(16|32);
g_mouseBits &= ~(16|32);
}
/* end Mapster32 */
@ -5919,10 +5919,10 @@ static void Keys3d(void)
if (eitherCTRL && !eitherSHIFT && (bstatus&1) && AIMING_AT_CEILING_OR_FLOOR)
{
mousex=0; mskip=1;
if (mousey)
g_mousePos.x=0; mskip=1;
if (g_mousePos.y)
{
i=klabs(mousey*2);
i=klabs(g_mousePos.y*2);
mouseaction=1;
}
}
@ -5930,8 +5930,8 @@ static void Keys3d(void)
tsign = 0;
if (ASSERT_AIMING)
{
tsign -= (PRESSED_KEYSC(LBRACK) || (mouseaction && mousey<0)); // [
tsign += (PRESSED_KEYSC(RBRACK) || (mouseaction && mousey>0)); // ]
tsign -= (PRESSED_KEYSC(LBRACK) || (mouseaction && g_mousePos.y<0)); // [
tsign += (PRESSED_KEYSC(RBRACK) || (mouseaction && g_mousePos.y>0)); // ]
}
if (tsign)
@ -6005,7 +6005,7 @@ static void Keys3d(void)
if ((bstatus&1) && eitherSHIFT)
mskip=1;
if ((bstatus&1) && eitherSHIFT && AIMING_AT_CEILING_OR_FLOOR && (mousex|mousey))
if ((bstatus&1) && eitherSHIFT && AIMING_AT_CEILING_OR_FLOOR && (g_mousePos.x|g_mousePos.y))
{
int32_t fw,x1,y1,x2,y2,stat,ma,a=0;
@ -6017,7 +6017,7 @@ static void Keys3d(void)
x2=POINT2(fw).x,y2=POINT2(fw).y;
a=getangle(x1-x2,y1-y2);
}
mouseax+=mousex; mouseay+=mousey;
mouseax+=g_mousePos.x; mouseay+=g_mousePos.y;
ma = getangle(mouseax,mouseay);
ma += ang-a;
@ -6082,8 +6082,8 @@ static void Keys3d(void)
}
}
}
mousex=0;
mousey=0;
g_mousePos.x=0;
g_mousePos.y=0;
}
@ -6094,7 +6094,7 @@ static void Keys3d(void)
updownunits=1;
mouseaction=0;
if (!mouseb)
if (!g_mouseBits)
{
mouseax=0;
mouseay=0;
@ -6105,10 +6105,10 @@ static void Keys3d(void)
if (eitherSHIFT)
{
mskip=1;
if (mousex)
if (g_mousePos.x)
{
mouseaction = 1;
mouseax += mousex;
mouseax += g_mousePos.x;
updownunits = klabs(mouseax/2);
if (updownunits)
mouseax=0;
@ -6117,11 +6117,11 @@ static void Keys3d(void)
else if (eitherCTRL && !eitherALT)
{
mskip=1;
if (mousex)
if (g_mousePos.x)
{
mouseaction = 2;
repeatpanalign = 0;
updownunits = klabs(mouseax+=mousex)/(16 - 12*AIMING_AT_SPRITE);
updownunits = klabs(mouseax+=g_mousePos.x)/(16 - 12*AIMING_AT_SPRITE);
if (updownunits)
mouseax=0;
}
@ -6133,9 +6133,9 @@ static void Keys3d(void)
if (repeatcountx == 0 || repeatcountx > 32 || mouseaction)
{
changedir = 0;
if (keystatus[KEYSC_gLEFT] || mousex>0)
if (keystatus[KEYSC_gLEFT] || g_mousePos.x>0)
changedir = -1;
if (keystatus[KEYSC_gRIGHT] || mousex<0)
if (keystatus[KEYSC_gRIGHT] || g_mousePos.x<0)
changedir = 1;
if (AIMING_AT_WALL_OR_MASK)
@ -6189,7 +6189,7 @@ static void Keys3d(void)
static int32_t sumxvect=0, sumyvect=0;
if (mouseaction==1)
mouseaction_movesprites(&sumxvect, &sumyvect, 1536, mousex);
mouseaction_movesprites(&sumxvect, &sumyvect, 1536, g_mousePos.x);
else
{
sumxvect = sumyvect = 0;
@ -6222,23 +6222,23 @@ static void Keys3d(void)
if (eitherSHIFT)
{
mskip=1;
if (mousey)
if (g_mousePos.y)
{
mouseaction = 1;
updownunits = klabs(mousey);
updownunits = klabs(g_mousePos.y);
if (!AIMING_AT_SPRITE)
updownunits = klabs((int32_t)(mousey*128./tilesiz[wall[searchwall].picnum].y));
updownunits = klabs((int32_t)(g_mousePos.y*128./tilesiz[wall[searchwall].picnum].y));
}
}
else if (eitherCTRL && !eitherALT)
{
mskip=1;
if (mousey)
if (g_mousePos.y)
{
mouseaction = 2;
repeatpanalign = 0;
mouseay += mousey;
mouseay += g_mousePos.y;
updownunits = klabs(mouseay)/(32 - 28*AIMING_AT_SPRITE);
if (updownunits)
mouseay=0;
@ -6246,7 +6246,7 @@ static void Keys3d(void)
}
}
if (!mouseb)
if (!g_mouseBits)
{
mouseax=0;
mouseay=0;
@ -6257,9 +6257,9 @@ static void Keys3d(void)
if (repeatcounty == 0 || repeatcounty > 32 || mouseaction)
{
changedir = 0;
if (keystatus[KEYSC_gUP] || mousey>0)
if (keystatus[KEYSC_gUP] || g_mousePos.y>0)
changedir = -1;
if (keystatus[KEYSC_gDOWN] || mousey<0)
if (keystatus[KEYSC_gDOWN] || g_mousePos.y<0)
changedir = 1;
if (AIMING_AT_WALL_OR_MASK)
@ -6298,7 +6298,7 @@ static void Keys3d(void)
static int32_t sumxvect=0, sumyvect=0;
if (mouseaction==1)
mouseaction_movesprites(&sumxvect, &sumyvect, 2048, mousey);
mouseaction_movesprites(&sumxvect, &sumyvect, 2048, g_mousePos.y);
else
{
sumxvect = sumyvect = 0;
@ -10853,7 +10853,7 @@ void ExtCheckKeys(void)
}
lastbstatus = bstatus;
readmousebstatus(&bstatus);
mouseReadButtons(&bstatus);
Keys2d3d();

View file

@ -6358,7 +6358,7 @@ int app_main(int argc, char const * const * argv)
}
#endif
flushlogwindow = 0;
g_logFlushWindow = 0;
G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad);
// flushlogwindow = 1;
@ -6517,8 +6517,8 @@ int app_main(int argc, char const * const * argv)
CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent);
// JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too
for (bssize_t i=0; i<joynumaxes; i++)
setjoydeadzone(i,ud.config.JoystickAnalogueDead[i],ud.config.JoystickAnalogueSaturate[i]);
for (bssize_t i=0; i<joystick.numAxes; i++)
joySetDeadZone(i,ud.config.JoystickAnalogueDead[i],ud.config.JoystickAnalogueSaturate[i]);
}
#ifdef HAVE_CLIPSHAPE_FEATURE

View file

@ -6625,7 +6625,7 @@ void C_Compile(const char *fileName)
initprintf("Compiling: %s (%d bytes)\n", fileName, kFileLen);
flushlogwindow = 0;
g_logFlushWindow = 0;
uint32_t const startcompiletime = getticks();
@ -6663,7 +6663,7 @@ void C_Compile(const char *fileName)
}
g_scriptModules.clear();
flushlogwindow = 1;
g_logFlushWindow = 1;
if (g_errorCnt > 63)
initprintf("fatal error: too many errors: Aborted\n");

View file

@ -34,7 +34,7 @@ int32_t I_CheckAllInput(void)
{
return (
#if defined EDUKE32_IOS
mousepressstate == Mouse_Pressed ||
g_mouseClickState == MOUSE_PRESSED ||
#endif
KB_KeyWaiting() ||
MOUSE_GetButtons() ||
@ -44,7 +44,7 @@ int32_t I_CheckAllInput(void)
void I_ClearAllInput(void)
{
#if defined EDUKE32_IOS
mousepressstateadvance();
mouseAdvanceClickState();
#endif
KB_FlushKeyboardQueue();
KB_ClearKeysDown();

View file

@ -1633,7 +1633,7 @@ void Menu_Init(void)
MEOS_Gamefuncs.numOptions = k;
for (i = 0; i < NUMKEYS; ++i)
MEOSN_Keys[i] = key_names[i];
MEOSN_Keys[i] = g_keyNameTable[i];
MEOSN_Keys[NUMKEYS-1] = MenuKeyNone;
@ -1761,18 +1761,18 @@ void Menu_Init(void)
MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE;
MEO_MOUSESETUPBTNS[i].data = &ud.config.MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]];
}
for (i = 0; i < 2*joynumbuttons + 8*joynumhats; ++i)
for (i = 0; i < 2*joystick.numButtons + 8*joystick.numHats; ++i)
{
if (i < 2*joynumbuttons)
if (i < 2*joystick.numButtons)
{
if (i & 1)
Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, "Double %s", getjoyname(1, i>>1));
Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, "Double %s", joyGetName(1, i>>1));
else
Bstrncpy(MenuJoystickNames[i], getjoyname(1, i>>1), MAXJOYBUTTONSTRINGLENGTH);
Bstrncpy(MenuJoystickNames[i], joyGetName(1, i>>1), MAXJOYBUTTONSTRINGLENGTH);
}
else
{
Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, (i & 1) ? "Double Hat %d %s" : "Hat %d %s", ((i - 2*joynumbuttons)>>3), MenuJoystickHatDirections[((i - 2*joynumbuttons)>>1) % 4]);
Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, (i & 1) ? "Double Hat %d %s" : "Hat %d %s", ((i - 2*joystick.numButtons)>>3), MenuJoystickHatDirections[((i - 2*joystick.numButtons)>>1) % 4]);
}
MEL_JOYSTICKBTNS[i] = &ME_JOYSTICKBTNS[i];
@ -1782,15 +1782,15 @@ void Menu_Init(void)
MEO_JOYSTICKBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE;
MEO_JOYSTICKBTNS[i].data = &ud.config.JoystickFunctions[i>>1][i&1];
}
M_JOYSTICKBTNS.numEntries = 2*joynumbuttons + 8*joynumhats;
for (i = 0; i < joynumaxes; ++i)
M_JOYSTICKBTNS.numEntries = 2*joystick.numButtons + 8*joystick.numHats;
for (i = 0; i < joystick.numAxes; ++i)
{
ME_JOYSTICKAXES[i] = ME_JOYSTICKAXES_TEMPLATE;
Bstrncpy(MenuJoystickAxes[i], getjoyname(0, i), MAXJOYBUTTONSTRINGLENGTH);
Bstrncpy(MenuJoystickAxes[i], joyGetName(0, i), MAXJOYBUTTONSTRINGLENGTH);
ME_JOYSTICKAXES[i].name = MenuJoystickAxes[i];
MEL_JOYSTICKAXES[i] = &ME_JOYSTICKAXES[i];
}
M_JOYSTICKAXES.numEntries = joynumaxes;
M_JOYSTICKAXES.numEntries = joystick.numAxes;
// prepare video setup
for (i = 0; i < validmodecnt; ++i)
@ -3000,7 +3000,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
}
case MENU_JOYSTICKAXES:
M_JOYSTICKAXIS.title = getjoyname(0, M_JOYSTICKAXES.currentEntry);
M_JOYSTICKAXIS.title = joyGetName(0, M_JOYSTICKAXES.currentEntry);
MEO_JOYSTICKAXIS_ANALOG.data = &ud.config.JoystickAnalogueAxes[M_JOYSTICKAXES.currentEntry];
MEO_JOYSTICKAXIS_SCALE.variable = &ud.config.JoystickAnalogueScale[M_JOYSTICKAXES.currentEntry];
MEO_JOYSTICKAXIS_DEAD.variable = &ud.config.JoystickAnalogueDead[M_JOYSTICKAXES.currentEntry];
@ -3327,9 +3327,9 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue)
else if (entry == &ME_JOYSTICKAXIS_SCALE)
CONTROL_SetAnalogAxisScale(M_JOYSTICKAXES.currentEntry, newValue, controldevice_joystick);
else if (entry == &ME_JOYSTICKAXIS_DEAD)
setjoydeadzone(M_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable);
joySetDeadZone(M_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable);
else if (entry == &ME_JOYSTICKAXIS_SATU)
setjoydeadzone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue);
joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue);
return 0;
}
@ -3638,7 +3638,7 @@ static void Menu_TextFormSubmit(char *input)
int8_t cheatID = -1;
if (inputlength > 2 && tempbuf[0] == scantoasc[CheatKeys[0]] && tempbuf[1] == scantoasc[CheatKeys[1]])
if (inputlength > 2 && tempbuf[0] == g_keyAsciiTable[CheatKeys[0]] && tempbuf[1] == g_keyAsciiTable[CheatKeys[1]])
{
for (size_t i = 0; i < NUMCHEATS; i++)
if (Menu_CheatStringMatch(tempbuf+2, CheatStrings[i]))
@ -4317,14 +4317,14 @@ void Menu_Open(size_t playerID)
{
g_player[playerID].ps->gm |= MODE_MENU;
readmouseabsxy(&m_prevmousepos, &mouseabs);
mouseReadAbs(&m_prevmousepos, &g_mouseAbs);
m_mouselastactivity = -M_MOUSETIMEOUT;
#if !defined EDUKE32_TOUCH_DEVICES
m_mousewake_watchpoint = 0;
#endif
AppGrabMouse(0);
mouseLockToWindow(0);
}
void Menu_Close(size_t playerID)
@ -4333,7 +4333,7 @@ void Menu_Close(size_t playerID)
{
// The following lines are here so that you cannot close the menu when no game is running.
g_player[playerID].ps->gm &= ~MODE_MENU;
AppGrabMouse(1);
mouseLockToWindow(1);
if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2)
{
@ -4524,7 +4524,7 @@ static void Menu_RunScrollbar(Menu_t *cm, MenuMenuFormat_t const * const format,
rotatesprite_fs(scrollx + (scrollwidth>>1) - ((tilesiz[scrollTileCursor].x*ud.menu_scrollcursorz)>>1), scrollregionstart + scale(scrollregionheight, *scrollPos, scrollPosMax), ud.menu_scrollcursorz, 0, scrollTileCursor, 0, 0, 26);
if (cm == m_currentMenu && !m_mousecaught && MOUSEACTIVECONDITIONAL(mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held))
if (cm == m_currentMenu && !m_mousecaught && MOUSEACTIVECONDITIONAL(g_mouseClickState == MOUSE_PRESSED || g_mouseClickState == MOUSE_HELD))
{
const int32_t scrolltilehalfheight = (tilesiz[scrollTileCursor].y*ud.menu_scrollcursorz)>>1;
const int32_t scrollregiony = scrollregionstart + scrolltilehalfheight;
@ -4733,7 +4733,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
Menu_RunInput_Menu_MovementVerify(menu);
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, entry->font->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, entry->font->get_yline()))
{
menu->currentEntry = e;
Menu_RunInput_Menu_MovementVerify(menu);
@ -4778,7 +4778,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
Menu_RunInput_Menu_MovementVerify(menu);
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, entry->font->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, entry->font->get_yline()))
{
menu->currentEntry = e;
Menu_RunInput_Menu_MovementVerify(menu);
@ -4828,7 +4828,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
menu->currentColumn = 1;
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, columnx[1], mousey, column1textsize.x, object->font->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, columnx[1], mousey, column1textsize.x, object->font->get_yline()))
{
menu->currentEntry = e;
Menu_RunInput_Menu_MovementVerify(menu);
@ -4851,7 +4851,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
menu->currentColumn = 0;
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, columnx[0], mousey, column0textsize.x, object->font->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, columnx[0], mousey, column0textsize.x, object->font->get_yline()))
{
menu->currentEntry = e;
Menu_RunInput_Menu_MovementVerify(menu);
@ -4936,7 +4936,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
Menu_RunInput_Menu_MovementVerify(menu);
}
if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held))
if (!m_mousecaught && (g_mouseClickState == MOUSE_PRESSED || g_mouseClickState == MOUSE_HELD))
{
const int32_t slidepointhalfwidth = mulscale16((((tilesiz[SLIDEBAR+1].x)*ud.menu_slidecursorz)>>2) + ud.menu_slidebarmargin, z);
const int32_t slideregionx = slidebarx + slidepointhalfwidth;
@ -5035,7 +5035,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
Menu_RunInput_Menu_MovementVerify(menu);
}
if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held))
if (!m_mousecaught && (g_mouseClickState == MOUSE_PRESSED || g_mouseClickState == MOUSE_HELD))
{
const int32_t slidepointhalfwidth = mulscale16((2+tilesiz[SLIDEBAR+1].x)<<15, z);
const int32_t slideregionx = slidebarx + slidepointhalfwidth;
@ -5135,7 +5135,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
Menu_RunInput_Menu_MovementVerify(menu);
}
if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held))
if (!m_mousecaught && (g_mouseClickState == MOUSE_PRESSED || g_mouseClickState == MOUSE_HELD))
{
const int32_t slidepointhalfwidth = mulscale16((2+tilesiz[SLIDEBAR+1].x)<<15, z);
const int32_t slideregionx = slidebarx + slidepointhalfwidth;
@ -5208,7 +5208,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
}
#ifndef EDUKE32_TOUCH_DEVICES
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousepos, mousex, mousey, mousewidth, h) && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, h))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousepos, mousex, mousey, mousewidth, h) && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, h))
#endif
{
if (entry == currentry && object->editfield != NULL)
@ -5336,7 +5336,7 @@ static void Menu_RunOptionList(Menu_t *cm, MenuEntry_t *entry, MenuOption_t *obj
object->options->currentEntry = e;
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, object->options->font->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, mousewidth, object->options->font->get_yline()))
{
object->options->currentEntry = e;
@ -5359,7 +5359,7 @@ static void Menu_RunOptionList(Menu_t *cm, MenuEntry_t *entry, MenuOption_t *obj
static int32_t Menu_RunInput_MouseAdvance(void)
{
return MOUSEACTIVECONDITIONAL(!m_mousecaught && mousepressstate == Mouse_Released);
return MOUSEACTIVECONDITIONAL(!m_mousecaught && g_mouseClickState == MOUSE_RELEASED);
}
static int32_t Menu_RunInput_MouseReturn_status;
@ -5404,10 +5404,10 @@ static int32_t Menu_RunInput_MouseReturn(void)
#if !defined EDUKE32_TOUCH_DEVICES
Menu_RunInput_MouseReturn_status = 1;
#else
Menu_RunInput_MouseReturn_status = (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held);
Menu_RunInput_MouseReturn_status = (g_mouseClickState == MOUSE_PRESSED || g_mouseClickState == MOUSE_HELD);
#endif
return !m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, MouseReturnRegionX, 0, backbuttonbound.x, backbuttonbound.y);
return !m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, MouseReturnRegionX, 0, backbuttonbound.x, backbuttonbound.y);
}
Menu_RunInput_MouseReturn_status = 0;
@ -5607,7 +5607,7 @@ static void Menu_Run(Menu_t *cm, const vec2_t origin)
Menu_RunInput_FileSelect_MovementVerify(object);
}
if (!m_mousecaught && mousepressstate == Mouse_Released && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, textdim.x, object->font[i]->get_yline()))
if (!m_mousecaught && g_mouseClickState == MOUSE_RELEASED && !Menu_MouseOutsideBounds(&m_mousedownpos, mousex, mousey, textdim.x, object->font[i]->get_yline()))
{
object->findhigh[i] = dir;
object->currentList = i;
@ -6814,8 +6814,8 @@ void M_DisplayMenus(void)
if (!Menu_IsTextInput(m_currentMenu) && KB_KeyPressed(sc_Q))
Menu_AnimateChange(MENU_QUIT, MA_Advance);
int32_t mousestatus = readmouseabsxy(&m_mousepos, &mouseabs);
if (mousestatus && mousepressstate == Mouse_Pressed)
int32_t mousestatus = mouseReadAbs(&m_mousepos, &g_mouseAbs);
if (mousestatus && g_mouseClickState == MOUSE_PRESSED)
m_mousedownpos = m_mousepos;
Menu_RunInput(m_currentMenu);
@ -6920,7 +6920,7 @@ void M_DisplayMenus(void)
m_mousewake_watchpoint = 1;
#endif
if (MOUSEACTIVECONDITIONAL(mousepressstateadvance()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y)
if (MOUSEACTIVECONDITIONAL(mouseAdvanceClickState()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y)
{
m_prevmousepos = m_mousepos;
m_mouselastactivity = totalclock;
@ -6984,7 +6984,7 @@ void M_DisplayMenus(void)
}
}
else
mousepressstate = Mouse_Idle;
g_mouseClickState = MOUSE_IDLE;
#endif
if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU)

View file

@ -128,7 +128,7 @@ void GAME_onshowosd(int32_t shown)
{
G_UpdateScreenArea();
AppGrabMouse((!shown) + 2);
mouseLockToWindow((!shown) + 2);
osdshown = shown;

View file

@ -1186,7 +1186,7 @@ void G_DisplayRest(int32_t smoothratio)
#ifdef GEKKO
// like the mouse cursor, the pointer doesn't use the crosshair enabled / scale options
if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.camerasprite == -1 &&
(g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && readmouseabsxy((vec2_t *)&ud.returnvar[0], &mouseabs))
(g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && mouseReadAbs((vec2_t *)&ud.returnvar[0], &g_mouseAbs))
{
int32_t a = VM_OnEventWithReturn(EVENT_DISPLAYPOINTER, g_player[screenpeek].ps->i, screenpeek, CROSSHAIR);
if ((unsigned) a < MAXTILES)

View file

@ -59,9 +59,9 @@ extern kb_scancode KB_LastScan;
keystatus[(scan)] = FALSE; \
}
#define KB_UnBoundKeyPressed(scan) (keystatus[(scan)] != 0 && !CONTROL_KeyBinds[scan].cmdstr)
#define KB_GetCh bgetchar
#define KB_KeyWaiting bkbhit
#define KB_FlushKeyboardQueue bflushchars
#define KB_GetCh keyGetChar
#define KB_KeyWaiting keyBufferWaiting
#define KB_FlushKeyboardQueue keyFlushChars
static inline void KB_ClearKeysDown(void)
{
@ -75,8 +75,8 @@ static inline void KB_KeyEvent(int32_t scancode, int32_t keypressed)
KB_LastScan = scancode;
}
static inline void KB_Startup(void) { setkeypresscallback(KB_KeyEvent); }
static inline void KB_Shutdown(void) { setkeypresscallback((void (*)(int32_t, int32_t))NULL); }
static inline void KB_Startup(void) { keySetCallback(KB_KeyEvent); }
static inline void KB_Shutdown(void) { keySetCallback((void (*)(int32_t, int32_t))NULL); }
const char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string
kb_scancode KB_StringToScanCode( const char * string ); // convert a string into a scancode

View file

@ -48,12 +48,12 @@ extern "C" {
static inline int32_t Mouse_Init(void)
{
initmouse();
mouseInit();
return ((inputdevices & 2) == 2);
}
static inline void MOUSE_Shutdown(void) { uninitmouse(); }
static inline void MOUSE_Shutdown(void) { mouseUninit(); }
#if 0
static inline void MOUSE_ShowCursor(void) {}
@ -63,13 +63,13 @@ static inline void MOUSE_HideCursor(void) {}
static inline int32_t MOUSE_GetButtons(void)
{
int32_t buttons;
readmousebstatus(&buttons);
mouseReadButtons(&buttons);
return buttons;
}
#define MOUSE_ClearButton(b) (mouseb &= ~b)
#define MOUSE_ClearAllButtons() mouseb = 0
#define MOUSE_GetDelta(x, y) readmousexy(x, y)
#define MOUSE_ClearButton(b) (g_mouseBits &= ~b)
#define MOUSE_ClearAllButtons() g_mouseBits = 0
#define MOUSE_GetDelta(x, y) mouseReadPos(x, y)
#ifdef __cplusplus
}

View file

@ -642,14 +642,14 @@ static void CONTROL_PollDevices(ControlInfo *info)
if (CONTROL_JoystickEnabled)
{
int32_t i = joynumaxes-1;
int32_t i = joystick.numAxes-1;
Bmemcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes));
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
for (; i>=0; i--)
{
CONTROL_JoyAxes[i].analog = joyaxis[i];
CONTROL_JoyAxes[i].analog = joystick.pAxis[i];
CONTROL_DigitizeAxis(i, controldevice_joystick);
CONTROL_ScaleAxis(i, controldevice_joystick);
@ -859,8 +859,8 @@ int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t
// break;
// case controltype_keyboardandjoystick:
CONTROL_NumJoyAxes = min(MAXJOYAXES,joynumaxes);
CONTROL_NumJoyButtons = min(MAXJOYBUTTONS,joynumbuttons + 4*(joynumhats>0));
CONTROL_NumJoyAxes = min(MAXJOYAXES,joystick.numAxes);
CONTROL_NumJoyButtons = min(MAXJOYBUTTONS,joystick.numButtons + 4*(joystick.numHats>0));
CONTROL_JoystickEnabled = CONTROL_JoyPresent = (inputdevices&4)>>2;
// break;
//}

View file

@ -44,31 +44,31 @@ int32_t JOYSTICK_GetButtons(void)
{
int32_t buttons;
readjoybstatus(&buttons);
joyReadButtons(&buttons);
if (joynumhats > 0)
if (joystick.numHats > 0)
{
int32_t hat = JOYSTICK_GetHat(0);
if (hat != 0)
buttons |= hat << min(MAXJOYBUTTONS, joynumbuttons);
buttons |= hat << min(MAXJOYBUTTONS, joystick.numButtons);
}
return buttons;
}
int32_t JOYSTICK_ClearButton(int32_t b)
{
return (joyb &= ~b);
return (joystick.bits &= ~b);
}
void JOYSTICK_ClearAllButtons(void)
{
joyb = 0;
joystick.bits = 0;
}
int32_t JOYSTICK_GetHat(int32_t h)
{
if (h>=0 && h<joynumhats)
if (h>=0 && h<joystick.numHats)
{
if (joyhat[h] == -1)
if (joystick.pHat[h] == -1)
return (HAT_CENTERED);
else
{
@ -76,7 +76,7 @@ int32_t JOYSTICK_GetHat(int32_t h)
int32_t val;
// thanks SDL for this much more sensible method
val = ((joyhat[0] + 4500 / 2) % 36000) / 4500;
val = ((joystick.pHat[0] + 4500 / 2) % 36000) / 4500;
if (val < 8)
return hatstate[val];
}
@ -85,28 +85,28 @@ int32_t JOYSTICK_GetHat(int32_t h)
}
void JOYSTICK_ClearHat(int32_t h)
{
if (h>=0 && h<joynumhats)
joyhat[h] = -1;
if (h>=0 && h<joystick.numHats)
joystick.pHat[h] = -1;
}
void JOYSTICK_ClearAllHats(void)
{
int32_t h;
for (h=0; h<joynumhats; ++h)
joyhat[h] = -1;
for (h=0; h<joystick.numHats; ++h)
joystick.pHat[h] = -1;
}
int32_t JOYSTICK_GetAxis(int32_t a)
{
return ((a>=0 && a<joynumaxes)?joyaxis[a]:0);
return ((a>=0 && a<joystick.numAxes)?joystick.pAxis[a]:0);
}
void JOYSTICK_ClearAxis(int32_t a)
{
if (a>=0 && a<joynumaxes)
joyaxis[a] = 0;
if (a>=0 && a<joystick.numAxes)
joystick.pAxis[a] = 0;
}
void JOYSTICK_ClearAllAxes(void)
{
int32_t a;
for (a=0; a<joynumaxes; ++a)
joyaxis[a] = 0;
for (a=0; a<joystick.numAxes; ++a)
joystick.pAxis[a] = 0;
}