Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Konami keycode to bring CE to front

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon May 23, 2016 7:09 pm    Post subject: Konami keycode to bring CE to front Reply with quote

This code will cause ce to come to the foreground if you use the konami code on your gamepad. I'm sure you can come up with other things to do with this

Code:

str=''
counter=0

function dosomethinginthegui()
  getMainForm().show()
  getMainForm().bringToFront()
  getMainForm().FormStyle="fsSystemStayOnTop"
  getMainForm().FormStyle="fsNormal"
end

delayperkey=500

keys={}
keys.U=0
keys.D=0
keys.L=0
keys.R=0
keys.A=0
keys.B=0

function getKey(s)
  if s.GAMEPAD_DPAD_UP and (getTickCount()>keys.U+delayperkey) then
    keys.U=getTickCount()
    return 'U'
  end

  if s.GAMEPAD_DPAD_DOWN and (getTickCount()>keys.D+delayperkey) then
    keys.D=getTickCount()
    return 'D'
  end
  if s.GAMEPAD_DPAD_LEFT and (getTickCount()>keys.L+delayperkey) then
    keys.L=getTickCount()
    return 'L'
  end
  if s.GAMEPAD_DPAD_RIGHT and (getTickCount()>keys.R+delayperkey) then
    keys.R=getTickCount()
    return 'R'
  end
  if s.GAMEPAD_A and (getTickCount()>keys.A+delayperkey) then
    keys.A=getTickCount()
    return 'A'
  end
  if s.GAMEPAD_B and (getTickCount()>keys.B+delayperkey) then
    keys.B=getTickCount()
    return 'B'
  end
end



function checkThread(t)
  local s=getXBox360ControllerState()
  if (s==nil) then
    lastID=0
  else
    local lastID=s.PacketNumber
  end
  local c
  local b
  local e

  counter=counter+100
  while not t.Terminated do
    counter=counter+1

    while ((s==nil) or (lastID==s.PacketNumber)) and (not t.Terminated) do
      sleep(10)
      s=getXBox360ControllerState()
    end

    if t.Terminated then return end

    lastID=s.PacketNumber
    c=getKey(s)
    if c~=nil then
      str=str..c
    end

    b,e=string.find('UUDDLRLRBA',str)
    if b==nil then str='' end
    if b~=1 then str='' end
    if e~=nil then
      if (e<#str) then str='' end
      if (b==1) and (e==10) then
        t.synchronize(dosomethinginthegui)
        str=''
      end
    end

  end
end

s=createNativeThread(checkThread)
return s

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Tue May 24, 2016 8:18 am    Post subject: Reply with quote

I'm not gonna lie, this is pretty awesome, DB. lol.

Is there a way to create a cheat that could only be enabled by doing this? Imagine implementing your own Konami code cheat like infinite lives or something for an NES game in an emulator. That would be a pretty sweet novelty, I think!

I've been dying to start doing some videos on Lua in CE and I think this would be a really cool way to jump into that! Very Happy

_________________
Back to top
View user's profile Send private message Visit poster's website
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue May 24, 2016 3:30 pm    Post subject: Reply with quote

I'm making my own controller handler for combos.

I started working on it just after I sent pull request on github (wButtons field)



Requirements:
- should detect those buttons:
A B X Y (aka cross circle square triangle),
digital pad, LB RB, pressed analogs (LA RA)

- detect combinations of pressed buttons:
two buttons:
AB
AX
AY
BX
BY
XY
A{dup}
A{ddown}
A{dleft}
A{dright}
A{LB}
A{RB}
A{LA}
A{RA}
...

three buttons:
ABX
ABY
AXY
BXY
...

four buttons
ABXY
...


- (AB,XY) combo is treated as (AB,release,XY) by default

- NORELEASE option, so this combo (DLA,DLY,DLX,DLB) should be entered without any pause, without releasing all buttons before entering very last button(s)

- should take into account that combinations of buttons can't be pressed at exact time
i.e. you pressed AB and a bit later (millisecond) pressed Y (while AB still pressed) should be detected as ABY

- be more forgiving,
i.e. you pressed AB and a bit later hit Y few times (while AB still pressed), release buttons, then hit X
It will still detect (ABY,X) combo

- satisfying above requirements can lead to collisions (detecting two or more combos while user wanted only one)





- when adding new combo (e.g. by using a Lua function) do some checks:

a) digital buttons dup and ddown (dleft and dright) can't be pressed at the same time

b) detect and inform about collisions. For example added combo is just other combo truncated




Why so complicated. Because every game can have very different function for the same buttons (A button in some games is "jump", and in other "use").





Almost finished code. Combos you can test:
first one is
releaserelease




second:
releaserelease





third:
release release release




fourth:
release release release release





fifth:
DLA,DLY,DLX,DLB without releasing button(s), so you should hit and press Digital Left, then hit A, then Y, then X, then B.


I will post finished extension in "Lua Extentions" subforum later.



Edit:
released first version here: http://forum.cheatengine.org/viewtopic.php?t=592204



 

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites