2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
13 SetCursorShape(uint16 width
, uint16 height
, uint16 hot_x
, uint16 hot_y
,
14 uint8
* andMask
, uint8
* xorMask
)
16 // NOTE: Currently, for BeOS, cursor width and height must be equal to 16.
18 if ((width
!= 16) || (height
!= 16)) {
20 } else if ((hot_x
>= width
) || (hot_y
>= height
)) {
23 // Update cursor variables appropriately.
25 SharedInfo
& si
= *gInfo
.sharedInfo
;
26 si
.cursorHotX
= hot_x
;
27 si
.cursorHotY
= hot_y
;
29 if ( ! gInfo
.LoadCursorImage(width
, height
, andMask
, xorMask
))
38 MoveCursor(uint16 xPos
, uint16 yPos
)
40 // Move the cursor to the specified position on the desktop. If we're
41 // using some kind of virtual desktop, adjust the display start position
42 // accordingly and position the cursor in the proper "virtual" location.
44 int x
= xPos
; // use signed int's since chip specific functions
45 int y
= yPos
; // need signed int to determine if cursor off screen
47 SharedInfo
& si
= *gInfo
.sharedInfo
;
48 DisplayModeEx
& dm
= si
.displayMode
;
50 uint16 hds
= dm
.h_display_start
; // current horizontal starting pixel
51 uint16 vds
= dm
.v_display_start
; // current vertical starting line
53 // Clamp cursor to virtual display.
54 if (x
>= dm
.virtual_width
)
55 x
= dm
.virtual_width
- 1;
56 if (y
>= dm
.virtual_height
)
57 y
= dm
.virtual_height
- 1;
59 // Adjust h/v display start to move cursor onto screen.
60 if (x
>= (dm
.timing
.h_display
+ hds
))
61 hds
= x
- dm
.timing
.h_display
+ 1;
65 if (y
>= (dm
.timing
.v_display
+ vds
))
66 vds
= y
- dm
.timing
.v_display
+ 1;
70 // Reposition the desktop on the display if required.
71 if (hds
!= dm
.h_display_start
|| vds
!= dm
.v_display_start
)
72 MoveDisplay(hds
, vds
);
74 // Put cursor in correct physical position.
75 x
-= (hds
+ si
.cursorHotX
);
76 y
-= (vds
+ si
.cursorHotY
);
78 // Position the cursor on the display.
79 gInfo
.SetCursorPosition(x
, y
);