BOOL OnApply() { servMgr->guiSimpleChannelList = getButtonState(m_hWnd, IDC_SIMPLE_CHANNELLIST); servMgr->guiSimpleConnectionList = getButtonState(m_hWnd, IDC_SIMPLE_CONNECTIONLIST); servMgr->guiTopMost = getButtonState(m_hWnd, IDC_TOPMOST); servMgr->guiMinimizeStore = getButtonState(m_hWnd, IDC_MINIMIZE_STORE); GetDlgItemText(IDC_EDIT_PLAYER, servMgr->PlayerPath.cstr(), String::MAX_LEN); return TRUE; }
uint8_t getReset(void){ if(getButtonState(&button1)+getButtonState(&button2)){ if((getPressDuration(&button1)>RESET_TIME)&&(getPressDuration(&button2)>RESET_TIME)){ return 1; }else{ return 0; } } return 0; }
void StateBasic::automaticCoils() { ///// Right Flipper if (getButtonState("right_flipper")){ setCoilState("right_flipper", COIL_ON); } else{ setCoilState("right_flipper", COIL_OFF); } ///// Left Flipper if (getButtonState("left_flipper")){ setCoilState("left_flipper", COIL_ON); } else{ setCoilState("left_flipper", COIL_OFF); } ///// Jets if (getButtonState("left_jet")){ fireCoil("left_jet"); } if (getButtonState("right_jet")){ fireCoil("right_jet"); } if (getButtonState("bottom_jet")){ fireCoil("bottom_jet"); } ///// Slingshots if (getButtonState("left_slingshot")){ fireCoil("left_slingshot"); } if (getButtonState("right_slingshot")){ fireCoil("right_slingshot"); } ///// Outhole if (getButtonState("outhole")){ //fireCoilDelay("outhole_kicker", 2000); fireCoil("outhole_kicker"); } if (getButtonState("credit_button")){ fireCoil("ball_shooter_lane_feeder"); } if (getButtonState("ball_popper")){ fireCoil("ball_popper"); } }
void CalibrationCheckTool::frame(void) { if(getButtonState(0)) { /* Get the interaction point: */ haveDepthPoint=false; Vrui::Point p(application->calcImagePoint(getButtonDeviceRay(0)).getComponents()); if(p[0]>=-640.0&&p[0]<0.0&&p[1]>=0.0&&p[1]<480.0) { int px=int(Math::floor(p[0]+640.0)); int py=int(Math::floor(p[1])); if(application->averageFrameForeground[py*640+px]>=float(application->averageNumFrames)*0.5f) { /* Remember the depth point: */ depthPoint=Point2(double(px)+0.5-640.0,double(py)+0.5); /* Calculate the color point: */ double depth=application->depthCorrection[py*640+px].correct(application->averageFrameDepth[py*640+px]/application->averageFrameForeground[py*640+px]); int cx=int(Math::floor(depthToColor[(479-py)*640+px][0]+dtcOffset+dtcScale*depth)); int cy=479-int(Math::floor(depthToColor[(479-py)*640+px][1]))-rowOffset; colorPoint[0]=double(cx)+0.5; colorPoint[1]=double(cy)+0.5; haveDepthPoint=true; } } } }
void moveTitleMenu() { int pad = getPadState(); int btn = getButtonState(); int p = -1; int sm; if ( pad & PAD_DOWN ) { p = 2; } else if ( pad & PAD_UP ) { p = 0; } else if ( pad & PAD_RIGHT ) { p = 1; } else if ( pad & PAD_LEFT ) { p = 3; } else if ( btn == 0 ) { mnp = 1; } if ( mnp && p >= 0 ) { mnp = 0; sm = stgMv[slcStg][p]; slcStg += sm; if ( sm != 0 ) { initTitleStage(slcStg); } titleCnt = 16; } if ( mnp && (btn & PAD_BUTTON1) ) { if ( slcStg == STAGE_NUM+ENDLESS_STAGE_NUM ) { quitLast(); return; } hiScore.stage = slcStg; initGame(slcStg); } titleCnt++; }
void RevolverTool::buttonCallback(int buttonSlotIndex,InputDevice::ButtonCallbackData* cbData) { if(buttonSlotIndex==0) { if(cbData->newButtonState) { /* Change the currently mapped button set: */ currentChamber=(currentChamber+1)%factory->numChambers; /* Set the newly mapped chamber's state to the input device's buttons' and valuators' states: */ for(int i=1;i<input.getNumButtonSlots();++i) transformedDevice->setButtonState((i-1)*factory->numChambers+currentChamber,getButtonState(i)); for(int i=0;i<input.getNumValuatorSlots();++i) transformedDevice->setValuator(i*factory->numChambers+currentChamber,getValuatorState(i)); /* Show the current button assignment for one second: */ showNumbersTime=getApplicationTime()+1.0; } } else { /* Pass the button event through to the virtual input device: */ transformedDevice->setButtonState((buttonSlotIndex-1)*factory->numChambers+currentChamber,cbData->newButtonState); } }
void Button::modifyButtonState() { if(isDoingKeyAction) { return; } if(isToggleButton() && toggled) { if(getButtonState() != CLICKED) { changeButtonState(CLICKED); } return; } if(mouseIsDown && mouseIsInside) { changeButtonState(CLICKED); } else if(mouseIsDown && !mouseIsInside) { changeButtonState(getMouseLeaveState()); } else if(!mouseIsDown && mouseIsInside) { changeButtonState(HOVERED); } else { changeButtonState(DEFAULT); } }
void GTextButton::onRender() { Vec2i const& pos = getWorldPos(); Vec2i const& size = getSize(); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); if( isEnable() ) { if( getButtonState() == BS_HIGHLIGHT ) glColor3f(0.0, 0.5, 0.0); else glColor3f(0.0, 0.25, 0.0); } else { glColor3f(0.05, 0.05, 0.05); } drawRect( pos , size ); if( isEnable() ) { if( getButtonState() == BS_HIGHLIGHT ) glColor3f(0.0, 1.0, 0.0); else glColor3f(0.0, 0.5, 0.0); } else { glColor3f(0.1, 0.1, 0.1); } drawRectLine( pos , size ); glColor3f(1.0, 1.0, 1.0); glDisable(GL_BLEND); if( isEnable() ) text->setColor(Color(50,255,50)); else text->setColor(Color(150,150,150)); getRenderSystem()->drawText( text , pos + size / 2 ); }
mir::EventUPtr mia::Lexicon::translate(droidinput::InputEvent const* android_event) { switch(android_event->getType()) { case AINPUT_EVENT_TYPE_KEY: { auto kev = static_cast<const droidinput::KeyEvent*>(android_event); return mev::make_event(MirInputDeviceId(android_event->getDeviceId()), kev->getEventTime(), kev->getMac(), mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()), kev->getKeyCode(), kev->getScanCode(), mia::mir_modifiers_from_android(kev->getMetaState())); } case AINPUT_EVENT_TYPE_MOTION: { if (mia::android_source_id_is_pointer_device(android_event->getSource())) { auto mev = static_cast<const droidinput::MotionEvent*>(android_event); return mev::make_event(MirInputDeviceId(android_event->getDeviceId()), mev->getEventTime(), mev->getMac(), mia::mir_modifiers_from_android(mev->getMetaState()), mia::mir_pointer_action_from_masked_android(mev->getAction() & AMOTION_EVENT_ACTION_MASK), mia::mir_pointer_buttons_from_android(mev->getButtonState()), mev->getX(0), mev->getY(0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_HSCROLL, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_VSCROLL, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_RX, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_RY, 0)); } else { auto mev = static_cast<const droidinput::MotionEvent*>(android_event); auto ev = mev::make_event(MirInputDeviceId(android_event->getDeviceId()), mev->getEventTime(), mev->getMac(), mia::mir_modifiers_from_android(mev->getMetaState())); auto action = mev->getAction(); size_t index_with_action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; auto masked_action = action & AMOTION_EVENT_ACTION_MASK; for (unsigned i = 0; i < mev->getPointerCount(); i++) { auto action = (i == index_with_action) ? mia::mir_touch_action_from_masked_android(masked_action) : mir_touch_action_change; mev::add_touch(*ev, mev->getPointerId(i), action, mia::mir_tool_type_from_android(mev->getToolType(i)), mev->getX(i), mev->getY(i), mev->getPressure(i), mev->getTouchMajor(i), mev->getTouchMinor(i), mev->getSize(i)); } return ev; } } default: BOOST_THROW_EXCEPTION(std::logic_error("Invalid android event")); } }
void Button::paintBackground( const PaintEvent &paintEvent ) { Color color = getBackColor(); switch (getButtonState()) { case HOVERED: color = Color((float)(color.getR() + 0.075f), (float)(color.getG() + 0.075f), (float)(color.getB() + 0.075f), (float)(color.getA() )); break; case CLICKED: color = Color((float)(color.getR() - 0.075f), (float)(color.getG() - 0.075f), (float)(color.getB() - 0.075f), (float)(color.getA() )); break; default: break; } paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),color); Color shadow = Color( color.getR() - 0.2f, color.getG() - 0.2f, color.getB() - 0.2f); Color highlight = Color( color.getR() + 0.2f, color.getG() + 0.2f, color.getB() + 0.2f); //top paintEvent.graphics()->drawLine(Point(0,1), Point(getSize().getWidth(),1),highlight); //left paintEvent.graphics()->drawLine(Point(1,1), Point(1,getSize().getHeight()),highlight); //bottom paintEvent.graphics()->drawLine(Point(0,getSize().getHeight() ), Point(getSize().getWidth(),getSize().getHeight() ),shadow); //right paintEvent.graphics()->drawLine(Point(getSize().getWidth() ,1), Point(getSize().getWidth() ,getSize().getHeight()),shadow); //bottom paintEvent.graphics()->drawLine(Point(0,getSize().getHeight() - 1 ), Point(getSize().getWidth(),getSize().getHeight() - 1 ),shadow); //right paintEvent.graphics()->drawLine(Point(getSize().getWidth() - 1,0), Point(getSize().getWidth() - 1 ,getSize().getHeight()),shadow); }
void moveStageClear() { int btn = getButtonState(); if ( scCnt > 900 || (scCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) { setHiScore(); initTitle(); return; } if ( btn == 0 ) { mnp = 1; } scCnt++; }
void moveGameover() { int btn = getButtonState(); if ( goCnt > 900 || (goCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) { setHiScore(); initTitle(); return; } if ( btn == 0 ) { mnp = 1; } goCnt++; }
/** * @brief Generate a string that represents slots that will be activated or * slots that are currently active if a button is pressed * @return String of currently applicable slots for a button */ QString JoyControlStickButton::getActiveZoneSummary() { QList<JoyButtonSlot*> tempList; JoyControlStickModifierButton *tempButton = stick->getModifierButton(); if (tempButton && tempButton->getButtonState() && getButtonState()) { QList<JoyButtonSlot*> activeModifierSlots = tempButton->getActiveZoneList(); tempList.append(activeModifierSlots); } tempList.append(getActiveZoneList()); QString temp = buildActiveZoneSummary(tempList); return temp; }
void GImageButton::onRenderSiblingsEnd() { if( getButtonState() == BS_HIGHLIGHT && mHelpText ) { Vec2f sizeHelp = mHelpText->getBoundSize() + 2 * Vec2f( 4 , 4 ); Vec2f posHelp = getGame()->getMousePos(); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glColor4f(0.0, 0.25, 0.0 , 0.4 ); drawRect( posHelp , sizeHelp ); glDisable(GL_BLEND); getRenderSystem()->drawText( mHelpText , posHelp + sizeHelp / 2 ); } }
void moveGameover() { int btn = getButtonState(); //senquack : make it so you can press either button 1 *or* 2 *or* the exit mapping to get back to main menu quicker // if ( goCnt > 900 || (goCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) { if ( goCnt > 900 || (goCnt > 128 && mnp && ((btn & PAD_BUTTON1) || (btn & PAD_BUTTON2) || control_state[ext_to_int_map[settings.map.exit]]))) { setHiScore(0); initTitle(); return; } if ( btn == 0 ) { mnp = 1; } goCnt++; }
/** GUI to get the player moves */ static uint8_t _getPlayerMove(NinjaState * state, NinjaPacket * packet) { uint32_t endTime = rtMillis() + 20000; while (1) { display.clearDisplay(); drawBitmapFlash(state->punch, 8, 0); drawBitmapFlash(state->kick, 48, 0); drawBitmapFlash(state->shield, 88, 0); drawBitmapFlash(state->right, 8, 32); drawBitmapFlash(state->down, 48, 32); drawBitmapFlash(state->up, 88, 32); //Time left display.setCursor(0, 0); display.print((endTime - rtMillis()) / 1000); safeDisplay(); uint8_t button = getButtonState(); if ((button & BUTTON_RIGHT) > 0) { clearButtonState(); return MOVE_PUNCH; } else if ((button & BUTTON_DOWN) > 0) { clearButtonState(); return MOVE_KICK; } else if ((button & BUTTON_UP) > 0) { clearButtonState(); return MOVE_SHIELD; } #ifdef MASTER else if ((button & BUTTON_ENTER) > 0) { clearButtonState(); return MOVE_TROLL; } #endif deepSleep(200); tick(); _handlePackets(state, packet); //If they're too slow, don't move if (endTime < rtMillis()) { return MOVE_NONE; } } }
void EVShield::waitForButtonPress(uint8_t btn, uint8_t led_pattern) { while(!getButtonState(btn)){ switch (led_pattern) { case 1: ledBreathingPattern(); break; case 2: ledHeartBeatPattern(); break; default: delay (300); break; } } if (led_pattern != 0) ledSetRGB(0,0,0); }
// moving about bool EditIsoView::eventDragBy(const AGEvent *event,const AGPoint &pDiff) { if(!mEditing) return CompleteIsoView::eventDragBy(event,pDiff); const AGSDLEvent *e=reinterpret_cast<const AGSDLEvent*>(event); if(e) { if(getButtonState()==SDL_BUTTON(SDL_BUTTON_MIDDLE)) { mPos=Pos3D(mPos.x-pDiff.x,mPos.y+pDiff.y,mPos.z); shallUpdate=true; // delay update til drawing - as this may be called several times a frame return true; } } return false; }
void WebDB::setButtonState(uint _id, char val) { if (_id < getDBButtonMaxRecords()) { recordButton = &m_button; getButtonState(_id); contador = 0; recordButton->state = val; for( int j = getDBButtonStart() + (sizeof(DBButtonRecord) * _id); j < getDBButtonStart() + ((sizeof(DBButtonRecord) * _id) + sizeof(DBButtonRecord)); j++) { EEPROM.write(j, ((uchar*)recordButton)[contador]); contador++; } } }
QString JoyControlStickButton::getCalculatedActiveZoneSummary() { JoyControlStickModifierButton *tempButton = stick->getModifierButton(); QString temp; QStringList stringlist; if (tempButton && tempButton->getButtonState() && tempButton->hasActiveSlots() && getButtonState()) { stringlist.append(tempButton->getCalculatedActiveZoneSummary()); } stringlist.append(JoyButton::getCalculatedActiveZoneSummary()); temp = stringlist.join(", "); return temp; }
void moveBossScoreAtr() { int btn = getButtonState(); if ( bsCnt == 128 ) addScore(bsAdd); if ( bsCnt > 600 || (bsCnt > 160 && mnp && (btn & PAD_BUTTON1)) ) { if ( status != STAGE_CLEAR ) { gotoNextScene(); } else { setHiScore(1); initTitle(); } return; } if ( btn == 0 ) { mnp = 1; } bsCnt++; }
static void recordMouseEvent(void) { int state= getButtonState(); sqMouseEvent *evt= allocateMouseEvent(); evt->x= mousePosition.x; evt->y= mousePosition.y; evt->buttons= (state & 0x7); evt->modifiers= (state >> 3); evt->nrClicks= evt->windowIndex= 0; signalInputEvent(); #if DEBUG_MOUSE_EVENTS printf("EVENT: mouse (%d,%d)", mousePosition.x, mousePosition.y); printModifiers(state >> 3); printButtons(state & 7); printf("\n"); #endif }
static void recordDragEvent(int dragType, int numFiles) { int state= getButtonState(); sqDragDropFilesEvent *evt= allocateDragEvent(); evt->dragType= dragType; evt->x= mousePosition.x; evt->y= mousePosition.y; evt->modifiers= (state >> 3); evt->numFiles= numFiles; evt->windowIndex= 0; signalInputEvent(); #if DEBUG_EVENTS printf("EVENT: drag (%d,%d)", mousePosition.x, mousePosition.y); printModifiers(state >> 3); printButtons(state & 7); printf("\n"); #endif }
void GImageButton::onRender() { if( getButtonState() == BS_HIGHLIGHT ) glColor3f(0.25, 0.25, 0.25); else glColor3f(1.0, 1.0, 1.0); Vec2f pos; pos.x = getWorldPos().x; pos.y = getWorldPos().y; Vec2f size; size.x = getSize().x; size.y = getSize().y; drawSprite( pos , size ,texImag ); glColor3f(1.0, 1.0, 1.0); }
void BluetoothController::process() { if(Serial2.available()) { // data received from smartphone delay(2); cmd[0] = Serial2.read(); if(cmd[0] == STX) { int i=1; while(Serial2.available()) { delay(1); cmd[i] = Serial2.read(); if(cmd[i]>127 || i>7) break; // Communication error if((cmd[i]==ETX) && (i==2 || i==7)) break; // Button or Joystick data i++; } if (i==2) getButtonState(cmd[1]); // 3 Bytes ex: < STX "C" ETX > else if(i==7) getJoystickState(cmd); // 6 Bytes ex: < STX "200" "180" ETX > } } sendBlueToothData(); while(Serial2.available()) Serial2.read(); // empty RX buffer }
void Joystick::main() { if(Serial.available()) { // data received from smartphone delay(2); // <<mod XXXXXXXX cmd[0] = Serial.read(); if(cmd[0] == STX) { i=1; while(Serial.available()) { delay(1); // <<mod XXXXXXXX cmd[i] = Serial.read(); if(cmd[i]>127 || i>5) break; // Communication error << XXX Mod if((cmd[i]==ETX) && ((i==2 && cmd[1]>2) || i==5)) break; // Button or Joystick data i++; } if (i==2 && cmd[1]>48 && cmd[1]<68) getButtonState(cmd[1]); // 3 Bytes else if(i==5 && cmd[1]<3 && cmd[3]<3 ) getJoystickState(cmd); // 6 Bytes } } sendBlueToothData(); // <<mod XXXXXXXX // delay(5); // <<mod XXXXXXXX // your code here }
// ---------------------------------Bluetooth reading // void BluetoothRobot::readBluetooth(){ byte cmd[8]; if(mySerial.available()) { // data received from smartphone delay(2); cmd[0] = mySerial.read(); if(cmd[0] == STX) { int i=1; while(mySerial.available()) { delay(1); cmd[i] = mySerial.read(); if(cmd[i]>127 || i>7) break; // Communication error if((cmd[i]==ETX) && (i==2 || i==7)) break; // Button or Joystick data i++; } if (i==2) getButtonState(cmd[1]); // 3 Bytes ex: < STX "C" ETX > else if(i==7) _getJoystickState(cmd); // 6 Bytes ex: < STX "200" "180" ETX > } } }
bool CompleteIsoView::eventDragBy(const AGEvent *event,const AGPoint &pDiff) { const AGSDLEvent *e=reinterpret_cast<const AGSDLEvent*>(event); if(e) { if(getButtonState()==SDL_BUTTON(SDL_BUTTON_RIGHT)) { mPos=Pos3D(mPos.x-pDiff.x,mPos.y+pDiff.y,mPos.z); if(mPos.x<0) mPos.x=0; if(mPos.y<0) mPos.y=0; if(mPos.x>maxPos.x) mPos.x=maxPos.x; if(mPos.y>maxPos.y) mPos.y=maxPos.y; //update();//checkView(); shallUpdate=true; // delay update til drawing - as this may be called several times a frame return true; } } return false; }
static sqInt display_ioGetButtonState(void) { ioProcessEvents(); /* process all pending events */ return getButtonState(); }
void moveTitleMenu() { int pad = getPadState(); int btn = getButtonState(); int bs = slcStg; if ( pad & PAD_DOWN ) { if ( mnp ) { if ( slcStg < STAGE_NUM-SAME_RANK_STAGE_NUM ) slcStg += SAME_RANK_STAGE_NUM; else if ( slcStg == QUIT_STAGE_NUM ) slcStg = -MODE_NUM; else slcStg = QUIT_STAGE_NUM; } } else if ( pad & PAD_UP ) { if ( mnp ) { if ( slcStg >= 0 ) slcStg -= SAME_RANK_STAGE_NUM; else slcStg = QUIT_STAGE_NUM ; } } else if ( pad & PAD_RIGHT ) { if ( mnp ) { if ( slcStg >= 0 ) { if ( (slcStg%SAME_RANK_STAGE_NUM) < SAME_RANK_STAGE_NUM-1 && slcStg != QUIT_STAGE_NUM ) { slcStg++; } } else if ( slcStg < -1 ) { slcStg++; } } } else if ( pad & PAD_LEFT ) { if ( mnp ) { if ( slcStg >= 0 ) { if ( (slcStg%SAME_RANK_STAGE_NUM) > 0 && slcStg != QUIT_STAGE_NUM ) { slcStg--; } } else if ( slcStg > -4 ) { slcStg--; } } } else if ( btn == 0 ) { mnp = 1; } if ( slcStg != bs ) { mnp = 0; initTitleStage(slcStg); titleCnt = 0; } if ( mnp && (btn & PAD_BUTTON1) ) { if ( slcStg == QUIT_STAGE_NUM ) { quitLast(); } else if ( slcStg < 0 ) { mnp = 0; setMode(MODE_NUM+slcStg); } else { hiScore.stage = slcStg; initGame(slcStg); } } if ( mnp && (btn & PAD_BUTTON2) ) { mnp = 0; setMode((mode+1)%MODE_NUM); initTitleStage(slcStg); titleCnt = 0; } titleCnt++; }