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 


Help with controller hotkeys in lua?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Wed Sep 22, 2021 9:46 am    Post subject: Help with controller hotkeys in lua? Reply with quote

Hiya. i've tried mapping controller buttons as hotkeys in lua, but they're not working. I can add my controller buttons as hotkeys in cheat list, but that's not what i need.

I have a lua script I want to execute by pressing a controller button, here's what I tried

Code:
function hack1()
print("blah")
end
createHotkey(hack1, GAMEPAD_A)


I looked up the codes and GAMEPAD_A is right one, but it doesn't do anything. If I replace "GAMEPAD_A" with something like "VK_UP" it works fine.
any ideas? thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Sep 22, 2021 10:03 am    Post subject: Reply with quote

what value is GAMEPAD_A ?

Is it 22528 ?(0x5800)

_________________
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
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Wed Sep 22, 2021 11:23 am    Post subject: Reply with quote

Dark Byte wrote:
what value is GAMEPAD_A ?

Is it 22528 ?(0x5800)


i'm lost, what do you mean value?
I just want to replace the VK_ hotkey with controller key, what should I do exactly?

I took the codes from here
https://wiki.cheatengine.org/index.php?title=Lua:getXBox360ControllerState

I assume those are the ones i need to put in lua, just like wtih VK_ codes. i have no idea how to do this, that's why i'm asking how i can use controller buttons to create a hotkey in lua. hope this makes sense. thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Sep 22, 2021 1:27 pm    Post subject: Reply with quote

Thise are unrelated to hotkeys . These entries aren't even key values

try
createHotkey(hack1, 0x5800)

and see if that works

_________________
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
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Thu Sep 23, 2021 3:15 am    Post subject: Reply with quote

Dark Byte wrote:
Thise are unrelated to hotkeys . These entries aren't even key values

try
createHotkey(hack1, 0x5800)

and see if that works


nice thanks. it works, but where can I see codes for controller? do you have a list or know where to find them?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Sep 23, 2021 3:22 am    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?p=5762739#5762739
_________________
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
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Thu Sep 23, 2021 3:51 am    Post subject: Reply with quote

TheyCallMeTim13 wrote:
I have never used this, so it's hard to say what to do. But from the documentation on it, it looks like you need to create a timer then in the timer's call back use 'getXBox360ControllerState' to get a table of the controller state, then check the state to see what you need to run.

Code:

local timer = nil
local timerInterval = 100 ---- Timer intervals are in milliseconds
local timerTicks = 0
local function timer_tick(t) ---- Timer tick call back
   local tbl = getXBox360ControllerState()
   if tbl.GAMEPAD_DPAD_UP then
       -- code
   elseif tbl.GAMEPAD_A and tbl.GAMEPAD_B and not tbl.GAMEPAD_X then
       -- code
   end
end
timer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
timer.Interval = timerInterval ---- Set timer interval
timer.OnTimer = timer_tick ---- Set timer tick call back


To deal with button holds, you need to add a second timer to time the holds.

But there are no global variables for the controller state that I have seen.
Back to top
View user's profile Send private message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Sun Oct 03, 2021 7:46 pm    Post subject: Reply with quote

Dark Byte wrote:
https://forum.cheatengine.org/viewtopic.php?p=5762739#5762739


nice thx. works fine

@Tim13 button holds works fine when using them in lua. maybe it was issue in older ce?
Back to top
View user's profile Send private message
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