Ejemplo n.º 1
0
	bool OISJoystick::buttonstate(const unsigned int index) const
	{
		if (index<numButtons()) {
			const OIS::JoyStickState &state=m_pObject->getJoyStickState();
			return state.buttonDown(index)!=0;
		} else return false;
	}
Ejemplo n.º 2
0
int QwtCounter::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: buttonReleased((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 1: valueChanged((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 2: btnReleased(); break;
        case 3: btnClicked(); break;
        case 4: textChanged(); break;
        }
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = numButtons(); break;
        case 1: *reinterpret_cast< double*>(_v) = step(); break;
        case 2: *reinterpret_cast< double*>(_v) = minVal(); break;
        case 3: *reinterpret_cast< double*>(_v) = maxVal(); break;
        case 4: *reinterpret_cast< int*>(_v) = stepButton1(); break;
        case 5: *reinterpret_cast< int*>(_v) = stepButton2(); break;
        case 6: *reinterpret_cast< int*>(_v) = stepButton3(); break;
        case 7: *reinterpret_cast< double*>(_v) = value(); break;
        case 8: *reinterpret_cast< bool*>(_v) = editable(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setNumButtons(*reinterpret_cast< int*>(_v)); break;
        case 1: setStep(*reinterpret_cast< double*>(_v)); break;
        case 2: setMinValue(*reinterpret_cast< double*>(_v)); break;
        case 3: setMaxValue(*reinterpret_cast< double*>(_v)); break;
        case 4: setStepButton1(*reinterpret_cast< int*>(_v)); break;
        case 5: setStepButton2(*reinterpret_cast< int*>(_v)); break;
        case 6: setStepButton3(*reinterpret_cast< int*>(_v)); break;
        case 7: setValue(*reinterpret_cast< double*>(_v)); break;
        case 8: setEditable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 3
0
void QJoystickInterface::init()
{
    //Reset axes information
    mDeadzones.clear();
    mAxesCurrent.clear();
    for(int i=0; i<numAxes(); i++)
    {
        mDeadzones.append(0);
        mAxesCurrent.append(0);
    }

    //Reset button information
    mButtonsCurrent.clear();
    mButtonsPrevious.clear();
    mButtonsToggled.clear();
    for(int i=0; i<numButtons(); i++)
    {
        mButtonsCurrent.append(false);
        mButtonsPrevious.append(false);
        mButtonsToggled.append(false);
    }

    //Reset hat information
    mHatsCurrent.clear();
    mHatsPrevious.clear();
    mHatsToggled.clear();
    for(int i=0; i<numHats(); i++)
    {
        QMap<int, bool> temp;
        mHatsCurrent.append(temp);
        mHatsPrevious.append(temp);
        mHatsToggled.append(temp);
    }

    mBilinearEnabled = false;
    mBilinearConstant = 1;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------
LRESULT CALLBACK WndMainProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int i, notif;
	Tsquare *t;

	switch(message){
		case WM_PAINT:
		{
			static PAINTSTRUCT ps;
			BeginPaint(hWnd, &ps);
			paint(ps.hdc, &ps.rcPaint);
			EndPaint(hWnd, &ps);
		}
			break;
		case WM_LBUTTONDOWN:
			lbutton(lParam);
			break;
		case WM_RBUTTONDOWN:
			rbutton(lParam);
			break;
		case WM_LBUTTONUP:
			if(inserting){
				ReleaseCapture();
				inserting=false;
				insertGroup();
				resetSolution();
			}
			break;
		case WM_MOUSEMOVE:
			if(inserting){
				t= hitTest(lParam);
				if(t && t!=insSquares[insLen-1] && insLen<Nsymbol){
					insSquares[insLen++]=t;
				}
			}
#ifdef _DEBUGM
			mousemove(lParam);
#endif
			break;

		case WM_TIMER:
			if(!IsIconic(hWin)){
				playtime++;
				statusTime();
				checkShowErr(false);
			}
			break;
		case WM_KEYDOWN:
			key(wParam);
			break;
		case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO lpmm = (LPMINMAXINFO)lParam;
			lpmm->ptMinTrackSize.x = 250;
			lpmm->ptMinTrackSize.y = 200+toolH;
			break;
		}
		case WM_SIZE:
			width=LOWORD(lParam);
			height=HIWORD(lParam);
			SendMessage(toolbar, TB_AUTOSIZE, 0, 0);
			SendMessage(statusbar, WM_SIZE, 0, 0);
			onMoved();
			invalidate();
			break;
		case WM_MOVE:
			onMoved();
			break;
		case WM_CLOSE:
			SendMessage(hWin, WM_COMMAND, ID_EXIT, 0);
			break;
		case WM_QUERYENDSESSION:
			writeini();
			return TRUE;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		case WM_COMMAND:
			notif=HIWORD(wParam);
			wParam=LOWORD(wParam);
			if(setLang(wParam)) break;
			if(wParam>=ID_SYMBOL && wParam<unsigned(ID_SYMBOL+size)){
				select(wParam-ID_SYMBOL);
				break;
			}
			if(wParam>=ID_SIZE+4 && wParam<=ID_SIZE+Msize){
				if(askNew()) break;
				size=wParam-ID_SIZE;
				newGameFormat();
				numButtons();
				break;
			}
			if(wParam>=ID_MULTI && wParam<ID_MULTI+sizeA(gameTypeA)-1){
				if(askNew()) break;
				gameType=wParam-ID_MULTI;
				newGameFormat();
				break;
			}

			switch(wParam){
				case ID_CLEAR:
					noScore=true;
					init(false);
					invalidate();
					break;
				case ID_CLEAR_ALL:
					noScore=true;
					initSquare(false);
					invalidate();
					break;
				case ID_EDITOR:
					if(!editor){
						if((undoPos==0 || done==Nsquare) && isGenerated()){
							initSquare(false);
						}
						editor=true;
						playtime=0;
						noScore=true;
						editorChanged();
					}
					break;
				case ID_EDITOR_END:
					if(editor){
						endEditor();
						editor=false;
						editorChanged();
					}
					break;
				case ID_SOLVE:
				case ID_SOLVE1:
					if(testTotal()) break;
					noScore=true;
					if(done<Nsquare){
						waitOn();
#ifdef _DEBUG
						DWORD time=getTickCount();
#endif
						Nsolution=0;
						curSolution=-1; //find all solutions (up to Msolution)
						undoAllPos=undoPos;
						if(wParam==ID_SOLVE1) resolve1(); else resolve();
						freeGroups();
#ifdef _DEBUG
						status(4, _T("%d ms"), getTickCount()-time);
#endif
						waitOff();
					}
					if(Nsolution>0){
						i=curSolution;
						curSolution++;
						if(curSolution>=Nsolution) curSolution=0;
						if(Nsolution>1){
							if(i<0){
								status(4, _T("%d %s"), Nsolution, lng(662, "solutions"));
							}
							else{
								status(4, _T("%d/%d"), curSolution+1, Nsolution);
							}
						}
						rdSolution();
					}
					else{ //easy solution (without recurse) or not solvable
						curSolution=0;
						status(4, _T(""));
					}
					checkErr();
					invalidate();
					break;
				case ID_CHEAT:
					noScore=true;
					if(errTime<0){
						waitOn();
						hint();
						waitOff();
					}
					checkShowErr(true);
					break;
				case ID_UNDO:
					undo();
					checkErr();
					break;
				case ID_REDO:
					redo();
					checkErr();
					break;
				case ID_UNDO_SYMBOL:
					undoSymbol();
					checkErr();
					break;
				case ID_REDO_SYMBOL:
					redoSymbol();
					checkErr();
					break;
				case ID_UNDO_ALL:
					undoAll();
					checkErr();
					break;
				case ID_REDO_ALL:
					while(redo());
					checkErr();
					break;
				case ID_DEL:
					select(-1);
					break;
				case ID_INS:
					select(-2);
					break;
				case ID_SIGN:
					select(-3);
					break;
				case ID_CONS:
					select(-4);
					break;
				case ID_EVEN:
					select(-5);
					break;
				case ID_EXIT:
					writeini();
					DestroyWindow(hWin);
					break;
				case ID_DIAGONAL:
					if(askNew()) break;
					diag=!diag;
					newGameFormat();
					break;
				case ID_SYMETRIC:
					if(askNew()) break;
					symetric=!symetric;
					newGameFormat();
					break;
				case ID_LEVEL:
					if(DialogBox(inst, MAKEINTRESOURCE(IDD_LEVEL), hWnd, (DLGPROC)LevelProc)){
						if(!editor) newGame();
					}
					break;
				case ID_SHOWERR:
					DialogBox(inst, MAKEINTRESOURCE(IDD_ERRTIME), hWnd, (DLGPROC)ShowErrProc);
					break;
				case ID_KILLER:
					if(askNew()) break;
					killer=!killer;
					newGameFormat();
					numButtons();
					break;
				case ID_GREATER:
					if(askNew()) break;
					greater=!greater;
					newGameFormat();
					break;
				case ID_CONSECUTIVE:
					if(askNew()) break;
					consecutive=!consecutive;
					newGameFormat();
					if(selectedNum==-4 && !consecutive) select(-1);
					break;
				case ID_ODDEVEN:
					if(askNew()) break;
					oddeven=!oddeven;
					newGameFormat();
					if(selectedNum==-5 && !oddeven) select(-1);
					break;
				case ID_DIGITS:
				case ID_LETTERS:
				case ID_COLORS:
					symbol0=wParam-350;
					checkMenus();
					invalidate();
					numButtons();
					break;
				case ID_NEWGAME:
					if(editor) SendMessage(hWnd, WM_COMMAND, ID_EDITOR_END, 0);
					else newGame();
					break;
				case ID_DELINI:
					delreg=true;
					break;
				case ID_DELHISCORE:
					if(MessageBox(hWnd,
						lng(799, "Do you really want to delete all hiscores ?"), title,
						MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDYES){
						for(TscoreTab *tab=score; tab;){
							TscoreTab *t1= tab->next;
							delete tab;
							tab=t1;
						}
						score=0;
						writeScore();
					}
					break;
				case ID_BEST_SCORES:
					DialogBox(inst, MAKEINTRESOURCE(IDD_HISCORE), hWnd, (DLGPROC)ScoreProc);
					break;
				case ID_COLORDLG:
					DialogBox(inst, MAKEINTRESOURCE(IDD_COLORS), hWin, (DLGPROC)ColorProc);
					break;
				case ID_ABOUT:
					DialogBox(inst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, (DLGPROC)AboutProc);
					break;
				case ID_HELP_README:
				{
					TCHAR *buf=(TCHAR*)_alloca(2*MAX_PATH);
					getExeDir(buf, lng(13, "readme.txt"));
					if(ShellExecute(0, _T("open"), buf, 0, 0, SW_SHOWNORMAL)==(HINSTANCE)ERROR_FILE_NOT_FOUND){
						msglng(730, "Cannot open %s", buf);
					}
				}
					break;
				case ID_WRBMP:
					if(saveFileDlg(&bmpOfn, hWnd, 0)){
						wrBmp(bmpFn, bmpOfn.nFilterIndex);
					}
					break;
				case ID_SAVE:
					if(saveFileDlg(&gameOfn, hWnd, OFN_OVERWRITEPROMPT)){
						save(gameFn);
					}
					break;
				case ID_OPEN:
					if(openFileDlg(&gameOfn, hWnd, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY)){
						open(gameFn);
						checkErr();
					}
					break;
				case ID_CLEAR_GRP:
					resetSolution();
					for(i=0; i<Ngroup; i++){
						delGroup(&group[i]);
					}
					invalidate();
					break;
				case ID_CLEAR_SGN:
				case ID_CLEAR_CONS:
					resetSolution();
					for(i=0; i<Nboard; i++){
						if(wParam==ID_CLEAR_SGN){
							putSign(0, &board[i], 0);
							putSign(0, &board[i], 1);
						}
						if(wParam==ID_CLEAR_CONS){
							putCons(false, &board[i], 0);
							putCons(false, &board[i], 1);
						}
					}
					invalidate();
					break;
				case ID_MARKS:
					noScore=true;
					showMarks();
					break;
				case ID_DELMARKS:
					delAllMarks();
					break;
				case ID_PDF:
					if(askNew()) break;
					DialogBox(inst, MAKEINTRESOURCE(IDD_PDF), hWnd, (DLGPROC)PdfProc);
					numButtons();
					break;
			}
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Ejemplo n.º 5
0
//------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int cmdShow)
{
	int i;
	HDC dc;
	MSG mesg;
	RECT rc;

	inst = hInstance;

	//DPIAware
	typedef BOOL(WINAPI *TGetProcAddress)();
	TGetProcAddress getProcAddress = (TGetProcAddress)GetProcAddress(GetModuleHandle(_T("user32")), "SetProcessDPIAware");
	if(getProcAddress) getProcAddress();

	memset(custom, 200, sizeof(custom));
	_tcscpy(pdfObject.fn, _T("sudoku.pdf"));
	pdfObject.pageWidth=595;
	pdfObject.pageHeight=842;
	pdfObject.count=6;
	pdfObject.countPerPage=6;
	pdfObject.border=40;
	pdfObject.spacing=20;
	readini();
	//load common controls
#if _WIN32_IE >= 0x0300
	INITCOMMONCONTROLSEX iccs;
	iccs.dwSize= sizeof(INITCOMMONCONTROLSEX);
	iccs.dwICC= ICC_BAR_CLASSES;
	InitCommonControlsEx(&iccs);
#else
	InitCommonControls();
#endif
	// create the main window
	WNDCLASS wc;
	ZeroMemory(&wc, sizeof(wc));
	wc.lpfnWndProc = WndMainProc;
	wc.hInstance = inst;
	wc.lpszClassName = CLASSNAME;
	wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);
	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon         = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
	if(!RegisterClass(&wc)){
#ifdef UNICODE
		msg("This version cannot run on Windows 95/98/ME.");
#else
		msg("RegisterClass failed");
#endif
		return 2;
	}
	scrW= GetSystemMetrics(SM_CXSCREEN);
	scrH= GetSystemMetrics(SM_CYSCREEN);
	aminmax(mainLeft, 0, scrW-50);
	aminmax(mainTop, 0, scrH-50);
	hWin = CreateWindow(CLASSNAME, title,
		WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN,
		mainLeft, mainTop, mainW, mainH, 0, 0, inst, 0);
	if(!hWin){
		msg("CreateWindow failed");
		return 3;
	}

	haccel= LoadAccelerators(inst, MAKEINTRESOURCE(IDR_ACCELERATOR));
	Naccel= CopyAcceleratorTable(haccel, accel, sizeA(accel));
	initLang();
	//create status bar
	statusbar= CreateStatusWindow(WS_CHILD, 0, hWin, 1);
	static int parts[]={100, 140, 210, 230, -1};
	dc=GetDC(hWin);
	for(i=0; i<sizeA(parts)-1; i++){
		parts[i]=parts[i]*GetDeviceCaps(dc, LOGPIXELSX)/96;
	}
	ReleaseDC(hWin, dc);
	SendMessage(statusbar, SB_SETPARTS, sizeA(parts), (LPARAM)parts);
	ShowWindow(statusbar, SW_SHOW);
	//create tool bar
	i=sizeA(tbb);
	for(TBBUTTON *u=tbb; u<endA(tbb); u++){
		if(u->fsStyle==TBSTYLE_SEP) i--;
	}
	toolbar = CreateToolbarEx(hWin,
		WS_CHILD|TBSTYLE_TOOLTIPS, 2, i,
		inst, IDB_TOOLBAR, tbb, sizeA(tbb),
		16, 16, 16, 15, sizeof(TBBUTTON));
	GetClientRect(toolbar, &rc);
	MapWindowPoints(toolbar, hWin, (POINT*)&rc, 2);
	toolH= rc.bottom;
	if(toolBarVisible) ShowWindow(toolbar, SW_SHOW);

	langChanged();
	ShowWindow(hWin, cmdShow);
	initSquare(false);

	UpdateWindow(hWin);
	toolBitmap();
	numButtons();

	while(GetMessage(&mesg, NULL, 0, 0)==TRUE){
		if(!TranslateAccelerator(hWin, haccel, &mesg)){
			TranslateMessage(&mesg);
			DispatchMessage(&mesg);
		}
	}
	if(delreg) deleteini(HKEY_CURRENT_USER);
	return 0;
}