Jump to content

[Version 1] Working Reverse Keyboard Led Channel Poc


Recommended Posts

Hi there,

i have thought about the solution transferring data via the keyboard leds back to the teensy.

first of all its a proove of concept. (so pritty slow)

what you need.

arduino ide

teensydurino addon from pjrc.com

#include <phukdlib.h> from irongeek.com

and for the sending part:

autoit from autoitscript.com

arduino code:

#include &lt;phukdlib.h&gt;
int ascii = 0;
char buf[12];
int changed = 0;

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {

if (IsNumbOn()){
  if (IsScrlOn()){
      // digitalWrite(6, HIGH);
      changed = 1;
    } 
    else {
      if (changed == 1){
          changed = 0;
          ascii += 1;
        }
      // digitalWrite(6,LOW); 
    }
  }
  else {
      if (ascii &gt; 0){
      char thisString = ascii;
      Keyboard.print(thisString);
      ascii = 0;
    }
  }
}

and the counterpart on the pc itself, written in autoit.

Global $speed = 36 ; lesser values for faster transfer, may result in false data...
sendstring("test")

Func sendstring($string)
	Send("{SCROLLLOCK off}")
	Send("{NUMLOCK off}")
	$src = StringSplit($string, "")
	For $i = 1 To $src[0]
		ConsoleWrite($src[$i] &amp; @CRLF)
		sendkey($src[$i])
	Next
EndFunc   ;==&gt;sendstring

Func sendkey($key)
	Send("{NUMLOCK on}")
	For $x = 1 To Asc($key)
		Send("{SCROLLLOCK on}")
		Sleep($speed)
		Send("{SCROLLLOCK off}")
		Sleep($speed)
	Next
	Send("{NUMLOCK off}")
	Sleep($speed)
EndFunc   ;==&gt;sendkey

it uses numlock to activate listening mode and sends the string as ascii codes to the teensy via scrolllock, i took those Keys to be able to type normaly during the transfer process.

i may switch to binary mode when i know more about arduinos capability to use it.

maybe using num as clock and scrolllock as data line.

what i figured out when lowering the send delay below 36ms between led iterations the arduino won't be able to keep up and misses some of the signal switches.

currently i only check for the scrolllock turning of so maybe there is a performance boost hidden in it too.

to see if the arduino has understood the signal correctly i managed to return the send keys as real keys back to the computer.

now i have a hardware keyboard controlable by software on the same machine.

good for anticheating tool workarounds (when it gets faster)...

please make sure you select a keyboard enabled usb type in the arduino ide via "Tools" > "USB-Type"

thats it for now, feel free to contribute or wait. ;)

Link to post
Share on other sites

ah like the teensy project

http://code.google.com/p/teensy-dlp-bypass/

indeet ... dammit there is always someone beeing faster and more elegant ;)

anyway:

here the binary converted PC part written in autoit (NOT compatible with the previous arduino code!):

$arr = stringtobase2("Dies ist ein sehr sehr langer Test 0123456789")
sendarray($arr, 40) ; 40 ms pause * 2 *8 = One Character every 640 ms !

Func sendarray($arr,$speed)
	For $i = 1 To UBound($arr) - 1
		ConsoleWrite($arr[$i] &amp; @CRLF)
		$arr2 = StringSplit($arr[$i], "")
		For $x = 1 To $arr2[0]
			If $arr2[$x] = 1 Then
				Send("{SCROLLLOCK on}")
			Else
				Send("{SCROLLLOCK off}")
			EndIf
			Send("{NUMLOCK on}")
			Sleep($speed)
			Send("{NUMLOCK off}")
			Sleep($speed)
		Next
		Send("{SCROLLLOCK off}")
	Next
EndFunc   ;==&gt;sendarray

Func stringtobase2($txt)
	Local $src = StringSplit($txt, "")
	Local $res[UBound($src)]
	For $x = 1 To $src[0]
		$res[$x] = chartobase2($src[$x])
	Next
	Return $res
EndFunc   ;==&gt;stringtobase2

Func chartobase2($chr)
	Local $nr = Asc($chr)
	Local $res = ""
	If BitAND($nr, 128) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 64) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 32) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 16) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 8) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 4) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 2) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	If BitAND($nr, 1) Then
		$res &amp;= "1"
	Else
		$res &amp;= "0"
	EndIf
	Return $res
EndFunc   ;==&gt;chartobase2

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...