Logitech G19 LCD ansprechen

Hardware- und Elektronikbasteleien, Ansteuerung von Schnittstellen und Peripherie.
Fragen zu "Consumer"-Problemen kommen in Offtopic.
Benutzeravatar
Hoto
Beiträge: 294
Registriert: 01.09.2004 22:51

Logitech G19 LCD ansprechen

Beitrag von Hoto »

Hi,

hier hat sich nicht zufällig mal Jemand eine Logitech G19 Tastatur zugelegt und sich damit beschäftigt deren LCD Farbdisplay anzusprechen?

Ich hab mich auch schon selbst daran versucht, war aber nicht sehr erfolgreich dabei, da ich bisher noch nie selbst so eine Schnittstelle für eine DLL geschrieben habe und mir doch deutlich der Durchblick gefehlt hat, leider fehlt mir in der Hinsicht doch noch einiges Wissen. Logitech hat zwar dem Treiber ein gutes SDK mit guter Dokumentation beigelegt, aber so wirklich weitergeholfen hat es mir leider nicht. Bevor ich mich hier jetzt noch weiter die Haare raufe (fehlen schon genug ;) ), frag ich dann doch mal lieber hier nach. Vielleicht hat sich ja schon mal inzwischen Jemand damit beschäftigt.

Gruß
Hoto
Benutzeravatar
SoS
Beiträge: 340
Registriert: 29.08.2004 09:31
Kontaktdaten:

Re: Logitech G19 LCD ansprechen

Beitrag von SoS »

Hier mal ein lauffähiges stück Code das Dir einen teil Deines Desktops anzeigt.
Hab da einiges gekürzt damit es nicht zu gross und besser überschaubar ist.
Ich hoffe Du kommst damit klar.

Code: Alles auswählen

#LGLCD_INVALID_CONNECTION = -1
#LGLCD_INVALID_DEVICE = -1
#LGLCDBUTTON_LEFT = $00000100
#LGLCDBUTTON_RIGHT = $00000200
#LGLCDBUTTON_OK = $00000400
#LGLCDBUTTON_CANCEL = $00000800
#LGLCDBUTTON_UP = $00001000
#LGLCDBUTTON_DOWN = $00002000
#LGLCDBUTTON_MENU = $00004000
#LGLCDBUTTON_BUTTON0 = $00000001
#LGLCDBUTTON_BUTTON1 = $00000002
#LGLCDBUTTON_BUTTON2 = $00000004
#LGLCDBUTTON_BUTTON3 = $00000008
#LGLCDBUTTON_BUTTON4 = $00000010
#LGLCDBUTTON_BUTTON5 = $00000020
#LGLCDBUTTON_BUTTON6 = $00000040
#LGLCDBUTTON_BUTTON7 = $00000080

#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 

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


#LGLCD_BMP_FORMAT_160x43x1 = $00000001
#LGLCD_BMP_FORMAT_QVGAx32 = $00000003
#LGLCD_BMP_WIDTH = 160
#LGLCD_BMP_HEIGHT = 43
#LGLCD_BMP_BPP = 1
#LGLCD_BW_BMP_WIDTH = 160
#LGLCD_BW_BMP_HEIGHT = 43
#LGLCD_BW_BMP_BPP = 1
#LGLCD_QVGA_BMP_WIDTH = 320
#LGLCD_QVGA_BMP_HEIGHT = 240
#LGLCD_QVGA_BMP_BPP = 4
Structure lgLcdBitmapHeader
  Format.l
EndStructure

Structure lgLcdBitmap160x43x1
  hdr.lgLcdBitmapHeader
  pixels.b[#LGLCD_BMP_WIDTH * #LGLCD_BMP_HEIGHT * #LGLCD_BMP_BPP]
EndStructure

Structure lgLcdBitmapQVGAx32
  hdr.lgLcdBitmapHeader
  pixels.b[#LGLCD_QVGA_BMP_WIDTH * #LGLCD_QVGA_BMP_HEIGHT * #LGLCD_QVGA_BMP_BPP]
EndStructure

#LGLCD_PRIORITY_IDLE_NO_SHOW = 0
#LGLCD_PRIORITY_BACKGROUND = 64
#LGLCD_PRIORITY_NORMAL = 128
#LGLCD_PRIORITY_ALERT = 255
#LGLCD_LCD_FOREGROUND_APP_NO = 0
#LGLCD_LCD_FOREGROUND_APP_YES = 1
#LGLCD_DEVICE_FAMILY_BW_160x43_GAMING = $00000001
#LGLCD_DEVICE_FAMILY_KEYBOARD_G15 = $00000001
#LGLCD_DEVICE_FAMILY_BW_160x43_AUDIO = $00000002
#LGLCD_DEVICE_FAMILY_SPEAKERS_Z10 = $00000002
#LGLCD_DEVICE_FAMILY_JACKBOX = $00000004
#LGLCD_DEVICE_FAMILY_BW_160x43_BASIC = $00000008
#LGLCD_DEVICE_FAMILY_LCDEMULATOR_G15 = $00000008
#LGLCD_DEVICE_FAMILY_RAINBOW = $00000010
#LGLCD_DEVICE_FAMILY_QVGA_BASIC = $00000020
#LGLCD_DEVICE_FAMILY_QVGA_GAMING = $00000040
#LGLCD_DEVICE_FAMILY_GAMEBOARD_G13 = $00000080
#LGLCD_DEVICE_FAMILY_OTHER = $80000000
#LGLCD_DEVICE_FAMILY_ALL_BW_160x43 = #LGLCD_DEVICE_FAMILY_BW_160x43_GAMING| #LGLCD_DEVICE_FAMILY_BW_160x43_AUDIO| #LGLCD_DEVICE_FAMILY_JACKBOX| #LGLCD_DEVICE_FAMILY_BW_160x43_BASIC| #LGLCD_DEVICE_FAMILY_RAINBOW| #LGLCD_DEVICE_FAMILY_GAMEBOARD_G13
#LGLCD_DEVICE_FAMILY_ALL_QVGA = #LGLCD_DEVICE_FAMILY_QVGA_BASIC| #LGLCD_DEVICE_FAMILY_QVGA_GAMING
#LGLCD_DEVICE_FAMILY_ALL = #LGLCD_DEVICE_FAMILY_ALL_BW_160x43| #LGLCD_DEVICE_FAMILY_ALL_QVGA
#LGLCD_APPLET_CAP_BASIC = $00000000
#LGLCD_APPLET_CAP_BW = $00000001
#LGLCD_APPLET_CAP_QVGA = $00000002
#LGLCD_NOTIFICATION_DEVICE_ARRIVAL = $00000001
#LGLCD_NOTIFICATION_DEVICE_REMOVAL = $00000002
#LGLCD_NOTIFICATION_CLOSE_CONNECTION = $00000003
#LGLCD_NOTIFICATION_APPLET_DISABLED = $00000004
#LGLCD_NOTIFICATION_APPLET_ENABLED = $00000005
#LGLCD_NOTIFICATION_TERMINATE_APPLET = $00000006
#LGLCD_DEVICE_BW = $00000001
#LGLCD_DEVICE_QVGA = $00000002



Prototype.l lgLcdOnConfigureCB(Connection.l, *pContext.l) 
Prototype.l lgLcdOnNotificationCB(Connection.l, notificationCode.l, notifyParm1.l, notifyParm2.l, notifyParm3.l, notifyParm4.l) 
Prototype.l lgLcdOnSoftButtonsCB(device.l, dwButtons.l, *pContext.l) 

Structure lgLcdConfigureContext
  configCallback.lgLcdOnConfigureCB
  configContext.l
EndStructure

Structure lgLcdNotificationContext
  notificationCallback.lgLcdOnNotificationCB
  notificationContext.l
EndStructure

Structure lgLcdConnectContext
  *appFriendlyName.l
  isPersistent.l
  isAutostartable.l
  onConfigure.lgLcdConfigureContext
  connection.l
EndStructure


Structure lgLcdConnectContextEx
  *appFriendlyName.l
  isPersistent.l
  isAutostartable.l
  onConfigure.lgLcdConfigureContext
  connection.l
  dwAppletCapabilitiesSupported.l
  dwReserved1.l
  onNotify.lgLcdNotificationContext
EndStructure


Structure lgLcdSoftbuttonsChangedContext
  softbuttonsChangedCallback.lgLcdOnSoftButtonsCB
  softbuttonsChangedContext.l
EndStructure

Structure lgLcdOpenContext
  connection.l
  index.l
  onSoftbuttonsChanged.lgLcdSoftbuttonsChangedContext
  device.l
EndStructure

Structure lgLcdOpenByTypeContext
  connection.l
  deviceType.l
  onSoftbuttonsChanged.lgLcdSoftbuttonsChangedContext
  device.l
EndStructure



Import "lglcd.lib"
  g_lgLcdLibIsInitialized() AS "_g_lgLcdLibIsInitialized"
  g_lgLcdLibLinkedRemoteInterface.l() AS "_g_lgLcdLibLinkedRemoteInterface"
  lgLcdClose(device.l) AS "_lgLcdClose@4"
  CompilerIf #PB_Compiler_Unicode
    lgLcdConnect(*ctx.lgLcdConnectContext) AS "_lgLcdConnectW@4"
    lgLcdConnectEx(*ctx.lgLcdConnectContextEx) AS "_lgLcdConnectExW@4"
    lgLcdEnumerateEx(connection.l, index.l, *description.lgLcdDeviceDescEx) AS "_lgLcdEnumerateExW@12"
	CompilerElse
    lgLcdConnect(*ctx.lgLcdConnectContext) AS "_lgLcdConnectA@4"
    lgLcdConnectEx(*ctx.lgLcdConnectContextEx) AS "_lgLcdConnectExA@4"
    lgLcdEnumerateEx(connection.l, index.l, *description.lgLcdDeviceDescEx) AS "_lgLcdEnumerateExA@12"
    
	CompilerEndIf 
  
  lgLcdDeInit() AS "_lgLcdDeInit@0"
  lgLcdDisconnect(connection.l) AS "_lgLcdDisconnect@4"
  lgLcdEnumerate(connection.l, index.l, *description.lgLcdDeviceDesc) AS "_lgLcdEnumerate@12"
  lgLcdInit() AS "_lgLcdInit@0"
  lgLcdOpen(*ctx.lgLcdOpenContext) AS "_lgLcdOpen@4"
  lgLcdOpenByType(*ctx.lgLcdOpenByTypeContext) AS "_lgLcdOpenByType@4"
  lgLcdReadSoftButtons(device.l, *buttons.l) AS "_lgLcdReadSoftButtons@8"
  lgLcdSetAsLCDForegroundApp(device.l, foregroundYesNoFlag.l) AS "_lgLcdSetAsLCDForegroundApp@8"
  lgLcdSetDeviceFamiliesToUse(connection.l,dwDeviceFamiliesSupported.l,dwReserved1.l) AS "_lgLcdSetDeviceFamiliesToUse@12"
  lgLcdUpdateBitmap(device.l, *bitmap.lgLcdBitmapHeader, priority.l) AS "_lgLcdUpdateBitmap@12"
EndImport

Procedure.l LGLCD_SYNC_UPDATE(priority.l) 
  ProcedureReturn ($80000000 | priority) 
EndProcedure 

Procedure.l LGLCD_ASYNC_UPDATE(priority.l) 
  ProcedureReturn priority 
EndProcedure 

Procedure.l LGLCD_SYNC_COMPLETE_WITHIN_FRAME(priority.l) 
  ProcedureReturn ($C0000000 | priority) 
EndProcedure 

Structure KBDLLHOOKSTRUCT 
  vkCode.l 
  scanCode.l 
  flags.l 
  time.l 
  dwExtraInfo.l 
EndStructure 

Global connectContext.lgLcdConnectContext
Global openContext.lgLcdOpenByTypeContext ;
Global *bmp.lgLcdBitmapQVGAx32 =AllocateMemory(SizeOf(lgLcdBitmapQVGAx32))

Procedure.l lgLcdOnSoftButtonsCB(device.l, dwButtons.l, pContext.l) 
  select dwButtons
		case #LGLCDBUTTON_BUTTON0
      debug "Button0";links
		case #LGLCDBUTTON_BUTTON1
      debug "Button1";rechts
		case #LGLCDBUTTON_BUTTON2
      debug "Button2";hoch
		case #LGLCDBUTTON_BUTTON3
      debug "Button3";runter
		case #LGLCD_AUDIO_SKIP_LAST
      debug "Button_SKIP_LAST"
		case #LGLCD_AUDIO_SKIP_NEXT
      debug "Button_SKIP_NEXT"
		case #LGLCD_AUDIO_STOP
      debug "Button_STOP"
		case #LGLCD_AUDIO_PLAY
      debug "Button_PLAY"
	EndSelect
EndProcedure 

Procedure.l G15_KeyboardHook(nCode.l, wParam.l, *p.KBDLLHOOKSTRUCT) 
  
  If nCode = #HC_ACTION And wParam = #WM_KEYDOWN
    Select *p\vkCode 
			Case 173 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_MUTE, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 174 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_WHEEL_DOWN, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 175 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_WHEEL_UP, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 176 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_SKIP_NEXT, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 177 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_SKIP_LAST, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 178 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_STOP, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
			Case 179 
        lgLcdOnSoftButtonsCB(openContext\device,#LGLCD_AUDIO_PLAY, openContext\onSoftbuttonsChanged\softbuttonsChangedContext) 
		EndSelect 
	EndIf 
  
  ProcedureReturn CallNextHookEx_(0, nCode, wParam, *p) 
EndProcedure 

Macro image2lcd(dc,Image)
  Define TemporaryBitmap.BITMAP, TemporaryBitmapInfo.BITMAPINFO 
  hBmp = ImageID(Image)
  GetObject_(hBmp, SizeOf(BITMAP), TemporaryBitmap.BITMAP) 
  TemporaryBitmapInfo\bmiHeader\biSize        = SizeOf(BITMAPINFOHEADER) 
  TemporaryBitmapInfo\bmiHeader\biWidth       = TemporaryBitmap\bmWidth 
  TemporaryBitmapInfo\bmiHeader\biHeight      = -TemporaryBitmap\bmHeight 
  TemporaryBitmapInfo\bmiHeader\biPlanes      = 1 
  TemporaryBitmapInfo\bmiHeader\biBitCount    = 32 
  TemporaryBitmapInfo\bmiHeader\biCompression = #BI_RGB 
  GetDIBits_(DC, hBmp, 0, TemporaryBitmap\bmHeight, @*bmp\pixels, TemporaryBitmapInfo, #DIB_RGB_COLORS)
  lgLcdUpdateBitmap(openContext\device, @*bmp\hdr, LGLCD_ASYNC_UPDATE(#LGLCD_PRIORITY_NORMAL))
EndMacro

Procedure MakeDesktopSCREENSHOT() 
	
  Shared dkx,dky,tdesk,desk,info,fix,quality.l,hCursor.l,piconinfo.ICONINFO
  static xm.d,ym.d,dmx.l,dmy.l,dkwx.l,dkwy.l
  dmx=DesktopMouseX()
  dmy=DesktopMouseY()
 
 
		desk=0
		dkx=DesktopWidth(desk)
		dky=DesktopHeight(desk)
		
    Width=xzoom:Height=yzoom
    bltImage=CreateImage(#PB_Any,320, 240,32)
    hImage = CreateImage(#PB_Any,320, 240,32) 
    ImageDC    = StartDrawing(ImageOutput(bltImage))  
      DeskDC =CreateDC_("DISPLAY", 0, 0, 0) 
      ImageDC2 =CreateCompatibleDC_(ImageDC)
      SelectObject_(ImageDC2, ImageID(hImage))
			BitBlt_(ImageDC2,0,0,320,240,DeskDC,dmx-160,dmy-120,#SRCCOPY)
			DrawIcon_(ImageDC2, 160-piconinfo\xHotspot,120-piconinfo\yHotspot,hCursor ) 
			StretchBlt_(ImageDC,0,0,320,240,ImageDC2,0,0,320,240,#SRCCOPY  );
			DeleteDC_ (ImageDC2)

      image2lcd(ImageDC,bltImage)  
			
		StopDrawing()  
    
    DeleteDC_(DeskDC)
    FreeImage(hImage)  
    FreeImage(bltImage)
EndProcedure 


If Not  lgLcdInit()
  
  
  ZeroMemory_(@connectContext, SizeOf(connectContext))
  connectContext\appFriendlyName = @"Zoom"
  connectContext\isAutostartable = #True
  connectContext\isPersistent = #True
  connectContext\onConfigure\configCallback = #NULL
  connectContext\onConfigure\configContext = #Null
  connectContext\connection = #LGLCD_INVALID_CONNECTION
  If Not lgLcdConnect(connectContext)
    
    
    ZeroMemory_(@openContext, SizeOf(openContext));
    openContext\connection = connectContext\connection;
    openContext\deviceType = #LGLCD_DEVICE_QVGA;
    openContext\onSoftbuttonsChanged\softbuttonsChangedCallback = @lgLcdOnSoftButtonsCB()
    global openContext\onSoftbuttonsChanged\softbuttonsChangedContext 
    global openContext\device = #LGLCD_INVALID_DEVICE;
    If Not lgLcdOpenByType(openContext);
      
      *bmp\hdr\Format = #LGLCD_BMP_FORMAT_QVGAx32;
      ZeroMemory_(@*bmp\pixels, SizeOf(*bmp\pixels))
			
			; ab hier kannst du mit deinem eigenen code beginnen
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			
			desk=ExamineDesktops()-1
      CreatePopupMenu(0) 
			
      MenuBar() 
      MenuItem(3, "Ende") 
      MenuBar()
      
			fps=60 ; Framerate festlegen 
      
      Window_0=OpenWindow(#PB_Any, 0, 0, 160, 30, "Zoom", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
      ShowWindow_(WindowID(Window_0),#SW_HIDE)
      SetWindowsHookEx_(#WH_KEYBOARD_LL, @G15_KeyboardHook(), GetModuleHandle_(0), #Null) 
      AddSysTrayIcon(1, WindowID(Window_0), CatchImage(10, ?Screenshoticon)) 
      SysTrayIconToolTip(1, "G19 Desktop Viewer,use the Softbuttons") 
      hCursor=LoadCursor_(0,#IDC_ARROW	)
      GetIconInfo_(hCursor,@piconinfo.ICONINFO)
			
      SetTimer_(WindowID(Window_0),1,1000/fps,@MakeDesktopSCREENSHOT())
			
      Quit=0
      
      Repeat
        EventID = waitWindowEvent(500)
				
        If EventID = #PB_Event_SysTray 
          Select EventType() 
						Case #PB_EventType_RightClick,#PB_EventType_LeftClick 
              DisplayPopupMenu(0, WindowID(Window_0))
					EndSelect 
				EndIf 
        If EventID = #PB_Event_Menu 
          Select EventMenu() 
						Case 3 ; Quit 
              KillTimer_(WindowID(Window_0),1)
              Quit=1
					EndSelect 
				EndIf 
			Until Quit=1
			
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			; und hier endet dein code
			
		EndIf
	EndIf
EndIf

DataSection 
  Screenshoticon: 
  IncludeBinary "player.ico"
  
EndDataSection 
Benutzeravatar
Hoto
Beiträge: 294
Registriert: 01.09.2004 22:51

Re: Logitech G19 LCD ansprechen

Beitrag von Hoto »

Vielen Dank! Hab den Code jetzt nur mal überflogen, sieht sehr vielversprechend aus, aber mit einigem hätte ich mich selbst wohl ziemlich schwer getan. Werde damit die Tage mal rumspielen. Wenn das wirklich klappt, werd ich wohl die nächste Zeit zu nicht mehr viel Anderem kommen außer zum coden. Dann kann ich endlich an einem Projekt weiter machen. ;)

Edit: mal etwas rumgespielt, läuft soweit alles super bis auf eine Kleinigkeit, weder OK, Menu noch Chancel Button werden erkannt, alle andere Tasten kann ich abfragen. Schon einiges rumgebastelt und auch die neuen (laut lglcd.h Comment) LGLCDBUTTON_LEFT usw. probiert, da erkennt er gleich gar nichts von. Komme einfach nicht dahinter woran das liegen könnte.
Benutzeravatar
SoS
Beiträge: 340
Registriert: 29.08.2004 09:31
Kontaktdaten:

Re: Logitech G19 LCD ansprechen

Beitrag von SoS »

Ich habe kein spezielles include sondern ich passe mir das immer so an wie ich es brauche.
Wenn Du dich damit mal befasst hättest ,dann hättest Du Dir das ColorAnd2Mono Sample aus
der SDK geschnappt und nach PB convertiert. /:->
Hier gehen alle ausser Media-Tasten da ohne KeyboardHook.

Code: Alles auswählen

#LGLCD_INVALID_CONNECTION = -1
#LGLCD_INVALID_DEVICE = -1
#LGLCDBUTTON_LEFT = $00000100
#LGLCDBUTTON_RIGHT = $00000200
#LGLCDBUTTON_OK = $00000400
#LGLCDBUTTON_CANCEL = $00000800
#LGLCDBUTTON_UP = $00001000
#LGLCDBUTTON_DOWN = $00002000
#LGLCDBUTTON_MENU = $00004000
#LGLCDBUTTON_BUTTON0 = $00000001
#LGLCDBUTTON_BUTTON1 = $00000002
#LGLCDBUTTON_BUTTON2 = $00000004
#LGLCDBUTTON_BUTTON3 = $00000008
#LGLCDBUTTON_BUTTON4 = $00000010
#LGLCDBUTTON_BUTTON5 = $00000020
#LGLCDBUTTON_BUTTON6 = $00000040
#LGLCDBUTTON_BUTTON7 = $00000080

#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 

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


#LGLCD_BMP_FORMAT_160x43x1 = $00000001
#LGLCD_BMP_FORMAT_QVGAx32 = $00000003
#LGLCD_BMP_WIDTH = 160
#LGLCD_BMP_HEIGHT = 43
#LGLCD_BMP_BPP = 1
#LGLCD_BW_BMP_WIDTH = 160
#LGLCD_BW_BMP_HEIGHT = 43
#LGLCD_BW_BMP_BPP = 1
#LGLCD_QVGA_BMP_WIDTH = 320
#LGLCD_QVGA_BMP_HEIGHT = 240
#LGLCD_QVGA_BMP_BPP = 4
Structure lgLcdBitmapHeader
  Format.l
EndStructure

Structure lgLcdBitmap160x43x1
  hdr.lgLcdBitmapHeader
  pixels.b[#LGLCD_BMP_WIDTH * #LGLCD_BMP_HEIGHT * #LGLCD_BMP_BPP]
EndStructure

Structure lgLcdBitmapQVGAx32
  hdr.lgLcdBitmapHeader
  pixels.b[#LGLCD_QVGA_BMP_WIDTH * #LGLCD_QVGA_BMP_HEIGHT * #LGLCD_QVGA_BMP_BPP]
EndStructure

#LGLCD_PRIORITY_IDLE_NO_SHOW = 0
#LGLCD_PRIORITY_BACKGROUND = 64
#LGLCD_PRIORITY_NORMAL = 128
#LGLCD_PRIORITY_ALERT = 255
#LGLCD_LCD_FOREGROUND_APP_NO = 0
#LGLCD_LCD_FOREGROUND_APP_YES = 1
#LGLCD_DEVICE_FAMILY_BW_160x43_GAMING = $00000001
#LGLCD_DEVICE_FAMILY_KEYBOARD_G15 = $00000001
#LGLCD_DEVICE_FAMILY_BW_160x43_AUDIO = $00000002
#LGLCD_DEVICE_FAMILY_SPEAKERS_Z10 = $00000002
#LGLCD_DEVICE_FAMILY_JACKBOX = $00000004
#LGLCD_DEVICE_FAMILY_BW_160x43_BASIC = $00000008
#LGLCD_DEVICE_FAMILY_LCDEMULATOR_G15 = $00000008
#LGLCD_DEVICE_FAMILY_RAINBOW = $00000010
#LGLCD_DEVICE_FAMILY_QVGA_BASIC = $00000020
#LGLCD_DEVICE_FAMILY_QVGA_GAMING = $00000040
#LGLCD_DEVICE_FAMILY_GAMEBOARD_G13 = $00000080
#LGLCD_DEVICE_FAMILY_OTHER = $80000000
#LGLCD_DEVICE_FAMILY_ALL_BW_160x43 = #LGLCD_DEVICE_FAMILY_BW_160x43_GAMING| #LGLCD_DEVICE_FAMILY_BW_160x43_AUDIO| #LGLCD_DEVICE_FAMILY_JACKBOX| #LGLCD_DEVICE_FAMILY_BW_160x43_BASIC| #LGLCD_DEVICE_FAMILY_RAINBOW| #LGLCD_DEVICE_FAMILY_GAMEBOARD_G13
#LGLCD_DEVICE_FAMILY_ALL_QVGA = #LGLCD_DEVICE_FAMILY_QVGA_BASIC| #LGLCD_DEVICE_FAMILY_QVGA_GAMING
#LGLCD_DEVICE_FAMILY_ALL = #LGLCD_DEVICE_FAMILY_ALL_BW_160x43| #LGLCD_DEVICE_FAMILY_ALL_QVGA
#LGLCD_APPLET_CAP_BASIC = $00000000
#LGLCD_APPLET_CAP_BW = $00000001
#LGLCD_APPLET_CAP_QVGA = $00000002
#LGLCD_NOTIFICATION_DEVICE_ARRIVAL = $00000001
#LGLCD_NOTIFICATION_DEVICE_REMOVAL = $00000002
#LGLCD_NOTIFICATION_CLOSE_CONNECTION = $00000003
#LGLCD_NOTIFICATION_APPLET_DISABLED = $00000004
#LGLCD_NOTIFICATION_APPLET_ENABLED = $00000005
#LGLCD_NOTIFICATION_TERMINATE_APPLET = $00000006
#LGLCD_DEVICE_BW = $00000001
#LGLCD_DEVICE_QVGA = $00000002



Prototype.l lgLcdOnConfigureCB(Connection.l, *pContext.l) 
Prototype.l lgLcdOnNotificationCB(Connection.l, notificationCode.l, notifyParm1.l, notifyParm2.l, notifyParm3.l, notifyParm4.l) 
Prototype.l lgLcdOnSoftButtonsCB(device.l, dwButtons.l, *pContext.l) 

Structure lgLcdConfigureContext
  configCallback.lgLcdOnConfigureCB
  configContext.l
EndStructure

Structure lgLcdNotificationContext
  notificationCallback.lgLcdOnNotificationCB
  notificationContext.l
EndStructure

Structure lgLcdConnectContext
  *appFriendlyName.l
  isPersistent.l
  isAutostartable.l
  *onConfigure.lgLcdConfigureContext
  connection.l
EndStructure


Structure lgLcdConnectContextEx
  *appFriendlyName.l
  isPersistent.l
  isAutostartable.l
  onConfigure.lgLcdConfigureContext
  connection.l
  dwAppletCapabilitiesSupported.l
  dwReserved1.l
  onNotify.lgLcdNotificationContext
EndStructure


Structure lgLcdSoftbuttonsChangedContext
  softbuttonsChangedCallback.lgLcdOnSoftButtonsCB
  softbuttonsChangedContext.l
EndStructure

Structure lgLcdOpenContext
  connection.l
  index.l
  onSoftbuttonsChanged.lgLcdSoftbuttonsChangedContext
  device.l
EndStructure

Structure lgLcdOpenByTypeContext
  connection.l
  deviceType.l
  onSoftbuttonsChanged.lgLcdSoftbuttonsChangedContext
  device.l
EndStructure



Import "lglcd.lib"
  g_lgLcdLibIsInitialized() AS "_g_lgLcdLibIsInitialized"
  g_lgLcdLibLinkedRemoteInterface.l() AS "_g_lgLcdLibLinkedRemoteInterface"
  lgLcdClose(device.l) AS "_lgLcdClose@4"
  CompilerIf #PB_Compiler_Unicode
    lgLcdConnect(*ctx.lgLcdConnectContext) AS "_lgLcdConnectW@4"
    lgLcdConnectEx(*ctx.lgLcdConnectContextEx) AS "_lgLcdConnectExW@4"
    lgLcdEnumerateEx(connection.l, index.l, *description.lgLcdDeviceDescEx) AS "_lgLcdEnumerateExW@12"
	CompilerElse
    lgLcdConnect(*ctx.lgLcdConnectContext) AS "_lgLcdConnectA@4"
    lgLcdConnectEx(*ctx.lgLcdConnectContextEx) AS "_lgLcdConnectExA@4"
    lgLcdEnumerateEx(connection.l, index.l, *description.lgLcdDeviceDescEx) AS "_lgLcdEnumerateExA@12"
    
	CompilerEndIf 
  
  lgLcdDeInit() AS "_lgLcdDeInit@0"
  lgLcdDisconnect(connection.l) AS "_lgLcdDisconnect@4"
  lgLcdEnumerate(connection.l, index.l, *description.lgLcdDeviceDesc) AS "_lgLcdEnumerate@12"
  lgLcdInit() AS "_lgLcdInit@0"
  lgLcdOpen(*ctx.lgLcdOpenContext) AS "_lgLcdOpen@4"
  lgLcdOpenByType(*ctx.lgLcdOpenByTypeContext) AS "_lgLcdOpenByType@4"
  lgLcdReadSoftButtons(device.l, *buttons.l) AS "_lgLcdReadSoftButtons@8"
  lgLcdSetAsLCDForegroundApp(device.l, foregroundYesNoFlag.l) AS "_lgLcdSetAsLCDForegroundApp@8"
  lgLcdSetDeviceFamiliesToUse(connection.l,dwDeviceFamiliesSupported.l,dwReserved1.l) AS "_lgLcdSetDeviceFamiliesToUse@12"
  lgLcdUpdateBitmap(device.l, *bitmap.lgLcdBitmapHeader, priority.l) AS "_lgLcdUpdateBitmap@12"
EndImport

Procedure.l LGLCD_SYNC_UPDATE(priority.l) 
  ProcedureReturn ($80000000 | priority) 
EndProcedure 

Procedure.l LGLCD_ASYNC_UPDATE(priority.l) 
  ProcedureReturn priority 
EndProcedure 

Procedure.l LGLCD_SYNC_COMPLETE_WITHIN_FRAME(priority.l) 
  ProcedureReturn ($C0000000 | priority) 
EndProcedure 

; LCD device state
Structure LCD_DEVICE_STATE
  nDeviceId.l
  dwButtonState.l
EndStructure

; Applet state
Structure APPLET_STATE
  Color.LCD_DEVICE_STATE
  Mono.LCD_DEVICE_STATE
  isEnabled.b
endStructure

; Global Variables:
Global g_hWnd            = #NULL;
Global g_hInst           = #NULL;
Global g_szName.l        = @"ColorAnd2Mono Sample";
Global g_dwTimerId       = $ABBABABE;
Global g_LCDConnectionCtx.lgLcdConnectContextEx
Global g_AppletState.APPLET_STATE


Declare OnLCDNotificationCallback(connection,pContext,notificationCode,notifyParm1,notifyParm2,notifyParm3,notifyParm4)
Declare OnTimerCallback()

; When an LGLCD notification occurs, we transfer it as a message
; so that it is processed by the main thread
; PostMessage messages
#WM_LGLCD_DEVICE_ARRIVAL    =     #WM_APP + 1
#WM_LGLCD_DEVICE_REMOVAL    =     #WM_APP + 2
#WM_LGLCD_CONNECTION_CLOSED =     #WM_APP + 3
#WM_LGLCD_APPLET_ENABLED    =     #WM_APP + 4
#WM_LGLCD_BUTTON_EVENT      =     #WM_APP + 5


; Forward declarations of functions included in this code module:
; DWORD CALLBACK      OnLCDButtonsCallback(int device, DWORD dwButtons, const PVOID pContext);
; DWORD CALLBACK      OnLCDNotificationCallback(int connection,
; const PVOID pContext,
; DWORD notificationCode,
; DWORD notifyParm1,
; DWORD notifyParm2,
; DWORD notifyParm3,
; DWORD notifyParm4);


;************************************************************************
;
; InitializeLCD
;
; This is where we will do the main LCD library initialization
;************************************************************************

Procedure.l  InitializeLCD()
  ret = 0;
  
  ; The first thing to do is initialize the library using lgLcdInit
  ; This requires that the Logitech GamePanel software is installed
  ; on the target
  ret = lgLcdInit();
  if ret <> #ERROR_SUCCESS 
    
    ; ERROR. Most likely the GamePanel software is not installed
    Procedurereturn #FALSE;
	endif
  
  ; Inititalize the applet state
  ZeroMemory_(@g_AppletState, sizeof(g_AppletState));
  g_AppletState\isEnabled = #TRUE;
  g_AppletState\Color\nDeviceId = #LGLCD_INVALID_DEVICE;
  g_AppletState\Mono\nDeviceId = #LGLCD_INVALID_DEVICE;
  
  ; Initialize our connection state
  ZeroMemory_(@g_LCDConnectionCtx, sizeof(g_LCDConnectionCtx));
  ; appFriendlyName: Display name of the applet
  g_LCDConnectionCtx\appFriendlyName = g_szName;
  ; isAutostartable: Set to TRUE if you want your applet to start when LCD Manager starts
  g_LCDConnectionCtx\isAutostartable = #FALSE;         
  ; dwAppletCapabilitiesSupported: We support color and monochrome
  g_LCDConnectionCtx\dwAppletCapabilitiesSupported = (#LGLCD_APPLET_CAP_BW|#LGLCD_APPLET_CAP_QVGA);
  ; connection: Initialize with LGLCD_INVALID_CONNECTION
  g_LCDConnectionCtx\connection = #LGLCD_INVALID_CONNECTION;
  ; onNotify: Set our internal callback
  g_LCDConnectionCtx\onNotify\notificationCallback = @OnLCDNotificationCallback()
  g_LCDConnectionCtx\onNotify\notificationContext = #NULL;
  
  ; Start our loop
  g_dwTimerId = SetTimer_(g_hWnd, g_dwTimerId, 100, @OnTimerCallback());
  
  Procedurereturn #TRUE;
EndProcedure


;************************************************************************
;
; OnTimerCallback
;
; Where the display output happens. We will:
;
; - Check if we need to attempt connect with the LCD Manager
; - If we have a color device, output data to that color device
; - If we have a monochrome device, output data to that monochrome device
;************************************************************************

Procedure OnTimerCallback()
  
  ; Check if we have an invalid connection. If so, attempt a connection
  if g_LCDConnectionCtx\connection=#LGLCD_INVALID_CONNECTION
    
    ; attempt to connect
    if  lgLcdConnectEx(@g_LCDConnectionCtx) <> #ERROR_SUCCESS
      Procedurereturn;
		else
      Debug"Connected to LCD Manager"
		endif
	endif
  
  ; If the applet is disabled, then we don't need to bother displaying
  ; anything
  if g_AppletState\isEnabled= #FALSE
    Procedurereturn;
	endif
  
  ; Check if we have a color device
  if  g_AppletState\Color\nDeviceId <> #LGLCD_INVALID_DEVICE
    ColorFrame.lgLcdBitmapQVGAx32
    ; draw color
		
    ; Use the tick count to determine a color
    ; Colors are in the RGBA format
    ; Let's alternate between red, green, and blue
    ColorFrame\hdr\Format = #LGLCD_BMP_FORMAT_QVGAx32;
    
    static nCurColor = 0;
    
    Dim colors(2) 
    colors(0)=#red     ; Red
    colors(1)=#green     ; Green
    colors(2)=#blue      ; Blue
		
		for  i = 0 to (#LGLCD_QVGA_BMP_WIDTH * #LGLCD_QVGA_BMP_HEIGHT)-1
      *pPixel.long = @ColorFrame\pixels[i*#LGLCD_QVGA_BMP_BPP];
      *pPixel\l =  i*(nCurColor*nCurColor+i*i) % #White
      
      nCurColor+1
		next
		
    lgLcdUpdateBitmap(g_AppletState\Color\nDeviceId, @ColorFrame\hdr,LGLCD_ASYNC_UPDATE(#LGLCD_PRIORITY_NORMAL));
	endif
  
  ; Check if we have a BW device
  if  g_AppletState\Mono\nDeviceId <> #LGLCD_INVALID_DEVICE
    
    ; draw monochrome
    MonoFrame.lgLcdBitmap160x43x1
    
    ; Draw (somewhat) random bytes
    ; Note: >= 128 is ON and < 128 is OFF
    MonoFrame\hdr\Format = #LGLCD_BMP_FORMAT_160x43x1;
    *bPixel.byte = MonoFrame\pixels;
    for  i = 0 to (#LGLCD_BW_BMP_WIDTH * #LGLCD_BW_BMP_HEIGHT)-1
      
      *bPixel\b+i = random(1);
		next
    
    lgLcdUpdateBitmap(g_AppletState\Mono\nDeviceId, @MonoFrame\hdr,LGLCD_ASYNC_UPDATE(#LGLCD_PRIORITY_NORMAL));
	endif
EndProcedure


;************************************************************************
;
; HandleButtonPress
;
;************************************************************************

Procedure HandleButtonPress()
  
  Debug "BUTTON EVENT"
  
  ; Handle the monochrome button state
  if (g_AppletState\Mono\dwButtonState)
    
    Debug"  MONOCHROME: "
    if (g_AppletState\Mono\dwButtonState & #LGLCDBUTTON_BUTTON0)
      
      Debug"BUTTON0 "
		endif
    if (g_AppletState\Mono\dwButtonState & #LGLCDBUTTON_BUTTON1)
      
      Debug"BUTTON1 "
		endif
    if (g_AppletState\Mono\dwButtonState & #LGLCDBUTTON_BUTTON2)
      
      Debug"BUTTON2 "
		endif
    if (g_AppletState\Mono\dwButtonState & #LGLCDBUTTON_BUTTON3)
      
      Debug"BUTTON3 "
		endif
	endif
  
  ; Handle the color button state
  if (g_AppletState\Color\dwButtonState)
    
    Debug"  COLOR: "
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_LEFT)
      
      Debug"LGLCDBUTTON_LEFT "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_RIGHT)
      
      Debug"LGLCDBUTTON_RIGHT "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_UP)
      
      Debug"LGLCDBUTTON_UP "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_DOWN)
      
      Debug"LGLCDBUTTON_DOWN "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_OK)
      
      Debug"LGLCDBUTTON_OK "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_MENU)
      
      Debug"LGLCDBUTTON_MENU "
		endif
    if (g_AppletState\Color\dwButtonState & #LGLCDBUTTON_CANCEL)
      
      Debug"LGLCDBUTTON_CANCEL "
		endif
	endif
EndProcedure



;************************************************************************
;
; OnLCDNotificationCallback
;
; IMPORTANT: This is called from a different thread than the main
; thread. You must take care to be thread-safe and return fast
;
; All we do here is pass on the notification to the main thread
;************************************************************************

Procedure OnLCDNotificationCallback(connection,pContext,notificationCode,notifyParm1,notifyParm2,notifyParm3,notifyParm4)
  
  Debug"OnLCDNotificationCallback"
  select notificationCode
      
		case #LGLCD_NOTIFICATION_DEVICE_ARRIVAL:
      PostMessage_(g_hWnd, #WM_LGLCD_DEVICE_ARRIVAL, notifyParm1, 0);
      
		case #LGLCD_NOTIFICATION_DEVICE_REMOVAL:
      PostMessage_(g_hWnd, #WM_LGLCD_DEVICE_REMOVAL, notifyParm1, 0);
      
		case #LGLCD_NOTIFICATION_APPLET_ENABLED:
		case #LGLCD_NOTIFICATION_APPLET_DISABLED:
      PostMessage_(g_hWnd, #WM_LGLCD_APPLET_ENABLED, notificationCode, 0);
      
		case #LGLCD_NOTIFICATION_CLOSE_CONNECTION:
      PostMessage_(g_hWnd, #WM_LGLCD_CONNECTION_CLOSED, notificationCode, 0);
      
	EndSelect
  
  Procedurereturn 1;
EndProcedure


;************************************************************************
;
; OnLCDButtonsCallback
;
; IMPORTANT: This is called from a different thread than the main
; thread. You must take care to be thread-safe and return fast
;************************************************************************

Procedure OnLCDButtonsCallback(device, dwButtons, pContext)
  
  PostMessage_(g_hWnd, #WM_LGLCD_BUTTON_EVENT, dwButtons, device);
  Procedurereturn 0;
EndProcedure


;************************************************************************
;
; WndProc
;
;************************************************************************

Procedure WndProc(hWnd, message, wParam, lParam)
  
  select message
      
			; case #WM_TIMER:
      ; OnTimerCallback();
      
		case #WM_DESTROY:
      PostQuitMessage_(0);
      
			
		case #WM_LGLCD_DEVICE_ARRIVAL:
      ; Check the capability of the new device, and then open up the
      ; appropriate device
      ; You will only get ONE arrival per device capability
      ; So, if you have 2 monochrome devices, you will still only get
      ; 1 arrival, but writing to that one device will multicast the
      ; the output to both devices
      
      OpenCtx.lgLcdOpenByTypeContext;
      ZeroMemory_(@OpenCtx, sizeof(OpenCtx));
      
      nDeviceType = wParam;
      
      ;The connection class has already filled in the connection index.
      ;OpenCtx.connection = doesn't matter
      OpenCtx\device = #LGLCD_INVALID_DEVICE;
      OpenCtx\deviceType = nDeviceType;
      OpenCtx\connection = g_LCDConnectionCtx\connection;
      OpenCtx\onSoftbuttonsChanged\softbuttonsChangedCallback = @OnLCDButtonsCallback()
      OpenCtx\onSoftbuttonsChanged\softbuttonsChangedContext = #NULL;
      if lgLcdOpenByType(@OpenCtx)= #ERROR_SUCCESS 
        
        if (wParam = #LGLCD_DEVICE_BW)
          
          Debug"Monochrome device was found"
          g_AppletState\Mono\nDeviceId = OpenCtx\device;
          
				elseif (wParam = #LGLCD_DEVICE_QVGA)
          
          Debug"Color device was found"
          g_AppletState\Color\nDeviceId = OpenCtx\device;
				endif
			endif
      
		case #WM_LGLCD_DEVICE_REMOVAL:
      ; It's important that the devices are closed upon notification
      ; Note that the notification is NOT the device ID, but rather
      ; the device capability
      if ( wParam = #LGLCD_DEVICE_BW)
        
        Debug"Monochrome device was removed"
        lgLcdClose(g_AppletState\Mono\nDeviceId );
        g_AppletState\Mono\nDeviceId = #LGLCD_INVALID_DEVICE;
        
			elseif (wParam = #LGLCD_DEVICE_QVGA)
        
        Debug"Color device was removed"
        lgLcdClose(g_AppletState\Color\nDeviceId );
        g_AppletState\Color\nDeviceId = #LGLCD_INVALID_DEVICE;
			endif
      
		case #WM_LGLCD_APPLET_ENABLED:
      ; One good optimization is to disable LCD rendering if the applet
      ; is disabled
      if wParam=#LGLCD_NOTIFICATION_APPLET_ENABLED
				g_AppletState\isEnabled =  #TRUE 
			else
				g_AppletState\isEnabled = #FALSE  
			endif
      if (g_AppletState\isEnabled)
        
        Debug"Applet was enabled"
        
			else
        
        Debug"Applet was disabled"
			endif
      
		case #WM_LGLCD_CONNECTION_CLOSED:
      ; Dereference the connection handle, and close all the open devices
      Debug"LCD Manager has closed its connection"
      if not g_LCDConnectionCtx\connection=#LGLCD_INVALID_CONNECTION
        
        lgLcdDisconnect(g_LCDConnectionCtx\connection);
        g_LCDConnectionCtx\connection = #LGLCD_INVALID_CONNECTION;
			endif
      
      if not g_AppletState\Mono\nDeviceId=#LGLCD_INVALID_DEVICE 
        
        lgLcdClose(g_AppletState\Mono\nDeviceId);
        g_AppletState\Mono\nDeviceId = #LGLCD_INVALID_DEVICE;
			endif
      
      if not g_AppletState\Color\nDeviceId=#LGLCD_INVALID_DEVICE
        
        lgLcdClose(g_AppletState\Color\nDeviceId);
        g_AppletState\Color\nDeviceId = #LGLCD_INVALID_DEVICE;
			endif
      
		case #WM_LGLCD_BUTTON_EVENT:
      ; Handling of the button state is left as an exercice t
      if (lParam = g_AppletState\Mono\nDeviceId)
        
        g_AppletState\Mono\dwButtonState = wParam;
			endif
      
      if (lParam = g_AppletState\Color\nDeviceId)
        
        g_AppletState\Color\dwButtonState = wParam;
			endif
      HandleButtonPress();
      
		default:
      Procedurereturn DefWindowProc_(hWnd, message, wParam, lParam);
	endselect
  Procedurereturn 0;
EndProcedure


;************************************************************************
;
; InitInstance
;
;************************************************************************


Procedure InitInstance()
  
  Window_0=OpenWindow(#PB_Any, 0, 0, 330, 264, ":)")
  g_hWnd = WindowID(Window_0)
  
  if not g_hWnd
    
    Procedurereturn #FALSE;
	endif
  SetWindowCallback(@wndproc())
  Procedurereturn #TRUE;
endProcedure
;************************************************************************
;
; WinMain
;
;************************************************************************

Procedure _tWinMain()
  
  
  ; Perform application initialization:
  if not InitInstance ()
    
    Procedurereturn #FALSE;
	endif
  
  ; seed
  RandomSeed( GetTickCount_() );
  
  ; Initialize the LCD portion
  initializeLCD();
  
  ; Main message loop:
  msg.MSG
  result = GetMessage_(@msg, #Null, #Null, #Null) 
  While result <> 0
    If result = -1 ; GetMessage failed 
      MessageRequester("Error", "Failure in GetMessage Loop", #MB_ICONERROR) 
      Break 
		EndIf
    TranslateMessage_(@msg);
    DispatchMessage_(@msg);
    result = GetMessage_(@msg.MSG, #Null, #Null, #Null)  
	wend
  
  ; De-initialize the library
  lgLcdDeInit();
  
  Procedurereturn  msg\wParam;
endProcedure

_tWinMain()

Benutzeravatar
Hoto
Beiträge: 294
Registriert: 01.09.2004 22:51

Re: Logitech G19 LCD ansprechen

Beitrag von Hoto »

Mal noch ein danke für den Code, funktioniert sehr gut.

Wenn ich C könnte, hätte ich das selbst probiert. Ich hatte mich vor Monaten schon mal vergeblich daran versucht. Selbst bei dem PB Code hier jetzt hab ich eine Weile gebraucht um dahinter zu steigen wie er genau funktioniert. Ich bin leider auch nicht mehr der jüngste und daher so langsam aber sich auch etwas Begriffsstutziger als früher, zumal ich halt das Ganze hier nur rein als Hobby mache und deshalb auch mal ein paar Monate gar nichts programmiere und so immer wieder etwas verlerne. Also nichts für ungut. ;)
Benutzeravatar
SoS
Beiträge: 340
Registriert: 29.08.2004 09:31
Kontaktdaten:

Re: Logitech G19 LCD ansprechen

Beitrag von SoS »

Hoto hat geschrieben:Wenn ich C könnte, hätte ich das selbst probiert.
Die Ausrede zählt nicht,ich habe mit C auch nix am Hut. :D
Hoto hat geschrieben:Ich bin leider auch nicht mehr der jüngste und daher so langsam aber sich auch etwas Begriffsstutziger als früher, zumal ich halt das Ganze hier nur rein als Hobby mache und deshalb auch mal ein paar Monate gar nichts programmiere und so immer wieder etwas verlerne. Also nichts für ungut. ;)
Mal schauen wie alt Du bist.......mhh nee haste nicht angegeben also schätze ich mal u13 ? :lol:
Der Rest trifft für mich auch zu.
Joebo2572
Beiträge: 9
Registriert: 01.11.2007 11:10
Wohnort: Schwelm

Re: Logitech G19 LCD ansprechen

Beitrag von Joebo2572 »

Hallo,

das Thema ist zwar schon älter, aber vielleicht kann man es "wiederbeleben"... Hab das Beispiel mit dem Bildschirmausschnitt zu einer Lupe umgebaut und geht in der IDE ohne Probleme. Die App startet und setzt sich in den Vordergrund auf den Display. Sobald ich aber ne exe raus mache, muss ich schon Glück haben wenn sie startet. Sehr wackelig eben. Das andere Beispiel hab ich eins zu eins ausprobiert... Selbe Reaktion. Naja... das ist eigentlich nicht die Frage, sondern wie ich die Apps dazu bringe sich automatisch in den Vorderund zu setzten ? Hat da jemand ne Ahnung ? Achja, wenn jetzt jemand sagt das geht nicht... guckst du hier => LCDHost... Vielen Dank !!!!
Benutzeravatar
HeX0R
Beiträge: 2954
Registriert: 10.09.2004 09:59
Computerausstattung: AMD Ryzen 7 5800X
96Gig Ram
NVIDIA GEFORCE RTX 3060TI/8Gig
Win10 64Bit
G19 Tastatur
2x 24" + 1x27" Monitore
Glorious O Wireless Maus
PB 3.x-PB 6.x
Oculus Quest 2
Kontaktdaten:

Re: Logitech G19 LCD ansprechen

Beitrag von HeX0R »

Joebo2572 hat geschrieben:[...]
Achja, wenn jetzt jemand sagt das geht nicht... guckst du hier => LCDHost... Vielen Dank !!!!
Wie ... guckst du hier? Wird das mal ein Link, wenn es groß ist?
Aber, um deine Frage zu beantworten, um Apps in den Vordergrund zu drängeln gibt es das Flag
#LGLCD_LCD_FOREGROUND_APP_YES.
Allerdings habe ich vergessen, wo man das setzen muss, ... ach nee, das war ja => hier.


( :lol: )
Benutzeravatar
SoS
Beiträge: 340
Registriert: 29.08.2004 09:31
Kontaktdaten:

Re: Logitech G19 LCD ansprechen

Beitrag von SoS »

HeX0R hat geschrieben: ... ach nee, das war ja => hier.
:lol: Der war gut.
Joebo2572 hat geschrieben:Hab das Beispiel mit dem Bildschirmausschnitt zu einer Lupe umgebaut..
Darfst gerne MEINE benutzen. :wink:
Joebo2572 hat geschrieben:Die App startet und setzt sich in den Vordergrund auf den Display.
Macht es nur wenn keine anderen laufen,wenn ich das richtig beobachtet habe.
Ich fände es nicht sehr prickelnd wenn sich ene App ständig in der Fordergrund drängelt.
Joebo2572
Beiträge: 9
Registriert: 01.11.2007 11:10
Wohnort: Schwelm

Re: Logitech G19 LCD ansprechen

Beitrag von Joebo2572 »

Sorry, wollte den Link für LCDHost eigentlich reinkopieren, hat wohl nicht geklappt. Man hätte auch googeln können... Konnte ja nicht ahnen das man hier so angep...t reagiert . Also hier ist der Link: http://www.linkdata.se/software/lcdhost . Das Lustige ist, dass es in Purebasic die Anwendung sofort auf dem Display erscheint, wenn ich sie compiliert habe muss ich sie erst auswählen und starten. Wäre toll wenn jemand eine Lösung hat.
Antworten