It is currently Sat Jun 24, 2017 11:45 pm




Post new topic Reply to topic  [ 9 posts ] 
and here comes the specs of optimus (?) 
Author Message

Joined: Wed Apr 09, 2008 7:01 am
Posts: 3
Post and here comes the specs of optimus (?)
hi everybody,
just received my kb today, plugged to my windows PC. Nice, working and good looking.

And as a hobbyist, i've tried to understand how the kb work internally, with the goal to develop my own keyboard configurator.

the dump of the memory stick give a good idea. each .sys file is a memory dump of the keys, each pixel being represented by 2 bytes (so 65536 colors), so the sys file length is 48*48*2.

playing around with the content of each sys file give the color map pretty easily (FF FF being white, 00 00 being black).

now, plugging the keyboard and watching at the vOptimus folder in the virtual disk created by optimus, structure seems to be very similar.

(btw, the virtual disk is not correctly created. Its letter may override a network disk connected, causing the configurator to fail taking control of the keyboard)

runtime analysis of the configurator show that it opens all the sys files in the [...]\vOptimus\dynamic\*.sys. It is evident that, loading images to the keys is done via these files.

So it looks like I'm near of loading by myself something in the keys. however, there is something missing: when the key bitmap is written into the sys file, what trigger the loading of that bitmap into the key ? DeviceIoControl ??? Event ???? something else ???

more extensive study of the configurator should give me the whole trick, however I'm a lazy person, so it's time to remeber the promise of art boss, to disclose enough information to developpers to be able to program ourselves the keyboard.

So I'm asking for such documentation, or at least a small explamation of how the load bitmap into key event is triggered.

by advance, thank you.


Wed Apr 09, 2008 9:41 am
Profile
Art Lebedev Software Developer
User avatar

Joined: Wed Mar 12, 2008 8:10 pm
Posts: 66
Post Re: and here comes the specs of optimus (?)
Quote:
...playing around with the content of each sys file give the color map pretty easily (FF FF being white, 00 00 being black).

Pixel color by bits 5-6-5 (RRRRRGGGGGGBBBBB)

Quote:
...runtime analysis of the configurator show that it opens all the sys files in the [...]\vOptimus\dynamic\*.sys. It is evident that, loading images to the keys is done via these files.

Yes.

Quote:
...what trigger the loading of that bitmap into the key

Record of a file also trigger. If to be exact, record in last sector of a file and causes its updating.

Quote:
...so it's time to remeber the promise of art boss, to disclose enough information to developpers to be able to program ourselves the keyboard.

At present the documentation all even in development.

Quote:
...or at least a small explamation of how the load bitmap into key event is triggered.

To the aforesaid still it is necessary to add, that in a file layout.sys should be written down 1 in the byte corresponding dynamically updated button. For the beginning it is possible to use a file entirely consisting from 1. ^__^


Wed Apr 09, 2008 2:58 pm
Profile
Art Lebedev Software Developer
User avatar

Joined: Thu Mar 20, 2008 7:08 pm
Posts: 55
Location: Moscow
Post Re: and here comes the specs of optimus (?)
Here is the code that translates any NSImage to sys-file image format:

Code:
- (NSData *) OLEDDataForImage:(NSImage *)image {   
   int oledDataSize = [image size].width * [image size].height * 2;
   int originalSize = 3 * oledDataSize / 2;
   
   NSMutableData *data = [NSMutableData dataWithLength:oledDataSize];
   
   NSData* tiffRep = [image TIFFRepresentation];
   NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:tiffRep];
      
   unsigned char* srcbuf = (unsigned char*)[rep bitmapData];
   unsigned char* dstbuf = [data bytes];   
   unsigned char *ptr = dstbuf;
   
   int pixelCnt = 0;   
   for (unsigned char *rgb=srcbuf; rgb<srcbuf+originalSize; rgb+=6 )
   {         
      unsigned char r1 = rgb[2], g1 = rgb[1], b1 = rgb[0];
      unsigned char r2 = rgb[5], g2 = rgb[4], b2 = rgb[3];
         
      if (g1<8) g1=0;
      if (g2<8) g2=0;

                //fix bright line at the right edge
      if ( ++pixelCnt == 24 )   { r2 /= 2; g2 /= 2; b2 /= 2; pixelCnt = 0; }
      
      ptr[0]=(b1&0xF8) + (g1>>5);
      ptr[1]=(r1>>3) + ((g1&0xFC)<<3);
         
      ptr[2]=(b2&0xF8) + (g2>>5);
      ptr[3]=(r2>>3) + ((g2&0xFC)<<3);
         
      ptr+=4;
   }
   
   return data;
}


Wed Apr 09, 2008 8:17 pm
Profile WWW

Joined: Wed Apr 09, 2008 7:01 am
Posts: 3
Post Re: and here comes the specs of optimus (?)
Hi,

Quote:
Record of a file also trigger. If to be exact, record in last sector of a file and causes its updating.


Thank you guys, that was the information I needed to start something.

now I've written a little test something in Delphi and it's working :-)



if that help, some code bricks for Delphi programmers:

Global variables
KeysFiles: array of THandleStream;
layout,
order,
present,
scancode,
version: THandleStream;

const DrvLetter = 'K'; // DOS letter of the virtual drive in which the keyboard is mounted


// Obtain Uncached IO handle on files to avoid windows Cache delay
function TForm1.GetUncachedIoHandle(Fn: TFileName): THandle;
begin
result := CreateFile(pchar(Fn),GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING,FILE_FLAG_NO_BUFFERING or FILE_FLAG_WRITE_THROUGH,0);
end;


// Open all the files when form is created
procedure TForm1.FormCreate(Sender: TObject);
var
F: TSearchRec;
FH: integer;
Fl: TStringList;
I: Integer;

begin
layout := THandleStream.Create(GetUncachedIoHandle(DrvLetter + ':\vOptimus\layout.sys'));
order := THandleStream.Create(GetUncachedIoHandle(DrvLetter + ':\vOptimus\order.sys'));
present := THandleStream.Create(GetUncachedIoHandle(DrvLetter + ':\vOptimus\present.sys'));
scancode := THandleStream.Create(GetUncachedIoHandle(DrvLetter + ':\vOptimus\scancode.sys'));
version := THandleStream.Create(GetUncachedIoHandle(DrvLetter + ':\vOptimus\version.sys'));
Fl := TStringList.Create;
if FindFirst(DrvLetter + ':\vOptimus\dynamic\*.sys',faAnyFile,F) = 0 then
begin
repeat
Fl.Add(DrvLetter + ':\vOptimus\dynamic\' + f.Name);
until FindNext(F) <> 0;
FindClose(F);
end;
SetLength(KeysFiles,Fl.Count);
for I := 0 to high(KeysFiles) do
begin
KeysFiles[I] := THandleStream.Create(GetUncachedIoHandle(Fl[I]));
end;
Fl.Free;
end;


// And close everything
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
I: Integer;

begin
layout.Free;
order.Free;
present.Free;
scancode.Free;
version.Free;
for I := 0 to high(KeysFiles) do
begin
KeysFiles[I].Free;
end;
SetLength(KeysFiles,0);
end;

// Convert a 48*48 bitmap into the memory buffer of a key, using GR32 (Graphics32), a well known free graphic library
function TForm1.BitmapToKey(Bm: TGraphic; K: PWordArray): boolean;
var
Bmp: TBitmap32;
C: PColor32;
R,G,B: Byte;
Pix: Word;
I: Integer;

begin
Bmp := TBitmap32.Create;
Bmp.Assign(Bm);
result := (Bmp.Width = 48) and (Bmp.Height = 48);
if result then
begin
C := @Bmp.Bits[0];
for I := 0 to 48*48 - 1 do
begin
R := RedComponent(C^);
G := GreenComponent(C^);
B := BlueComponent(C^);
// Bitmask RRRRRGGGGGGBBBBB
K[I] := ((R and $F8) or (G shr 5)) or
(((B shr 3) or ((G shr 2) and $07)) shl 8);
inc(C);
end;
end;
Bmp.Free;
end;

// Put in all buttons a random 48*48 bitmap that could comes from a PNG image list that I've dropped on my form
procedure TForm1.TntButton1Click(Sender: TObject);
var
I,J: Integer;
WM: PWordArray;
LP: PByteArray;

begin
// Because IO are uncached, we must write an integer multiple of sector size (512 bytes) at once otherwise the IO would fail,
// so this requires the use of a working memory buffer for both the key (9 sectors), and the layout file (1 sector)
Getmem(Wm,48*48*2);
Getmem(Lp,512);
Fillchar(lp^,512,0);
for I := 0 to high(KeysFiles) do
begin
BitmapToKey(Imgl.PngImages[Random(Imgl.PngImages.Count)].PngImage,Wm);
Keysfiles[I].Position := 0;
Keysfiles[I].Write(WM^,48*48*2);
Lp[I] := 1;
end;
layout.Position := 0;
Layout.Write(Lp^,512);
freemem(Wm);
Freemem(Lp);
end;


I hope this wasn't too long, it's just testapp, if it may help someone ... ;)


Wed Apr 09, 2008 10:32 pm
Profile
Art Lebedev Software Developer
User avatar

Joined: Wed Mar 12, 2008 8:10 pm
Posts: 66
Post Re: and here comes the specs of optimus (?)
Current protocol draft:

http://optimus.artlebedev.com/maximus/O ... 4Users.doc


Thu Apr 10, 2008 12:38 am
Profile

Joined: Wed Apr 09, 2008 7:01 am
Posts: 3
Post Re: and here comes the specs of optimus (?)
Quote:
Current protocol draft:


thank you very much !


Thu Apr 10, 2008 1:06 am
Profile
User avatar

Joined: Fri Apr 18, 2008 12:26 am
Posts: 4
 Re: and here comes the specs of optimus (?)
Hi All,

I just found this place. I've been interested in this keyboard for a while, but I need to know if I can change layouts dynamically from within my software. If this is possible, I might be able to use the keyboard, and demonstrate its use as a possible replacement for a custom keyboard that my company makes. From looking at these specs, it seems like it just might be possible.

Is there going to be a published API or an SDK available to software developers, or is this it?


Fri Apr 18, 2008 1:24 am
Profile
Art Lebedev Software Developer
User avatar

Joined: Wed Mar 12, 2008 8:10 pm
Posts: 66
Post Re: and here comes the specs of optimus (?)
Quote:
...I need to know if I can change layouts dynamically from within my software.


Yes, you can. Optimus Maximus is a Mass Storage device (disk drive), with a file for each button image. So you can use even a .bat file to copy desired layout images to the keyboard and they will appear on the keyboard instantly.

Quote:
Is there going to be a published API or an SDK available to software developers, or is this it?


http://optimus.artlebedev.com/maximus/O ... 4Users.doc
It is a draft of the future SDK.


Sun Apr 20, 2008 5:43 pm
Profile
User avatar

Joined: Fri Apr 18, 2008 12:26 am
Posts: 4
Post Re: and here comes the specs of optimus (?)
Pretender wrote:
Quote:
...I need to know if I can change layouts dynamically from within my software.


Yes, you can. Optimus Maximus is a Mass Storage device (disk drive), with a file for each button image. So you can use even a .bat file to copy desired layout images to the keyboard and they will appear on the keyboard instantly.

Quote:
Is there going to be a published API or an SDK available to software developers, or is this it?


http://optimus.artlebedev.com/maximus/O ... 4Users.doc
It is a draft of the future SDK.


OK, thanks for the info. I've got the protocol specs, I'll have to get a keyboard now and try it out. ;)


Mon Apr 21, 2008 7:08 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forum/DivisionCore.