void GamePadManager::setButtons() { unsigned char buttons = getButtons(); if (Joystick::isConnected(0)) { gamepad = true; nbrButtons = getButtons(); if (buttons >= 12) { this->buttons[0] = 0; this->buttons[1] = 1; this->buttons[2] = 8; this->buttons[3] = 9; } else if (buttons < 12 && buttons > 3) { this->buttons[0] = 1; this->buttons[1] = 2; this->buttons[2] = 3; this->buttons[3] = 0; } else if (buttons < 4) { std::cout << "Your controller is not compatible. It has buttons " << to_string(buttons) << "." << std::endl; gamepadIgnored = true; gamepad = false; gamepadConnected = false; } } else { std::cout << "No controller detected." << std::endl; gamepad = false; gamepadConnected = false; } keys[0] = Keyboard::LControl; keys[1] = Keyboard::LShift; keys[2] = Keyboard::Space; keys[3] = Keyboard::Return; }
uint8_t Control::getDeltaButtons() { static uint8_t res = 0; static uint8_t last = getButtons(); if(updateDeltaButtons) { updateDeltaButtons = false; uint8_t current = getButtons(); res = last & ~current; last = current; } return res; }
void buttonClear() { // Initialize with state of buttons instead of zero. That prevents false // press events at program start ButtonLedInstance.curButtonsS = getButtons(); ButtonLedInstance.curButtonsE = ButtonLedInstance.curButtonsS; }
DrugStorageManagement::DrugStorageManagement(QWidget *parent) : FTabWidget(parent) { initUI(); getButtons().at(0)->click(); }
Selection show(const char *message, const char *title, Style style, Buttons buttons) { UINT flags = MB_TASKMODAL; flags |= getIcon(style); flags |= getButtons(buttons); return getSelection(MessageBoxW(nullptr, (wchar_t*)utf8_to_utf16(message).c_str(), (wchar_t*)utf8_to_utf16(title).c_str(), flags), buttons); }
HospitalizationManagement::HospitalizationManagement(QWidget *parent): FTabWidget(parent) { initUI(); getButtons().at(0)->click(); connect(registry->ui.saveButton,SIGNAL(clicked()),this,SLOT(refresh())); connect(registry->ui.deleteButton,SIGNAL(clicked()),this,SLOT(refresh())); }
void ZMouseEvent::print() const { std::cout << "Mouse event: "; if (getButtons() & Qt::LeftButton) { std::cout << "Left button; "; } if (getButtons() & Qt::RightButton) { std::cout << "Right button; "; } if (getButtons() & Qt::MidButton) { std::cout << "Middle button; "; } switch (getAction()) { case ACTION_DOUBLE_CLICK: std::cout << "Double click; "; break; case ACTION_MOVE: std::cout << "Move; "; break; case ACTION_PRESS: std::cout << "Press; "; break; case ACTION_RELEASE: std::cout << "Release; "; break; default: break; } if (getModifiers() & Qt::ShiftModifier) { std::cout << "Shift; "; } if (getModifiers() & Qt::ControlModifier) { std::cout << "Control; "; } if (getModifiers() & Qt::AltModifier) { std::cout << "Alt; "; } std::cout << std::endl; }
GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown) const { GHOST_Buttons buttons; // Get the state of all mouse buttons GHOST_TSuccess success = getButtons(buttons); if (success) { // Isolate the state of the mouse button requested isDown = buttons.get(mask); } return success; }
inline bool pressedButtons(Buttons b, uint16_t ms) { cli(); delayStartI(ms); while (delay_countdown != 0 && getButtons() == b) { sei(); sleep_cpu(); cli(); } delayStopI(); sei(); return delay_countdown == 0; }
int main(void) { if (!openDisplay()) { return 1; } grab(getKeys(), getButtons()); while (1) { nextEvent(); processEvent(); } }
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config, int (*available)(int), unsigned int (*getButtons)(WPADData*)) { if(wpadNeedScan){ WPAD_ScanPads(); wpadNeedScan = 0; } WPADData* wpad = WPAD_Data(Control); BUTTONS* c = Keys; memset(c, 0, sizeof(BUTTONS)); //Reset buttons & sticks c->btns.All = 0xFFFF; c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128; // Only use a connected nunchuck controller if(!available(Control)) return 0; unsigned int b = getButtons(wpad); inline int isHeld(button_tp button){ return (b & button->mask) == button->mask ? 0 : 1; } c->btns.SQUARE_BUTTON = isHeld(config->SQU); c->btns.CROSS_BUTTON = isHeld(config->CRO); c->btns.CIRCLE_BUTTON = isHeld(config->CIR); c->btns.TRIANGLE_BUTTON = isHeld(config->TRI); c->btns.R1_BUTTON = isHeld(config->R1); c->btns.L1_BUTTON = isHeld(config->L1); c->btns.R2_BUTTON = isHeld(config->R2); c->btns.L2_BUTTON = isHeld(config->L2); c->btns.L_DPAD = isHeld(config->DL); c->btns.R_DPAD = isHeld(config->DR); c->btns.U_DPAD = isHeld(config->DU); c->btns.D_DPAD = isHeld(config->DD); c->btns.START_BUTTON = isHeld(config->START); c->btns.R3_BUTTON = isHeld(config->R3); c->btns.L3_BUTTON = isHeld(config->L3); c->btns.SELECT_BUTTON = isHeld(config->SELECT); //adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos s8 stickX = 0; s8 stickY = 0; if(config->analogL->mask == NUNCHUK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.nunchuk.js, STICK_X, 127); stickY = getStickValue(&wpad->exp.nunchuk.js, STICK_Y, 127); } else if(config->analogL->mask == IR_AS_ANALOG){ if(wpad->ir.smooth_valid){ stickX = ((short)(wpad->ir.sx - 512)) >> 2; stickY = -(signed char)((wpad->ir.sy - 384) / 3); } else {
////////////////////////////////////////////////////////////////////////////// TASK MAIN!!! \(^0^)/ task main() { clearDebugStream(); gyroCal(); getSeeker(); int left = 0; int delay = 0; int endDump = 0; int ramp = 0; int* switches = getButtons(); //asign meaning to the touch sensors if(switches[3]) left = 1; else left = 0; if(switches[2]) delay = 1; else delay = 0; if(switches[1]) endDump = 1; else endDump = 0; if(switches[0]) ramp = 1; else ramp = 0; //Round starts here waitForStart(); nMotorEncoder[BR] = 0; nMotorEncoder[wrist1] = 0; nMotorEncoder[arms] = 0; if(endDump) EndDump(left, delay); else if(ramp) Ramp(left, delay); else IRramp(left , delay); }
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config, int (*available)(int), unsigned int (*getButtons)(WPADData*)) { WPADData* wpad = WPAD_Data(Control); BUTTONS* c = Keys; memset(c, 0, sizeof(BUTTONS)); // Only use a connected nunchuck controller if(!available(Control)) return 0; WPAD_ReadPending(Control, NULL); unsigned int b = getButtons(wpad); inline int isHeld(button_tp button){ return (b & button->mask) == button->mask; } c->R_DPAD = isHeld(config->DR); c->L_DPAD = isHeld(config->DL); c->D_DPAD = isHeld(config->DD); c->U_DPAD = isHeld(config->DU); c->START_BUTTON = isHeld(config->START); c->B_BUTTON = isHeld(config->B); c->A_BUTTON = isHeld(config->A); c->Z_TRIG = isHeld(config->Z); c->R_TRIG = isHeld(config->R); c->L_TRIG = isHeld(config->L); c->R_CBUTTON = isHeld(config->CR); c->L_CBUTTON = isHeld(config->CL); c->D_CBUTTON = isHeld(config->CD); c->U_CBUTTON = isHeld(config->CU); if(config->analog->mask == NUNCHUK_AS_ANALOG){ c->X_AXIS = getStickValue(&wpad->exp.nunchuk.js, STICK_X, 128); c->Y_AXIS = getStickValue(&wpad->exp.nunchuk.js, STICK_Y, 128); } else if(config->analog->mask == IR_AS_ANALOG){ if(wpad->ir.smooth_valid){ c->X_AXIS = ((short)(wpad->ir.sx - 512)) >> 2; c->Y_AXIS = -(signed char)((wpad->ir.sy - 384) / 3); } else {
unsigned int MT_RobotControlFrameBase::createButtons(wxBoxSizer* pSizer, wxPanel* pPanel) { unsigned int nbuttons = MT_TrackerControlFrameBase::createButtons(pSizer, pPanel); if(getButtons() & MT_RCF_AUTOID) { m_pButtonAutoIdentify = new wxButton(pPanel, MT_RCF_ID_BUTTON_AUTOIDENTIFY, wxT("AutoID Robots")); pSizer->Add(m_pButtonAutoIdentify, 0, wxALL | wxCENTER, 10); m_pButtonAutoIdentify->Disable(); Connect(MT_RCF_ID_BUTTON_AUTOIDENTIFY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MT_RobotControlFrameBase::onButtonAutoIdentifyPressed)); nbuttons++; } return nbuttons; }
void MouseConfig::loadConfig() { QList<RecordItNow::MouseButton> buttons = getButtons(config()); foreach (const RecordItNow::MouseButton &button, buttons) { ColorRow *cRow = newColorRow(); cRow->setButton(MouseButtonWidget::getButtonFromXButton(button.code())); cRow->setColor(button.color()); m_colorLayout->addRow(cRow); if (button.sound().isEmpty()) { continue; } SoundRow *sRow = newSoundRow(); sRow->setButton(MouseButtonWidget::getButtonFromXButton(button.code())); sRow->setSound(button.sound()); m_soundLayout->addRow(sRow); }
/* * Main program entry point * Start with 8 moles and flick LEDs via rotating mask. * Choose a random mole to light for fraction of a second. * If the mole button is pushed while the LED is lit, kill the mole. * When all moles are dead celebrate - check button press for restart. */ int main(void) { int molemask = 0xff; // live moles int ontime = 1; // flicker on time in ms int offtime = 80; // flicker off time int whacked = 0; // it's whacked? int direction = 1; // keep direction of LED mole run int popcount = 6; // initial popcount int countmask = 0x0700; // allow up to 7 mole run steps int popmask = 0x7; // only 8 LEDs, choose from rand int popupspot = 0; // show popup position int popuptime = 500; // popup on time /* mole run forever loop */ for(;;) { /* nothing whacked */ whacked = 0; /* seed random function with Propeller CNT */ srand(CNT); /* blank moles */ LEDOUT(0); /* sleep a little */ msleep(offtime); /* if all moles gone, celebrate */ while(!molemask) { /* make LEDs dance */ celebrate(); /* if button press, restart game */ if(getButtons()) { molemask = 0xff; } } /* get popup spot */ if(popcount-- == 0) { /* get random number */ popupspot = rand(); /* use upper bits for popup count */ popcount = (popupspot & countmask) >> 8; /* use lower popmask bits for popup mole LED */ popupspot &= popmask; /* show popup and check button */ if(molemask & (1<<popupspot)) { /* set LED to show a mole to whack */ LEDOUT((1<<popupspot) & molemask); /* single thread limit. sample twice */ msleep(popuptime>>1); whacked = getButton(popupspot); msleep(popuptime>>1); whacked |= getButton(popupspot); /* set back to mole mask */ LEDOUT(molemask); } }
void PE1MEW_RotorSteering::buttonTest(void) { // read button status uint8_t inputVariable = getButtons(); if (inputVariable != 0x00) { _PressMemory = true; } else { _PressMemory = false; } if (_PressMemory) { if (_ButtonSpeedHoldCounter < PRESS_COUNTER_MAX) { _ButtonSpeedHoldCounter++; } switch (_CurrentButtonSpeedState) { case STEP1: if (PRESS_COUNTER_TRESHOLD1 < _ButtonSpeedHoldCounter) { if (_SpeedStateCounter < PRESS_COUNTER_STEP1_TRESHOLD) { _SpeedStateCounter++; } else { _SpeedStateCounter = 0; _NextButtonSpeedState = STEP2; //_ProcessVariableIncrement = 1; } ProcessButtons(inputVariable); _ButtonSpeedHoldCounter = 0; } break; case STEP2: if (PRESS_COUNTER_TRESHOLD2 < _ButtonSpeedHoldCounter) { if (_SpeedStateCounter < PRESS_COUNTER_STEP2_TRESHOLD) { _SpeedStateCounter++; } else { _SpeedStateCounter = 0; _NextButtonSpeedState = STEP3; //_ProcessVariableIncrement = 1; } ProcessButtons(inputVariable); _ButtonSpeedHoldCounter = 0; } break; case STEP3: if (PRESS_COUNTER_TRESHOLD3 < _ButtonSpeedHoldCounter) { if (_SpeedStateCounter < PRESS_COUNTER_STEP3_TRESHOLD) { _SpeedStateCounter++; } else { _SpeedStateCounter = 0; _NextButtonSpeedState = STEP4; //_ProcessVariableIncrement = 1; } ProcessButtons(inputVariable); _ButtonSpeedHoldCounter = 0; } break; case STEP4: if (PRESS_COUNTER_TRESHOLD4 < _ButtonSpeedHoldCounter) { if (_SpeedStateCounter < PRESS_COUNTER_STEP4_TRESHOLD) { _SpeedStateCounter++; } else { _SpeedStateCounter = 0; } ProcessButtons(inputVariable); _ButtonSpeedHoldCounter = 0; } break; } } else { _ButtonSpeedHoldCounter = 0; _NextButtonSpeedState = STEP1; _ProcessVariableIncrement = INCREMENT_DEFAULT; } _CurrentButtonSpeedState = _NextButtonSpeedState; }
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config) { if(wpadNeedScan){ WPAD_ScanPads(); wpadNeedScan = 0; } WPADData* wpad = WPAD_Data(Control); BUTTONS* c = Keys; memset(c, 0, sizeof(BUTTONS)); //Reset buttons & sticks c->btns.All = 0xFFFF; c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128; // Only use a connected classic controller if(!available(Control)) return 0; unsigned int b = getButtons(&wpad->exp.classic); inline int isHeld(button_tp button){ return (b & button->mask) == button->mask ? 0 : 1; } c->btns.SQUARE_BUTTON = isHeld(config->SQU); c->btns.CROSS_BUTTON = isHeld(config->CRO); c->btns.CIRCLE_BUTTON = isHeld(config->CIR); c->btns.TRIANGLE_BUTTON = isHeld(config->TRI); c->btns.R1_BUTTON = isHeld(config->R1); c->btns.L1_BUTTON = isHeld(config->L1); c->btns.R2_BUTTON = isHeld(config->R2); c->btns.L2_BUTTON = isHeld(config->L2); c->btns.L_DPAD = isHeld(config->DL); c->btns.R_DPAD = isHeld(config->DR); c->btns.U_DPAD = isHeld(config->DU); c->btns.D_DPAD = isHeld(config->DD); c->btns.START_BUTTON = isHeld(config->START); c->btns.R3_BUTTON = isHeld(config->R3); c->btns.L3_BUTTON = isHeld(config->L3); c->btns.SELECT_BUTTON = isHeld(config->SELECT); //adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos s8 stickX = 0; s8 stickY = 0; if(config->analogL->mask == L_STICK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.classic.ljs, STICK_X, 127); stickY = getStickValue(&wpad->exp.classic.ljs, STICK_Y, 127); } else if(config->analogL->mask == R_STICK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.classic.rjs, STICK_X, 127); stickY = getStickValue(&wpad->exp.classic.rjs, STICK_Y, 127); } c->leftStickX = (u8)(stickX+127) & 0xFF; if(config->invertedYL) c->leftStickY = (u8)(stickY+127) & 0xFF; else c->leftStickY = (u8)(-stickY+127) & 0xFF; if(config->analogR->mask == L_STICK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.classic.ljs, STICK_X, 127); stickY = getStickValue(&wpad->exp.classic.ljs, STICK_Y, 127); } else if(config->analogR->mask == R_STICK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.classic.rjs, STICK_X, 127); stickY = getStickValue(&wpad->exp.classic.rjs, STICK_Y, 127); } c->rightStickX = (u8)(stickX+127) & 0xFF; if(config->invertedYR) c->rightStickY = (u8)(stickY+127) & 0xFF; else c->rightStickY = (u8)(-stickY+127) & 0xFF; // Return 1 if whether the exit button(s) are pressed return isHeld(config->exit) ? 0 : 1; }
// See mousePressEvent void QtCanvas::mouseMoveEvent(QMouseEvent* e) { cgt::MouseEvent* movEv = new cgt::MouseEvent(e->x(), e->y(), cgt::MouseEvent::MOTION, getModifier(e), getButtons(e), cgt::ivec2(width(), height())); // FIXME: submit information which mouse buttons are pressed eventHandler_->broadcastEvent(movEv); }
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config) { if(padNeedScan) { gc_connected = PAD_ScanPads(); padNeedScan = 0; } BUTTONS* c = Keys; memset(c, 0, sizeof(BUTTONS)); //Reset buttons & sticks c->btns.All = 0xFFFF; c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128; controller_GC.available[Control] = (gc_connected & (1<<Control)) ? 1 : 0; if (!controller_GC.available[Control]) return 0; unsigned int b = getButtons(Control); inline int isHeld(button_tp button) { return (b & button->mask) == button->mask ? 0 : 1; } c->btns.SQUARE_BUTTON = isHeld(config->SQU); c->btns.CROSS_BUTTON = isHeld(config->CRO); c->btns.CIRCLE_BUTTON = isHeld(config->CIR); c->btns.TRIANGLE_BUTTON = isHeld(config->TRI); c->btns.R1_BUTTON = isHeld(config->R1); c->btns.L1_BUTTON = isHeld(config->L1); c->btns.R2_BUTTON = isHeld(config->R2); c->btns.L2_BUTTON = isHeld(config->L2); c->btns.L_DPAD = isHeld(config->DL); c->btns.R_DPAD = isHeld(config->DR); c->btns.U_DPAD = isHeld(config->DU); c->btns.D_DPAD = isHeld(config->DD); c->btns.START_BUTTON = isHeld(config->START); c->btns.R3_BUTTON = isHeld(config->R3); c->btns.L3_BUTTON = isHeld(config->L3); c->btns.SELECT_BUTTON = isHeld(config->SELECT); //adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos int stickX = 0, stickY = 0; if(config->analogL->mask == ANALOG_AS_ANALOG) { stickX = PAD_StickX(Control); stickY = PAD_StickY(Control); } else if(config->analogL->mask == C_STICK_AS_ANALOG) { stickX = PAD_SubStickX(Control); stickY = PAD_SubStickY(Control); } c->leftStickX = GCtoPSXAnalog(stickX); c->leftStickY = GCtoPSXAnalog(config->invertedYL ? stickY : -stickY); if(config->analogR->mask == ANALOG_AS_ANALOG) { stickX = PAD_StickX(Control); stickY = PAD_StickY(Control); } else if(config->analogR->mask == C_STICK_AS_ANALOG) { stickX = PAD_SubStickX(Control); stickY = PAD_SubStickY(Control); } c->rightStickX = GCtoPSXAnalog(stickX); c->rightStickY = GCtoPSXAnalog(config->invertedYR ? stickY : -stickY); // Return 1 if whether the exit button(s) are pressed return isHeld(config->exit) ? 0 : 1; }
bool Joystick::getB() { return (getButtons() & buttonB) != 0; }
bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPARAM lParam, CEventServer *server) { if (!server) server=&_InternalServer; /// Process IME messages /*if ( _IMEEventsEnabled && (ImmIsUIMessage( ImmGetDefaultIMEWnd((HWND)_HWnd), msg, wParam, lParam) == TRUE) ) { server->postEvent( new CEventIME(msg, wParam, lParam, this) ); return true; // trap message (however DefWindowProc will still be called in some instances by the event listener) }*/ switch (msg) { case WM_KEYDOWN: case WM_SYSKEYDOWN: if (_KeyboardEventsEnabled) { // Ctrl, shit or alt ? if ((sint)wParam==VK_MENU) _AltButton=true; if ((sint)wParam==VK_CONTROL) _CtrlButton=true; if ((sint)wParam==VK_SHIFT) _ShiftButton=true; // Post the message if (wParam < KeyCount) server->postEvent (new CEventKeyDown ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), (((int) lParam)&(1<<30))==0, this)); } break; case WM_SYSKEYUP: case WM_KEYUP: if (_KeyboardEventsEnabled) { // Ctrl, shit or alt ? if ((int)wParam==VK_MENU) _AltButton=false; if ((int)wParam==VK_CONTROL) _CtrlButton=false; if ((int)wParam==VK_SHIFT) _ShiftButton=false; // As Print Screen button does not trigger a WM_KEYDOWN msg, simulate it here if ((int)wParam==VK_SNAPSHOT) { if (wParam < KeyCount) server->postEvent (new CEventKeyDown ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), true, this)); } // Post the message if (wParam < KeyCount) server->postEvent (new CEventKeyUp ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break; case WM_CHAR: if (_KeyboardEventsEnabled) { //if (wParam < KeyCount) //nlinfo("WM_CHAR with %u", wParam); server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break; /*case WM_IME_CHAR: if (_KeyboardEventsEnabled && _IMEEventsEnabled) { server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break;*/ case WM_ACTIVATE: if (WA_INACTIVE==LOWORD(wParam)) server->postEvent (new CEventActivate (false, this)); else { // Reset flags state resetButtonFlagState (); // Post the message server->postEvent (new CEventActivate (true, this)); } break; case WM_KILLFOCUS: server->postEvent (new CEventSetFocus (false, this)); break; case WM_SETFOCUS: // Reset flags state resetButtonFlagState (); // Post the message server->postEvent (new CEventSetFocus (true, this)); break; case WM_MOUSEMOVE: case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONUP: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_LBUTTONDBLCLK: { if (_MouseEventsEnabled) { // MSWindows coordinates to NeL window coordinate float fX, fY; RECT client; float xPos = (float)GET_X_LPARAM(lParam); float yPos = (float)GET_Y_LPARAM(lParam); GetClientRect (hWnd, &client); fX=xPos/(float)(client.right-client.left); fY=1.f-yPos/(float)(client.bottom-client.top); // buttons TMouseButton button=getButtons(); // Reswitch switch (msg) { case WM_MOUSEMOVE: server->postEvent (new CEventMouseMove (fX, fY, button, this)); break; case WM_RBUTTONDOWN: _MouseButtons[1] = true; server->postEvent (new CEventMouseDown (fX, fY, (TMouseButton)(rightButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_MBUTTONDOWN: _MouseButtons[2] = true; server->postEvent (new CEventMouseDown (fX, fY, (TMouseButton)(middleButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_LBUTTONDOWN: _MouseButtons[0] = true; server->postEvent (new CEventMouseDown (fX, fY, (TMouseButton)(leftButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_RBUTTONUP: _MouseButtons[1] = false; server->postEvent (new CEventMouseUp (fX, fY, (TMouseButton)(rightButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_MBUTTONUP: _MouseButtons[2] = false; server->postEvent (new CEventMouseUp (fX, fY, (TMouseButton)(middleButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_LBUTTONUP: _MouseButtons[0] = false; server->postEvent (new CEventMouseUp (fX, fY, (TMouseButton)(leftButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_RBUTTONDBLCLK: server->postEvent (new CEventMouseDblClk (fX, fY, (TMouseButton)(rightButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_MBUTTONDBLCLK: server->postEvent (new CEventMouseDblClk (fX, fY, (TMouseButton)(middleButton|(button&~(leftButton|middleButton|rightButton))), this)); break; case WM_LBUTTONDBLCLK: server->postEvent (new CEventMouseDblClk (fX, fY, (TMouseButton)(leftButton|(button&~(leftButton|middleButton|rightButton))), this)); break; } break; } break; } case WM_DESTROY: server->postEvent (new CEventDestroyWindow (this)); break; case WM_DISPLAYCHANGE: server->postEvent (new CEventDisplayChange (LOWORD(lParam), HIWORD(lParam), (uint)wParam, this)); break; case WM_MOUSEWHEEL: if (_MouseEventsEnabled) { // MSWindows coordinates to NeL window coordinate float fX, fY; RECT client; GetClientRect (hWnd, &client); if (client.right-client.left > 0) fX=(float)LOWORD(lParam)/(float)(client.right-client.left); else fX=0; if (client.bottom-client.top > 0) fY=1.f-(float)HIWORD(lParam)/(float)(client.bottom-client.top); else fY=0; // buttons TMouseButton button=getButtons(); server->postEvent (new CEventMouseWheel (fX, fY, button, (short) HIWORD(wParam)>=0, this)); break; } case WM_IME_SETCONTEXT: case WM_IME_STARTCOMPOSITION: case WM_IME_COMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_NOTIFY: //case WM_INPUTLANGCHANGEREQUEST: case WM_INPUTLANGCHANGE: if ( _IMEEventsEnabled ) { // wParam = Specifies the character set of the new locale. // lParam = Input locale identifier. server->postEvent( new CEventIME( msg, (uint32)wParam, (uint32)lParam, this ) ); return true; // trap message } break; } return false; }
void waitButtonsRelease() { while (getButtons() != 0) sleep_cpu(); delay(BUTTON_DELAY_MS); }
/* main code entry point */ int main(void) { display_context_t _dc; char temp[128]; int res = 0; unsigned short buttons, previous = 0; init_n64(); while (1) { int j; int width[4] = { 320, 640, 256, 512 }; int height[4] = { 240, 480, 240, 480 }; unsigned int color; _dc = lockVideo(1); color = graphics_make_color(0xCC, 0xCC, 0xCC, 0xFF); graphics_fill_screen(_dc, color); color = graphics_make_color(0xFF, 0xFF, 0xFF, 0xFF); graphics_draw_line(_dc, 0, 0, width[res]-1, 0, color); graphics_draw_line(_dc, width[res]-1, 0, width[res]-1, height[res]-1, color); graphics_draw_line(_dc, width[res]-1, height[res]-1, 0, height[res]-1, color); graphics_draw_line(_dc, 0, height[res]-1, 0, 0, color); graphics_draw_line(_dc, 0, 0, width[res]-1, height[res]-1, color); graphics_draw_line(_dc, 0, height[res]-1, width[res]-1, 0, color); color = graphics_make_color(0x00, 0x00, 0x00, 0xFF); graphics_set_color(color, 0); printText(_dc, "Video Resolution Test", width[res]/16 - 10, 3); switch (res) { case 0: printText(_dc, "320x240", width[res]/16 - 3, 5); break; case 1: printText(_dc, "640x480", width[res]/16 - 3, 5); break; case 2: printText(_dc, "256x240", width[res]/16 - 3, 5); break; case 3: printText(_dc, "512x480", width[res]/16 - 3, 5); break; } for (j=0; j<8; j++) { sprintf(temp, "Line %d", j); printText(_dc, temp, 3, j); sprintf(temp, "Line %d", height[res]/8 - j - 1); printText(_dc, temp, 3, height[res]/8 - j - 1); } printText(_dc, "0123456789", 0, 16); printText(_dc, "9876543210", width[res]/8 - 10, 16); unlockVideo(_dc); while (1) { // wait for change in buttons buttons = getButtons(0); if (buttons ^ previous) break; delay(1); } if (A_BUTTON(buttons ^ previous)) { // A changed if (!A_BUTTON(buttons)) { resolution_t mode[4] = { RESOLUTION_320x240, RESOLUTION_640x480, RESOLUTION_256x240, RESOLUTION_512x480 }; res = (res+1) & 3; display_close(); display_init(mode[res], DEPTH_16_BPP, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE); } } previous = buttons; } return 0; }
int getButton(int button) { int buttons = getButtons(); return BITMASK_CHECK(buttons, button) ? BUTTON_ON : BUTTON_OFF; }
void FWMenu::useMenu() { unsigned long value; // To provide (long)selection[p].value. // Populate the buttonz private member variable. setButtonz(getButtons()); // Menu functionality - Display and set values. //============================================= // B1 - Spare at present. if (aButtonPressed(button1)) { //Later this will be used to start a cycle. } // B2 - Up/--. if (aButtonPressed(button2)) { if (mode == 'o') { if (p > 0) { // Not at top? p--; // Move up 1 cell. } String s = selection[p].option; setDisplayToString(s); } if (mode == 'v') { if (selection[p].access == 'w') { // Don't allow a decrement below zero float testval = selection[p].value - selection[p].delta; if (testval >= 0) selection[p].value -= selection[p].delta; // Display value. value = (unsigned long)(selection[p].value * 10); setDisplayToDecNumber(value, 2, false); } } } // B3 - Down/++. if (aButtonPressed(button3)) { if (mode == 'o') { if (p < n - 1) { // Not at bottom? p++; // Move down 1 cell. } String s = selection[p].option; setDisplayToString(s); } if (mode == 'v') { if (selection[p].access == 'w') { selection[p].value += selection[p].delta; // Display value. value = (unsigned long)(selection[p].value * 10); setDisplayToDecNumber(value, 2, false); // provided cast value here } } } // B4 - <Enter> and swap modes. if (aButtonPressed(button4)) { if (mode == 'o') { mode = 'v'; // Display value. value = (unsigned long)(selection[p].value * 10); setDisplayToDecNumber(value, 2, false); } else if (mode == 'v') { mode = 'o'; // Display option. setDisplayToString(selection[p].option); } } // B5 - Clear display if (aButtonPressed(button5)) { showDisplay = !showDisplay; if (!showDisplay) { clearDisplay(); } mode = 'o'; // We always 'switch on' (display something on the LED's) again in 'Option Mode'. // A little trick here - when you switch back on using B2 or B3, press each of these buttons once to return to where you were. } // B8 - Reset menu to default values if (aButtonPressed(button8)) { resetMenu(); setDisplayToString("DEFAULTS"); } delay(_pace); // How fast the display changes. }
word readButtons() { word Result = getButtons(); ButtonLedInstance.curButtonsS = Result; return Result; }
void CInputTranslator::mouseMove(int special, const Point &pt) { CMouseMoveMsg msg(pt, getButtons(special)); _inputHandler->handleMessage(msg); }
PharmacyManagement::PharmacyManagement(QWidget *parent) : FTabWidget(parent) { initUI(); getButtons().at(0)->click(); }
bool Joystick::getA() { return (getButtons() & buttonA) != 0; }