예제 #1
0
파일: pinpad.c 프로젝트: EDDA-BA/daemon
char* makePinpad()
{
  handleClick(NULL,GINT_TO_POINTER(11));
  GtkWidget window;
  _makePinpad(&window);
  return handleClick (NULL,GINT_TO_POINTER(10));
}
예제 #2
0
파일: chatscene.cpp 프로젝트: hades/quassel
void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
  if(event->buttons() == Qt::LeftButton) {
    _leftButtonPressed = true;
    _clickHandled = false;
    if(!isPosOverSelection(event->scenePos())) {
      // immediately clear selection if clicked outside; otherwise, wait for potential drag
      clearSelection();
    }
    if(_clickMode != NoClick && _clickTimer.isActive()) {
      switch(_clickMode) {
        case NoClick: _clickMode = SingleClick; break;
        case SingleClick: _clickMode = DoubleClick; break;
        case DoubleClick: _clickMode = TripleClick; break;
        case TripleClick: _clickMode = DoubleClick; break;
        case DragStartClick: break;
      }
      handleClick(Qt::LeftButton, _clickPos);
    } else {
      _clickMode = SingleClick;
      _clickPos = event->scenePos();
    }
    _clickTimer.start();
  }
  if(event->type() == QEvent::GraphicsSceneMouseDoubleClick)
    QGraphicsScene::mouseDoubleClickEvent(event);
  else
    QGraphicsScene::mousePressEvent(event);
}
예제 #3
0
void HTMLAnchorElement::defaultEventHandler(Event* event)
{
    if (isLink()) {
        if (focused() && isEnterKeyKeydownEvent(event) && treatLinkAsLiveForEventType(NonMouseEvent)) {
            event->setDefaultHandled();
            dispatchSimulatedClick(event);
            return;
        }

        if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event))) {
            handleClick(event);
            return;
        }

        if (rendererIsEditable()) {
            // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
            // for the LiveWhenNotFocused editable link behavior
            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
                setRootEditableElementForSelectionOnMouseDown(document()->frame()->selection()->rootEditableElement());
                m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
            } else if (event->type() == eventNames().mouseoverEvent) {
                // These are cleared on mouseover and not mouseout because their values are needed for drag events,
                // but drag events happen after mouse out events.
                clearRootEditableElementForSelectionOnMouseDown();
                m_wasShiftKeyDownOnMouseDown = false;
            }
        }
    }

    HTMLElement::defaultEventHandler(event);
}
예제 #4
0
BOOL LLNetMap::handleMouseUp( S32 x, S32 y, MASK mask )
{
	if(abs(mMouseDown.mX-x)<3 && abs(mMouseDown.mY-y)<3)
		handleClick(x,y,mask);

	if (hasMouseCapture())
	{
		if (mPanning)
		{
			// restore mouse cursor
			S32 local_x, local_y;
			local_x = mMouseDown.mX + llfloor(mCurPan.mV[VX] - mStartPan.mV[VX]);
			local_y = mMouseDown.mY + llfloor(mCurPan.mV[VY] - mStartPan.mV[VY]);
			LLRect clip_rect = getRect();
			clip_rect.stretch(-8);
			clip_rect.clipPointToRect(mMouseDown.mX, mMouseDown.mY, local_x, local_y);
			LLUI::setMousePositionLocal(this, local_x, local_y);

			// finish the pan
			mPanning = false;

			mMouseDown.set(0, 0);

			// auto centre
			mTargetPan.setZero();
		}
		gViewerWindow->showCursor();
		gFocusMgr.setMouseCapture(NULL);
		return TRUE;
	}
	return FALSE;
}
예제 #5
0
void MouseListener::handleEvent(const MinVR::EventRef& event,
		double synchronizedTime) {

	if (startsWith(event->getName(), "mouse_", 6))
	{
		if (event->getName() == "mouse_scroll")
		{
			handleClick(MouseButton::SCROLL, event->get2DData().y > 0, event->get2DData());
			return;
		}

		MinVR::WindowRef window = event->getWindow();
		glm::dvec2 res(window->getWidth(), window->getHeight());
		glm::dvec2 pos = event->get2DData() / res;

		if (event->getName() == "mouse_pointer")
		{
			handleMove(pos);
		}
		else
		{
			MouseButton button;
			if (stringCompare(event->getName(), "left", 10, 4))
			{
				button = LEFT;
			}
			else if (stringCompare(event->getName(), "middle", 10, 6))
			{
				button = MIDDLE;
			}
			else if (stringCompare(event->getName(), "right", 10, 5))
			{
				button = RIGHT;
			}

			if (stringCompare(event->getName(), "up", event->getName().size()-2, 2))
			{
				handleClick(button, false, pos);
			}
			else
			{
				handleClick(button, true, pos);
			}
		}
	}
}
예제 #6
0
//called after render
void Application::update(Uint dt)
{
    if(gs.dwg && gs.tool == FREEHAND && mouse_position.distTo(&gs.lastMDown) > 0)
    {
        LLPos2Add(curLLPos2, mouse_position);
        gs.lastMDown = mouse_position;
    }
    if(checkColor) handleClick(&colorSelector, mouse_position);
}
예제 #7
0
NielsenVis::NielsenVis(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::NielsenVis),
    hasDDIData(false)
{
    ui->setupUi(this);

    // Set the initial value of the status area
    ui->statusBar->showMessage("Please add the necessary CSV data files.");

    // Bind unique identifiers to the radio buttons
    ui->sortStyles->setId(ui->Name, ALPHA_SORT);
    ui->sortStyles->setId(ui->Int, INTER_SORT);
    ui->sortStyles->setId(ui->Plan, PLANN_SORT);
    ui->sortStyles->setId(ui->Final, FINAL_SORT);

    /////////////// END RADIO BUTTON STUFF ///////////////

    // Connect all radio buttons to DisplayManager sort orders
    connect(ui->sortStyles, SIGNAL(buttonClicked(int)), &renderer, SLOT(setSortOrder(int)));

    // Connect buttons to local file dialog functions
    connect(ui->Planning, SIGNAL(clicked()), this, SLOT(findPlanningData()));
    connect(ui->Interim, SIGNAL(clicked()), this, SLOT(findCurrentData()));
    connect(ui->FinalCsv, SIGNAL(clicked()), this, SLOT(findFinalData()));

    // Connect the gotDataFile signal to the display manager
    connect(this, SIGNAL(gotDataFile(string,eDataType)), &renderer, SLOT(updateFile(string,eDataType)));

    // Make the combo box populate when the DDIMatrix changes
    connect(&renderer, SIGNAL(ddiDataAdded(list<string>,list<string>)),
            this, SLOT(updateDDI(list<string>,list<string>)));
    connect(ui->PrimKey, SIGNAL(activated(int)), this, SLOT(populateCBox(int)));

    // Set off the event chain when the Add Graph button is clicked
    connect(ui->Add, SIGNAL(clicked()), this, SLOT(prepareChartAdd()));
    connect(this, SIGNAL(chartAddRequest(string,bool)), &renderer, SLOT(chartAdd(string, bool)));
    connect(&renderer, SIGNAL(requestRedraw()), ui->Render, SLOT(chartAdded()));

    // Make the display manager resize its contents when the window resizes
    connect(ui->Render, SIGNAL(resized(int,int)), &renderer, SLOT(renderAreaResized(int,int)));

    // Make the display manager report what files it has
    connect(&renderer, SIGNAL(updateStatusLine(QString)), ui->statusBar, SLOT(showMessage(QString)));

    // Allow display manager to handle mouse actions within the render area
    connect(ui->Render, SIGNAL(mouseMoved(int,int)), &renderer, SLOT(handleMouseMove(int,int)));
    connect(ui->Render, SIGNAL(mouseClicked()), &renderer, SLOT(handleClick()));

    ////////////// END EVENT BINDING //////////////////

    // Set the display manager on the render widget
    ui->Render->setDisplayManager(&renderer);
}
예제 #8
0
ItemButton::ItemButton(QString nTitle, QString nDescription, QString nPrice, QIcon nIcon, int slot, QWidget *parent) : QAbstractButton(parent) {
	setText(nTitle);
	description = nDescription;
	price = nPrice;
	setIcon(nIcon);
	this->slot = slot;

	setContentsMargins(13, 13, 13, 13);
	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
	setMinimumHeight(getMinSize());

	connect(this, SIGNAL(clicked()), this, SLOT(handleClick()));
}
예제 #9
0
void HTMLAnchorElement::defaultEventHandler(Event* event)
{
    if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) {
        event->setDefaultHandled();
        dispatchSimulatedClick(event);
        return;
    }

    if (isLinkClick(event) && isLiveLink()) {
        handleClick(event);
        return;
    }
}
예제 #10
0
ItemButton::ItemButton(QWidget *parent) : QAbstractButton(parent) {
	description = "";
	price = "";
	slot = 0;

	setContentsMargins(9, 9, 9, 9);
	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);


	setMinimumHeight(getMinSize());

	connect(this, SIGNAL(clicked()), this, SLOT(handleClick()));
}
int CardWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: handleClick((*reinterpret_cast< CardWidget*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
예제 #12
0
파일: MainMenu.cpp 프로젝트: SMemsky/pang
MainMenu::MenuResult MainMenu::show(sf::RenderWindow& window)
{
	sf::Texture image;
	if (!image.loadFromFile("res/mainmenu.png"))
	{
		return Nothing;
	}
	sf::Sprite sprite(image);

	MenuItem playButton;
	playButton.rect.top = 145;
	playButton.rect.left = 0;
	playButton.rect.width = 1023;
	playButton.rect.height = 235;
	playButton.action = Play;

	MenuItem exitButton;
	exitButton.rect.top = 383;
	exitButton.rect.left = 0;
	exitButton.rect.width = 1023;
	exitButton.rect.height = 235;
	exitButton.action = Exit;

	m_menuItems.push_back(playButton);
	m_menuItems.push_back(exitButton);

	window.draw(sprite);
	window.display();

	while (true)
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::MouseButtonPressed)
			{
				return handleClick(event.mouseButton.x, event.mouseButton.y);
			}
			else if (event.type == sf::Event::Closed)
			{
				return Exit;
			}
		}

		// Redraw menu sprite on every frame
		window.draw(sprite);
		window.display();
	}
}
예제 #13
0
static void handleScreenEvent(bps_event_t *event) {
	int screen_val, buttons;
	int pair[2];

	static bool mouse_pressed = false;

	screen_event_t screen_event = screen_event_get_event(event);

	//Query type of screen event and its location on the screen
	screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE,
			&screen_val);
	screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION,
			pair);

	//There is a difference between touch screen events and mouse events
	if (screen_val == SCREEN_EVENT_MTOUCH_RELEASE) {
		//Handle touch screen event
		handleClick(pair[0], pair[1]);

	} else if (screen_val == SCREEN_EVENT_POINTER) {
		//This is a mouse move event, it is applicable to a device with a usb mouse or simulator
		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS,
				&buttons);

		if (buttons == SCREEN_LEFT_MOUSE_BUTTON) {
			//Left mouse button is pressed
			mouse_pressed = true;
		} else {
			if (mouse_pressed) {
				//Left mouse button was released, handle left click
				handleClick(pair[0], pair[1]);
				mouse_pressed = false;
			}
		}
	}
}
예제 #14
0
ConfigureInput::ConfigureInput(QWidget* parent)
    : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()) {

    ui->setupUi(this);

    // Initialize mapping of input enum to UI button.
    input_mapping = {
        {Settings::NativeInput::Values::A, ui->buttonA},
        {Settings::NativeInput::Values::B, ui->buttonB},
        {Settings::NativeInput::Values::X, ui->buttonX},
        {Settings::NativeInput::Values::Y, ui->buttonY},
        {Settings::NativeInput::Values::L, ui->buttonL},
        {Settings::NativeInput::Values::R, ui->buttonR},
        {Settings::NativeInput::Values::ZL, ui->buttonZL},
        {Settings::NativeInput::Values::ZR, ui->buttonZR},
        {Settings::NativeInput::Values::START, ui->buttonStart},
        {Settings::NativeInput::Values::SELECT, ui->buttonSelect},
        {Settings::NativeInput::Values::HOME, ui->buttonHome},
        {Settings::NativeInput::Values::DUP, ui->buttonDpadUp},
        {Settings::NativeInput::Values::DDOWN, ui->buttonDpadDown},
        {Settings::NativeInput::Values::DLEFT, ui->buttonDpadLeft},
        {Settings::NativeInput::Values::DRIGHT, ui->buttonDpadRight},
        {Settings::NativeInput::Values::CUP, ui->buttonCStickUp},
        {Settings::NativeInput::Values::CDOWN, ui->buttonCStickDown},
        {Settings::NativeInput::Values::CLEFT, ui->buttonCStickLeft},
        {Settings::NativeInput::Values::CRIGHT, ui->buttonCStickRight},
        {Settings::NativeInput::Values::CIRCLE_UP, ui->buttonCircleUp},
        {Settings::NativeInput::Values::CIRCLE_DOWN, ui->buttonCircleDown},
        {Settings::NativeInput::Values::CIRCLE_LEFT, ui->buttonCircleLeft},
        {Settings::NativeInput::Values::CIRCLE_RIGHT, ui->buttonCircleRight},
        {Settings::NativeInput::Values::CIRCLE_MODIFIER, ui->buttonCircleMod},
    };

    // Attach handle click method to each button click.
    for (const auto& entry : input_mapping) {
        connect(entry.second, SIGNAL(released()), this, SLOT(handleClick()));
    }
    connect(ui->buttonRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));
    setFocusPolicy(Qt::ClickFocus);
    timer = new QTimer(this);
    timer->setSingleShot(true);
    connect(timer, &QTimer::timeout, this, [&]() {
        key_pressed = Qt::Key_Escape;
        setKey();
    });
    this->setConfiguration();
}
예제 #15
0
파일: MainMenu.cpp 프로젝트: geecode/Spades
    MainMenu::MenuResult MainMenu::menuResponse( sf::RenderWindow &window )
    {
        sf::Event menuEvent;

        while( true )
        {
            while ( window.pollEvent( menuEvent ) )
            {
                if ( menuEvent.type == sf::Event::MouseButtonPressed )
                {
                    return handleClick( menuEvent.mouseButton.x, menuEvent.mouseButton.y );
                }
            
                if ( menuEvent.type == sf::Event::Closed )
                {
                    return EXIT;
                }
            }
        }
    }
예제 #16
0
파일: chatscene.cpp 프로젝트: hades/quassel
void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
  if(event->button() == Qt::LeftButton && _leftButtonPressed) {
    _leftButtonPressed = false;
    if(_clickMode != NoClick) {
      if(_clickMode == SingleClick)
        clearSelection();
      event->accept();
      if(!_clickTimer.isActive())
        handleClick(Qt::LeftButton, _clickPos);
    } else {
      // no click -> drag or selection move
      if(isGloballySelecting()) {
        selectionToClipboard(QClipboard::Selection);
        _isSelecting = false;
        event->accept();
        return;
      }
    }
  }
  QGraphicsScene::mouseReleaseEvent(event);
}
예제 #17
0
파일: chatscene.cpp 프로젝트: hades/quassel
void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
  if(event->buttons() == Qt::LeftButton) {
    if(!_clickHandled && (event->scenePos() - _clickPos).toPoint().manhattanLength() >= QApplication::startDragDistance()) {
      if(_clickTimer.isActive())
        _clickTimer.stop();
      if(_clickMode == SingleClick && isPosOverSelection(_clickPos))
        initiateDrag(event->widget());
      else {
        _clickMode = DragStartClick;
        handleClick(Qt::LeftButton, _clickPos);
      }
      _clickMode = NoClick;
    }
    if(_isSelecting) {
      updateSelection(event->scenePos());
      emit mouseMoveWhileSelecting(event->scenePos());
      event->accept();
    } else if(_clickHandled && _clickMode < DoubleClick)
      QGraphicsScene::mouseMoveEvent(event);
  } else
    QGraphicsScene::mouseMoveEvent(event);
}
예제 #18
0
void RunManager::pressButton(int x, int y, sf::Sprite *button, string key, sf::Text *text) {
    bool *keyPointer = &buttonMap.at(key);
    // If the button contains the mouse position, handles the click accordingly.
    if (button->getGlobalBounds().contains(x, y)) {
        handleClick(key);
        // If a cipher button is clicked, this will unhighlight all other cipher buttons.
        unhighlightButtons(cipherType);
    }
    else {
        // If no button was clicked, but a random space was, the encryptfileselector will be unselected, assuming it was selected in the first place.
        if (button == &encryptFileSelector && typing == 1) {
            typing = 0;
            encryptFileSelector.setColor(sf::Color(255, 255, 255));
            encryptFileLocationText.setColor(sf::Color(0, 0, 0));
        }
        // Same but for decryption.
        if (button == &decryptFileSelector && typing == 2) {
            typing = 0;
            decryptFileSelector.setColor(sf::Color(255, 255, 255));
            decryptFileLocationText.setColor(sf::Color(0, 0, 0));
        }
    }
    
}
예제 #19
0
//mouse button event
void Application::onMouseButtonDown( SDL_MouseButtonEvent event )
{
    if(checkColor = handleClick(&colorSelector, mouse_position)) return;
    if(gs.tool == BUCKET) {
        fill(canvas, mouse_position, colorSelector.c);
        return;
    }
    if(!gs.dwg) {
        gs.dwg = -1;
        if(gs.tool == POLYGONAL || (gs.tool == FREEHAND || gs.tool == SHAPE))
        {
            curLLPos2 = LLPos2New();
            LLPos2Add(curLLPos2, mouse_position);
        }
    }
    else {
        switch(gs.tool) {
        case POLYGONAL:
        case SHAPE:
        case FREEHAND:
            LLPos2Add(curLLPos2, mouse_position);
            break;
        case LINE:
            gs.dwg = 0;
            drawLine(canvas, gs.lastMDown, mouse_position, colorSelector.c);
            break;
        case CIRCLE:
            gs.dwg = 0;
            drawCircle(canvas, gs.lastMDown, mouse_position.distTo(&gs.lastMDown),
                       colorSelector.c);
        default:
            ;
        }
    }
    gs.lastMDown = mouse_position;
}
예제 #20
0
파일: main.c 프로젝트: X123M3-256/LatinQuiz
int main ( int argc, char** argv )
{
      if(Load_Wordlist()==-1)
    {
     printf( "Unable to load wordlist\n");
    return 1;
    }
    // initialize SDL video
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }
    if (TTF_Init()==-1)
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }


    // make sure SDL cleans up before exit
    atexit(SDL_Quit);

    // create a new window
   screen = SDL_SetVideoMode(480, 640, 16,SDL_HWSURFACE|SDL_DOUBLEBUF);
    if ( !screen )
    {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        return 1;
    }

    // *******************************************Load Resources********************************************/
    //******************************************************************************************************/
    //****************************************That's right, resources***************************************/
    //******************************************************************************************************/
    option=IMG_Load("option.png");
    if (!option)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
      option2=IMG_Load("option2.png");
    if (!option)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
    background=IMG_Load("background.png");
    if (!background)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
   gamefont=TTF_OpenFont("Courier_New.ttf",25);
   gamefontsmall=TTF_OpenFont("Courier_New.ttf",16);
    if (gamefont==NULL||gamefontsmall==NULL)
    {
        printf("Unable to load font: %s\n", SDL_GetError());
        return 1;
    }
    // *************************************Initialising some vars********************************************/
    //********************************************************************************************************/
    cur_rect.w=200;
    cur_rect.h=80;
    cur_rect.x=(480-200)/2;
    cur_text_rect.h=20;
    screen_rect.w=480;
    screen_rect.h=640;
    screen_rect.x=0;
    screen_rect.y=0;
    int i;
    for(i=0;i<6;i++){options[i].text=NULL;}
    textColor.r=0;
    textColor.g=0;
    textColor.b=0;
    milliseconds=SDL_GetTicks();
    srand(time(NULL));
    //**************************************************Main loop LOL*******************************************/
    //**********************************************************************************************************/
    //****************************************************Here we go...*****************************************/
    //**********************************************************************************************************/
    displayMainMenu();

    //***********************************************************************************************************
    //********************************************Event processing***********************************************
    //***********************************************************************************************************

    while (!done)
    {
        // message processing loop
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = true;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
                {
                    // exit if ESCAPE is pressed
                    if (event.key.keysym.sym == SDLK_ESCAPE)
                        done = true;
                    break;
                }
            case SDL_MOUSEBUTTONDOWN:
            {
            handleClick(GetClickedOption(event.button.x,event.button.y));
            }
            } // end switch
        } // end of message processing
        //***************************************************************************************
        //*****************************Rendering*************************************************
        //***************************************************************************************
  // clear screengetline
        SDL_BlitSurface(background, 0, screen, &screen_rect);
        if(gamestate>=1&&gamestate<=3)
        {
        SDL_BlitSurface(questiontext,0,screen,&screen_rect);
        }
        int i;
        for(i=0;i<optnum;i++)
        {
        displayOption(options[i]);
        }

        //Run the physics
        runPhysics();
        // finally, update the screen :)
        SDL_Flip(screen);
    } // end main loop

    // free loaded bitmap
    SDL_FreeSurface(questiontext);
    SDL_FreeSurface(option2);
    SDL_FreeSurface(option);
    SDL_FreeSurface(background);
    TTF_CloseFont(gamefont);
    TTF_Quit();
    for(i=0;i<numwords;i++)
    {
    Free_Word(Words[i]);
    }
    free(Words);
    // all is well ;)
    printf("Exited cleanly\n");
    return 0;
    }
예제 #21
0
파일: chatscene.cpp 프로젝트: hades/quassel
void ChatScene::clickTimeout() {
  if(!_leftButtonPressed && _clickMode == SingleClick)
    handleClick(Qt::LeftButton, _clickPos);
}
예제 #22
0
ConfigureInput::ConfigureInput(QWidget* parent)
    : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()),
      timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) {

    ui->setupUi(this);
    setFocusPolicy(Qt::ClickFocus);

    button_map = {
        ui->buttonA,        ui->buttonB,        ui->buttonX,         ui->buttonY,  ui->buttonDpadUp,
        ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL,  ui->buttonR,
        ui->buttonStart,    ui->buttonSelect,   ui->buttonZL,        ui->buttonZR, ui->buttonHome,
    };

    analog_map_buttons = {{
        {
            ui->buttonCircleUp, ui->buttonCircleDown, ui->buttonCircleLeft, ui->buttonCircleRight,
            ui->buttonCircleMod,
        },
        {
            ui->buttonCStickUp, ui->buttonCStickDown, ui->buttonCStickLeft, ui->buttonCStickRight,
            nullptr,
        },
    }};

    analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog};

    for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
        if (button_map[button_id])
            connect(button_map[button_id], &QPushButton::released, [=]() {
                handleClick(
                    button_map[button_id],
                    [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; },
                    InputCommon::Polling::DeviceType::Button);
            });
    }

    for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
        for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
            if (analog_map_buttons[analog_id][sub_button_id] != nullptr) {
                connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released,
                        [=]() {
                            handleClick(analog_map_buttons[analog_id][sub_button_id],
                                        [=](const Common::ParamPackage& params) {
                                            SetAnalogButton(params, analogs_param[analog_id],
                                                            analog_sub_buttons[sub_button_id]);
                                        },
                                        InputCommon::Polling::DeviceType::Button);
                        });
            }
        }
        connect(analog_map_stick[analog_id], &QPushButton::released, [=]() {
            QMessageBox::information(
                this, "Information",
                "After pressing OK, first move your joystick horizontally, and then vertically.");
            handleClick(
                analog_map_stick[analog_id],
                [=](const Common::ParamPackage& params) { analogs_param[analog_id] = params; },
                InputCommon::Polling::DeviceType::Analog);
        });
    }

    connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });

    timeout_timer->setSingleShot(true);
    connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });

    connect(poll_timer.get(), &QTimer::timeout, [this]() {
        Common::ParamPackage params;
        for (auto& poller : device_pollers) {
            params = poller->GetNextInput();
            if (params.Has("engine")) {
                setPollingResult(params, false);
                return;
            }
        }
    });

    this->loadConfiguration();

    // TODO(wwylele): enable this when we actually emulate it
    ui->buttonHome->setEnabled(false);
}
예제 #23
0
void RegisterLabel::clicked(QMouseEvent *e, const QPoint &parentPos) {
   handleClick(e);
}
예제 #24
0
void PauseWindow::update()
{
    if ( bPromptToQuit || bPromptToAbort )
    {
        LogisticsOKDialog::instance()->update();
        if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::YES )
        {
            if ( bPromptToQuit )
                gos_TerminateApplication();
            else {
                //if (MPlayer) {
                //	MPlayer->leaveSession();
                //	}
                //else
                scenarioResult = mis_PLAYER_LOST_BIG;
                aborted = true;
            }

            bPromptToQuit = bPromptToAbort = 0;
        }
        else if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::NO )
        {
            if ( LogisticsOKDialog::instance()->isDone() )
                bPromptToQuit = bPromptToAbort = 0;
        }

    }

    long mouseX = userInput->getMouseX();
    long mouseY = userInput->getMouseY();

    gosEnum_KeyIndex key;
    bool bShift, bCtrl, bAlt;
    MissionInterfaceManager::instance()->getHotKey( OBJECTVIES_COMMAND_KEY, key, bShift, bCtrl, bAlt );


    // hack, mission gui message isn't getting here...
    if ( gos_GetKeyStatus( key ) != KEY_HELD
            && gos_GetKeyStatus( key ) == KEY_PRESSED )
    {
        buttons[OBJECTIVES].toggle(); // big big hack.
    }


    if ( currentTime != 0 )
    {
        currentTime += frameLength;
        float p0 = 0.f;
        float p1 = 0.f;
        float t0 = 0.f;
        float t1 = 0.f;
        // figure out position based on time
        for ( int j = 0; j < 7; j++ )
        {
            if ( moveInfo[j].time <= currentTime && moveInfo[j+1].time > currentTime )
            {
                t0 = moveInfo[j].time;
                t1 = moveInfo[j + 1].time;
                //p0 = -(800.f - moveInfo[j].position)  + ((float)Environment.screenWidth);
                //p1 = -(800.f - moveInfo[j + 1].position) + ((float)Environment.screenWidth);
                //magic 05032012 begin
                p0 = -(850.f - moveInfo[j].position)  + ((float)Environment.screenWidth);
                p1 = -(850.f - moveInfo[j + 1].position) + ((float)Environment.screenWidth);
                //magic 05032012 end
                break;
            }
        }
        if ( p1 )
        {
            float dT = currentTime - t0;
            float currentPosition = p0 + dT * ( (p1 - p0)/(t1 -t0) );
            float delta = currentPosition - currentPos;
            currentPos += delta;

            for ( int i = 0; i < buttonCount; i++ )
            {
                buttons[i].move( delta, 0 );
            }

            for ( i = 0; i < staticCount; i++ )
            {
                statics[i].move( delta, 0 );
            }


            for ( i = 0; i < 2; i++ )
            {
                float dif = backgrounds[i].right - backgrounds[i].left;
                backgrounds[i].left = .5 + currentPos;
                backgrounds[i].right = .5 + currentPos + dif;
            }
        }
    }



    for ( int i = 0; i < buttonCount; i++ )
    {
        if ( buttons[i].location[0].x <= mouseX && mouseX <= buttons[i].location[2].x
                && mouseY >= buttons[i].location[0].y && mouseY <= buttons[i].location[1].y  )
        {
            if ( buttons[i].isEnabled() )
            {
                helpTextHeaderID = buttonData[i].helpTextHeader;
                helpTextID = buttonData[i].helpTextID;

                long lastX = mouseX - userInput->getMouseXDelta();
                long lastY = mouseY - userInput->getMouseYDelta();

                if ( buttons[i].location[0].x >= lastX || lastX >= buttons[i].location[2].x
                        || lastY <= buttons[i].location[0].y || lastY >= buttons[i].location[1].y )
                {
                    soundSystem->playDigitalSample( LOG_HIGHLIGHTBUTTONS );
                }

                if ( buttons[i].state != ControlButton::PRESSED )
                    buttons[i].makeAmbiguous( true );
            }
            else
            {
                helpTextHeaderID = 0;
                helpTextID = 0;
                continue;
            }

            if ( userInput->leftMouseReleased() && !wasDragging )
            {
                {
                    handleClick( buttons[i].ID );
                }
            }
        }
        else if ( buttons[i].isEnabled() && buttons[i].state != ControlButton::PRESSED  )
            buttons[i].makeAmbiguous( 0 );
    }

    if ( currentTime == 0 )
    {
        currentTime = .0001f;
        currentPos = -(800 - PauseWindow::moveInfo[0].position) + ((float)Environment.screenWidth);
        float delta = backgrounds[0].left - currentPos;

        for ( int i = 0; i < buttonCount; i++ )
        {
            for ( int j = 0; j < 4; j++ )
            {
                buttons[i].location[j].x -= delta;
            }
        }

        for ( i = 0; i < staticCount; i++ )
        {
            for ( int j = 0; j < 4; j++ )
            {
                statics[i].location[j].x -= delta;
            }
        }


        for ( i = 0; i < 2; i++ )
        {
            float dif = backgrounds[i].right - backgrounds[i].left;
            backgrounds[i].left = .5 + currentPos;
            backgrounds[i].right = .5 + currentPos + dif;
        }


    }

    wasDragging = userInput->wasLeftDrag();

    const char * campaignName = LogisticsData::instance->getCampaignName().Data();
    char campName[1024];
    _splitpath(campaignName,NULL,NULL,campName,NULL);
    if ( MPlayer ||
            LogisticsData::instance->isSingleMission() ||
            (stricmp("tutorial",campName) == 0))
    {
        buttons[ SAVE ].disable( true );
        buttons[ LOAD ].disable( true );
    }
    if ( MPlayer )
    {
        buttons[OPTIONS].disable( true );
    }

}
예제 #25
0
void InfoWindow::update()
{
	if ( pUnit && ( pUnit->getTeamId() != Team::home->getId() &&
		( CONTACT_VISUAL != (pUnit->getContactStatus(Team::home->getId(), true)) 
		&& !pUnit->isDisabled() ) ) )
	{
		setUnit( 0 );
		return;
	}

	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();



	if ( icon )
		icon->update();

	for ( int i = 0; i < 2; i++ )
	{	
		if ( buttons[i].location[0].x <= mouseX && mouseX <= buttons[i].location[2].x
				&& mouseY >= buttons[i].location[0].y && mouseY <= buttons[i].location[1].y  )
		{
			if ( userInput->getMouseLeftButtonState() == MC2_MOUSE_DOWN && buttons[i].isEnabled() )
			{
				{
					handleClick( buttons[i].ID );
					return;
				}
			}
		}
	}

	if ( userInput->isLeftDrag() )
	{
		if ( lastYClick != -1.f )
		{
			int tmpLastY = mouseY; 
			tmpLastY -= userInput->getMouseDragY();
			setScrollPos( lastYClick + tmpLastY );
			return;
		}

	}	
	// see if its in the scroll bar area
	else if ( mouseX > SCROLLLEFT && mouseX < SCROLLRIGHT
				&& mouseY > SCROLLTOP && mouseY < SCROLLBOTTOM 
				&&  buttons[0].isEnabled() 
				&& userInput->getMouseDragX() > SCROLLLEFT && userInput->getMouseDragX() < SCROLLRIGHT
				&& userInput->getMouseDragY() > SCROLLTOP && userInput->getMouseDragY() < SCROLLBOTTOM 
				)
		{


		// if its in the thumbdrag thingie, save the y
			float physicalRange = buttons[1].location[0].y - buttons[0].location[2].y;
			float buttonHeight = SCROLLBUTTONHEIGHT;

			float RealRange = infoLength;

			buttonHeight =  physicalRange * physicalRange/(physicalRange + RealRange);

			if ( buttonHeight < SCROLLBUTTONHEIGHT )
				buttonHeight = SCROLLBUTTONHEIGHT;

			if ( mouseY > scrollPos + SCROLLMIN && mouseY < scrollPos + SCROLLMIN + buttonHeight )
			{
				lastYClick = scrollPos;
			}
			else if ( ( userInput->leftMouseReleased() || userInput->getMouseLeftHeld() > .5 ) )
			{
				lastYClick = -1;
				if ( mouseY > buttons[0].location[2].y 
					&& mouseY < buttons[1].location[0].y )
				{
			
					float newScrollPos = scrollPos;
					// if above the thumb, page up, otherwise page down
					if ( mouseY < SCROLLMIN + scrollPos )
					{
							newScrollPos = scrollPos - buttonHeight;
					}
					else if ( mouseY > SCROLLMIN + scrollPos + buttonHeight )
					{
							newScrollPos = scrollPos + buttonHeight;
					}

					if( newScrollPos < 0 )
							newScrollPos = 0;

					if( newScrollPos > infoLength )
						newScrollPos = infoLength;

					
					setScrollPos( newScrollPos );

				}

			}			
		}
		
		

		if ( userInput->leftMouseReleased() )
			lastYClick = -1;
		
}
예제 #26
0
파일: playground.cpp 프로젝트: geckoxx/yasg
void Playground::mouseReleaseEvent(QMouseEvent *me)
{
    handleClick(me->x(), me->y());
}
예제 #27
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    server(BUFSIZE + 1, this),
    client(BUFSIZE + 1, this)
{
    setMenuBar(new QMenuBar(this));
    QMenu *gameMenu = new QMenu("Game", menuBar());
    createAction = new QAction("Create", gameMenu);
    createAction->setIcon(QIcon(":/create.icns"));
    joinAction = new QAction("Join in", gameMenu);
    joinAction->setIcon(QIcon(":/join.icns"));
    abortAction = new QAction("Abort", gameMenu);
    abortAction->setIcon(QIcon(":/abort.icns"));
    menuBar()->addMenu(gameMenu);
    gameMenu->addAction(createAction);
    gameMenu->addAction(joinAction);
    gameMenu->addAction(abortAction);
    QToolBar *toolbar = new QToolBar(this);
    toolbar->setMovable(0);
    addToolBar(Qt::LeftToolBarArea, toolbar);
    toolbar->addAction(createAction);
    toolbar->addAction(joinAction);
    toolbar->addAction(abortAction);
    abortAction->setEnabled(0);

    setStatusBar(new QStatusBar(this));


    setCentralWidget(new QWidget(this));
    QHBoxLayout *mainLayout = new QHBoxLayout();
    centralWidget()->setLayout(mainLayout);

    chessBoard = new ChessBoard(centralWidget());
    mainLayout->addWidget(chessBoard);

    opp = new UserWidget(this);
    loc = new UserWidget(this);
    oppName = new QLabel(this);
    locName = new QLabel(this);
    QVBoxLayout *rightLayout = new QVBoxLayout();
    mainLayout->addLayout(rightLayout);

    rightLayout->addWidget(opp);
    rightLayout->addWidget(oppName);
    startButton = new QPushButton("Start", this);
    startButton->setEnabled(0);
    rightLayout->addWidget(startButton);
    tieButton = new QPushButton("Tie", this);
    tieButton->setEnabled(0);
    rightLayout->addWidget(tieButton);
    surButton = new QPushButton("Surrender", this);
    surButton->setEnabled(0);
    rightLayout->addWidget(surButton);
    rightLayout->addWidget(tieButton);

    number = new QLCDNumber(this);
    rightLayout->addWidget(number);
    rightLayout->addWidget(loc);
    rightLayout->addWidget(locName);
    tieTimer.setSingleShot(1);
    //TODO rightLayout for some information


    QObject::connect(createAction, SIGNAL(triggered()), this, SLOT(createGame()));
    QObject::connect(joinAction, SIGNAL(triggered()), this, SLOT(joinGame()));
    QObject::connect(abortAction, SIGNAL(triggered()), this, SLOT(abortLink()));
    QObject::connect(chessBoard, SIGNAL(clickPiece(QPair<int,int>)), this, SLOT(handleClick(QPair<int, int>)));
    QObject::connect(&server, SIGNAL(received(void*, int)), this, SLOT(handleReceive(void*, int)));
    QObject::connect(&server, SIGNAL(connected()), this, SLOT(handleConnected()));
    QObject::connect(&client, SIGNAL(received(void*,int)), this, SLOT(handleReceive(void*, int)));
    QObject::connect(startButton, SIGNAL(clicked()), this, SLOT(startGame()));
    QObject::connect(&tieTimer, SIGNAL(timeout()), this, SLOT(enableTie()));
    QObject::connect(tieButton, SIGNAL(clicked()), this, SLOT(handleTie()));
    QObject::connect(surButton, SIGNAL(clicked()), this, SLOT(abortLink()));
    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(timeOut()));
}