So. Nun hab ich das auch mit den Symbolen hinbekommen.
Das Ganze ist für Windows (das Beispiel ist auf Win7 x64 und einer G19 getestet) und PB5.21 (Modul)
Anbei noch ein Thread, der ein Event an ein vorhandenes Window sendet, wenn ein Button gedrückt wurde.
Ich hoffe es ist relativ selbsterklärend...
Ansonsten gilt ! : Fragen und Verbesserungsvorschläge ... Her damit
Code: Alles auswählen
DeclareModule LGSDK
;:- There is one event for the button
;:- here you have to change the enumeration start value
;:- if it troubles with your own...
Enumeration #PB_Event_FirstCustomValue
#LGSDK_Button
EndEnumeration
;:-
;:- Logitech Gaming LCD SDK V1.01 (Driver >8.50)
;:- Copyright (C) 2011-2012 Logitech. All rights reserved.
;:-
;:- Supported Displays :
;:- Color LCD, resolution of 320 by 240 pixels, full RGBA : G19, G19s
;:- Monochrome LCD, resolution of 160 by 43 pixels : G510, G13, G15v1, G15v2
;:-
;:- no UDK functions. (Is someone using the UnReal Engine with PureBasic ???)
;:-
#LOGI_LCD_TYPE_MONO = $00000001
#LOGI_LCD_TYPE_COLOR = $00000002
#LOGI_LCD_MONO_BUTTON_0 = $00000001
#LOGI_LCD_MONO_BUTTON_1 = $00000002
#LOGI_LCD_MONO_BUTTON_2 = $00000004
#LOGI_LCD_MONO_BUTTON_3 = $00000008
#LOGI_LCD_COLOR_BUTTON_LEFT = $00000100
#LOGI_LCD_COLOR_BUTTON_RIGHT = $00000200
#LOGI_LCD_COLOR_BUTTON_OK = $00000400
#LOGI_LCD_COLOR_BUTTON_CANCEL = $00000800
#LOGI_LCD_COLOR_BUTTON_UP = $00001000
#LOGI_LCD_COLOR_BUTTON_DOWN = $00002000
#LOGI_LCD_COLOR_BUTTON_MENU = $00004000
#LOGI_LCD_MONO_WIDTH = 160
#LOGI_LCD_MONO_HEIGHT = 43
#LOGI_LCD_COLOR_WIDTH = 320
#LOGI_LCD_COLOR_HEIGHT = 240
Declare LcdInit(AppName.s, lcdType.l = #LOGI_LCD_TYPE_COLOR | #LOGI_LCD_TYPE_MONO)
Declare LcdIsButton(Button)
Declare LcdUpdate()
Declare LcdShutDown()
Declare LcdSetBackground(Image)
Declare LcdSetText(LineNumber, Text.s, Red = 255, Green = 255, Blue = 255)
Declare LcdSetTitle(Text.s, Red = 255, Green = 255, Blue = 255)
Declare LcdButtonInit(Window, Delay = 200)
EndDeclareModule
Module LGSDK
EnableExplicit
Structure struct_lgsdk_data
Init.i
Color.i
bCount.i
thread.i
halt.i
tDelay.i
Size.POINT
Array BitMapArray.b(1)
EndStructure
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
Import "x64\LogitechLcd.lib"
LogiLcdInit.b(appName.p-unicode, lcdType.l) As "?LogiLcdInit@@YA_NPEA_WH@Z"
LogiLcdIsConnected.b(lcdType.l) As "?LogiLcdIsConnected@@YA_NH@Z"
LogiLcdIsButtonPressed.b(button.l) As "?LogiLcdIsButtonPressed@@YA_NH@Z"
LogiLcdUpdate() As "?LogiLcdUpdate@@YAXXZ"
LogiLcdShutdown() As "?LogiLcdShutdown@@YAXXZ"
LogiLcdMonoSetBackground.b(*MonoBitMapArray) As "?LogiLcdMonoSetBackground@@YA_NQEAE@Z"
LogiLcdMonoSetText.b(linenumber.l, text.p-Unicode) As "?LogiLcdMonoSetText@@YA_NHPEA_W@Z"
LogiLcdColorSetBackground.b(*ColorBitMapArray) As "?LogiLcdColorSetBackground@@YA_NQEAE@Z"
LogiLcdColorSetTitle.b(text.p-Unicode, red.l = 255, green.l = 255, blue.l = 255) As "?LogiLcdColorSetTitle@@YA_NPEA_WHHH@Z"
LogiLcdColorSetText.b(lineNumber.l, text.p-Unicode, red.l = 255, green.l = 255, blue.l = 255) As "?LogiLcdColorSetText@@YA_NHPEA_WHHH@Z"
EndImport
CompilerElse
Import "x86\LogitechLcd.lib"
LogiLcdInit.b(appName.p-unicode, lcdType.l) As "?LogiLcdInit@@YA_NPA_WH@Z"
LogiLcdIsConnected.b(lcdType.l) As "?LogiLcdIsConnected@@YA_NH@Z"
LogiLcdIsButtonPressed.b(button.l) As "?LogiLcdIsButtonPressed@@YA_NH@Z"
LogiLcdUpdate() As "?LogiLcdUpdate@@YAXXZ"
LogiLcdShutdown() As "?LogiLcdShutdown@@YAXXZ"
LogiLcdMonoSetBackground.b(*MonoBitMapArray) As "?LogiLcdMonoSetBackground@@YA_NQAE@Z"
LogiLcdMonoSetText.b(linenumber.l, text.p-Unicode) As "?LogiLcdMonoSetText@@YA_NHPA_W@Z"
LogiLcdColorSetBackground.b(*ColorBitMapArray) As "?LogiLcdColorSetBackground@@YA_NQAE@Z"
LogiLcdColorSetTitle.b(text.p-Unicode, red.l = 255, green.l = 255, blue.l = 255) As "?LogiLcdColorSetTitle@@YA_NPA_WHHH@Z"
LogiLcdColorSetText.b(lineNumber.l, text.p-Unicode, red.l = 255, green.l = 255, blue.l = 255) As "?LogiLcdColorSetText@@YA_NHPA_WHHH@Z"
EndImport
CompilerEndIf
Global LogiLcd.struct_lgsdk_data
Procedure LcdInit(AppName.s, lcdType.l = #LOGI_LCD_TYPE_COLOR | #LOGI_LCD_TYPE_MONO)
Protected Result.b = #False
Result = LogiLcdInit(AppName, lcdType)
If Result
If LogiLcdIsConnected(#LOGI_LCD_TYPE_COLOR)
LogiLcd\Color = #True
LogiLcd\bCount = 32
LogiLcd\Size\x = #LOGI_LCD_COLOR_WIDTH
LogiLcd\Size\y = #LOGI_LCD_COLOR_HEIGHT
Dim LogiLcd\BitMapArray(#LOGI_LCD_COLOR_WIDTH * #LOGI_LCD_COLOR_HEIGHT * 4)
ElseIf LogiLcdIsConnected(#LOGI_LCD_TYPE_MONO)
LogiLcd\Color = #False
LogiLcd\bCount = 8
LogiLcd\Size\x = #LOGI_LCD_MONO_WIDTH
LogiLcd\Size\y = #LOGI_LCD_MONO_HEIGHT
Dim LogiLcd\BitMapArray(#LOGI_LCD_MONO_WIDTH * #LOGI_LCD_MONO_HEIGHT)
EndIf
LogiLcd\Init = #True
Else
CompilerIf #PB_Compiler_Debugger
Debug "LcdInit : Could not connect display!"
CompilerElse
MessageRequester("Error", "Could not connect display !")
CompilerEndIf
EndIf
ProcedureReturn LogiLcd\Init
EndProcedure
Procedure LcdIsButton(Button)
Protected Result = #False
If LogiLcd\Init
Result = LogiLcdIsButtonPressed(Button) - Button
EndIf
ProcedureReturn Result
EndProcedure
Procedure LcdUpdate()
If LogiLcd\Init
LogiLcdUpdate()
EndIf
EndProcedure
Procedure LcdShutDown()
If LogiLcd\Init
If IsThread(LogiLcd\thread)
LogiLcd\halt = #True
WaitThread(LogiLcd\thread)
LogiLcd\thread = #False
EndIf
LogiLcdShutdown()
LogiLcd\Init = #False
LogiLcd\Color = #False
LogiLcd\bCount = 8
LogiLcd\Size\x = #LOGI_LCD_MONO_WIDTH
LogiLcd\Size\y = #LOGI_LCD_MONO_HEIGHT
FreeArray(LogiLcd\BitMapArray())
EndIf
EndProcedure
Procedure LcdButtonThread(Window)
If LogiLcd\Init
Repeat
If LogiLcd\halt = #True
Break
EndIf
If IsWindow(Window)
If LogiLcd\Color = #False
If LcdIsButton(#LOGI_LCD_MONO_BUTTON_0)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_MONO_BUTTON_0)
ElseIf LcdIsButton(#LOGI_LCD_MONO_BUTTON_1)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_MONO_BUTTON_1)
ElseIf LcdIsButton(#LOGI_LCD_MONO_BUTTON_2)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_MONO_BUTTON_2)
ElseIf LcdIsButton(#LOGI_LCD_MONO_BUTTON_3)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_MONO_BUTTON_3)
EndIf
Else
If LcdIsButton(#LOGI_LCD_COLOR_BUTTON_LEFT)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_LEFT)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_RIGHT)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_RIGHT)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_OK)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_OK)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_CANCEL)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_CANCEL)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_UP)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_UP)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_DOWN)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_DOWN)
ElseIf LcdIsButton(#LOGI_LCD_COLOR_BUTTON_MENU)
PostEvent(#LGSDK_Button, Window, #LOGI_LCD_COLOR_BUTTON_MENU)
EndIf
EndIf
EndIf
Delay(LogiLcd\tDelay)
ForEver
EndIf
EndProcedure
Procedure LcdButtonInit(Window, Delay = 200)
If IsWindow(Window)
If LogiLcd\Init
If Not IsThread(LogiLcd\thread)
LogiLcd\halt = #False
LogiLcd\tDelay = Delay
LogiLcd\thread = CreateThread(@LcdButtonThread(), Window)
EndIf
EndIf
EndIf
EndProcedure
Procedure LcdSetBackground(Image)
Protected hDC, i, Result, Mono = #LOGI_LCD_MONO_WIDTH * #LOGI_LCD_MONO_HEIGHT
Protected BMINFO.BITMAPINFO
If Not LogiLcd\Init : ProcedureReturn #False : EndIf
If Not IsImage(Image) : ProcedureReturn #False : EndIf
If LogiLcd\Size\x <> ImageWidth(Image) Or LogiLcd\Size\y <> ImageHeight(Image)
ResizeImage(Image, LogiLcd\Size\x, LogiLcd\Size\y)
EndIf
BMINFO\bmiHeader\biSize = SizeOf(BITMAPINFO)
BMINFO\bmiheader\biWidth = LogiLcd\Size\x
BMINFO\bmiheader\biHeight = -(LogiLcd\Size\y)
BMINFO\bmiheader\biPlanes = 1
BMINFO\bmiheader\biCompression = #BI_RGB
BMINFO\bmiheader\biBitCount = LogiLcd\bCount
hDC = StartDrawing(ImageOutput(Image))
If hDC
Result = GetDIBits_(hDC, ImageID(Image), 0, LogiLcd\Size\y, @LogiLcd\BitMapArray(), @BMINFO, #DIB_RGB_COLORS)
; Ist das hier so richtig fuer Mono Display ?
If LogiLcd\Color = #False
For i = 0 To Mono
LogiLcd\BitMapArray(i) = LogiLcd\BitMapArray(i) ! $FF
Next i
EndIf
If Result
If LogiLcd\Color
LogiLcdColorSetBackground(@LogiLcd\BitMapArray())
Else
LogiLcdMonoSetBackground(@LogiLcd\BitMapArray())
EndIf
EndIf
StopDrawing()
EndIf
EndProcedure
Procedure LcdSetText(LineNumber, Text.s, Red = 255, Green = 255, Blue = 255)
Protected Result.b = #False
If LogiLcd\Init
If LogiLcd\Color
If LineNumber => 0 And LineNumber <= 7
Result = LogiLcdColorSetText(LineNumber, Text, Red, Green, Blue)
EndIf
Else
If LineNumber => 0 And LineNumber <= 3
Result = LogiLcdMonoSetText(LineNumber, Text)
EndIf
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure LcdSetTitle(Text.s, Red = 255, Green = 255, Blue = 255)
Protected Result.b = #False
If LogiLcd\Init
If LogiLcd\Color
Result = LogiLcdColorSetTitle(Text, Red, Green, Blue)
EndIf
EndIf
ProcedureReturn Result
EndProcedure
EndModule
CompilerIf #PB_Compiler_IsMainFile
Image = CreateImage(#PB_Any, LGSDK::#LOGI_LCD_COLOR_WIDTH, LGSDK::#LOGI_LCD_COLOR_HEIGHT, 32)
If StartDrawing(ImageOutput(Image))
Box(0,50,OutputWidth(), 20, #Red)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(10, 51, "Hello World !", #White)
StopDrawing()
EndIf
Text.s = "": OldText.s = ""
If OpenWindow(0, 0, 0, 0, 0, "Logitech G19 Applet Demo (PBx64 on Win7-x64)", #PB_Window_Invisible)
If LGSDK::LcdInit("G19 Demo")
LGSDK::LcdUpdate()
LGSDK::LcdSetBackground(Image)
LGSDK::LcdButtonInit(0, 200)
Repeat
Event = WaitWindowEvent(25)
Text = ""
If Event = #PB_Event_CloseWindow
Quit = 1
EndIf
Select Event
Case #PB_Event_CloseWindow
Quit = 1
Case LGSDK::#LGSDK_Button
Select EventGadget()
Case LGSDK::#LOGI_LCD_COLOR_BUTTON_MENU
text = "you pressed : Menu"
Case LGSDK::#LOGI_LCD_COLOR_BUTTON_OK
text = "you pressed : Ok"
Case LGSDK::#LOGI_LCD_MONO_BUTTON_0
text = "you pressed : Button 0"
Case LGSDK::#LOGI_LCD_MONO_BUTTON_1
text = "you pressed : Button 1"
EndSelect
If StartDrawing(ImageOutput(Image))
Box(0,0,OutputWidth(),OutputHeight(),0)
Box(0,50,OutputWidth(), 20, #Red)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(10, 51, "Hello World !", #White)
If Text <> ""
DrawText(10, 71, Text, $cccccc)
EndIf
StopDrawing()
EndIf
If Text <> OldText
OldText = Text
LGSDK::LcdSetBackground(Image)
EndIf
EndSelect
LGSDK::LcdUpdate()
Until Quit > 0
LGSDK::LcdShutDown()
CloseWindow(0)
End
EndIf
EndIf
CompilerEndIf