Odamex
Setting the Standard in Multiplayer Doom
ag-odalaunch/Xbox/xbox_main.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*- 
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: xbox_main.h 2170 2011-05-08 00:04:57Z hypereye $
00005 //
00006 // Copyright (C) 2006-2010 by The Odamex Team.
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // DESCRIPTION:
00019 //      Xbox Support
00020 //
00021 // AUTHORS:
00022 //       Michael Wood (mwoodj at huntsvegas dot org)
00023 //
00024 //-----------------------------------------------------------------------------
00025 
00026 #ifndef _XBOX_MAIN_H
00027 #define _XBOX_MAIN_H
00028 
00029 #ifdef _XBOX
00030 
00031 #include <fstream>
00032 #include <agar/core.h>
00033 #include <SDL/SDL.h>
00034 
00035 #include "typedefs.h"
00036 
00043 namespace agOdalaunch {
00044 
00045 #define inet_ntoa Xbox::InetNtoa
00046 #define gethostbyname Xbox::GetHostByName
00047 
00053 struct hostent
00054 {
00055         char  *h_name;       
00056         char **h_aliases;    
00057         int    h_addrtype;   
00058         int    h_length;     
00059         char **h_addr_list;  
00060 #define h_addr h_addr_list[0] 
00061 };
00062 
00069 class Xbox
00070 {
00071 public:
00081         static char *InetNtoa(struct in_addr in);
00082 
00093         static struct hostent *GetHostByName(const char *name);
00094 
00103         static int  InitializeJoystick(void);
00104 
00113         static void EnableJoystickUpdates(bool enable);
00114 
00121         static void MountPartitions();
00122 
00128         static void UnMountPartitions();
00129 
00140         static void OutputDebugString(const char *str, ...);
00141 
00149         static int  InitLogFile();
00150 
00156         static void CloseLogFile();
00157 
00163         static void InitNet();
00164 
00170         static void CloseNetwork();
00171 
00178         static void EnableDebugConsole();
00179 
00180 private:
00181         Xbox() {};
00182         Xbox(const Xbox&) {};
00183         Xbox& operator=(const Xbox&) {};
00184 
00185         static LONG MountDevice(LPSTR sSymbolicLinkName, LPSTR sDeviceName);
00186         static LONG UnMountDevice(LPSTR sSymbolicLinkName);
00187 
00188         static uint32_t UpdateJoystick(void *obj, uint32_t ival, void *arg);
00189 
00190         static const int JOYPAD1 = 0;
00191         static const int JOY_DEADZONE = 3200;
00192 
00193         enum
00194         {
00195                 JOY_BTTN_A = 0,
00196                 JOY_BTTN_B,
00197                 JOY_BTTN_X,
00198                 JOY_BTTN_Y,
00199                 JOY_BTTN_WHITE,
00200                 JOY_BTTN_BLACK,
00201                 JOY_BTTN_LTRIG,
00202                 JOY_BTTN_RTRIG,
00203                 JOY_BTTN_START,
00204                 JOY_BTTN_BACK,
00205                 JOY_BTTN_RSTICK,
00206                 JOY_BTTN_LSTICK,
00207                 JOY_BTTN_TOTAL
00208         };
00209 
00210         enum
00211         {
00212                 JOY_AXIS_LX = 0,
00213                 JOY_AXIS_LY,
00214                 JOY_AXIS_RX,
00215                 JOY_AXIS_RY,
00216                 JOY_AXIS_TOTAL
00217         };
00218 
00219         static SDL_Joystick *OpenedJoy;
00220         static AG_Timeout    JoyUpdateTimeout;
00221         static bool          BPressed[JOY_BTTN_TOTAL];
00222         static uint8_t       HPressed;
00223 
00224         static std::ofstream XBLogFile;
00225         static AG_Mutex      XBLogMutex;
00226         static bool          DebugConsole;
00227 };
00228 
00229 } // namespace
00230 
00231 #endif // _XBOX
00232 
00233 #endif // _XBOX_MAIN_H
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends