SDL事件处理(一些数据类型)
2014-11-10 17:33
260 查看
SDL1.2中的定义:
SDL2.0中的事件类型明显比SDL1.2中的多!
SDL采用int SDL_PollEvent(SDL_Event* event);来从底层抽取事件。每一个事件都有一个独立的数据结构来定义,但是第一个成员都是int type.
例如:SDL1.2中的:
typedef enum { SDL_NOEVENT = 0, /**< Unused (do not remove) */ SDL_ACTIVEEVENT, /**< Application loses/gains visibility */ SDL_KEYDOWN, /**< Keys pressed */ SDL_KEYUP, /**< Keys released */ SDL_MOUSEMOTION, /**< Mouse moved */ SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_JOYAXISMOTION, /**< Joystick axis motion */ SDL_JOYBALLMOTION, /**< Joystick trackball motion */ SDL_JOYHATMOTION, /**< Joystick hat position change */ SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_QUIT, /**< User-requested quit */ SDL_SYSWMEVENT, /**< System specific event */ SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */ SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */ SDL_VIDEORESIZE, /**< User resized video mode */ SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */ SDL_EVENT_RESERVED2, /**< Reserved for future use.. */ SDL_EVENT_RESERVED3, /**< Reserved for future use.. */ SDL_EVENT_RESERVED4, /**< Reserved for future use.. */ SDL_EVENT_RESERVED5, /**< Reserved for future use.. */ SDL_EVENT_RESERVED6, /**< Reserved for future use.. */ SDL_EVENT_RESERVED7, /**< Reserved for future use.. */ /** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ SDL_USEREVENT = 24, /** This last event is only for bounding internal arrays * It is the number of bits in the event mask datatype -- Uint32 */ SDL_NUMEVENTS = 32 } SDL_EventType;
SDL2.0中的定义: typedef enum { SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ /* Application events */ SDL_QUIT = 0x100, /**< User-requested quit */ /* These application events have special meaning on iOS, see README-ios.txt for details */ SDL_APP_TERMINATING, /**< The application is being terminated by the OS Called on iOS in applicationWillTerminate() Called on Android in onDestroy() */ SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onLowMemory() */ SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background Called on iOS in applicationWillResignActive()Called on Android in onPause()*/ SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time Called on iOS in applicationDidEnterBackground()Called on Android in onPause() */ SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground Called on iOS in applicationWillEnterForeground() Called on Android in onResume() */ SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive Called on iOS in applicationDidBecomeActive() Called on Android in onResume() */ /* Window events */ SDL_WINDOWEVENT = 0x200, /**< Window state change */ SDL_SYSWMEVENT, /**< System specific event */ /* Keyboard events */ SDL_KEYDOWN = 0x300, /**< Key pressed */ SDL_KEYUP, /**< Key released */ SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ SDL_TEXTINPUT, /**< Keyboard text input */ /* Mouse events */ SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_MOUSEWHEEL, /**< Mouse wheel motion */ /* Joystick events */ SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ SDL_JOYBALLMOTION, /**< Joystick trackball motion */ SDL_JOYHATMOTION, /**< Joystick hat position change */ SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ /* Game controller events */ SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ /* Touch events */ SDL_FINGERDOWN = 0x700, SDL_FINGERUP, SDL_FINGERMOTION, /* Gesture events */ SDL_DOLLARGESTURE = 0x800, SDL_DOLLARRECORD, SDL_MULTIGESTURE, /* Clipboard events */ SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ /* Drag and drop events */ SDL_DROPFILE = 0x1000, /**< The system requests a file open */ /* Render events */ SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset */ /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, * and should be allocated with SDL_RegisterEvents() */ SDL_USEREVENT = 0x8000, /** * This last event is only for bounding internal arrays */ SDL_LASTEVENT = 0xFFFF } SDL_EventType;
SDL2.0中的事件类型明显比SDL1.2中的多!
SDL采用int SDL_PollEvent(SDL_Event* event);来从底层抽取事件。每一个事件都有一个独立的数据结构来定义,但是第一个成员都是int type.
例如:SDL1.2中的:
typedef struct SDL_JoyBallEvent { Uint8 type; Uint8 which; Uint8 ball; Sint16 xrel; Sint16 yrel; } SDL_JoyBallEvent; /** Joystick hat position change event structure */ typedef struct SDL_JoyHatEvent { Uint8 type; Uint8 which; Uint8 hat; Uint8 value; } SDL_JoyHatEvent; SDL2.0中的: typedef struct SDL_JoyBallEvent { Uint32 type; Uint32 timestamp; SDL_JoystickID which; Uint8 ball; Uint8 padding1; Uint8 padding2; Uint8 padding3; Sint16 xrel; Sint16 yrel; } SDL_JoyBallEvent; /** * \brief Joystick hat position change event structure (event.jhat.*) */ typedef struct SDL_JoyHatEvent { Uint32 type; Uint32 timestamp; SDL_JoystickID which; Uint8 hat; Uint8 value; Uint8 padding1; Uint8 padding2; } SDL_JoyHatEvent; 从上面也可以看出SDL2.0相对于SDL1.2事件类型的改变 而SDL_Event是各种事件的联合: SDL1.2: typedef union SDL_Event { Uint8 type; SDL_ActiveEvent active; SDL_KeyboardEvent key; SDL_MouseMotionEvent motion; SDL_MouseButtonEvent button; SDL_JoyAxisEvent jaxis; SDL_JoyBallEvent jball; SDL_JoyHatEvent jhat; SDL_JoyButtonEvent jbutton; SDL_ResizeEvent resize; SDL_ExposeEvent expose; SDL_QuitEvent quit; SDL_UserEvent user; SDL_SysWMEvent syswm; } SDL_Event; SDL2.0: typedef union SDL_Event { Uint32 type; /**< Event type, shared with all events */SDL_EventType中定义的。具体的去看SDL源码 SDL_CommonEvent common; /**< Common event data */ SDL_WindowEvent window; /**< Window event data */ SDL_KeyboardEvent key; /**< Keyboard event data */ SDL_TextEditingEvent edit; /**< Text editing event data */ SDL_TextInputEvent text; /**< Text input event data */ SDL_MouseMotionEvent motion; /**< Mouse motion event data */ SDL_MouseButtonEvent button; /**< Mouse button event data */ SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ SDL_JoyBallEvent jball; /**< Joystick ball event data */ SDL_JoyHatEvent jhat; /**< Joystick hat event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ SDL_MultiGestureEvent mgesture; /**< Gesture event data */ SDL_DollarGestureEvent dgesture; /**< Gesture event data */ SDL_DropEvent drop; /**< Drag and drop event data */ Uint8 padding[56]; } SDL_Event;
相关文章推荐
- Esper事件处理引擎_17_EPL 语法_9_Schema 声明数据类型
- javawebday46(大数据【存储大的文件】事件类型 time批处理 batch)
- spring对一些常见数据类型的配置处理
- 一个类型转换而引起的三级事件的一些思考 数据检查
- 利用Servlet上传文件(在servlet中处理MIME类型的post数据)
- 处理回发数据和处理回发事件的比较
- .NET中的数据类型的一些变化
- C语言一些基础:数据类型,运算类型及表达式
- 在Snmp++中处理DateAndTime类型数据
- SqlServer中处理datetime数据类型
- 长varchar值与text数据类型在应用中的一些问题
- 通过web服务传递复杂类型数据的一些尝试和心得(欢迎讨论)
- 运用C#处理lob数据类型 (Oracle)
- 跟我一起学Windows Workflow Foundation(3)-----使用If/Else活动,定制活动处理工作流,使用事件传递数据
- MySQL的一些数据类型
- Windows处理重要事件的一些操作
- AS 数据类型的一些探索(1)
- 运用C#处理lob数据类型 (Oracle)
- 关于MSSQL Server中DATETIME类型数据的处理[摘]
- 跟我一起学Windows Workflow Foundation(3)-----使用If/Else活动,定制活动处理工作流,使用事件传递数据