View previous topic :: View next topic |
Author |
Message |
mordax Expert Cheater Reputation: 1
Joined: 16 Apr 2010 Posts: 121
|
Posted: Wed Sep 22, 2021 9:46 am Post subject: Help with controller hotkeys in lua? |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Wed Sep 22, 2021 10:03 am Post subject: |
|
|
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 |
|
|
mordax Expert Cheater Reputation: 1
Joined: 16 Apr 2010 Posts: 121
|
Posted: Wed Sep 22, 2021 11:23 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Wed Sep 22, 2021 1:27 pm Post subject: |
|
|
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 |
|
|
mordax Expert Cheater Reputation: 1
Joined: 16 Apr 2010 Posts: 121
|
Posted: Thu Sep 23, 2021 3:15 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Thu Sep 23, 2021 3:51 am Post subject: |
|
|
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 |
|
|
mordax Expert Cheater Reputation: 1
Joined: 16 Apr 2010 Posts: 121
|
Posted: Sun Oct 03, 2021 7:46 pm Post subject: |
|
|
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 |
|
|
|