예제 #1
0
파일: Module.cpp 프로젝트: CYBORUS/SDL2TK
    void Module::OnEvent(const SDL_Event& event)
    {
        switch (event.type)
        {
            case SDL_WINDOWEVENT:
            {
                switch (event.window.event)
                {
                    case SDL_WINDOWEVENT_ENTER: OnMouseFocus(); break;
                    case SDL_WINDOWEVENT_LEAVE: OnMouseBlur(); break;
                    case SDL_WINDOWEVENT_FOCUS_GAINED: OnInputFocus(); break;
                    case SDL_WINDOWEVENT_FOCUS_LOST: OnInputBlur(); break;
                    case SDL_WINDOWEVENT_RESTORED: OnRestore(); break;
                    case SDL_WINDOWEVENT_MINIMIZED: OnMinimize(); break;
                    case SDL_WINDOWEVENT_MAXIMIZED: OnMaximize(); break;
                    case SDL_WINDOWEVENT_EXPOSED: OnExpose(); break;

                    case SDL_WINDOWEVENT_SIZE_CHANGED:
                        OnResize(event.window.data1, event.window.data2);
                        break;

                    default: break;
                }

                break;
            }

            case SDL_KEYDOWN:
                if (event.key.repeat)
                    OnKeyRepeat(event.key.keysym);
                else
                    OnKeyDown(event.key.keysym);
                break;

            case SDL_KEYUP: OnKeyUp(event.key.keysym); break;
            case SDL_MOUSEMOTION: OnMouseMove(event.motion); break;
            case SDL_MOUSEWHEEL: OnMouseWheel(event.wheel); break;
            case SDL_MOUSEBUTTONDOWN: OnMouseButtonDown(event.button); break;
            case SDL_MOUSEBUTTONUP: OnMouseButtonUp(event.button); break;

            case SDL_JOYAXISMOTION: OnJoyAxis(event.jaxis); break;
            case SDL_JOYBALLMOTION: OnJoyBall(event.jball); break;
            case SDL_JOYHATMOTION: OnJoyHat(event.jhat); break;
            case SDL_JOYBUTTONDOWN: OnJoyButtonDown(event.jbutton); break;
            case SDL_JOYBUTTONUP: OnJoyButtonUp(event.jbutton); break;
            case SDL_QUIT: OnExit(); break;
            case SDL_SYSWMEVENT: break;

            default: OnUser(event.user);break;
        }
    }
예제 #2
0
void CEvent::OnEvent(SDL_Event* Event) {
	switch(Event->type) {

		case SDL_ACTIVEEVENT: {
			switch(Event->active.state) {
				case SDL_APPMOUSEFOCUS: {
					if ( Event->active.gain )	OnMouseFocus();
					else				OnMouseBlur();

					break;
				}
				case SDL_APPINPUTFOCUS: {
					if ( Event->active.gain )	OnInputFocus();
					else				OnInputBlur();

					break;
				}
				case SDL_APPACTIVE:	{
					if ( Event->active.gain )	OnRestore();
					else				OnMinimize();

					break;
				}
			}
			break;
		}

		case SDL_KEYDOWN: {
			OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_KEYUP: {
			OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_MOUSEMOTION: {
			OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
			break;
		}

		case SDL_MOUSEBUTTONDOWN: {
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonDown(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_MOUSEBUTTONUP:	{
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonUp(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_JOYAXISMOTION: {
			OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
			break;
		}

		case SDL_JOYBALLMOTION: {
			OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
			break;
		}

		case SDL_JOYHATMOTION: {
			OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
			break;
		}
		case SDL_JOYBUTTONDOWN: {
			OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_JOYBUTTONUP: {
			OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_QUIT: {
			OnExit();
			break;
		}

		case SDL_SYSWMEVENT: {
			//Ignore
			break;
		}

		case SDL_VIDEORESIZE: {
			OnResize(Event->resize.w,Event->resize.h);
			break;
		}

		case SDL_VIDEOEXPOSE: {
			OnExpose();
			break;
		}

		default: {
			OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
			break;
		}
	}
}
void Gevents::OnEvent(SDL_Event* Event) {
    switch(Event->type) {
 
        case SDL_KEYDOWN: {
            OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode);
            break;
        }
 
        case SDL_KEYUP: {
            OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(Event->button.x,Event->button.y);
                    OnLButtonDown(Event->button.x, Event->button.y, Event->key.keysym.mod);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_JOYAXISMOTION: {
            OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
        }
        
        default: {
            OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }
}
예제 #4
0
void Event::OnEvent(SDL_Event* Event) {
    switch(Event->type) {
		case SDL_TEXTINPUT:
			{
				OnTextEdit(Event->text.text);
				break;
			}
        case SDL_KEYDOWN: {
            OnKeyDown(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod);
            break;
        }
 
        case SDL_KEYUP: {
            OnKeyUp(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }

		case SDL_MOUSEWHEEL:
			{
				if(Event->wheel.y > 0)
				{
					OnMouseWheel(true, false);
				}
				else
				{
					OnMouseWheel(false, true);
				}
				break;
			}
 
        case SDL_JOYAXISMOTION: {
            OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
							 }
        default: {
            OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }
}
예제 #5
0
void CEvent::OnEvent(SDL_Event* Event) {
	switch (Event->type) {
	case SDL_WINDOWEVENT: {
		switch (Event->window.event) {
		case SDL_WINDOWEVENT_ENTER:			{ OnMouseFocus();	break; }
		case SDL_WINDOWEVENT_LEAVE:			{ OnMouseBlur();	break; }
		case SDL_WINDOWEVENT_FOCUS_GAINED:	{ OnInputFocus();	break; }				//keyboard focus. What is keyboard focus?
		case SDL_WINDOWEVENT_FOCUS_LOST:	{ OnInputBlur();	break; }
		case SDL_WINDOWEVENT_RESTORED:		{ OnRestore();		break; }
		case SDL_WINDOWEVENT_MINIMIZED:		{ OnMinimize();		break; }

		case SDL_WINDOWEVENT_RESIZED:		{ OnResize(Event->window.data1, Event->window.data2); break; }
		case SDL_WINDOWEVENT_EXPOSED:		{ OnExpose();		break; }
		case SDL_WINDOWEVENT_CLOSE:			{ OnExit();			break; }
		}
		break;
	}

	case SDL_KEYDOWN:					{ OnKeyDown(Event->key.keysym.sym, Event->key.keysym.mod);	break; }
	case SDL_KEYUP:						{ OnKeyUp(Event->key.keysym.sym, Event->key.keysym.mod);	break; }

	case SDL_MOUSEMOTION: {
		OnMouseMove(Event->motion.x, Event->motion.y, Event->motion.xrel, Event->motion.yrel, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0);
		break;
	}

	case SDL_MOUSEBUTTONDOWN: {
								  switch (Event->button.button) {
								  case SDL_BUTTON_LEFT: {
															OnLButtonDown(Event->button.x, Event->button.y);
															break;
								  }
								  case SDL_BUTTON_RIGHT: {
															 OnRButtonDown(Event->button.x, Event->button.y);
															 break;
								  }
								  case SDL_BUTTON_MIDDLE: {
															  OnMButtonDown(Event->button.x, Event->button.y);
															  break;
								  }
								  }
								  break;
	}

	case SDL_MOUSEBUTTONUP:    {
								   switch (Event->button.button) {
								   case SDL_BUTTON_LEFT: {
															 OnLButtonUp(Event->button.x, Event->button.y);
															 break;
								   }
								   case SDL_BUTTON_RIGHT: {
															  OnRButtonUp(Event->button.x, Event->button.y);
															  break;
								   }
								   case SDL_BUTTON_MIDDLE: {
															   OnMButtonUp(Event->button.x, Event->button.y);
															   break;
								   }
								   }
								   break;
	}

	case SDL_JOYAXISMOTION: {
								OnJoyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
								break;
	}

	case SDL_JOYBALLMOTION: {
								OnJoyBall(Event->jball.which, Event->jball.ball, Event->jball.xrel, Event->jball.yrel);
								break;
	}

	case SDL_JOYHATMOTION: {
							   OnJoyHat(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
							   break;
	}
	case SDL_JOYBUTTONDOWN: {
								OnJoyButtonDown(Event->jbutton.which, Event->jbutton.button);
								break;
	}

	case SDL_JOYBUTTONUP: {
							  OnJoyButtonUp(Event->jbutton.which, Event->jbutton.button);
							  break;
	}

	case SDL_QUIT: {
					   OnExit();
					   break;
	}

	case SDL_SYSWMEVENT: {
							 //Ignore
							 break;
	}

	default: {
				 OnUser(Event->user.type, Event->user.code, Event->user.data1, Event->user.data2);
				 break;
	}
	}
}
예제 #6
0
//==============================================================================
void CEvent::OnEvent(SDL_Event* Event) {
	switch(Event->type) {
		case SDL_ACTIVEEVENT: {
			switch(Event->active.state) {//check to see what event has occured
				case SDL_APPMOUSEFOCUS: {
					if ( Event->active.gain )	OnMouseFocus();
					else				OnMouseBlur();

					break;
				}
				case SDL_APPINPUTFOCUS: {
					if ( Event->active.gain )	OnInputFocus();
					else				OnInputBlur();

					break;
				}
				case SDL_APPACTIVE:	{
					if ( Event->active.gain )	OnRestore();
					else				OnMinimize();

					break;
				}
			}
			break;
		}

		case SDL_KEYDOWN: {//on key down pass in what was pressed
			OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_KEYUP: {//on key up pass in what was depressed
			OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_MOUSEMOTION: {//
			OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
			break;
		}

		case SDL_MOUSEBUTTONDOWN: {//if the button on the mouse is pressed pass in its x and y
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonDown(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_MOUSEBUTTONUP:	{
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonUp(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_JOYAXISMOTION: {//stuff we dont use
			OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
			break;
		}

		case SDL_JOYBALLMOTION: {
			OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
			break;
		}

		case SDL_JOYHATMOTION: {
			OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
			break;
		}
		case SDL_JOYBUTTONDOWN: {
			OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_JOYBUTTONUP: {
			OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_QUIT: {//if SDL is quit then run the exit function
			OnExit();
			break;
		}
		//more stufff we dont use

		case SDL_SYSWMEVENT: {
			//Ignore
			break;
		}

		case SDL_VIDEORESIZE: {
			OnResize(Event->resize.w,Event->resize.h);
			break;
		}

		case SDL_VIDEOEXPOSE: {
			OnExpose();
			break;
		}

		default: {
			OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
			break;
		}
	}
}