Changeset 645 for abuse/trunk/src/sdlport/mouse.cpp
- Timestamp:
- May 13, 2011, 1:36:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/sdlport/mouse.cpp
r579 r645 50 50 // Constructor 51 51 // 52 JCMouse::JCMouse( image *Screen, palette *pal)52 JCMouse::JCMouse(image *screen, palette *pal) 53 53 { 54 54 image *im; … … 58 58 cx = cy = 0; 59 59 here = 1; 60 sp = NULL;61 60 62 screen = Screen;61 m_screen = screen; 63 62 br = pal->brightest( 1 ); 64 63 dr = pal->darkest( 1 ); … … 77 76 JCMouse::~JCMouse() 78 77 { 79 if( sp ) 80 { 81 delete sp->visual; 82 delete sp; 83 } 78 delete sp->visual; 79 delete sp; 84 80 } 85 81 … … 88 84 // Set the shape of the mouse cursor 89 85 // 90 void JCMouse::set_shape( image *im, int centerx, int centery)86 void JCMouse::set_shape(image *im, int centerx, int centery) 91 87 { 92 sp->change_visual( im, 1);88 sp->change_visual(im, 1); 93 89 cx = -centerx; 94 90 cy = -centery; … … 99 95 // Set the position of the mouse cursor 100 96 // 101 void JCMouse::set_position( int new_mx, int new_my)97 void JCMouse::set_position(int new_mx, int new_my) 102 98 { 103 99 // Make sure the values we are given are sensible. 104 if( new_mx > screen->Size().x - 1 ) 105 { 106 new_mx = screen->Size().x - 1; 107 } 108 if( new_my > screen->Size().y - 1 ) 109 { 110 new_my = screen->Size().y - 1; 111 } 100 mx = Min(new_mx, m_screen->Size().x - 1); 101 my = Min(new_my, m_screen->Size().y - 1); 112 102 113 103 // Set the new position 114 mx = new_mx; 115 my = new_my; 116 SDL_WarpMouse( new_mx, new_my ); 104 SDL_WarpMouse(mx, my); 117 105 } 118 106 119 107 // 120 108 // update() 121 // Update the mouse s position and buttonsstates109 // Update the mouse position and button states 122 110 // 123 void JCMouse::update( int newx, int newy, int new_but)111 void JCMouse::update(int newx, int newy, int new_but) 124 112 { 125 if ( newx < 0)113 if (newx < 0) 126 114 { 127 Uint8 mask;128 129 115 lx = mx; 130 116 ly = my; 131 117 lbut = but; 132 mask = SDL_GetMouseState( &mx, &my ); 133 but = ( ( mask & SDL_BUTTON(1) ) != 0 ) | 134 ( ( mask & SDL_BUTTON(2) ) != 0 ) << 2 | 135 ( ( mask & SDL_BUTTON(3) ) != 0 ) << 1; 118 119 uint8_t mask = SDL_GetMouseState(&mx, &my); 120 but = ((mask & SDL_BUTTON(1)) != 0) | 121 ((mask & SDL_BUTTON(2)) != 0) << 2 | 122 ((mask & SDL_BUTTON(3)) != 0) << 1; 136 123 } 137 124 else … … 142 129 } 143 130 } 131
Note: See TracChangeset
for help on using the changeset viewer.