示例#1
0
void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents)
{
	if (SDL_AtariXbios_enabled==0) {
		return;
	}

	/* Mouse motion ? */
	if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
		SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
		SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
	}
	
	/* Mouse button ? */
	if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
		int i;

		for (i=0;i<2;i++) {
			int curbutton, prevbutton;

			curbutton = SDL_AtariXbios_mouseb & (1<<i);
			prevbutton = atari_prevmouseb & (1<<i);

			if (curbutton && !prevbutton) {
				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
			}
			if (!curbutton && prevbutton) {
				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
			}
		}
		atari_prevmouseb = SDL_AtariXbios_mouseb;
	}
}
void HELENOS_PumpEvents(_THIS){
	kbd_event_t kbd_event;
	pos_event_t pos_event;
	SDL_keysym keysym;
	int posted=0;
	while(canvas_pop_keyboard_event(&kbd_event)){
		if(kbd_event.type == KEY_PRESS) {
			posted += SDL_PrivateKeyboard(SDL_PRESSED, HelenOS_TranslateKey(&kbd_event, &keysym));
		} else if(kbd_event.type == KEY_RELEASE){
			posted += SDL_PrivateKeyboard(SDL_RELEASED, HelenOS_TranslateKey(&kbd_event, &keysym));
		}
	}

	while(canvas_pop_position_event(&pos_event)){
		static int mouse_x = 0, mouse_y = 0;

		if(pos_event.type == POS_PRESS){
			posted += SDL_PrivateMouseButton(SDL_PRESSED, (uint8_t)pos_event.btn_num, 0, 0);
		} else if(pos_event.type == POS_RELEASE){
			posted += SDL_PrivateMouseButton(SDL_RELEASED, (uint8_t)pos_event.btn_num, 0, 0);
		} else if(pos_event.type == POS_UPDATE){
			if (mouse_x != pos_event.hpos || mouse_y != pos_event.vpos)
			{
				mouse_x = pos_event.hpos;
				mouse_y = pos_event.vpos;
//				int x = pos_event.hpos - mouse_x;
//				int y = pos_event.vpos - mouse_y;
				posted += SDL_PrivateMouseMotion(0, 0, pos_event.hpos,  pos_event.vpos);
			}
		}
	}
}
示例#3
0
/**
 * Kludge a mouse event by taking advantage of unprotected global funcs 
 *
 * \param ev An analog joystick event
 */
void fakemouse_event(SDL_Event ev) {
	int x, y;

	SDL_GetMouseState (&x, &y);

	switch (ev.type) {
		case SDL_JOYAXISMOTION:
			if ((ev.jaxis.value > -JOY_DEADZONE) && (ev.jaxis.value < JOY_DEADZONE))
				return;
			switch (ev.jaxis.axis) {
				case 0:         
					SDL_PrivateMouseMotion(0, 1, ev.jaxis.value / 1024, 0);
					break;
				case 1:         
					SDL_PrivateMouseMotion(0, 1, 0, ev.jaxis.value / 1024);
					break;
			}
			break;

		case SDL_JOYBUTTONUP:
			SDL_PrivateMouseButton(SDL_RELEASED, 1, x, y);
			break;

		case SDL_JOYBUTTONDOWN:
			SDL_PrivateMouseButton(SDL_PRESSED, 1, x, y);
			break;
	}
}
示例#4
0
/**
 * Kludge a mouse event by taking advantage of unprotected global funcs 
 *
 * \param ev An analog joystick event
 */
void fakemouse_event(SDL_Event ev) {
	int x, y;

	SDL_GetMouseState (&x, &y);

	switch (ev.type) {
			
		case SDL_JOYAXISMOTION:
			SDL_SemWait(sem);
			switch (ev.jaxis.axis) {
				case 0:         
					dx = ev.jaxis.value / 2048;
					break;
				case 1:         
					dy = ev.jaxis.value / 2048;
					break;
			}
			SDL_SemPost(sem);
			break;

		case SDL_JOYBUTTONUP:
			SDL_PrivateMouseButton(SDL_RELEASED, 1, x, y);
			break;

		case SDL_JOYBUTTONDOWN:
			SDL_PrivateMouseButton(SDL_PRESSED, 1, x, y);
			break;
	}
}
示例#5
0
int handleTap()
{
    int mouseX, mouseY;
    SDL_GetMouseState(&mouseX, &mouseY);
    SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, mouseX, mouseY);
    SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, mouseX, mouseY);
    return TCO_SUCCESS;
}
示例#6
0
int handleTouchScreen(int x, int y, int tap, int hold)
{
    if (tap) {
        SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, x, y);
        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, x, y);
    } else if (hold) {
        SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, x, y);
        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, x, y);
    } else {
        SDL_PrivateMouseMotion(SDL_GetMouseState(0, 0), 0, x, y);
    }
    return TCO_SUCCESS;
}
static int DGA_DispatchEvent(_THIS)
{
	int posted;
	SDL_NAME(XDGAEvent) xevent;

	XNextEvent(DGA_Display, (XEvent *)&xevent);

	posted = 0;
	xevent.type -= DGA_event_base;
	switch (xevent.type) {

	    /* Mouse motion? */
	    case MotionNotify: {
		if ( SDL_VideoSurface ) {
			posted = SDL_PrivateMouseMotion(0, 1,
					xevent.xmotion.dx, xevent.xmotion.dy);
		}
	    }
	    break;

	    /* Mouse button press? */
	    case ButtonPress: {
		posted = SDL_PrivateMouseButton(SDL_PRESSED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Mouse button release? */
	    case ButtonRelease: {
		posted = SDL_PrivateMouseButton(SDL_RELEASED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Key press or release? */
	    case KeyPress:
	    case KeyRelease: {
		SDL_keysym keysym;
		XKeyEvent xkey;

		SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey);
		posted = SDL_PrivateKeyboard((xevent.type == KeyPress), 
					X11_TranslateKey(DGA_Display,
							 &xkey, xkey.keycode,
							 &keysym));
	    }
	    break;

	}
	return(posted);
}
示例#8
0
void AtariIkbd_PumpEvents(_THIS)
{
	int i, specialkeys;
	SDL_keysym keysym;

	/*--- Send keyboard events ---*/

	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
		/* Key pressed ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
			SDL_PrivateKeyboard(SDL_PRESSED,
				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
			
		/* Key released ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
			SDL_PrivateKeyboard(SDL_RELEASED,
				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
	}

	/*--- Send mouse events ---*/

	/* Mouse motion ? */
	if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
		SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
		SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
	}

	/* Mouse button ? */
	if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
		for (i=0;i<2;i++) {
			int curbutton, prevbutton;

			curbutton = SDL_AtariIkbd_mouseb & (1<<i);
			prevbutton = atari_prevmouseb & (1<<i);

			if (curbutton && !prevbutton) {
				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
			}
			if (!curbutton && prevbutton) {
				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
			}
		}
		atari_prevmouseb = SDL_AtariIkbd_mouseb;
	}
}
void DirectFB_PumpEvents (_THIS)
{
  DFBInputEvent evt;

  while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer,
                                        DFB_EVENT (&evt)) == DFB_OK)
    {
      SDL_keysym keysym;

      switch (evt.type)
        {
        case DIET_BUTTONPRESS:
          posted += SDL_PrivateMouseButton(SDL_PRESSED,
                                           DirectFB_TranslateButton (&evt), 0, 0);
          break;
        case DIET_BUTTONRELEASE:
          posted += SDL_PrivateMouseButton(SDL_RELEASED,
                                           DirectFB_TranslateButton (&evt), 0, 0);
          break;
        case DIET_KEYPRESS:
          posted += SDL_PrivateKeyboard(SDL_PRESSED, DirectFB_TranslateKey(&evt, &keysym));
          break;
        case DIET_KEYRELEASE:
          posted += SDL_PrivateKeyboard(SDL_RELEASED, DirectFB_TranslateKey(&evt, &keysym));
          break;
        case DIET_AXISMOTION:
          if (evt.flags & DIEF_AXISREL)
            {
              if (evt.axis == DIAI_X)
                posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
              else if (evt.axis == DIAI_Y)
                posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
            }
          else if (evt.flags & DIEF_AXISABS)
            {
              static int last_x, last_y;
              if (evt.axis == DIAI_X)
                last_x = evt.axisabs;
              else if (evt.axis == DIAI_Y)
                last_y = evt.axisabs;
              posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y);
            }
          break;
        default:
          ;
        }
    }
}
示例#10
0
extern void JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse)(JNIEnv* env, jobject thiz, jint x, jint y, jint action) {
	//__android_log_print(ANDROID_LOG_INFO, "libSDL", "mouse event %i at (%03i, %03i)", action, x, y);
	if (action == MOUSE_DOWN || action == MOUSE_UP)
		SDL_PrivateMouseButton((action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, 1, x, y);
	if (action == MOUSE_MOVE)
		SDL_PrivateMouseMotion(0, 0, x, y);
}
示例#11
0
void						CELL_DoMouseEvent			(uint32_t aButton, uint32_t aState)
{
	if(aButton < 4 && aButton > 0 && ((MouseEventMap[aButton] && aState == SDL_PRESSED) || (!MouseEventMap[aButton] && aState == SDL_RELEASED)))
	{
		SDL_PrivateMouseButton(aState, aButton, 0, 0);
		MouseEventMap[aButton - 1] = !MouseEventMap[aButton - 1];
	}
}
示例#12
0
static void handlePointerEvent(screen_event_t event, screen_window_t window)
{
	int buttonState = 0;
	screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState);

	int coords[2];
	screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, coords);

	int screen_coords[2];
	screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, screen_coords);

	int wheel_delta;
	screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel_delta);

	if (coords[1] < 0) {
		fprintf(stderr, "Detected pointer swipe event: %d,%d\n", coords[0], coords[1]);
		return;
	}
	//fprintf(stderr, "Pointer: %d,(%d,%d),(%d,%d),%d\n", buttonState, coords[0], coords[1], screen_coords[0], screen_coords[1], wheel_delta);
	if (wheel_delta != 0) {
		int button;
		if ( wheel_delta > 0 )
			button = SDL_BUTTON_WHEELDOWN;
		else if ( wheel_delta < 0 )
			button = SDL_BUTTON_WHEELUP;
		SDL_PrivateMouseButton(
			SDL_PRESSED, button, 0, 0);
		SDL_PrivateMouseButton(
			SDL_RELEASED, button, 0, 0);
	}

	// FIXME: Pointer events have never been tested.
	static int lastButtonState = 0;
	if (lastButtonState == buttonState) {
		moveEvent.touching = buttonState;
		moveEvent.pos[0] = coords[0];
		moveEvent.pos[1] = coords[1];
		moveEvent.pending = 1;
		return;
	}
	lastButtonState = buttonState;

	SDL_PrivateMouseButton(buttonState ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT, coords[0], coords[1]); // FIXME: window
	moveEvent.pending = 0;
}
示例#13
0
void SDL_ResetMouse(void)
{
	Uint8 i;
	for ( i = 0; i < sizeof(SDL_ButtonState)*8; ++i ) {
		if ( SDL_ButtonState & SDL_BUTTON(i) ) {
			SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0);
		}
	}
}
extern void SDL_ANDROID_PumpEvents()
{
    static int oldMouseButtons = 0;
    SDL_Event ev;

    SDL_mutexP(BufferedEventsMutex);
    while( BufferedEventsStart != BufferedEventsEnd )
    {
        ev = BufferedEvents[BufferedEventsStart];
        BufferedEvents[BufferedEventsStart].type = 0;
        BufferedEventsStart++;
        if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
            BufferedEventsStart = 0;
        SDL_mutexV(BufferedEventsMutex);

        switch( ev.type )
        {
        case SDL_MOUSEMOTION:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEMOTION REAL: x=%i y=%i", ev.motion.x, ev.motion.y);
            if( SDL_ANDROID_sWindowWidth > 0 && SDL_ANDROID_sWindowHeight > 0 ) {
                int x = ev.motion.x * SDL_ANDROID_sFakeWindowWidth  / SDL_ANDROID_sWindowWidth;
                int y = ev.motion.y * SDL_ANDROID_sFakeWindowHeight / SDL_ANDROID_sWindowHeight;
                //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEMOTION: x=%i y=%i", x, y);
                SDL_PrivateMouseMotion(0, 0, x, y);
            }
            break;
        case SDL_MOUSEBUTTONDOWN:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEBUTTONDOWN: %i %i", ev.button.button, ev.button.state);
            if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
            {
                oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
                SDL_PrivateMouseButton( ev.button.state, ev.button.button, 0, 0 );
            }
            break;
        case SDL_KEYDOWN:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev.key.keysym.sym, ev.key.state);
            SDL_PrivateKeyboard( ev.key.state, &ev.key.keysym );
            break;

        //
        case SDL_VIDEOEXPOSE:
        {
            SDL_Surface* screen = SDL_GetVideoSurface();
            if(screen) {
                SDL_Flip(screen);
            }
        }
        break;
        default:
            break;
        }

        SDL_mutexP(BufferedEventsMutex);
    }
    SDL_mutexV(BufferedEventsMutex);
};
示例#15
0
static void mouse_update(void)
{
	int mouseX, mouseY;
	unsigned char changed;
	XMOUSE_INPUT mouseinput = XInputGetMouseData();

	if(lastMouseX == mouseinput.cX && lastMouseY == mouseinput.cY)
	{
		mouseX = 0;
		mouseY = 0;
	}
	else
	{
		mouseX = mouseinput.cX;
		mouseY = mouseinput.cY;
	}

	if (mouseX||mouseY)
		SDL_PrivateMouseMotion(0,1, mouseX, mouseY);

	changed = mouseinput.ucButtons ^ prevMouseButtons;

	if(changed & XMOUSE_BUTTON_1)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_1) ? SDL_PRESSED : SDL_RELEASED, 1, 0, 0);

	if(changed & XMOUSE_BUTTON_2)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_2) ? SDL_PRESSED : SDL_RELEASED, 2, 0, 0);

	if(changed & XMOUSE_BUTTON_3)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_3) ? SDL_PRESSED : SDL_RELEASED, 3, 0, 0);

	if(changed & XMOUSE_BUTTON_4)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_4) ? SDL_PRESSED : SDL_RELEASED, 4, 0, 0);

	if(changed & XMOUSE_BUTTON_5)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_5) ? SDL_PRESSED : SDL_RELEASED, 5, 0, 0);


	prevMouseButtons = mouseinput.ucButtons;
	lastMouseX = mouseinput.cX;
	lastMouseY = mouseinput.cY;

}
示例#16
0
int PG_HandleMouseButton(struct pgEvent *evt)
{        
        /* We need to focus the canvas when it's clicked */
        if (evt->extra) {
	        SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra;
		pgFocus(this->hidden->wCanvas);
	}
        SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn,
			       evt->e.pntr.x, evt->e.pntr.y);
	return 0;
}
示例#17
0
// Go check a Flash event queue for events SDL should be aware of!
void FLASH_PumpEvents(_THIS)
{
	if (!FLASH_EMPTY_PARAMS)
		FLASH_EMPTY_PARAMS = AS3_Array("");
	
	// Event Vars
	AS3_Val mouseEvent, mouseEvents, mousePosition, keyboardEvent, keyboardEvents;
	int buttonState, rawKeyboardEvent, scanCode, keyState;
	SDL_keysym keysym;
	
	mousePosition = AS3_CallS( "pumpMousePosition", FLASH_EVENT_MANAGER_OBJECT, FLASH_EMPTY_PARAMS );
	mouseEvents = AS3_CallS( "pumpMouseEvents", FLASH_EVENT_MANAGER_OBJECT, FLASH_EMPTY_PARAMS );
	keyboardEvents = AS3_CallS( "pumpKeyEvents", FLASH_EVENT_MANAGER_OBJECT, FLASH_EMPTY_PARAMS );
	
	// Mouse Position
	if (mousePosition) {
		AS3_ObjectValue( mousePosition, "x:IntType, y:IntType", &FLASH_mouseX, &FLASH_mouseY );	
		SDL_PrivateMouseMotion( 0, 0, FLASH_mouseX, FLASH_mouseY );
	}
	
	// Mouse Click Events
	while( AS3_IntValue(AS3_GetS(mouseEvents, "size")) > 0 ) {
		mouseEvent = AS3_CallS( "dequeue", mouseEvents, FLASH_EMPTY_PARAMS );
		buttonState = AS3_IntValue( mouseEvent )? SDL_PRESSED: SDL_RELEASED;
		SDL_PrivateMouseButton(buttonState, SDL_BUTTON_LEFT, FLASH_mouseX, FLASH_mouseY);
	}
	
	// Keyboard Events
	while( AS3_IntValue(AS3_GetS(keyboardEvents, "size")) > 0 ) {
		keyboardEvent = AS3_CallS( "dequeue", keyboardEvents, FLASH_EMPTY_PARAMS );
		rawKeyboardEvent = AS3_IntValue( keyboardEvent );
		scanCode = rawKeyboardEvent & 0xFF;		// Packed event format: 9th bit for press/release, lower 8 bits for scan code
		keyState = rawKeyboardEvent >> 8;
		SDL_PrivateKeyboard(keyState, TranslateKey(scanCode, &keysym));
	}
}
示例#18
0
LOCAL_C TInt PointerEvent(_THIS, const TWsEvent& aWsEvent)
    {
    
    const TPointerEvent* pointerEvent = aWsEvent.Pointer();
    const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition - Private->iScreenPos);

    TInt posted = 0;
    
    if(mousePos.iX >= 0 && mousePos.iY >= 0 && mousePos.iX < _this->screen->w && mousePos.iY < _this->screen->h)
        {
        posted = SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
        }
    
    switch (pointerEvent->iType)
        {
        case TPointerEvent::EButton1Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton1Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton2Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton2Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton3Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        case TPointerEvent::EButton3Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        default:;
        } // switch
    return posted;
    }
示例#19
0
static void handleMtouchEvent(screen_event_t event, screen_window_t window, int type)
{
#ifdef TOUCHPAD_SIMULATE

	unsigned buttonWidth = 200;
	unsigned buttonHeight = 300;

	int contactId;
	int pos[2];
	int screenPos[2];
	screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, (int*)&contactId);
	screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, pos);
	screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, screenPos);

	int mouseX, mouseY;
	SDL_GetMouseState(&mouseX, &mouseY);

	if (state.leftId == contactId) {
		if (type == SCREEN_EVENT_MTOUCH_RELEASE) {
			state.leftId = -1;
			SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, mouseX, mouseY);
		}
		return;
	}
	if (state.rightId == contactId) {
		if (type == SCREEN_EVENT_MTOUCH_RELEASE) {
			state.rightId = -1;
			SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, mouseX, mouseY);
		}
		return;
	}

	if (screenPos[0] < buttonWidth && contactId != state.moveId) {
		// Special handling for buttons

		if (screenPos[1] < buttonHeight) {
			// Left button
			if (type == SCREEN_EVENT_MTOUCH_TOUCH) {
				if (state.leftId == -1 && contactId != state.rightId) {
					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, mouseX, mouseY);
					state.leftId = contactId;
				}
			}
		} else {
			// Right button
			if (type == SCREEN_EVENT_MTOUCH_TOUCH) {
				if (state.rightId == -1 && contactId != state.leftId) {
					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, mouseX, mouseY);
					state.rightId = contactId;
				}
			}
		}
	} else {
		// Can only generate motion events
		int doMove = 0;
		switch (type) {
		case SCREEN_EVENT_MTOUCH_TOUCH:
			if (state.moveId == -1 || state.moveId == contactId) {
				state.moveId = contactId;
			}
			break;
		case SCREEN_EVENT_MTOUCH_RELEASE:
			if (state.moveId == contactId) {
				doMove = 1;
				state.moveId = -1;
			}
			break;
		case SCREEN_EVENT_MTOUCH_MOVE:
			if (state.moveId == contactId) {
				doMove = 1;
			}
			break;
		}

		if (doMove) {
			int mask = 0;
			if (state.leftDown)
				mask |= SDL_BUTTON_LEFT;
			if (state.rightDown)
				mask |= SDL_BUTTON_RIGHT;
			state.mask = mask;
			state.pending[0] += pos[0] - state.oldPos[0];
			state.pending[1] += pos[1] - state.oldPos[1];
			//SDL_PrivateMouseMotion(mask, 1, pos[0] - state.oldPos[0], pos[1] - state.oldPos[1]);
		}
		state.oldPos[0] = pos[0];
		state.oldPos[1] = pos[1];
	}
#else
    int contactId;
    int pos[2];
    int screenPos[2];
    int orientation;
    int pressure;
    long long timestamp;
    int sequenceId;

    screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, (int*)&contactId);
    screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, pos);
    screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, screenPos);
    screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ORIENTATION, (int*)&orientation);
    screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_PRESSURE, (int*)&pressure); // Pointless - always 1 if down
    screen_get_event_property_llv(event, SCREEN_PROPERTY_TIMESTAMP, (long long*)&timestamp);
    screen_get_event_property_iv(event, SCREEN_PROPERTY_SEQUENCE_ID, (int*)&sequenceId);

//    char typeChar = 'D';
//    if (type == SCREEN_EVENT_MTOUCH_RELEASE)
//    	typeChar = 'U';
//    else if (type == SCREEN_EVENT_MTOUCH_MOVE)
//    	typeChar = 'M';
//
//    fprintf(stderr, "Touch %d: (%d,%d) %c\n", contactId, pos[0], pos[1], typeChar);

    if (pos[1] < 0) {
    	fprintf(stderr, "Detected swipe event: %d,%d\n", pos[0], pos[1]);
    	return;
    }
    static int touching = 0;
    if (type == SCREEN_EVENT_MTOUCH_TOUCH) {
    	if (touching) {
    		SDL_PrivateMouseMotion(SDL_BUTTON_LEFT, 0, pos[0], pos[1]);
    	} else {
    		SDL_PrivateMouseMotion(0, 0, pos[0], pos[1]);
    		SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, pos[0], pos[1]);
    	}
    	moveEvent.pending = 0;
    	touching = 1;
    } else if (type == SCREEN_EVENT_MTOUCH_RELEASE) {
    	if (touching) {
    		SDL_PrivateMouseMotion(SDL_BUTTON_LEFT, 0, pos[0], pos[1]);
    		SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, pos[0], pos[1]);
    	} else {
    		SDL_PrivateMouseMotion(0, 0, pos[0], pos[1]);
    	}
    	moveEvent.pending = 0;
    	touching = 0;
    } else if (type == SCREEN_EVENT_MTOUCH_MOVE) {
    	moveEvent.pending = 1;
    	moveEvent.touching = touching;
    	moveEvent.pos[0] = pos[0];
    	moveEvent.pos[1] = pos[1];
    	//SDL_PrivateMouseMotion((touching?SDL_BUTTON_LEFT:0), 0, pos[0], pos[1]);
    }

    // TODO: Possibly need more complicated touch handling
#endif
}
示例#20
0
static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
{
	int i;
	Sint16 xrel, yrel;
	Uint8 state;
	Uint8 button;
	DWORD timestamp = 0;

	
	if (SDL_PublicSurface == NULL) {
		return;
	}

	
	if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
		mouse_lost = 1;
		ClipCursor(NULL);
	} else {
		
		if ( mouse_lost ) {
			POINT mouse_pos;
			Uint8 old_state;
			Uint8 new_state;

			
			GetCursorPos(&mouse_pos);
			ScreenToClient(SDL_Window, &mouse_pos);
			post_mouse_motion( 0, (Sint16)mouse_pos.x, (Sint16)mouse_pos.y);

			
			old_state = SDL_GetMouseState(NULL, NULL);
			new_state = 0;
			{ 
	#if DIRECTINPUT_VERSION >= 0x700
				DIMOUSESTATE2 distate;
	#else
				DIMOUSESTATE distate;
	#endif
				HRESULT result;

				result=IDirectInputDevice2_GetDeviceState(SDL_DIdev[1],
							sizeof(distate), &distate);
				if ( result != DI_OK ) {
					
					SetDIerror(
					"IDirectInputDevice2::GetDeviceState", result);
					return;
				}
				for ( i=3; i>=0; --i ) {
					if ( (distate.rgbButtons[i]&0x80) == 0x80 ) {
						new_state |= 0x01;
					}
					new_state <<= 1;
				}
			}
			for ( i=0; i<8; ++i ) {
				if ( (old_state&0x01) != (new_state&0x01) ) {
					button = (Uint8)(i+1);
					
					switch ( button ) {
						case 2: button = SDL_BUTTON_RIGHT; break;
						case 3: button = SDL_BUTTON_MIDDLE; break;
						case 4: button = SDL_BUTTON_X1; break;
						case 5: button = SDL_BUTTON_X2; break;
						default: break;
					}
					if ( new_state & 0x01 ) {
						
						if ( ++mouse_pressed > 0 ) {
							SetCapture(SDL_Window);
						}
						state = SDL_PRESSED;
					} else {
						
						if ( --mouse_pressed <= 0 ) {
							ReleaseCapture();
							mouse_pressed = 0;
						}
						state = SDL_RELEASED;
					}
					if ( mouse_buttons_swapped ) {
						if ( button == 1 ) button = 3;
						else
						if ( button == 3 ) button = 1;
					}
					posted = SDL_PrivateMouseButton(state, button,
										0, 0);
				}
				old_state >>= 1;
				new_state >>= 1;
			}
			mouse_lost = 0;
			return;
		}

		
		xrel = 0;
		yrel = 0;
		for ( i=0; i<(int)numevents; ++i ) {
			switch (ptrbuf[i].dwOfs) {
				case DIMOFS_X:
					if ( timestamp != ptrbuf[i].dwTimeStamp ) {
						if ( xrel || yrel ) {
							post_mouse_motion(1, xrel, yrel);
							xrel = 0;
							yrel = 0;
						}
						timestamp = ptrbuf[i].dwTimeStamp;
					}
					xrel += (Sint16)ptrbuf[i].dwData;
					break;
				case DIMOFS_Y:
					if ( timestamp != ptrbuf[i].dwTimeStamp ) {
						if ( xrel || yrel ) {
							post_mouse_motion(1, xrel, yrel);
							xrel = 0;
							yrel = 0;
						}
						timestamp = ptrbuf[i].dwTimeStamp;
					}
					yrel += (Sint16)ptrbuf[i].dwData;
					break;
				case DIMOFS_Z:
					if ( xrel || yrel ) {
						post_mouse_motion(1, xrel, yrel);
						xrel = 0;
						yrel = 0;
					}
					timestamp = 0;
					if((int)ptrbuf[i].dwData > 0)
						button = SDL_BUTTON_WHEELUP;
					else
						button = SDL_BUTTON_WHEELDOWN;
					posted = SDL_PrivateMouseButton(
							SDL_PRESSED, button, 0, 0);
					posted |= SDL_PrivateMouseButton(
							SDL_RELEASED, button, 0, 0);
					break;
				case DIMOFS_BUTTON0:
				case DIMOFS_BUTTON1:
				case DIMOFS_BUTTON2:
				case DIMOFS_BUTTON3:
	#if DIRECTINPUT_VERSION >= 0x700
				case DIMOFS_BUTTON4:
				case DIMOFS_BUTTON5:
				case DIMOFS_BUTTON6:
				case DIMOFS_BUTTON7:
	#endif
					if ( xrel || yrel ) {
						post_mouse_motion(1, xrel, yrel);
						xrel = 0;
						yrel = 0;
					}
					timestamp = 0;
					button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
					
					switch ( button ) {
						case 2: button = SDL_BUTTON_RIGHT; break;
						case 3: button = SDL_BUTTON_MIDDLE; break;
						case 4: button = SDL_BUTTON_X1; break;
						case 5: button = SDL_BUTTON_X2; break;
						default: break;
					}
					if ( ptrbuf[i].dwData & 0x80 ) {
						
						if ( ++mouse_pressed > 0 ) {
							SetCapture(SDL_Window);
						}
						state = SDL_PRESSED;
					} else {
						
						if ( --mouse_pressed <= 0 ) {
							ReleaseCapture();
							mouse_pressed = 0;
						}
						state = SDL_RELEASED;
					}
					if ( mouse_buttons_swapped ) {
						if ( button == 1 ) button = 3;
						else
						if ( button == 3 ) button = 1;
					}
					posted = SDL_PrivateMouseButton(state, button,
										0, 0);
					break;
			}
		}
		if ( xrel || yrel ) {
			post_mouse_motion(1, xrel, yrel);
		}
	}
}
示例#21
0
void AtariIkbd_PumpEvents(_THIS)
{
	int i;
	SDL_keysym keysym;
	int specialkeys;

	/*--- Send keyboard events ---*/

	/* Update caps lock state */
	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK]==KEY_PRESSED) {
		caps_state ^= 1;
	}

	/* Choose the translation table */
	specialkeys=KT_UNSHIFT;
	if ((SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT]==KEY_PRESSED)
		|| (SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT]==KEY_PRESSED))
	{
		specialkeys = KT_SHIFT;
	}
	if (caps_state) {
		specialkeys = KT_CAPS;
	}

	/* Now generate events */
	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
		/* Key pressed ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
			SDL_PrivateKeyboard(SDL_PRESSED,
				TranslateKey(i, specialkeys, &keysym, SDL_TRUE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
			
		/* Key released ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
			SDL_PrivateKeyboard(SDL_RELEASED,
				TranslateKey(i, specialkeys, &keysym, SDL_FALSE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
	}

	/*--- Send mouse events ---*/

	/* Mouse motion ? */
	if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
		SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
		SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
	}

	/* Mouse button ? */
	if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
		for (i=0;i<2;i++) {
			int curbutton, prevbutton;

			curbutton = SDL_AtariIkbd_mouseb & (1<<i);
			prevbutton = atari_prevmouseb & (1<<i);

			if (curbutton && !prevbutton) {
				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
			}
			if (!curbutton && prevbutton) {
				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
			}
		}
		atari_prevmouseb = SDL_AtariIkbd_mouseb;
	}
}
示例#22
0
void PumpEvents()
{
#ifdef HW_RVL
	if (TerminateRequested) Terminate();
#endif
	wd = WPAD_Data(0);
	stat = KEYBOARD_GetEvent(&ke);
	mstat = MOUSE_GetEvent(&me);

	if (wd->ir.valid)
	{
		int newx = wd->ir.x;
		int newy = wd->ir.y;
		int diffx = newx - lastx;
		int diffy = newy - lasty;
		lastx = newx;
		lasty = newy;

		posted += SDL_PrivateMouseMotion(0, 1, diffx, diffy);

		Uint8 stateA = SDL_RELEASED;
		Uint8 stateB = SDL_RELEASED;

		if (wd->btns_h & WPAD_BUTTON_A)
		{
			stateA = SDL_PRESSED;
		}
		if (wd->btns_h & WPAD_BUTTON_B)
		{
			stateB = SDL_PRESSED;
		}
		if (stateA != lastButtonStateA)
		{
			lastButtonStateA = stateA;
			posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0);
		}
		if (stateB != lastButtonStateB)
		{
			lastButtonStateB = stateB;
			posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0);
		}
	}

	if (stat && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED))
	{
		SDL_keysym keysym;
		memset(&keysym, 0, sizeof(keysym));
		Uint8 keystate = (ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED
				: SDL_RELEASED;
		keysym.sym = keymap[ke.keycode];
		keysym.mod = 0;
		posted += SDL_PrivateKeyboard(keystate, &keysym);
	}

	if (mstat)
	{
		posted += SDL_PrivateMouseMotion(0, 1, me.rx, me.ry);

		u8 button = me.button;

		if (button & 0x1)
		{
			if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)))
			{
				posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
			}
		}
		else
		{
			if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)))
			{
				posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
			}
		}

		if (button & 0x2)
		{
			if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)))
			{
				posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
			}
		}
		else
		{
			if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)))
			{
				posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
			}
		}
	}
}
示例#23
0
void QUINN_PumpEvents(_THIS) {
	int i;
	int l;
	if (this->hidden->doexit == 1) {
		SDLK_PrivateQuit();
	}

	if (current_req_current) {
		for (l=0;l<current_req.event_msgs_count;l++) {
			if (current_req.event_msgs[l].type == 1) {
				// keyboard
				SDL_keysym keysym;

				if (_k_e0 == 0 && current_req.event_msgs[l].code == 0xe0) {
					_k_e0 = 1;
					continue;
				}

				if (_k_last_state[current_req.event_msgs[l].code] != current_req.event_msgs[l].state) {
					keysym.scancode = current_req.event_msgs[l].code;
					if (_k_last_state[42] == 1 || _k_last_state[54] == 1) {
						keysym.unicode = SDLK_unicode_shift[current_req.event_msgs[l].code];
					} else {
						keysym.unicode = SDLK_unicode[current_req.event_msgs[l].code];
					}
					keysym.mod = make_mod(_k_last_state);

					if (current_req.event_msgs[l].state == 1) {
						if (_k_e0) {
							keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
						} else {
							keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
						}
						SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
					} else {
						// key up
						if (_k_e0) {
							keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
						} else {
							keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
						}
						SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
					}
				}
				_k_e0 = 0;
				_k_last_state[current_req.event_msgs[l].code] = current_req.event_msgs[l].state;
			} else if (current_req.event_msgs[l].type == 2) {
				// mouse
				if (current_req.event_msgs[l].code == 1) {
					if (current_req.event_msgs[l].state != _lmstate) {
						if (current_req.event_msgs[l].state == 1) {
							SDL_PrivateMouseButton(SDL_PRESSED, 1, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						} else {
							SDL_PrivateMouseButton(SDL_RELEASED, 1, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						}
					}
					_lmstate = current_req.event_msgs[l].state;
				} else if (current_req.event_msgs[l].code == 2) {
					if (current_req.event_msgs[l].state != _mmstate) {
						if (current_req.event_msgs[l].state == 1) {
							SDL_PrivateMouseButton(SDL_PRESSED, 2, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						} else {
							SDL_PrivateMouseButton(SDL_RELEASED, 2, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						}
					}
					_mmstate = current_req.event_msgs[l].state;
				} else if (current_req.event_msgs[l].code == 3) {
					if (current_req.event_msgs[l].state != _rmstate) {
						if (current_req.event_msgs[l].state == 1) {
							SDL_PrivateMouseButton(SDL_PRESSED, 3, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						} else {
							SDL_PrivateMouseButton(SDL_RELEASED, 3, current_req.event_msgs[l].x, current_req.event_msgs[l].y);
						}
					}
					_rmstate = current_req.event_msgs[l].state;
				}
			}
		}

		SDL_PrivateMouseMotion(0, 0, current_req.mousex, current_req.mousey);



		current_req_current = 0;
	}
	quinn_process_input();
}
示例#24
0
static int DGA_DispatchEvent(_THIS)
{
	int posted;
	SDL_NAME(XDGAEvent) xevent;

	XNextEvent(DGA_Display, (XEvent *)&xevent);

	posted = 0;
	xevent.type -= DGA_event_base;
	switch (xevent.type) {

	    /* Mouse motion? */
	    case MotionNotify: {
		if ( SDL_VideoSurface ) {
			posted = SDL_PrivateMouseMotion(0, 1,
					xevent.xmotion.dx, xevent.xmotion.dy);
		}
	    }
	    break;

	    /* Mouse button press? */
	    case ButtonPress: {
		posted = SDL_PrivateMouseButton(SDL_PRESSED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Mouse button release? */
	    case ButtonRelease: {
		posted = SDL_PrivateMouseButton(SDL_RELEASED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Key press? */
	    case KeyPress: {
		SDL_keysym keysym;
		KeyCode keycode;
		XKeyEvent xkey;

		SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey);
		keycode = xkey.keycode;
#ifdef DEBUG_XEVENTS
printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode);
#endif
		/* Get the translated SDL virtual keysym */
		keysym.scancode = keycode;
		keysym.sym = X11_TranslateKeycode(DGA_Display, keycode);
		keysym.mod = KMOD_NONE;
		keysym.unicode = 0;

		/* Look up the translated value for the key event */
		if ( SDL_TranslateUNICODE ) {
			static XComposeStatus state;
			char keybuf[32];

			if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, &state) ) {
				/*
				* FIXME: XLookupString() may yield more than one
				* character, so we need a mechanism to allow for
				* this (perhaps null keypress events with a
				* unicode value)
				*/
				keysym.unicode = (Uint8)keybuf[0];
			}
		}
		posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
	    }
	    break;

	    /* Key release? */
	    case KeyRelease: {
		SDL_keysym keysym;
		KeyCode keycode;
		XKeyEvent xkey;

		SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey);
		keycode = xkey.keycode;
#ifdef DEBUG_XEVENTS
printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode);
#endif
		/* Get the translated SDL virtual keysym */
		keysym.scancode = keycode;
		keysym.sym = X11_TranslateKeycode(DGA_Display, keycode);
		keysym.mod = KMOD_NONE;
		keysym.unicode = 0;
		posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
	    }
	    break;
	}
	return(posted);
}
示例#25
0
void AA_PumpEvents(_THIS)
{
	int posted = 0;
	int mouse_button, mouse_x, mouse_y;
	int evt;
	SDL_keysym keysym;

	static int prev_button = -1, prev_x = -1, prev_y = -1;

	if( ! this->screen ) /* Wait till we got the screen initialized */
	  return;

	do {
		posted = 0;
		/* Gather events */

		/* Get mouse status */
		SDL_mutexP(AA_mutex);
		aa_getmouse (AA_context, &mouse_x, &mouse_y, &mouse_button);
		SDL_mutexV(AA_mutex);
		mouse_x = mouse_x * this->screen->w / aa_scrwidth (AA_context);
		mouse_y = mouse_y * this->screen->h / aa_scrheight (AA_context);

		/* Compare against previous state and generate events */
		if( prev_button != mouse_button ) {
			if( mouse_button & AA_BUTTON1 ) {
				if ( ! (prev_button & AA_BUTTON1) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON1 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
				}
			}
			if( mouse_button & AA_BUTTON2 ) {
				if ( ! (prev_button & AA_BUTTON2) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON2 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0);
				}
			}
			if( mouse_button & AA_BUTTON3 ) {
				if ( ! (prev_button & AA_BUTTON3) ) {
					posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
				}
			} else {
				if ( prev_button & AA_BUTTON3 ) {
					posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
				}
			}
		}
		if ( prev_x != mouse_x || prev_y != mouse_y ) {
			posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y);
		}

		prev_button = mouse_button;
		prev_x = mouse_x; prev_y = mouse_y;

		/* Get keyboard event */
		SDL_mutexP(AA_mutex);
		evt = aa_getevent(AA_context, 0);
		SDL_mutexV(AA_mutex);
		if ( (evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) && (evt != AA_RESIZE) ) {
			/* Key pressed */
/*    			printf("Key pressed: %d (%c)\n", evt, evt); */
			posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym));
		} else if ( evt >= AA_RELEASE ) {
			/* Key released */
			evt &= ~AA_RELEASE;
/*  			printf("Key released: %d (%c)\n", evt, evt); */
			posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym));
		}
	} while ( posted );
}
示例#26
0
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    int posted = 0;
    SDL_keysym keysym;


    switch (aWsEvent.Type()) {
    
    case EEventPointer: /* Mouse pointer events */
    {
        const TPointerEvent* pointerEvent = aWsEvent.Pointer();
        TPoint mousePos = pointerEvent->iPosition;

        //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!

        if (Private->EPOC_ShrinkedHeight) {
            mousePos.iY <<= 1; /* Scale y coordinate to shrinked screen height */
        }
		posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
        if (pointerEvent->iType==TPointerEvent::EButton1Down) {
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton1Up) {
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton2Down) {
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton2Up) {
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
        }
	    //!!posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
        break;
    }
    
    case EEventKeyDown: /* Key events */
    {
       (void*)TranslateKey(aWsEvent.Key()->iScanCode, &keysym);
        
        /* Special handling */
        switch((int)keysym.sym) {
        case SDLK_CAPSLOCK:
            if (!isCursorVisible) {
                /* Enable virtual cursor */
	            HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
            }
            else {
                /* Disable virtual cursor */
                HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
            }
            isCursorVisible = !isCursorVisible;
            break;
        }
        
	    posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
        break;
	} 

    case EEventKeyUp: /* Key events */
    {
	    posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
        break;
	} 
    
    case EEventFocusGained: /* SDL window got focus */
    {
        //Private->EPOC_IsWindowFocused = ETrue;
        /* Draw window background and screen buffer */
        RedrawWindowL(_this);  
        break;
    }

    case EEventFocusLost: /* SDL window lost focus */
    {
        //Private->EPOC_IsWindowFocused = EFalse;

        // Wait and eat events until focus is gained again
        /*
	    while (ETrue) {
            Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            User::WaitForRequest(Private->EPOC_WsEventStatus);
		    Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
            TInt eventType = Private->EPOC_WsEvent.Type();
		    Private->EPOC_WsEventStatus = KRequestPending;
		    //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            if (eventType == EEventFocusGained) {
                RedrawWindowL(_this);
                break;
            }
	    }
        */
        break;
    }

    case EEventModifiersChanged: 
    {
	    TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
        TUint modstate = KMOD_NONE;
        if (modEvent->iModifiers == EModifierLeftShift)
            modstate |= KMOD_LSHIFT;
        if (modEvent->iModifiers == EModifierRightShift)
            modstate |= KMOD_RSHIFT;
        if (modEvent->iModifiers == EModifierLeftCtrl)
            modstate |= KMOD_LCTRL;
        if (modEvent->iModifiers == EModifierRightCtrl)
            modstate |= KMOD_RCTRL;
        if (modEvent->iModifiers == EModifierLeftAlt)
            modstate |= KMOD_LALT;
        if (modEvent->iModifiers == EModifierRightAlt)
            modstate |= KMOD_RALT;
        if (modEvent->iModifiers == EModifierLeftFunc)
            modstate |= KMOD_LMETA;
        if (modEvent->iModifiers == EModifierRightFunc)
            modstate |= KMOD_RMETA;
        if (modEvent->iModifiers == EModifierCapsLock)
            modstate |= KMOD_CAPS;
        SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
        break;
    }
    default:            
        break;
	} 
	
    return posted;
}
void NX_PumpEvents (_THIS)
{
    GR_EVENT         event ;
    static GR_BUTTON last_button_down = 0 ;

    GrCheckNextEvent (& event) ;
    while (event.type != GR_EVENT_TYPE_NONE) {

        // dispatch event
        switch (event.type) {
            case GR_EVENT_TYPE_MOUSE_ENTER :
            {
                Dprintf ("mouse enter\n") ;
                SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_MOUSE_EXIT :
            {
                Dprintf ("mouse exit\n") ;
                SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_FOCUS_IN :
            {
                Dprintf ("focus in\n") ;
                SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_FOCUS_OUT :
            {
                Dprintf ("focus out\n") ;
                SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_MOUSE_MOTION :
            {               
                Dprintf ("mouse motion\n") ;

                if (SDL_VideoSurface) {
                    if (currently_fullscreen) {
                        if (check_boundary (this, event.button.x, event.button.y)) {
                            SDL_PrivateMouseMotion (0, 0, event.button.x - OffsetX, 
                                event.button.y - OffsetY) ;
                        }
                    } else {
                        SDL_PrivateMouseMotion (0, 0, event.button.x, event.button.y) ;
                    }
                }
                break ;
            }

            case GR_EVENT_TYPE_BUTTON_DOWN :
            {
                int button = event.button.buttons ;
                
                Dprintf ("button down\n") ;

                switch (button) {
                    case MWBUTTON_L :
                        button = 1 ;
                        break ;
                    case MWBUTTON_M :
                        button = 2 ;
                        break ;
                    case MWBUTTON_R :
                        button = 3 ;
                        break ;
                    default :
                        button = 0 ;
                }
                last_button_down = button ;
                
                if (currently_fullscreen) {
                    if (check_boundary (this, event.button.x, event.button.y)) {
                        SDL_PrivateMouseButton (SDL_PRESSED, button, 
                            event.button.x - OffsetX, event.button.y - OffsetY) ;
                    }
                } else {
                    SDL_PrivateMouseButton (SDL_PRESSED, button, 
                        event.button.x, event.button.y) ;
                }
                break ;
            }

            // do not konw which button is released
            case GR_EVENT_TYPE_BUTTON_UP :
            {   
                Dprintf ("button up\n") ;

                if (currently_fullscreen) {
                    if (check_boundary (this, event.button.x, event.button.y)) {
                        SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, 
                            event.button.x - OffsetX, event.button.y - OffsetY) ;
                    }
                } else {
                    SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, 
                        event.button.x, event.button.y) ;
                }
                last_button_down = 0 ;
                break ;
            }

            case GR_EVENT_TYPE_KEY_DOWN :
            {
                SDL_keysym keysym ;

                Dprintf ("key down\n") ;
                SDL_PrivateKeyboard (SDL_PRESSED,
                    NX_TranslateKey (& event.keystroke, & keysym)) ;
                break ;
            }

            case GR_EVENT_TYPE_KEY_UP :
            {
                SDL_keysym keysym ;

                Dprintf ("key up\n") ;
                SDL_PrivateKeyboard (SDL_RELEASED,
                    NX_TranslateKey (& event.keystroke, & keysym)) ;
                break ;
            }

            case GR_EVENT_TYPE_CLOSE_REQ :
            {
                Dprintf ("close require\n") ;
                SDL_PrivateQuit () ;
                break ;
            }

            case GR_EVENT_TYPE_EXPOSURE :
            {
                Dprintf ("event_type_exposure\n") ;
                if (SDL_VideoSurface) {
                    NX_RefreshDisplay (this) ;//, & event.exposure) ;
                }
                break ;
            }

            case GR_EVENT_TYPE_UPDATE :
            {
                switch (event.update.utype) {
                    case GR_UPDATE_MAP :
                    {
                        Dprintf ("GR_UPDATE_MAP\n") ;
                        // If we're not active, make ourselves active
                        if (!(SDL_GetAppState () & SDL_APPACTIVE)) {
                            // Send an internal activate event
                            SDL_PrivateAppActive (1, SDL_APPACTIVE) ;
                        }
                        if (SDL_VideoSurface) {
                            NX_RefreshDisplay (this) ;
                        }
                        break ;
                    }
                    
                    case GR_UPDATE_UNMAP :
                    case GR_UPDATE_UNMAPTEMP :
                    {
                        Dprintf ("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n") ;
                        // If we're active, make ourselves inactive
                        if (SDL_GetAppState () & SDL_APPACTIVE) {
                            // Send an internal deactivate event
                            SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS) ;
                        }
                        break ; 
                    }
                    
                    case GR_UPDATE_SIZE :
                    {
                        Dprintf ("GR_UPDATE_SIZE\n") ;
                        SDL_PrivateResize (event.update.width, event.update.height) ;
                        break ; 
                    }

                    case GR_UPDATE_MOVE :
		    case GR_UPDATE_REPARENT :
                    {
                        Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n") ;
#ifdef ENABLE_NANOX_DIRECT_FB
			if (Clientfb) {
			    /* Get current window position and fb pointer*/
			    if (currently_fullscreen) 
				GrGetWindowFBInfo(FSwindow, &fbinfo);
			    else
				GrGetWindowFBInfo(SDL_Window, &fbinfo);
			}
#endif
                        break ; 
                    }
                    
                    default :
                        Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ;
                        break ; 
                }
                break ; 
            }
                
            default :
            {
                Dprintf ("pump event default\n") ;
            }
        }

        GrCheckNextEvent (& event) ;
    }
}
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    int posted = 0;
    SDL_keysym keysym;
    
//    SDL_TRACE1("hws %d", aWsEvent.Type());

    switch (aWsEvent.Type())
		{    
    case EEventPointer: /* Mouse pointer events */
		{

        const TPointerCursorMode mode =  Private->EPOC_WsSession.PointerCursorMode();

        if(mode == EPointerCursorNone) 
            {
            return 0; //TODO: Find out why events are get despite of cursor should be off
            }

        const TPointerEvent* pointerEvent = aWsEvent.Pointer();
        TPoint mousePos = pointerEvent->iPosition;

        /*!! TODO Pointer do not yet work properly
        //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!

        if (Private->EPOC_ShrinkedHeight) {
            mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
        }
        if (Private->EPOC_ShrinkedWidth) {
            mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
        }
        */

		posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */

		switch (pointerEvent->iType)
			{
        case TPointerEvent::EButton1Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
			break;
        case TPointerEvent::EButton1Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
			break;
        case TPointerEvent::EButton2Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
			break;
		case TPointerEvent::EButton2Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
			break;
        case TPointerEvent::EButton3Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
			break;
        case TPointerEvent::EButton3Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
			break;
			} // switch
        break;
	    }
    
    case EEventKeyDown: /* Key events */
    {
#ifdef SYMBIAN_CRYSTAL
		// special case: 9300/9500 rocker down, simulate left mouse button
		if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
			{
            const TPointerCursorMode mode =  Private->EPOC_WsSession.PointerCursorMode();
            if(mode != EPointerCursorNone) 
                posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
			}
#endif
       (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
            
#ifndef DISABLE_JOYSTICK
        /* Special handling */
        switch((int)keysym.sym) {
        case SDLK_CAPSLOCK:
            if (!isCursorVisible) {
                /* Enable virtual cursor */
	            HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
            }
            else {
                /* Disable virtual cursor */
                HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
            }
            isCursorVisible = !isCursorVisible;
            break;
        }
#endif        
	    posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
        break;
	} 

    case EEventKeyUp: /* Key events */
		{
#ifdef SYMBIAN_CRYSTAL
		// special case: 9300/9500 rocker up, simulate left mouse button
		if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
			{
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
			}
#endif
	    posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym));
        break;
		}
    
    case EEventFocusGained: /* SDL window got focus */
	    {
        Private->EPOC_IsWindowFocused = ETrue;
		posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
        /* Draw window background and screen buffer */
        DisableKeyBlocking(_this);  //Markus: guess why:-)
 
        RedrawWindowL(_this);  
        break;
	    }

    case EEventFocusLost: /* SDL window lost focus */
		{
/*        
        CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
        bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode);
        Private->EPOC_WsScreen->CopyScreenToBitmap(bmp);
        Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
        Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size()));
	    Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp);
	    Private->EPOC_WsWindow.EndRedraw();
	    Private->EPOC_WindowGc->Deactivate();
        bmp->Save(_L("C:\\scr.mbm"));
        delete bmp;
*/       

		Private->EPOC_IsWindowFocused = EFalse;

		posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);

        RWsSession s;
        s.Connect();
        RWindowGroup g(s);
        g.Construct(TUint32(&g), EFalse);
        g.EnableReceiptOfFocus(EFalse);
        RWindow w(s);
        w.Construct(g, TUint32(&w));
        w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size());
        w.SetOrdinalPosition(0);
        w.Activate();
        w.Close();
        g.Close();
        s.Close();

/*
        Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1);

            
        SDL_Delay(500);
        TInt focus = -1;
        while(focus < 0)
            {
            const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup();
            if(curr != Private->EPOC_WsWindowGroupID)
                focus = curr;
            else
                SDL_Delay(500);
            }

        if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID))
            {
            Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1);
            SDL_Delay(500);
            Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0);
            }
*/
        /*//and the request redraw
        TRawEvent redrawEvent;
        redrawEvent.Set(TRawEvent::ERedraw);
        Private->EPOC_WsSession.SimulateRawEvent(redrawEvent);
        Private->EPOC_WsSession.Flush();*/
#if 0
        //!! Not used
        // Wait and eat events until focus is gained again
	    while (ETrue) {
            Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            User::WaitForRequest(Private->EPOC_WsEventStatus);
		    Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
            TInt eventType = Private->EPOC_WsEvent.Type();
		    Private->EPOC_WsEventStatus = KRequestPending;
		    //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            if (eventType == EEventFocusGained) {
                RedrawWindowL(_this);
                break;
            }
	    }
#endif
        break;
	    }

    case EEventModifiersChanged: 
    {
	    TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
        TUint modstate = KMOD_NONE;
        if (modEvent->iModifiers == EModifierLeftShift)
            modstate |= KMOD_LSHIFT;
        if (modEvent->iModifiers == EModifierRightShift)
            modstate |= KMOD_RSHIFT;
        if (modEvent->iModifiers == EModifierLeftCtrl)
            modstate |= KMOD_LCTRL;
        if (modEvent->iModifiers == EModifierRightCtrl)
            modstate |= KMOD_RCTRL;
        if (modEvent->iModifiers == EModifierLeftAlt)
            modstate |= KMOD_LALT;
        if (modEvent->iModifiers == EModifierRightAlt)
            modstate |= KMOD_RALT;
        if (modEvent->iModifiers == EModifierLeftFunc)
            modstate |= KMOD_LMETA;
        if (modEvent->iModifiers == EModifierRightFunc)
            modstate |= KMOD_RMETA;
        if (modEvent->iModifiers == EModifierCapsLock)
            modstate |= KMOD_CAPS;
        SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
        break;
    }
    default:            
        break;
	} 
	
    return posted;
}
示例#29
0
void PumpEvents()
{   
#if 0
	WPAD_ScanPads();

/*
	if (!keyboard_initialized) {
		wii_keyboard_init();
		keyboard_initialized = 1;
	}
*/

	WPADData *wd = WPAD_Data(0);	
#endif

	stat =  KEYBOARD_getEvent(&ke);
#if 0
	mstat =  MOUSE_getEvent(&me);
	int x, y;

	SDL_GetMouseState(&x, &y);

	if(wd->ir.valid) {

		//int x = (wd->ir.dot[0].rx*640)/1024;
		//int y = (wd->ir.dot[0].ry*480)/768;
	       
		x = wd->ir.x;
		y = wd->ir.y;


		if(lastX!= x || lastY != y) {
			posted += SDL_PrivateMouseMotion(0, 0, x, y);
			lastX = x;
			lastY = y;
		} 
	}
		

	Uint8 stateA = SDL_RELEASED;
	Uint8 stateB = SDL_RELEASED;
	if(wd->btns_h & WPAD_BUTTON_A)
	{
		stateA = SDL_PRESSED;
	}
	if(wd->btns_h & WPAD_BUTTON_B)
	{
		stateB = SDL_PRESSED;
	}
	
	if(stateA != lastButtonStateA)
	{
		lastButtonStateA = stateA;
		posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, x, y);
	}
	if(stateB != lastButtonStateB)
	{
		lastButtonStateB = stateB;
		posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, x, y);
	}
	
	
	Uint8 stateHome = SDL_RELEASED;
	if(wd->btns_h & WPAD_BUTTON_HOME)
	{
		stateHome = SDL_PRESSED;
	}
	
	if(stateHome != lastButtonStateHome)
	{
		lastButtonStateHome = stateHome;
		/*
		SDL_keysym keysym;
		SDL_memset(&keysym, 0, (sizeof keysym));
		keysym.sym = SDLK_ESCAPE;
		SDL_PrivateKeyboard(stateHome, &keysym);*/
		if (stateHome == SDL_RELEASED) {
/*
			SDL_Event event;
			event.type = SDL_QUIT;
			SDL_PushEvent(&event);
*/
		}

	}
#endif

	if (stat && (ke.type==KEYBOARD_RELEASED || ke.type==KEYBOARD_PRESSED) ) {
		SDL_keysym keysym;
		memset(&keysym, 0, sizeof(keysym));
		Uint8 keystate =  (ke.type==KEYBOARD_PRESSED)?SDL_PRESSED:SDL_RELEASED;
		keysym.sym = ke.scancode;
		SDL_SetModState(to_SDL_Modifiers(ke.modifiers));
		posted += SDL_PrivateKeyboard(keystate, &keysym);  
	}

#if 0
	if (mstat) {		
		int x, y;
		posted +=SDL_PrivateMouseMotion(me.button, 1, me.rx, me.ry);

		u8 button = me.button;

		if ( button & 0x1 ) {
			if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) {
				posted +=SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
			}
		} else {
			if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) {
				posted +=SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
			}
		}

		if ( button & 0x2 ) {
			if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) {
				posted +=SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
			}
		} else {
			if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) {
				posted +=SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
			}
		}

	}
#endif 
}
示例#30
0
int handleMouseButton(int button, int mask, int event)
{
    int mouseX, mouseY;
    int sdlEvent;
    int sdlButton;

    switch (event)
    {
    case TCO_MOUSE_BUTTON_UP:
        sdlEvent = SDL_RELEASED;
        break;
    case TCO_MOUSE_BUTTON_DOWN:
        sdlEvent = SDL_PRESSED;
        break;
    default:
        fprintf(stderr, "No mouse button event?? (%d)\n", event);
        sdlEvent = SDL_PRESSED;
        break;
    }

    switch (button)
    {
    case TCO_MOUSE_LEFT_BUTTON:
        sdlButton = SDL_BUTTON_LEFT;
        break;
    case TCO_MOUSE_RIGHT_BUTTON:
        sdlButton = SDL_BUTTON_RIGHT;
        break;
    case TCO_MOUSE_MIDDLE_BUTTON:
        sdlButton = SDL_BUTTON_MIDDLE;
        break;
    default:
        fprintf(stderr, "No mouse button?? (%d)\n", button);
        sdlButton = SDL_BUTTON_LEFT;
        break;
    }
    SDL_GetMouseState(&mouseX, &mouseY);
    mouseY += (current_video->hidden)->eventYOffset;

    SDL_keysym shift, ctrl, alt;
    shift.scancode = 42;
    shift.sym = SDLK_LSHIFT;
    ctrl.scancode = 29;
    ctrl.sym = SDLK_LCTRL;
    alt.scancode = 56;
    alt.sym = SDLK_LALT;

    if (sdlEvent == SDL_PRESSED) {
        if (mask & TCO_SHIFT) {
            SDL_PrivateKeyboard(SDL_PRESSED, &shift);
        }
        if (mask & TCO_CTRL) {
            SDL_PrivateKeyboard(SDL_PRESSED, &ctrl);
        }
        if (mask & TCO_ALT) {
            SDL_PrivateKeyboard(SDL_PRESSED, &alt);
        }
    }
    SDL_PrivateMouseButton(sdlEvent, sdlButton, mouseX, mouseY);
    if (sdlEvent == SDL_RELEASED) {
        if (mask & TCO_SHIFT) {
            SDL_PrivateKeyboard(SDL_RELEASED, &shift);
        }
        if (mask & TCO_CTRL) {
            SDL_PrivateKeyboard(SDL_RELEASED, &ctrl);
        }
        if (mask & TCO_ALT) {
            SDL_PrivateKeyboard(SDL_RELEASED, &alt);
        }
    }
    return TCO_SUCCESS;
}