void PollControls (void) { id0_unsigned_t buttons; IN_ReadControl(0,&control); if (MousePresent) { // (REFKEEN) Minor difference from vanilla Catacomb buttons = BE_ST_GetEmuMouseButtons(); BE_ST_GetEmuAccuMouseMotion(&mousexmove, &mouseymove); #if 0 Mouse(MButtons); buttons = _BX; Mouse(MDelta); mousexmove = _CX; mouseymove = _DX; #endif if (buttons&1) control.button0 = 1; if (buttons&2) control.button1 = 1; } if (Keyboard[sc_V] || Keyboard[sc_Tab]) running = true; else running = false; }
// // END ARTICLES // void EndText (void) { int artnum; char far *text; memptr layout; ClearMemory (); CA_UpLevel (); MM_SortMem (); #ifdef JAPAN ShowArticle(gamestate.episode + 1); VW_FadeOut(); SETFONTCOLOR(0,15); IN_ClearKeysDown(); if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement FreeMusic (); CA_DownLevel (); MM_SortMem (); #else #ifdef ARTSEXTERN artnum = endextern+gamestate.episode; CA_CacheGrChunk (artnum); text = (char _seg *)grsegs[artnum]; MM_SetLock (&grsegs[artnum], true); #else endfilename[6] = '1'+gamestate.episode; CA_LoadFile (endfilename,&layout); text = (char _seg *)layout; MM_SetLock (&layout, true); #endif ShowArticle (text); #ifdef ARTSEXTERN MM_FreePtr (&grsegs[artnum]); #else MM_FreePtr (&layout); #endif VW_FadeOut(); SETFONTCOLOR(0,15); IN_ClearKeysDown(); if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement FreeMusic (); CA_DownLevel (); MM_SortMem (); #endif }
void PollControls (void) { id0_unsigned_t buttons; IN_ReadControl(0,&c); if (MousePresent) { buttons = BE_ST_GetMouseButtons(); BE_ST_GetMouseDelta(&mousexmove, &mouseymove); #if 0 Mouse(MButtons); buttons = _BX; Mouse(MDelta); mousexmove = _CX; mouseymove = _DX; #endif if (buttons&1) c.button0 = 1; if (buttons&2) c.button1 = 1; } if (Controls[0]==ctrl_Joystick) { if (c.x>120 || c.x <-120 || c.y>120 || c.y<-120) running = true; else running = false; if (c.x>-48 && c.x<48) slowturn = true; else slowturn = false; } else { if (Keyboard[sc_RShift]) running = true; else running = false; if (c.button0) slowturn = true; else slowturn = false; } }
/* ================ idUsercmdGenLocal::UsercmdInterrupt Called asyncronously ================ */ void idUsercmdGenLocal::UsercmdInterrupt( void ) { // dedicated servers won't create usercmds if ( !initialized ) { return; } // init the usercmd for com_ticNumber+1 InitCurrent(); // process the system mouse events Mouse(); // process the system keyboard events Keyboard(); // process the system joystick events Joystick(); // create the usercmd for com_ticNumber+1 MakeCurrent(); // save a number for debugging cmdDemos and networking cmd.sequence = com_ticNumber+1; buffered[(com_ticNumber+1) & (MAX_BUFFERED_USERCMD-1)] = cmd; }
// default constructor set nulls and report success TSRInputSubSystem::TSRInputSubSystem() { Init(); Mouse() = new TSRMouse(); TSRKeyboard::Init(); TSRPrintln( "Input subsystem Successfully Initialized" ); }
void WinInputManager::CursorEvent() { POINT Position; GetCursorPos(&Position); Position.x -= m_windowRect.left; Position.y -= m_windowRect.top; if (Position.x < 0 || Position.y < 0) return; if (m_curX == Position.x && m_curY == Position.y) return; m_curX = Position.x; m_curY = Position.y; for (auto i : m_listenerList) { if (!i) continue; else if (i->IsMouseMove(Mouse(m_curX, m_curY)) == true) return; } }
void cSnakeAppCallbacks::OnTouchDelta( float _fx, float _fy, int type ) { if ( pTheSnake->m_SelectedIndex != -1 ) { return; } pTheSnake->m_ArcBall.Update( Graphics()->m_uiWidth - Mouse()->m_Loc.x, Graphics()->m_uiHeight - Mouse()->m_Loc.y, true ); }
void GetEvent(int *key, int *x, int *y, int *buttons) { static int scaling = 1; static int wasDown = 0; static int isRepeating = 0; int xPrev = -1, yPrev = -1; int drawn = 0; //void *old = GetDstScreen(); Mouse(x, y, buttons); if (*buttons != 0 && wasDown) SDL_EnableKeyRepeat(isRepeating ? 100 : 500, 250); //SetDstScreen(new); *buttons = *key = 0; do { //if (kbhit()) if (AnyKeyDown()) { *key = GetKey(); } Mouse(x, y, buttons); *x /= scaling; if (*x > 319) scaling++; if (!(*buttons) && !(*key) && (*x != xPrev || *y != yPrev)) { if (drawn) ; //RestoreBkg(xPrev, yPrev, old); DrawCursor(*x, *y); xPrev = *x; yPrev = *y; drawn = 1; } } while (!(*buttons) && !(*key)); if (drawn) ; //RestoreBkg(xPrev, yPrev, old); isRepeating = wasDown && (buttons != 0); wasDown = (*buttons != 0); //SetDstScreen(old); }
void Scroll(float x, float y) { // cout << "Scroll: " << x << ", " << y << endl; if(x==0) { Mouse(y>0?3:4,0, last_x, last_y); context->mouse_state &= !MouseWheelUp; context->mouse_state &= !MouseWheelDown; } }
extern "C" _declspec(dllexport) void __cdecl DragMouse(int x, int y, TClickType button) { GetMousePosition(x, y); HoldMouse(x, y, button); Sleep( 50 + rand()% 50); Mouse(x,y,0,0,button); GetMousePosition(x, y); Sleep( 50 + rand()% 50); ReleaseMouse(x, y, button); }
// destructor will release all direct input stuff and report success TSRInputSubSystem::~TSRInputSubSystem() { #if defined( WIN32 ) || defined( WIN64 ) if ( m_lpdimouse ) { m_lpdimouse->Unacquire(); } SAFE_RELEASE( m_lpdimouse ); SAFE_RELEASE( m_lpdi ); #endif SAFE_DELETE( Mouse() ); TSRPrintln( "Input subsystem Successfully ShutDown" ); }
void CCamera::Update(int width, int height) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(Perspective, (GLfloat)width / (GLfloat)height, 0.01f, 40000.0f); m_vStrafe = norm_ort(m_vView - m_vPosition, m_vUpVector); if (MouseFlag) { Mouse(); } fl3 dir = m_vView - m_vPosition; }
void cJewelsGameCallbacks::OnUpdate( float _fDeltaTime ) { PointLightData& light0Data = *LightsManager()->m_SceneLightsContext.m_PointLights[ 0 ]; TSRVector2 mLoc = Mouse()->m_GuiLoc; light0Data.m_Position.Assign( mLoc.x, mLoc.y, -90.0f, 0.0f ); m_pWorld->Update( _fDeltaTime ); #ifdef WIN32 m_pWorld->SetDeferredEnabled( !KEYDOWN( TWISTER_KEY_SPACE ) ); #endif }
int CGraphicView::GetSelectionHitList( CPoint p, int selSizeX, int selSizeY, CHitRecordCollection& rRecordCollection ) { if( !wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC) ) return 0; // Create buffer to hold selection hits //(must be done before entering selection mode) // TeK Change 1/19/2009: We shouldn't be dynamically allocating memory on EVERY mouse-move! // Changed to use a static buffer (twice as big!) const int nBufSize = 4096*2; static UINT selectBuf[nBufSize]; memset( selectBuf,0, sizeof(selectBuf)); m_Camera.StartMousePicking( p, CSize(selSizeX, selSizeY), nBufSize, selectBuf ); m_graphicsModel.DrawModelForSelection( GetDC(), Mouse( MOUSE_SELECTIONBOX_DRAGGING ) ); /*glLoadName(1); glBegin(GL_QUADS); glColor3f(1.0, 1.0, 0.0); glVertex3i(2, 0, 0); glVertex3i(2, 6, 0); glVertex3i(6, 6, 0); glVertex3i(6, 0, 0); glEnd(); glLoadName(2); glBegin(GL_QUADS); glColor3f(0.0, 1.0, 1.0); glVertex3i(3, 2, -1); glVertex3i(3, 8, -1); glVertex3i(8, 8, -1); glVertex3i(8, 2, -1); glEnd(); glLoadName(3); glBegin(GL_QUADS); glColor3f(1.0, 0.0, 1.0); glVertex3i(0, 2, -2); glVertex3i(0, 7, -2); glVertex3i(5, 7, -2); glVertex3i(5, 2, -2); glEnd();*/ int nHits = m_Camera.EndMousePicking( rRecordCollection, selectBuf ); wglMakeCurrent( NULL, NULL ); return nHits; }
//------------------------------------------------------- // handle mouse input // // return true = send command to game // return false = do not send the command to the game //------------------------------------------------------- bool HandleMouse() { if (!Loaded) return true; MouseInfo xMouse = Mouse(); if (xMouse.cState == 0) // mouse move { } else if (xMouse.cState == 1) // left button down { /** // (optional) cancel click if other buttons are being pressed if (xMouse.MButtonDown || xMouse.RButtonDown) return false; /**/ } else if (xMouse.cState == 2) // left button up { } else if (xMouse.cState == 3) // middle button down { /** // (optional) cancel click if other buttons are being pressed if (xMouse.LButtonDown || xMouse.RButtonDown) return false; /**/ } else if (xMouse.cState == 4) // middle button up { } else if (xMouse.cState == 5) // right button down { /** // (optional) cancel click if other buttons are being pressed if (xMouse.LButtonDown || xMouse.MButtonDown) return false; /**/ } else if (xMouse.cState == 6) // right button up { } else // mouse scroll { } return true; }
int main(int argc, char **argv) { PoleaxeManager = Manager(new manager()); Alleg::Init(); Mouse m = Mouse(new mouse()); Keyboard k = Keyboard(new keyboard()); Display disp = Display(new display()); Timer t = Timer(new timer()); disp->SetDisplayMode(840, 525, 32); Window w = Window(new window("test window", 10, 10, 300, 200, 0)); PoleaxeManager->AddWindow(w); disp->SetBackground("background.bmp"); w->Draw(); PoleaxeManager->MessageLoop(); return 0; }
void basic_mouse_handler::Init(const u32 max_connect) { m_mice.emplace_back(Mouse()); memset(&m_info, 0, sizeof(MouseInfo)); m_info.max_connect = max_connect; m_info.now_connect = std::min(m_mice.size(), (size_t)max_connect); m_info.info = 0; // Ownership of mouse data: 0=Application, 1=System for (u32 i = 1; i < max_connect; i++) { m_info.status[i] = CELL_MOUSE_STATUS_DISCONNECTED; m_info.mode[i] = CELL_MOUSE_INFO_TABLET_MOUSE_MODE; m_info.tablet_is_supported[i] = CELL_MOUSE_INFO_TABLET_NOT_SUPPORTED; } m_info.status[0] = CELL_MOUSE_STATUS_CONNECTED; // (TODO: Support for more mice) m_info.vendor_id[0] = 0x1234; m_info.product_id[0] = 0x1234; }
void cSnakeAppCallbacks::OnTouchEvent( int x, int y, int type ) { if ( type == 1 ) { if ( pTheSnake->m_SelectedIndex != -1 ) { pTheSnake->StartMove( -1, pTheSnake->m_SelectedIndex ); } } if ( type == 2 ) { pTheSnake->m_SelectedIndex = -1; } if ( pTheSnake->m_SelectedIndex == -1 ) { pTheSnake->m_ArcBall.Update( Graphics()->m_uiWidth - Mouse()->m_Loc.x, Graphics()->m_uiHeight - Mouse()->m_Loc.y, false ); } }
void iphone_controls::handle_event (const SDL_Event& event) { int x = event.type == SDL_MOUSEMOTION ? event.motion.x : event.button.x; int y = event.type == SDL_MOUSEMOTION ? event.motion.y : event.button.y; int i = event.type == SDL_MOUSEMOTION ? event.motion.which : event.button.which; translate_mouse_coords(&x, &y); while(all_mice.size() <= i) { all_mice.push_back(Mouse()); all_mice[i].active = false; } if(!all_mice[i].active) { all_mice[i].starting_x = x; all_mice[i].starting_y = y; } all_mice[i].x = x; all_mice[i].y = y; all_mice[i].active = event.type != SDL_MOUSEBUTTONUP; }
void write(char ch='o') { fout<<"#include<graphics.h>\n" <<"#include<conio.h>\n\n" <<"void main()\n" <<"{\nint gd=DETECT,gm;\n" <<"initgraph(&gd,&gm,\"\\\\tc\\\\bgi\");\n\n"; fout<<"setfillstyle(SOLID_FILL,15);\n" <<"bar(0,0,640,480);\n" <<"/*remove the above 2 lines if u dont want white background*/\n\n"; if(ch=='o') { fout<<"setfillstyle(SOLID_FILL,1);\n" <<"setcolor(1);\n"; fout<<"rectangle(42,62,598,458);\n"; } Mouse(ch); fout<<"getch();\nclosegraph();\n}"; rename("temp.cpp",f); }
/* ================ idUsercmdGenLocal::GetDirectUsercmd ================ */ usercmd_t idUsercmdGenLocal::GetDirectUsercmd( void ) { // initialize current usercmd InitCurrent(); // process the system mouse events Mouse(); // process the system keyboard events Keyboard(); // process the system joystick events Joystick(); // create the usercmd MakeCurrent(); cmd.duplicateCount = 0; return cmd; }
void iphone_controls::read_controls() { active_mice.clear(); #if defined(TARGET_OS_HARMATTAN) || defined(TARGET_BLACKBERRY) || defined(__ANDROID__) // there is no SDL_Get_NumMice and SDL_SelectMouse support on // Harmattan, so all_mice has been updated via calls to handle_event const int nmice = all_mice.size(); #else const int nmice = SDL_GetNumMice(); if(all_mice.size() > nmice) { all_mice.resize(nmice); } for(int i = 0; i < nmice; i++) { int x, y; SDL_SelectMouse(i); Uint8 button_state = SDL_GetMouseState(&x, &y); translate_mouse_coords(&x, &y); if(all_mice.size() == i) { all_mice.push_back(Mouse()); all_mice[i].active = false; } if(!all_mice[i].active) { all_mice[i].starting_x = x; all_mice[i].starting_y = y; } all_mice[i].x = x; all_mice[i].y = y; all_mice[i].active = button_state & SDL_BUTTON(SDL_BUTTON_LEFT); } #endif for(int i = 0; i < nmice; i++) { if(all_mice[i].active) { active_mice.push_back(all_mice[i]); } } }
void iphone_controls::handle_event (const SDL_Event& event) { int x = event.type == SDL_JOYBALLMOTION ? event.jball.xrel : event.jbutton.x; int y = event.type == SDL_JOYBALLMOTION ? event.jball.yrel : event.jbutton.y; int i = event.type == SDL_JOYBALLMOTION ? event.jball.ball : event.jbutton.button; std::string joy_txt = event.type == SDL_JOYBUTTONUP ? "up" : event.type == SDL_JOYBUTTONDOWN ? "down" : "move"; LOG( "mouse " << joy_txt << " (" << x << "," << y << ";" << i << ")"); translate_mouse_coords(&x, &y); while(all_mice.size() <= i) { all_mice.push_back(Mouse()); all_mice[i].active = false; } if(!all_mice[i].active) { all_mice[i].starting_x = x; all_mice[i].starting_y = y; } all_mice[i].x = x; all_mice[i].y = y; all_mice[i].active = event.type != SDL_JOYBUTTONUP; }
// this will catch all input keyboard and mouse // i may try to make a thread which continuously catches input void TSRInputSubSystem::CatchAll() { #if defined( PLATFORM_MACOSX ) || defined( WIN32 )|| defined( WIN64 ) #if defined( WIN32 )|| defined( WIN64 ) // this will hold mouse state and position, global for external use DIMOUSESTATE dInputMouseState; if ( FAILED( m_lpdimouse->GetDeviceState( sizeof( DIMOUSESTATE ), ( LPVOID ) &dInputMouseState ) ) ) { TSRFatalError( "Error reading mouse" ); } Mouse()->m_DeltaZ = dInputMouseState.lZ; #endif int iMouseX = 0; int iMouseY = 0; bool bLButtonPrevious = Mouse()->m_bLButtonDown; #ifdef TSR_SDL_ENABLED uint8 sdlMouseButtons = SDL_GetMouseState( &iMouseX, &iMouseY ); iMouseY = TSRSystem()->m_DisplayMode.m_uiHeight - iMouseY; // update mouse buttons states Mouse()->m_bLButtonDown = ( sdlMouseButtons & SDL_BUTTON( 1 ) ) != 0; Mouse()->m_bRButtonDown = ( sdlMouseButtons & SDL_BUTTON( 3 ) ) != 0; Mouse()->m_bMButtonDown = ( sdlMouseButtons & SDL_BUTTON( 2 ) ) != 0; SDL_GetRelativeMouseState( &Mouse()->m_DeltaX, &Mouse()->m_DeltaY ); #endif #if defined( WIN32 )|| defined( WIN64 ) //Mouse()->UpdateLocation( iMouseX, iMouseY ); Mouse()->m_bLButtonDown = dInputMouseState.rgbButtons[ 0 ] != 0; Mouse()->m_bRButtonDown = dInputMouseState.rgbButtons[ 1 ] != 0; Mouse()->m_bMButtonDown = dInputMouseState.rgbButtons[ 2 ] != 0; Mouse()->m_DeltaX = dInputMouseState.lX; Mouse()->m_DeltaY = dInputMouseState.lY; #endif if ( Mouse()->m_bLButtonDown && ( Mouse()->m_DeltaX || Mouse()->m_DeltaY ) ) { TSRSystem()->GetCallBacks()->OnTouchDelta( ( float ) Mouse()->m_DeltaX, ( float ) Mouse()->m_DeltaY, 3 ); } if ( Mouse()->m_bLButtonDown && !bLButtonPrevious ) { TSRSystem()->GetCallBacks()->OnTouchEvent( iMouseX, iMouseY, 0 ); } if ( !Mouse()->m_bLButtonDown && bLButtonPrevious ) { TSRSystem()->GetCallBacks()->OnTouchEvent( iMouseX, iMouseY, 1 ); } #endif }
bool CGraphicView::GetSnapped3DPoint( const CPoint& screenPt, CPoint3D& worldPt ) { // JL Note 2/15/2008 - not sure why we were return false when dragging a zoombox... // zoombox will not draw if the code below is uncommented if( /*Mouse( MOUSE_ZOOMBOX_DRAGGING ) ||*/ Mouse( MOUSE_MODEL_DRAGGING ) ) return FALSE; //this function returns true and sets worldPt to the 3D coordinates of the closest grid point, node //point or member point if a grid, node point or member is found in the selection area. //If nothing is found then it does nothing to worldPt and returns false // CTimeThisFunction timer( "GetSnapped3DPoint" ); CPoint point = screenPt; bool bSuccess = false; if( !m_hRC || !m_pDC ) { TRACE( "Failed in CGraphicView::GetSnapped3DPoint\n" ); return bSuccess; } if( !wglMakeCurrent( m_pDC->GetSafeHdc(), m_hRC ) ) { TRACE( "Failed in CGraphicView::GetSnapped3DPoint\n" ); return bSuccess; } // Create buffer to hold selection hits //(must be done before entering selection mode) // TeK Change 1/19/2009: We shouldn't be dynamically allocating memory on EVERY mouse-move! // Changed to use a static buffer (twice as big!) const int nBufSize = 4096*2; static UINT selectBuf[nBufSize]; memset( selectBuf,0, sizeof(selectBuf)); double pickSize = double(ini.size().node*5); m_Camera.StartMousePicking( point, CSize(pickSize, pickSize), nBufSize, selectBuf ); m_graphicsModel.SetWindowFilter( m_Filter ); m_graphicsModel.DrawMembersForSnapping( m_pDC ); CHitRecordCollection rRecCol; m_Camera.EndMousePicking( rRecCol, selectBuf ); //first check for node and grid hits if( m_graphicsModel.OverNodeOrGridPoint( screenPt, worldPt, m_Filter ) ) { bSuccess = true; } CPoint screenSnapPt; int screenDistanceToSnapPoint = 0; if( GetScreenPtFrom3DPoint( worldPt, screenSnapPt ) ) { screenDistanceToSnapPoint = max( abs( screenPt.x - screenSnapPt.x ), abs( screenPt.y - screenSnapPt.y ) ); } //if we have snapped to a node or grid point and the distance between //this point and the node or grid point is less than x pixels then we //stay snapped to the node or grid point //SHORT altState = GetAsyncKeyState( VK_MENU ); if( /*!(altState & 0x8000) && nHits > 0 &&*/ screenDistanceToSnapPoint > 8 ) { if( const CMember* pM = m_graphicsModel.OverMember( rRecCol ) ) { CPoint3D nearPt, farPt; if( Get3DPointFromScreen( screenPt, nearPt, 0.f ) && Get3DPointFromScreen( screenPt, farPt, 1.f ) ) { CLine3D ray( nearPt, farPt ); CPoint3D p1( pM->node(1)->x(), pM->node(1)->y(), pM->node(1)->z() ); CPoint3D p2( pM->node(2)->x(), pM->node(2)->y(), pM->node(2)->z() ); CLine3D memLine( p1, p2 ); CPoint3D pt3D = memLine.nearest_point( ray ); if( pt3D != CPoint3D::undefined_point && memLine.is_on_segment( pt3D ) ) { worldPt = pt3D; bSuccess = true; } else bSuccess = false; } } } //delete[] selectBuf; return bSuccess; }
Mouse Manager::mouse() const { return Mouse(); }
void TrackSelectionState::Update() { m_continue_button.Update(MouseInfo(Mouse())); m_back_button.Update(MouseInfo(Mouse())); if (IsKeyPressed(KeyEscape) || m_back_button.hit) { if (m_state.midi_out) m_state.midi_out->Reset(); m_state.track_properties = BuildTrackProperties(); ChangeState(new TitleState(m_state)); return; } if (IsKeyPressed(KeyEnter) || m_continue_button.hit) { if (m_state.midi_out) m_state.midi_out->Reset(); m_state.track_properties = BuildTrackProperties(); ChangeState(new PlayingState(m_state)); return; } if (IsKeyPressed(KeyDown) || IsKeyPressed(KeyRight)) { m_current_page++; if (m_current_page == m_page_count) m_current_page = 0; } if (IsKeyPressed(KeyUp) || IsKeyPressed(KeyLeft)) { m_current_page--; if (m_current_page < 0) m_current_page += m_page_count; } m_tooltip = L""; if (m_back_button.hovering) m_tooltip = L"Click to return to the title screen."; if (m_continue_button.hovering) m_tooltip = L"Click to begin playing with these settings."; // Our delta milliseconds on the first frame after we seek down to the // first note is extra long because the seek takes a while. By skipping // the "Play" that update, we don't have an artificially fast-forwarded // start. if (!m_first_update_after_seek) { PlayTrackPreview(static_cast<microseconds_t>(GetDeltaMilliseconds()) * 1000); } m_first_update_after_seek = false; // Do hit testing on each tile button on this page size_t start = m_current_page * m_tiles_per_page; size_t end = std::min( static_cast<size_t>((m_current_page+1) * m_tiles_per_page), m_track_tiles.size() ); for (size_t i = start; i < end; ++i) { TrackTile &t = m_track_tiles[i]; MouseInfo mouse = MouseInfo(Mouse()); mouse.x -= t.GetX(); mouse.y -= t.GetY(); t.Update(mouse); if (t.ButtonLeft().hovering || t.ButtonRight().hovering) { switch (t.GetMode()) { case Track::ModeNotPlayed: m_tooltip = L"Track won't be played or shown during the game."; break; case Track::ModePlayedAutomatically: m_tooltip = L"Track will be played automatically by the game."; break; case Track::ModePlayedButHidden: m_tooltip = L"Track will be played automatically by the game, but also hidden from view."; break; case Track::ModeYouPlay: m_tooltip = L"'You Play' means you want to play this track yourself."; break; } } if (t.ButtonPreview().hovering) { if (t.IsPreviewOn()) m_tooltip = L"Turn track preview off."; else m_tooltip = L"Preview how this track sounds."; } if (t.ButtonColor().hovering) m_tooltip = L"Pick a color for this track's notes."; if (t.HitPreviewButton()) { if (m_state.midi_out) m_state.midi_out->Reset(); if (t.IsPreviewOn()) { // Turn off any other preview modes for (size_t j = 0; j < m_track_tiles.size(); ++j) { if (i == j) continue; m_track_tiles[j].TurnOffPreview(); } const microseconds_t PreviewLeadIn = 25000; const microseconds_t PreviewLeadOut = 25000; m_preview_on = true; m_preview_track_id = t.GetTrackId(); m_state.midi->Reset(PreviewLeadIn, PreviewLeadOut); PlayTrackPreview(0); // Find the first note in this track so we can skip right to the good part. microseconds_t additional_time = -PreviewLeadIn; const MidiTrack &track = m_state.midi->Tracks()[m_preview_track_id]; for (size_t i = 0; i < track.Events().size(); ++i) { const MidiEvent &ev = track.Events()[i]; if (ev.Type() == MidiEventType_NoteOn && ev.NoteVelocity() > 0) { additional_time += track.EventUsecs()[i] - m_state.midi->GetDeadAirStartOffsetMicroseconds() - 1; break; } } PlayTrackPreview(additional_time); m_first_update_after_seek = true; } else { m_preview_on = false; } } } }
Input::Input(Window& window) { _mouse = Mouse(window); }
// the update function void TSRGuiFileBrowser::Update() { m_bEntered = false; TSRGuiComponent::Update(); m_VScrollBar.Update(); m_HScrollBar.Update(); if ( m_bIsUnderMouse ) { // scrolling up if ( m_VScrollBar.m_ButtonA.m_bIsHolded ) { m_VScrollBar.ScrollUp(); Refresh(); } // scrolling down if ( m_VScrollBar.m_ButtonB.m_bIsHolded ) { m_VScrollBar.ScrollDown(); Refresh(); } // scrolling right if ( m_HScrollBar.m_ButtonB.m_bIsHolded ) { m_HScrollBar.ScrollDown(); Refresh(); } // scrolling left if ( m_HScrollBar.m_ButtonA.m_bIsHolded ) { m_HScrollBar.ScrollUp(); Refresh(); } // the Z of the mouse moves up and down too if ( Mouse()->m_DeltaZ ) { if ( Mouse()->m_DeltaZ > 0 ) { m_VScrollBar.ScrollUp(); } else { m_VScrollBar.ScrollDown(); } Refresh(); } // updating the colors in case of being under mouse or not for ( unsigned int i = 0; i < m_DirectoryItems.size(); i++ ) { TSRGuiStaticText* pCurrItem = m_DirectoryItems[ i ]; pCurrItem->Update(); if ( pCurrItem->m_bIsUnderMouse ) { pCurrItem->m_TextColor = m_HotColor; } else { pCurrItem->m_TextColor = m_FolderColor; } } for ( unsigned int i = 0; i < m_FileItems.size(); i++ ) { TSRGuiStaticText* pCurrItem = m_FileItems[ i ]; pCurrItem->Update(); if ( pCurrItem->m_bIsUnderMouse ) { pCurrItem->m_TextColor = m_HotColor; } else { pCurrItem->m_TextColor = m_FileColor; } } } // only a double click can make something happens if ( IsDblClicked() ) { // if a directory is double clicked for ( unsigned int i = 0; i < m_DirectoryItems.size(); i++ ) { if ( m_DirectoryItems[ i ]->IsDblClicked() ) { int indexOffset = m_VScrollBar.m_StartIndex; const char* newSubPath = m_FoldersNames[ i + indexOffset ].c_str(); // if it . or .., change the path accordingly if ( newSubPath[ 0 ] == '.' ) { if ( newSubPath[ 1 ] == '.' ) { UpOneLevel( m_Path ); } } // otherwise just append and move to a new path else { sprintf( m_Path, "%s%s\\", m_Path,newSubPath ); } SetPath( m_Path ); return; } } //if a file is double clicked, entered becomes true and it becomes ready for reading for just one frame for ( unsigned int i = 0; i < m_FileItems.size(); i++ ) { if ( m_FileItems[ i ]->IsDblClicked() ) { unsigned int indexOffset = 0; if ( m_VScrollBar.m_StartIndex >= ( int ) m_FoldersNames.size() ) { indexOffset = ( int ) ( m_VScrollBar.m_StartIndex - m_FoldersNames.size() ); } const char* newSubPath = m_FilesNames[ i + indexOffset ].c_str(); sprintf( m_FileName, "%s%s", m_Path, newSubPath ); m_bEntered = true; return; } } } }
HID::HID( HWND p_hwnd ) { m_keyboard = Keyboard( p_hwnd ); m_mouse = Mouse( p_hwnd ); m_observable = HIDObservable(); }