Sign in to follow this  
Followers 0
GtaSpider

G15 LCD SDK

14 posts in this topic

Hi!

I've got again a question: how i can head for my lcd from my gamekeyboard logitech g15? i knew that it gaves a SDK, but i dont knew how i can head for!

I've got a c++ code, but I can begin thereby nothing!

The c++ code:

//************************************************************************
//
// LCDText.cpp
//
// The CLCDText class draws simple text onto the LCD.
// 
// Logitech LCD SDK
//
// Copyright 2005 Logitech Inc.
//************************************************************************

#include "StdAfx.h"
#include "LCDText.h"
CLCDText::SetText("TEST")


//************************************************************************
//
// CLCDText::CLCDText
//
//************************************************************************


CLCDText::CLCDText()
{
    m_nTextLength = 0;
    m_hFont = NULL;
    ZeroMemory(m_szText, sizeof(m_szText));
    m_crColor = RGB(255, 255, 255); // white
    m_bRecalcExtent = TRUE;
    ZeroMemory(&m_dtp, sizeof(DRAWTEXTPARAMS));
    m_dtp.cbSize = sizeof(DRAWTEXTPARAMS);
    m_nTextFormat = m_nTextAlignment = (DT_LEFT | DT_NOPREFIX);
    m_nTextAlignment = DT_LEFT;
    ZeroMemory(&m_sizeVExtent, sizeof(m_sizeVExtent));
    ZeroMemory(&m_sizeHExtent, sizeof(m_sizeHExtent));
}


//************************************************************************
//
// CLCDText::~CLCDText
//
//************************************************************************

CLCDText::~CLCDText()
{

    if (m_hFont)
    {
        DeleteObject(m_hFont);
        m_hFont = NULL;
    }
}


//************************************************************************
//
// CLCDText::Initialize
//
//************************************************************************

HRESULT CLCDText::Initialize()
{

    m_hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
    if(NULL != m_hFont)
    {
        SetFontPointSize(DEFAULT_POINTSIZE);
    }

    return (NULL != m_hFont) ? S_OK : E_OUTOFMEMORY;
}


//************************************************************************
//
// CLCDText::SetFont
//
//************************************************************************

void CLCDText::SetFont(LOGFONT& lf)
{
    if (m_hFont)
    {
        DeleteObject(m_hFont);
        m_hFont = NULL;
    }

    m_hFont = CreateFontIndirect(&lf);
    m_bRecalcExtent = TRUE;
}


//************************************************************************
//
// CLCDText::GetFont
//
//************************************************************************

HFONT CLCDText::GetFont()
{
    return m_hFont;
}


//************************************************************************
//
// CLCDText::SetFontFaceName
//
//************************************************************************

void CLCDText::SetFontFaceName(LPCTSTR szFontName)
{
    // if NULL, uses the default gui font
    if (NULL == szFontName)
        return;

    LOGFONT lf;
    ZeroMemory(&lf, sizeof(lf));
    GetObject(m_hFont, sizeof(LOGFONT), &lf);

    _tcsncpy(lf.lfFaceName, szFontName, LF_FACESIZE);

    SetFont(lf);
}


//************************************************************************
//
// CLCDText::SetFontPointSize
//
//************************************************************************

void CLCDText::SetFontPointSize(int nPointSize)
{
    LOGFONT lf;
    ZeroMemory(&lf, sizeof(lf));
    GetObject(m_hFont, sizeof(LOGFONT), &lf);

    lf.lfHeight = -MulDiv(nPointSize, DEFAULT_DPI, 72);

    SetFont(lf);
}


//************************************************************************
//
// CLCDText::SetFontWeight
//
//************************************************************************

void CLCDText::SetFontWeight(int nWeight)
{
    LOGFONT lf;
    ZeroMemory(&lf, sizeof(lf));
    GetObject(m_hFont, sizeof(LOGFONT), &lf);

    lf.lfWeight = nWeight;

    SetFont(lf);
}


//************************************************************************
//
// CLCDText::SetText
//
//************************************************************************

void CLCDText::SetText(LPCTSTR szText)
{
    ASSERT(NULL != szText);
    if(szText && _tcscmp(m_szText, szText))
    {
        _tcsncpy(m_szText, szText, MAX_TEXT);
        m_nTextLength = (int)_tcslen(szText);
        m_dtp.iLeftMargin = 0;
        m_dtp.iRightMargin = 0;
        m_bRecalcExtent = TRUE;
    }
}


//************************************************************************
//
// CLCDText::GetText
//
//************************************************************************

LPCTSTR CLCDText::GetText()
{
    return m_szText;
}


//************************************************************************
//
// CLCDText::SetWordWrap
//
//************************************************************************

void CLCDText::SetWordWrap(BOOL bEnable)
{
    if (bEnable)
    {
        m_nTextFormat |= DT_WORDBREAK;
    }
    else
    {
        m_nTextFormat &= ~DT_WORDBREAK;
    }
    m_bRecalcExtent = TRUE;
}


//************************************************************************
//
// CLCDText::SetLeftMargin
//
//************************************************************************

void CLCDText::SetLeftMargin(int nLeftMargin)
{
    m_dtp.iLeftMargin = nLeftMargin;
}


//************************************************************************
//
// CLCDText::SetRightMargin
//
//************************************************************************

void CLCDText::SetRightMargin(int nRightMargin)
{
    m_dtp.iRightMargin = nRightMargin;
}


//************************************************************************
//
// CLCDText::GetLeftMargin
//
//************************************************************************

int CLCDText::GetLeftMargin(void)
{
    return m_dtp.iLeftMargin;
}


//************************************************************************
//
// CLCDText::GetRightMargin
//
//************************************************************************

int CLCDText::GetRightMargin(void)
{
    return m_dtp.iRightMargin;
}


//************************************************************************
//
// CLCDText::GetVExtent
//
//************************************************************************

SIZE& CLCDText::GetVExtent()
{
    return m_sizeVExtent;
}


//************************************************************************
//
// CLCDText::GetHExtent
//
//************************************************************************

SIZE& CLCDText::GetHExtent()
{
    return m_sizeHExtent;
}


//************************************************************************
//
// CLCDText::SetAlignment
//
//************************************************************************

void CLCDText::SetAlignment(int nAlignment)
{
    m_nTextFormat &= ~m_nTextAlignment;
    m_nTextFormat |= nAlignment;
    m_nTextAlignment = nAlignment;
}


//************************************************************************
//
// CLCDText::DrawText
//
//************************************************************************

void CLCDText::DrawText(CLCDGfx &rGfx)
{
    // draw the text
    RECT rBoundary = { 0, 0,0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 
    DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rBoundary, m_nTextFormat, &m_dtp);
    
//  TRACE(_T("Drawing %s at (%d,%d)-(%d-%d) lmargin=%d, rmargin=%d\n"),
//       m_szText, m_Origin.x, m_Origin.y, GetWidth(), GetHeight(),
//       m_dtp.iLeftMargin, m_dtp.iRightMargin);

    if (m_bInverted)
    {
        InvertRect(rGfx.GetHDC(), &rBoundary);
    }
}


//************************************************************************
//
// CLCDText::OnDraw
//
//************************************************************************

void CLCDText::OnDraw(CLCDGfx &rGfx)
{

    if (GetBackgroundMode() == OPAQUE)
    {
        // clear the clipped area
        RECT rcClp = { 0, 0, m_Size.cx, m_Size.cy };
        FillRect(rGfx.GetHDC(), &rcClp, (HBRUSH) GetStockObject(BLACK_BRUSH));
    
        // clear the logical area
        RECT rcLog = { 0, 0, m_sizeLogical.cx, m_sizeLogical.cy };
        FillRect(rGfx.GetHDC(), &rcLog, (HBRUSH) GetStockObject(BLACK_BRUSH));
    }
    
    if (m_nTextLength)
    {

        // map mode text, with transparency
        int nOldMapMode = SetMapMode(rGfx.GetHDC(), MM_TEXT);
        int nOldBkMode = SetBkMode(rGfx.GetHDC(), GetBackgroundMode()); 

        // select current font
        HFONT hOldFont = (HFONT)SelectObject(rGfx.GetHDC(), m_hFont);   

        // select color
        COLORREF crOldTextColor = SetTextColor(rGfx.GetHDC(), m_crColor);
        
        if (m_bRecalcExtent)
        {
            int nTextFormat;

            RECT rExtent;
            // calculate vertical extent with word wrap
            nTextFormat = (m_nTextFormat | DT_WORDBREAK | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rExtent, nTextFormat, &m_dtp);
            m_sizeVExtent.cx = rExtent.right;
            m_sizeVExtent.cy = rExtent.bottom;

            // calculate horizontal extent w/o word wrap
            nTextFormat = (m_nTextFormat | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rExtent, nTextFormat, &m_dtp);
            m_sizeHExtent.cx = rExtent.right;
            m_sizeHExtent.cy = rExtent.bottom;

            m_bRecalcExtent = FALSE;
        }

        if (IsVisible())
        {
            DrawText(rGfx);
        }

        // restores
        SetMapMode(rGfx.GetHDC(), nOldMapMode);
        SetTextColor(rGfx.GetHDC(), crOldTextColor);
        SetBkMode(rGfx.GetHDC(), nOldBkMode);
        SelectObject(rGfx.GetHDC(), hOldFont);
    }
}


//** end of LCDText.cpp **************************************************

the sdk can be downloaded here: http://www.logitech.com/index.cfm/downlo...contentid=10824

sry again for my bad english :whistle:

so long spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites



can't anybody help me? it importent for me :] ive searched again in this forum but i cant find anithing yet :whistle: please help me

Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

I've got again a question: how i can head for my lcd from my gamekeyboard logitech g15? i knew that it gaves a SDK, but i dont knew how i can head for!

I've got a c++ code, but I can begin thereby nothing!

the sdk can be downloaded here: http://www.logitech.com/index.cfm/downlo...contentid=10824

sry again for my bad english :whistle:

so long spider

GtaSpider,

I don't understand your question. But I think I can help you post a message that other users can understand in order to help you.

I suggest that you write your question in your own language and use a translation engine to convert it to English. Then, post your question in both English and your native language. I think then you will have the best chance at communicating what you need.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

Hi!

I've got again a question: how i can head for my lcd from my gamekeyboard logitech g15? i knew that it gaves a SDK, but i dont knew how i can head for!

forget about the SDK, use this ActiveX control: http://g15forums.com/forum/viewtopic.php?t=521

Oh, and please ask the author of the control how to use it. The documentation is virtually non existent.

As soon, as you know what methods the Control provides, you can call them from AutoIT with the COM functions. ObjCreate() and others. See help file.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

@taurus: ok thx! next time :)

@kurt: verry big thx for this link! but im not a newby :)

ok ive looked at google and so one but i cant find how didt it works in autoit

now ive got an vb code but i don't knew what to do with tihs code.. i cant translate this code in autoit :whistle:

i hope smb can help me..

i can explain it in german:

Also ich habe ein VB code mit dem ich aber nichts anzufangen weiß! ich kann ihn einfach nicht in einen autoitcode umwandeln, bzw es funktioniert einfach nicht

here the vb code:

VERSION 5.00
Begin VB.Form frmTest 
   Caption       =   "LCD Demo"
   ClientHeight =   1380
   ClientLeft     =   60
   ClientTop       =   345
   ClientWidth   =   2505
   LinkTopic       =   "Form1"
   ScaleHeight   =   92
   ScaleMode       =   3  'Pixel
   ScaleWidth     =   167
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command2 
      Caption        =   "Fast Demo"
      Height          =   555
      Left          =   1320
      TabIndex      =   2
      Top            =   780
      Width        =   1155
   End
   Begin VB.CommandButton Command1 
      Caption        =   "Slow Demo"
      Height          =   555
      Left          =   60
      TabIndex      =   1
      Top            =   780
      Width        =   1215
   End
   Begin VB.PictureBox LCD 
      AutoRedraw      =   -1  'True
      BackColor    =   &H00000000&
      BorderStyle    =   0  'None
      FillColor    =   &H00FFFFFF&
      BeginProperty Font 
         Name           =   "Small Fonts"
         Size           =   6
         Charset         =   0
         Weight       =   400
         Underline     =   0   'False
         Italic       =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor    =   &H00FFFFFF&
      Height          =   645
      Left          =   60
      ScaleHeight    =   43
      ScaleMode    =   3  'Pixel
      ScaleWidth      =   160
      TabIndex      =   0
      Top            =   60
      Width        =   2400
   End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    
    ' Create an array of 6880 bytes
    Dim byteArrayDemo(0 To 6879) As Byte

    ' Turn on every second pixel, to create a checkerboard pattern.
    ' Set the value to 255 to make it ON, or 0 to make it OFF.
    
    ' Loop through the entire screen.
    For X = 0 To 159
        For Y = 0 To 42
            byteArrayDemo((Y * 160) + X) = IIf((X + Y) Mod 2 = 0, 255, 0)
        Next
    Next
    
    lcdControl.showPixels byteArrayDemo, 0
    
    
End Sub

Private Sub Command2_Click()
    
    ' Clear the picturebox and then write some text onto it.
    LCD.Cls
    LCD.Print "This is a fast demo."
    LCD.Print "The current time is " & Time
        
    ' Update the LCD.
    updatePreview


End Sub

Private Sub Form_Load()
    
    ' Create a new instance of the AvLCD component
    Set lcdControl = New AvLCD
    
    ' Initialize the LCD.
    lcdControl.initLCD "AvLCD Demo File"
    
    ' Set a callback to our ButtonPress Handler.
    lcdControl.setCallback AddressOf LCDbuttonPress
    

End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    ' When unloading, close the LCD interface.
    lcdControl.closeLCD
    
End Sub

and here the autoit code (it doesn't work)

$obj = ObjCreate("LogLCD.AvLCD.1")
MsgBox(0,"",IsObj($obj))
;~ $con.initLCD = "TESTTEST"
#include <GUIConstants.au3>

GUICreate("test", 100, 40)
$but = GUICtrlCreateButton("test", 10, 10, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $but Then $obj.print = "This is a fast demo."
WEnd

he crashed with

D:\skripts\Autoit\wg\005.au3 (12) : ==> The requested action with this object has failed.: 
If $msg = $but Then $obj.print = "This is a fast demo." 
If $msg = $but Then $obj.print = "This is a fast demo."^ ERROR

i hope smb can help me..

Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

@kurt: verry big thx for this link! but im not a newby :)

ok ive looked at google and so one but i cant find how didt it works in autoit

now ive got an vb code but i don't knew what to do with tihs code.. i cant translate this code in autoit :whistle:

i hope smb can help me..

nope. That's just the sample code from the ZIP archive. That does not help much. As I said, ask the author for a proper documentation.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

first: thx at all!

@ dev null:

ok ive got it! he has me sayed the name and so one! ok and now ive written a script, but it doesn't work again! i think when i can this code translate in autoit then i think it can works, but i can't!maiby smb can help me pls?

in german:

ok ich hab es! er sagte mir den name usw! ok! ich habe jetzt ein script geschrieben, aber es geht nicht so richtig! (das konnte ich nicht in englisch sagen: er zeigt mir jetzt den name auf der lcd so das ich ihn auswählen kann, aber mehr auch nicht!)ich denke wenn ich den code in autoit übersetze kann es gehen, aber ích kann es nicht übersetzen! villeicht kann mir netter weise jmd helfen?!?

here the code:

Dim byteArrayDemo(0 To 6879) As Byte

    ' Turn on every second pixel, to create a checkerboard pattern.
    ' Set the value to 255 to make it ON, or 0 to make it OFF.
    
    ' Loop through the entire screen.
    For X = 0 To 159
        For Y = 0 To 42
            byteArrayDemo((Y * 160) + X) = IIf((X + Y) Mod 2 = 0, 255, 0)
        Next
    Next
    lcdControl.showPixels byteArrayDemo, 0

and now my attempt (it doesn't work)

#include <misc.au3>
$obj = ObjCreate("LogLCD.AvLCD.1")
Dim $byteArrayDemo[6880]
For $X = 0 To 159
    For $Y = 0 To 42
        If _IIf(($X + $Y),0,255) = 255 Then MsgBox(0,$y,$x)
        $byteArrayDemo[($Y * 160) + $X] =  _IIf(($X + $Y),0,255)
    Next
Next
$obj.showPixels($byteArrayDemo, 0)

i think it doenst work cause the array.. but i dont knew!

the error is the same!

so long spider :whistle:

Edited by GtaSpider

www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

i think it doenst work cause the array.. but i dont knew!

the error is the same!

O.K. if it's a COM error, try to figure out what is is.

add this to your code.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 

; Performing a deliberate failure here (object does not exist)

; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 
   SetError(1); something to check for when this function returns 
Endfunc

also read about "COM Error Handling" in the help file.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Hi!

Yeah! this i tried bevor, too! but i can't begin smth with this error!:

Ja! das habe ich auch schon probiert, aber ich kann mit dem error nichts anfangen!:

We intercepted a COM Error !

Number is: 80020005

Windescription is: Typkonflikt.

can you?

kannst du :whistle:?

so long spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

Yeah! this i tried bevor, too! but i can't begin smth with this error!:

Ja! das habe ich auch schon probiert, aber ich kann mit dem error nichts anfangen!:

O.K. why didn't you mention this in the first run? Would have saved us a lot of time!

We intercepted a COM Error !

Number is: 80020005

Windescription is: Typkonflikt.

"Data type conflict"?? Well, I would say, that the method expects another data type than you gave it (array).

I don't know the COM implementation of AutoIT, so I cannot say what gets passed if you specify an array. However, the method apparently needs a byte array (maybe a pointer to that). Again, you should ask the author of the Control what he expects here.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

O.K. why didn't you mention this in the first run? Would have saved us a lot of time!

sorry but ive thinked that is not important :lmao:

"Data type conflict"?? Well, I would say, that the method expects another data type than you gave it (array).

I don't know the COM implementation of AutoIT, so I cannot say what gets passed if you specify an array. However, the method apparently needs a byte array (maybe a pointer to that). Again, you should ask the author of the Control what he expects here.

ok ive asked him again! and he says that i need a byte array (the same u have sayed!)

he has sayed that this line

Dim byteArrayDemo(0 To 6879) As Byte

Dimmed a array as byte :) Wow! ok.. but i dont knew how i can translate this in autoit :whistle: !did anybody how?

german:

ok ich habe in schon wider gefragt! er hat gesagt das i ein byte array brauche (das gleiche was du gesagt hast!)

er hat gesagt das diesie linie

Dim byteArrayDemo(0 To 6879) As Byte

das array als byte gedimmmt hat :) Wow wer hätte das gedacht ;)! ok aber ich weiß nicht wie ich es in autoit umwandeln kann.kann mir jmd helfen?

So long Spider

Mfg Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

ok ive asked him again! and he says that i need a byte array (the same u have sayed!)

he has sayed that this line

as I said, I don't know the COM implementation of AutoIT, so I cannot help you any further. You should ask the developer responsible for the COM stuff (don't know who it is).

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Hello!

ive sayed this: "did anybody knew how?" so i mean anybody :whistle:

yeah.. who has createt com for autoit? or who knew how to make a byte array...

so long spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0