ich habe mich entschlossen die Lib als Source nun anzubieten, weil sie mal wieder durch PB4.3 inkompatibel wurde und mich das Tailbite-Gepfrimel nervt.
Wie bei mir üblich, wurde nahezu gar nix kommentiert.
Hier gibts auch noch die ursprüngliche Lib-Hilfedatei.
Viel Spaß!
Code: Alles auswählen
;/---------------------------------
;|
;| G15.pb
;|
;| Main Include for playing with
;| the Logitech G15 Keyboard-Display
;|
;| You need to copy the 'lgLcd.lib'
;| to the same dir as this Header.
;| The SDK with the 'lgLcd.lib' should be here:
;| C:\Program Files\Common Files\Logitech\LCD Manager\SDK
;|
;| lglcd.h (c)Logitech,
;| G15.pb (PB-Version) (c)HeX0R
;|
;/---------------------------------
;Invalid handle definitions
CompilerIf Defined(LGLCD_INVALID_CONNECTION, #PB_Constant) = 0
#LGLCD_INVALID_CONNECTION = -1
#LGLCD_INVALID_DEVICE = -1
;Soft-Button masks
#LGLCDBUTTON_BUTTON0 = $00000001
#LGLCDBUTTON_BUTTON1 = $00000002
#LGLCDBUTTON_BUTTON2 = $00000004
#LGLCDBUTTON_BUTTON3 = $00000008
;
#LGLCD_AUDIO_WHEEL_UP = $00001000
#LGLCD_AUDIO_WHEEL_DOWN = $00001010
#LGLCD_AUDIO_SKIP_LAST = $00001020
#LGLCD_AUDIO_SKIP_NEXT = $00001040
#LGLCD_AUDIO_STOP = $00001080
#LGLCD_AUDIO_PLAY = $00001100
#LGLCD_AUDIO_MUTE = $00001200
;lgLcdBitmap
#LGLCD_BMP_FORMAT_160x43x1 = $00000001
#LGLCD_BMP_WIDTH = 160
#LGLCD_BMP_HEIGHT = 43
;Priorities
#LGLCD_PRIORITY_IDLE_NO_SHOW = 0
#LGLCD_PRIORITY_BACKGROUND = 64
#LGLCD_PRIORITY_NORMAL = 128
#LGLCD_PRIORITY_ALERT = 255
#LGLCD_LCD_FOREGROUND_APP_YES = 1
#LGLCD_LCD_FOREGROUND_APP_NO = 0
#LGLCD_APPLET_CAP_BASIC = $0000
#LGLCD_APPLET_CAP_CAN_CLOSE_DEVICE = $0001
#LGLCD_APPLET_CAP_CAN_CLOSE_CONNECTION = $0002
#LGLCD_APPLET_CAP_CAN_CLOSE_AND_REOPEN_DEVICE = $0004
#LGLCD_APPLET_CAP_CAN_RUN_ON_MULTIPLE_DEVICES = $0008
#LGLCD_NOTIFICATION_DEVICE_ARRIVAL = $0001
#LGLCD_NOTIFICATION_DEVICE_REMOVAL = $0002
#LGLCD_NOTIFICATION_CLOSE_DEVICE = $0003
#LGLCD_NOTIFICATION_CLOSE_AND_REOPEN_DEVICE = $0004
#LGLCD_NOTIFICATION_CLOSE_CONNECTION = $0005
#LGLCD_NOTIFICATION_RUN_NEW_INSTANCE_ON_DEVICE = $0006
#LGLCD_INIT_NORMAL = 0
#LGLCD_INIT_ADD_DISPLAY = $01
#LGLCD_INIT_ONLY_DISPLAY = $02
#LGLCD_INIT_NEED_EXTRA_KEYS = $04
#LGLCD_MSG_UPDATE_IMAGE = #WM_USER + 2
CompilerEndIf
#LCD_SIMULATE = $00000001
#LCD_INIT_OK = $00000002
#LCD_CONNECT_OK = $00000004
#LCD_OPEN_OK = $00000008
Prototype.l lgLcdOnConfigureCB(Connection.l, *pContext)
Prototype.l lgLcdOnNotificationCB(Connection.l, notificationCode.l, notifyParm1.l, notifyParm2.l, notifyParm3.l, notifyParm4.l)
Prototype.l lgLcdOnSoftButtonsCB(device.l, dwButtons.l, *pContext)
Structure KBDLLHOOKSTRUCT
vkCode.l
scanCode.l
flags.l
time.l
dwExtraInfo.l
EndStructure
Structure _MY_G15_GLOBALS_
Simulate.l
Device.l
Connection.l
*ConfigContext
*pContext
CB.lgLcdOnSoftButtonsCB
CB2.lgLcdOnConfigureCB
WindowID.l
ThreadID.l
ImageGadget.l
ImageID.l
Buttons.l[5]
ButtonState.l[4]
HookHandle.l
HookActivated.l
WheelCallBack.lgLcdOnSoftButtonsCB
EndStructure
CompilerIf Defined(lgLcdDeviceDesc, #PB_Structure) = 0
Structure lgLcdDeviceDesc
Width.l
Height.l
Bpp.l
NumSoftButtons.l
EndStructure
Structure lgLcdDeviceDescEx
deviceFamilyId.l
deviceDisplayName.c[#MAX_PATH]
Width.l
Height.l
Bpp.l
NumSoftButtons.l
Reserved1.l
Reserved2.l
EndStructure
Structure lgLcdBitmapHeader
Format.l
EndStructure
Structure lgLcdBitmap160x43x1
hdr.lgLcdBitmapHeader
pixels.b[#LGLCD_BMP_WIDTH * #LGLCD_BMP_HEIGHT]
EndStructure
Structure lgLcdConfigureContext
;configCallback.lgLcdOnConfigureCB
*configCallback
*configContext
EndStructure
Structure lgLcdNotificationContext
;notificationCallback.lgLcdOnNotificationCB
*notificationCallback
*notificationContext
EndStructure
Structure lgLcdConnectContext
*appFriendlyName
isPersistent.l
isAutostartable.l
onConfigure.lgLcdConfigureContext
connection.l
EndStructure
Structure lgLcdConnectContextEx
*appFriendlyName
isPersistent.l
isAutostartable.l
onConfigure.lgLcdConfigureContext
Connection.l
dwAppletCapabilitiesSupported.l
dwReserved1.l
onNotify.lgLcdNotificationContext
EndStructure
Structure lgLcdSoftbuttonsChangedContext
;softbuttonsChangedCallback.lgLcdOnSoftButtonsCB
*softbuttonsChangedCallback
*softbuttonsChangedContext
EndStructure
Structure lgLcdOpenContext
connection.l
index.l
onSoftbuttonsChanged.lgLcdSoftbuttonsChangedContext
device.l
EndStructure
CompilerEndIf
Global MyG15._MY_G15_GLOBALS_
Procedure.l MY_lgLcdOnSoftButtonsCB(device.l, dwButtons.l, *pContext)
If MyG15\WindowID
If dwButtons & #LGLCDBUTTON_BUTTON0
SetGadgetText(MyG15\Buttons[0], "< 1 >")
Else
SetGadgetText(MyG15\Buttons[0], "1")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON1
SetGadgetText(MyG15\Buttons[1], "< 2 >")
Else
SetGadgetText(MyG15\Buttons[1], "2")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON2
SetGadgetText(MyG15\Buttons[2], "< 3 >")
Else
SetGadgetText(MyG15\Buttons[2], "3")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON3
SetGadgetText(MyG15\Buttons[3], "< 4 >")
Else
SetGadgetText(MyG15\Buttons[3], "4")
EndIf
EndIf
If MyG15\CB
MyG15\CB(device.l, dwButtons.l, *pContext)
EndIf
EndProcedure
Procedure.l G15_KeyboardHook(nCode.l, wParam.l, *p.KBDLLHOOKSTRUCT)
If nCode = #HC_ACTION And wParam = #WM_KEYDOWN And MyG15\HookActivated And MyG15\WheelCallBack
Select *p\vkCode
Case 173
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_MUTE, MyG15\pContext)
Case 174
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_WHEEL_DOWN, MyG15\pContext)
Case 175
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_WHEEL_UP, MyG15\pContext)
Case 176
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_SKIP_NEXT, MyG15\pContext)
Case 177
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_SKIP_LAST, MyG15\pContext)
Case 178
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_STOP, MyG15\pContext)
Case 179
MyG15\WheelCallBack(MyG15\device, #LGLCD_AUDIO_PLAY, MyG15\pContext)
EndSelect
EndIf
ProcedureReturn CallNextHookEx_(0, nCode, wParam, *p)
EndProcedure
Procedure Open_Config_Window(Dummy.l)
If MyG15\CB2
MyG15\CB2(MyG15\Connection, MyG15\configContext)
EndIf
EndProcedure
Procedure Open_Window_LCD(Status.l)
Protected y.l = 140, ThreadID.l, T.l = -1
If Status
y = 160
EndIf
MyG15\WindowID = OpenWindow(#PB_Any, 434, 217, 330, y, "LCD-Display Simulation", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_TitleBar)
If MyG15\WindowID
MyG15\ImageGadget = ImageGadget(#PB_Any, 5, 5, 320, 86, 0, #PB_Image_Border)
MyG15\Buttons[0] = ButtonGadget(#PB_Any, 25, 110, 40, 20, "1")
MyG15\Buttons[1] = ButtonGadget(#PB_Any, 80, 110, 40, 20, "2")
MyG15\Buttons[2] = ButtonGadget(#PB_Any, 215, 110, 40, 20, "3")
MyG15\Buttons[3] = ButtonGadget(#PB_Any, 270, 110, 40, 20, "4")
If Status
MyG15\Buttons[4] = ButtonGadget(#PB_Any, 135, 135, 60, 20, "Config")
EndIf
StickyWindow(MyG15\WindowID, #True)
Repeat
Select WaitWindowEvent(T)
Case 0
If ThreadID And IsThread(ThreadID) = 0
ThreadID = 0
T = -1
EndIf
Case #PB_Event_CloseWindow
If EventWindow() = MyG15\WindowID
MyG15\WindowID = 0
Break
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case MyG15\Buttons[0]
If MyG15\CB
MyG15\CB(MyG15\device, #LGLCDBUTTON_BUTTON0, MyG15\pContext)
EndIf
Case MyG15\Buttons[1]
If MyG15\CB
MyG15\CB(MyG15\device, #LGLCDBUTTON_BUTTON1, MyG15\pContext)
EndIf
Case MyG15\Buttons[2]
If MyG15\CB
MyG15\CB(MyG15\device, #LGLCDBUTTON_BUTTON2, MyG15\pContext)
EndIf
Case MyG15\Buttons[3]
If MyG15\CB
MyG15\CB(MyG15\device, #LGLCDBUTTON_BUTTON3, MyG15\pContext)
EndIf
Case MyG15\Buttons[4]
If MyG15\CB2 And ThreadID = 0
ThreadID = CreateThread(@Open_Config_Window(), 0)
T = 100
EndIf
EndSelect
Case #LGLCD_MSG_UPDATE_IMAGE
If IsImage(MyG15\ImageID)
SetGadgetState(MyG15\ImageGadget, ImageID(MyG15\ImageID))
EndIf
EndSelect
ForEver
MyG15\ThreadID = 0
EndIf
If IsThread(ThreadID)
KillThread(ThreadID)
ThreadID = 0
EndIf
EndProcedure
ProcedureDLL.l LGLCD_SYNC_UPDATE(priority.l)
ProcedureReturn ($80000000 | priority)
EndProcedure
ProcedureDLL.l LGLCD_ASYNC_UPDATE(priority.l)
ProcedureReturn priority
EndProcedure
ProcedureDLL.l LGLCD_SYNC_COMPLETE_WITHIN_FRAME(priority.l)
ProcedureReturn ($C0000000 | priority)
EndProcedure
;Callback used To notify client of soft button change
;Declare.l lgLcdOnSoftButtonsCB(device.l, dwButtons, pContext.l)
;Callback used To allow client To pop up a "configuration panel"
;Declare.l lgLcdOnConfigureCB(connection.l, pContect.l)
Import "lgLcd.lib"
lgLcdInit__.l() As "_lgLcdInit@0"
lgLcdDeInit__.l() As "_lgLcdDeInit@0"
CompilerIf #PB_Compiler_Unicode
lgLcdConnect__.l(*ctx.lgLcdConnectContext) As "_lgLcdConnectW@4"
lgLcdConnectEx__.l(*ctx.lgLcdConnectContextEx) As "_lgLcdConnectExW@4"
lgLcdEnumerateEx__.l(connection.l, index.l, *description.lgLcdDeviceDescEx) As "_lgLcdEnumerateExW@12"
CompilerElse
lgLcdConnect__.l(*ctx.lgLcdConnectContext) As "_lgLcdConnectA@4"
lgLcdConnectEx__.l(*ctx.lgLcdConnectContextEx) As "_lgLcdConnectExA@4"
lgLcdEnumerateEx__.l(connection.l, index.l, *description.lgLcdDeviceDescEx) As "_lgLcdEnumerateExA@12"
CompilerEndIf
lgLcdDisconnect__.l(connection.l) As "_lgLcdDisconnect@4"
lgLcdSetDeviceFamiliesToUse__.l(connection.l, dwDeviceFamiliesSupported.l, dwReserved1.l) As "_lgLcdSetDeviceFamiliesToUse@12"
lgLcdEnumerate__.l(connection.l, index.l, *description.lgLcdDeviceDesc) As "_lgLcdEnumerate@12"
lgLcdOpen__.l(*ctx.lgLcdOpenContext) As "_lgLcdOpen@4"
lgLcdClose__.l(device.l) As "_lgLcdClose@4"
lgLcdReadSoftButtons__.l(device.l, *buttons) As "_lgLcdReadSoftButtons@8"
lgLcdUpdateBitmap__.l(device.l, *bitmap.lgLcdBitmapHeader, priority.l) As "_lgLcdUpdateBitmap@12"
lgLcdSetAsLCDForegroundApp__.l(device.l, foregroundYesNoFlag.l) As "_lgLcdSetAsLCDForegroundApp@8"
EndImport
ProcedureDLL.l lgLcdInit(Init.l = 0)
Protected Result.l = #ERROR_SUCCESS, i.l
If Init = 0
MyG15\Simulate = #False
ProcedureReturn lgLcdInit__()
EndIf
If Init & (#LGLCD_INIT_ADD_DISPLAY | #LGLCD_INIT_ONLY_DISPLAY)
MyG15\Simulate = #LCD_SIMULATE
EndIf
If Init & (#LGLCD_INIT_ADD_DISPLAY | #LGLCD_INIT_ONLY_DISPLAY) < #LGLCD_INIT_ONLY_DISPLAY
Result = lgLcdInit__()
If Result = #ERROR_SUCCESS
MyG15\Simulate | #LCD_INIT_OK
EndIf
EndIf
If Init & #LGLCD_INIT_NEED_EXTRA_KEYS
MyG15\HookHandle = SetWindowsHookEx_(#WH_KEYBOARD_LL, @G15_KeyboardHook(), GetModuleHandle_(0), #Null)
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdDeInit()
Protected Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_INIT_OK
Result = lgLcdDeInit__()
EndIf
MyG15\Simulate = #False
If MyG15\HookHandle
UnhookWindowsHookEx_(MyG15\HookHandle)
MyG15\HookHandle = 0
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdConnect(*ctx.lgLcdConnectContext)
Protected Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_INIT_OK
Result = lgLcdConnect__(*ctx)
If Result = #ERROR_SUCCESS
MyG15\Simulate | #LCD_CONNECT_OK
MyG15\Connection = *ctx\connection
MyG15\CB2 = *ctx\onConfigure\configCallback
MyG15\ConfigContext = *ctx\onConfigure\configcontext
EndIf
Else
*ctx\connection = 1
MyG15\Connection = *ctx\connection
MyG15\CB2 = *ctx\onConfigure\configCallback
MyG15\ConfigContext = *ctx\onConfigure\configcontext
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdConnectEx(*ctx.lgLcdConnectContextEx)
Protected Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_INIT_OK
Result = lgLcdConnectEx__(*ctx)
If Result = #ERROR_SUCCESS
MyG15\Simulate | #LCD_CONNECT_OK
MyG15\Connection = *ctx\connection
MyG15\CB2 = *ctx\onConfigure\configCallback
MyG15\ConfigContext = *ctx\onConfigure\configcontext
EndIf
Else
*ctx\connection = 1
MyG15\Connection = *ctx\connection
MyG15\CB2 = *ctx\onConfigure\configCallback
MyG15\ConfigContext = *ctx\onConfigure\configcontext
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdDisconnect(connection.l)
Protected Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_CONNECT_OK
Result = lgLcdDisconnect__(connection)
EndIf
MyG15\CB2 = 0
MyG15\ConfigContext = 0
MyG15\Connection = 0
MyG15\Simulate & ($FFFFFFFF - #LCD_CONNECT_OK)
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdOpen(*ctx.lgLcdOpenContext)
Protected TimeOUT.l, Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE
MyG15\CB = *ctx\OnSoftButtonsChanged\softbuttonsChangedCallback
*ctx\OnSoftButtonsChanged\softbuttonsChangedCallback = @MY_lgLcdOnSoftButtonsCB()
EndIf
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_INIT_OK
Result = lgLcdOpen__(*ctx)
MyG15\Device = *ctx\device
If Result = #ERROR_SUCCESS
MyG15\Simulate | #LCD_OPEN_OK
EndIf
EndIf
If MyG15\Simulate & #LCD_SIMULATE
MyG15\ImageID = CreateImage(#PB_Any, 320, 86)
If MyG15\Simulate & #LCD_INIT_OK = 0 And MyG15\CB2
MyG15\ThreadID = CreateThread(@Open_Window_LCD(), 1)
Else
MyG15\ThreadID = CreateThread(@Open_Window_LCD(), 0)
EndIf
If MyG15\Simulate & (#LCD_SIMULATE | #LCD_INIT_OK) = #LCD_SIMULATE
TimeOUT = ElapsedMilliseconds() + 500
Repeat
Delay(10)
Until MyG15\WindowID Or TimeOUT < ElapsedMilliseconds()
If MyG15\WindowID
*ctx\device = WindowID(MyG15\WindowID)
MyG15\Device = *ctx\device
EndIf
EndIf
EndIf
MyG15\WheelCallBack = *ctx\onSoftbuttonsChanged\softbuttonsChangedCallback
MyG15\pContext = *ctx\OnSoftButtonsChanged\softbuttonsChangedContext
MyG15\Device = *ctx\device
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdClose(device.l)
Protected Result.l = #ERROR_SUCCESS
If MyG15\HookHandle
UnhookWindowsHookEx_(MyG15\HookHandle)
MyG15\HookHandle = 0
EndIf
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_OPEN_OK
Result = lgLcdClose__(device)
EndIf
MyG15\Simulate & ($FFFFFFFF - #LCD_OPEN_OK)
MyG15\CB = 0
MyG15\Device = 0
MyG15\pContext = 0
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdSetDeviceFamiliesToUse(connection.l, dwDeviceFamiliesSupported.l, dwReserved1.l)
ProcedureReturn lgLcdSetDeviceFamiliesToUse__(connection, dwDeviceFamiliesSupported, dwReserved1)
EndProcedure
ProcedureDLL.l lgLcdEnumerate(connection.l, index.l, *description.lgLcdDeviceDesc)
ProcedureReturn lgLcdEnumerate__(connection, index, *description)
EndProcedure
ProcedureDLL.l lgLcdEnumerateEx(connection.l, index.l, *description.lgLcdDeviceDescEx)
ProcedureReturn lgLcdEnumerateEx__(connection, index, *description)
EndProcedure
ProcedureDLL.l lgLcdReadSoftButtons(device.l, *buttons)
ProcedureReturn lgLcdReadSoftButtons__(device, *buttons)
EndProcedure
Procedure G15_MakeImage(Image, *bitmap.lgLcdBitmap160x43x1, Invers = 0)
Protected A, x, y, w, h, d, Result, hDC, *bmi.BITMAPINFO, *Buffer
Protected *HB.BYTE, *HW.WORD, *HL.LONG, *H2.LONG
If IsImage(Image) = 0
ProcedureReturn #False
EndIf
w = ImageWidth(Image)
h = ImageHeight(Image)
d = ImageDepth(Image)
; If w > #LGLCD_BMP_WIDTH Or h > #LGLCD_BMP_HEIGHT
; ProcedureReturn #False
; EndIf
; fix widths and heights
If d = 1
d = 8
EndIf
If w > #LGLCD_BMP_WIDTH
w = #LGLCD_BMP_WIDTH
h = h * #LGLCD_BMP_WIDTH / ImageWidth(Image)
If h > #LGLCD_BMP_HEIGHT
h = #LGLCD_BMP_HEIGHT
w = w * #LGLCD_BMP_HEIGHT / ImageHeight(Image)
EndIf
ElseIf h > #LGLCD_BMP_HEIGHT
h = #LGLCD_BMP_HEIGHT
w = w * #LGLCD_BMP_HEIGHT / ImageHeight(Image)
If w > #LGLCD_BMP_WIDTH
w = #LGLCD_BMP_WIDTH
h = h * #LGLCD_BMP_WIDTH / ImageWidth(Image)
EndIf
EndIf
If w <> ImageWidth(Image) Or h <> ImageHeight(Image)
ResizeImage(Image, w, h)
EndIf
If MyG15\Simulate & #LCD_SIMULATE
CopyImage(Image, MyG15\ImageID)
ResizeImage(MyG15\ImageID, w*2, h*2)
If *bitmap = 0
ProcedureReturn #True
EndIf
EndIf
*bitmap\hdr\Format = #LGLCD_BMP_FORMAT_160x43x1
hDC = StartDrawing(ImageOutput(Image))
If hDC
*bmi = AllocateMemory(SizeOf(BITMAPINFO) + 255 * SizeOf(RGBQUAD))
If *bmi
*bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
*bmi\bmiheader\biWidth = w
*bmi\bmiheader\biHeight = - h
*bmi\bmiheader\biPlanes = 1
*bmi\bmiheader\biBitCount = d
*bmi\bmiheader\biCompression = #BI_RGB
*Buffer = AllocateMemory(w * h * (d / 8))
If *Buffer = 0
StopDrawing()
Else
Result = GetDIBits_(hDC, ImageID(Image), 0, h, *Buffer, *bmi, #DIB_RGB_COLORS)
StopDrawing()
If Result
Select d
Case 8
*HB = *Buffer
For y = 0 To #LGLCD_BMP_HEIGHT - 1
For x = 0 To #LGLCD_BMP_WIDTH - 1
If y >= h Or x >= w
A = 255
Else
*H2 = *bmi\bmiColors + (*HB\b & $FF) * SizeOf(RGBQUAD)
A = (*H2\l & $FF) + ((*H2\l >> 8) & $FF) + ((*H2\l >> 16) & $FF)
*HB + 1
EndIf
If Invers
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = B / 3
Else
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = 255 - (A / 3)
EndIf
Next x
Next y
Case 16
*HW = *Buffer
For y = 0 To #LGLCD_BMP_HEIGHT - 1
For x = 0 To #LGLCD_BMP_WIDTH - 1
If y >= h Or x >= w
A = 510
Else
A = (*HW\w & $ff) + ((*HW\w >> 8) & $ff)
*HW + 2
EndIf
If Invers
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = A / 2
Else
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = 255 - (A / 2)
EndIf
Next x
Next y
Case 24
*HL = *Buffer
For y = 0 To #LGLCD_BMP_HEIGHT - 1
For x = 0 To #LGLCD_BMP_WIDTH - 1
If y >= h Or x >= w
A = 765
Else
A = (*HL\l & $FF) + ((*HL\l >> 8) & $FF) + ((*HL\L >> 16) & $FF)
*HL + 3
EndIf
If Invers
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = A / 3
Else
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = 255 - (A / 3)
EndIf
Next x
Next y
Case 32
*HL = *Buffer
For y = 0 To #LGLCD_BMP_HEIGHT - 1
For x = 0 To #LGLCD_BMP_WIDTH - 1
If y >= h Or x >= w
A = 765
Else
A = (*HL\l & $FF) + ((*HL\l >> 8) & $FF) + ((*HL\L >> 16) & $FF)
*HL + 4
EndIf
If Invers
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = A / 3
Else
*bitmap\pixels[y * #LGLCD_BMP_WIDTH + x] = 255 - (A / 3)
EndIf
Next x
Next y
EndSelect
EndIf
FreeMemory(*Buffer)
EndIf
FreeMemory(*bmi)
Else
StopDrawing()
EndIf
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdUpdateBitmap(device.l, Image.l, priority.l)
Protected *bitmap, Result.l = #ERROR_SUCCESS
If MyG15\Simulate & #LCD_SIMULATE = 0 Or MyG15\Simulate & #LCD_INIT_OK
*bitmap = AllocateMemory(SizeOf(lgLcdBitmap160x43x1))
If *bitmap
Result = #ERROR_INVALID_PARAMETER
If G15_MakeImage(Image, *bitmap)
Result = lgLcdUpdateBitmap__(device, *bitmap, priority)
EndIf
FreeMemory(*bitmap)
EndIf
Else
G15_MakeImage(Image, 0)
EndIf
If MyG15\WindowID And IsImage(MyG15\ImageID)
PostMessage_(WindowID(MyG15\WindowID), #LGLCD_MSG_UPDATE_IMAGE, #Null, #Null)
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL.l lgLcdSetAsLCDForegroundApp(device.l, foregroundYesNoFlag.l)
ProcedureReturn lgLcdSetAsLCDForegroundApp__(device, foregroundYesNoFlag)
EndProcedure
ProcedureDLL.l lgLcdUseExtraKeys(Mode.l)
If Mode = 0
MyG15\HookActivated = 0
Else
MyG15\HookActivated = #True
EndIf
If MyG15\HookHandle
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
ProcedureDLL MyLib_End()
If MyG15\HookHandle
UnhookWindowsHookEx_(MyG15\HookHandle)
EndIf
EndProcedure