So about Freelook lua script for Desmume.

Malik177

Member
OP
Newcomer
Joined
Jun 17, 2022
Messages
12
Trophies
0
Age
23
Location
New York
XP
103
Country
United States
I wanted bring this up it really sucks that the forum for this on the desmume site is dead same with the issues page in github page. So I was wondering if anyone can modify this freelook lua text to where it can work with using the keys on a keyboard. Im surprised no one has done this yet, I really want to have the ability to move the camera freely as I play my fav nintendo ds games, but I don't have a xbox controller to do so, nor even have any xbox like controller to make it happen. So if anyone can makes this happen I would really appreciate it.
Post automatically merged:

wasn't too sure if this was supposed to go in the ds section since this is about the emulator
 

Attachments

  • freelook.lua.txt
    6 KB · Views: 63

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,348
Country
United Kingdom
Are they not available for pennies any more? "Compatible" Windows/PC things were going for next to nothing at one point and the script/3d in general does benefit from the kind of input those things can give vs hoping keyboard and mouse does what you want (though at the same time some of that does appear to be a concession to them not doing wonderfully for all aspects).
Most people were also all about having their joysticks appear as mouse and keyboard for things that did not support them but you can probably find something to go the other way and have a virtual joypad.

Anyway had a quick scan. If you are big enough and ugly enough to wind up on the issues page of a source repository then you can probably muddle through remapping/redoing for keyboard input for some of this.
https://wiki.desmume.org/index.php?title=DeSmuME_Manual_for_the_Windows_port
Has the DS specific stuff, most of it is based on the fceux take on the matter (as opposed to the TAS videos efforts)
https://fceux.com/web/help/Commands.html
http://www.lua.org/manual/5.4/
https://www.tutorialspoint.com/lua/index.htm if you wanted a more general intro to programming (not my favourite but it works for this, if you find another works better for you then by all means, sounds like you already have this as a project to deal with).

Most of the heart of the script you can probably leave alone and instead look at the inputs.

I am not sure how much detail to go into.
In schoolboy maths concerning 3d spaces you will probably have been introduced to the option to move things (translation), rotate things (rotation) and make things bigger or smaller (scaling). In not always in schoolboy maths you would then be introduced to matrices and vectors which work wonderfully for a lot of 3d things as well. This looks fairly independent of the control aspects you likely care about in this. Curiously rotation is limited to two axes (this script using the pitch, yaw and roll convention, or I guess pitch and yaw as there is no roll option) but I guess free look Dutch angle is probably just going to confuse things and there are not really enough analogue inputs to do it well so best to skip it.
There is a scan through all the IDs of controller and a check to see if it has the required axes (someone might be using a N64 controller, old school joystick or similar). Can probably lose this if you wanted.
Left and right bumper appear to be used to set a global scaling factor (think DPI switch on a gaming/graphics mouse) which you will probably want to keep in this if only because some games operate on some odd scales.
Dpad then gets used to set the independent movement and rotation scaling factors.

Code:
if(math.abs(key.x)>0.25) then --Left Stick
        MoveRight(-key.x * movscale);
end

This might benefit from some unpacking.
if then end are part of the if loop in this language (sometimes also seen as IF ELSE in other things), that is to say IF this thing happens THEN do this other thing. Loops will be covered in any programming language course but they are usually joined by While loops (while this is the case then do this, usually ending when something trips a flag) and FOR loops which are a bit more advanced in their setup but allow you to do a more repetitive task on a whole series of data.
abs refers to absolute which as a crude explanation makes things positive. When a joystick is in the middle it is typically referred to as 0,0 and will have negative numbers in one direction and positive the other.
-- is Lua's way of comments in code it seems. Something there to help explain code and thus can be ignored for this.
> is greater than (is the left hand part greater than the right), which serves two purposes here. https://www.tutorialspoint.com/lua/lua_operators.htm
1) As a crude dead zone -- analogue sticks wobble, send out noise and more besides. To that end most code using them will ignore things coming out unless it is beyond a certain threshold.
2) Accounts for human factor -- as a mighty gamer of many years I can send a stick down the exact path I want but not everybody can, this then means it only registers and activates when you go beyond a threshold and don't find your up on the stick movement slightly moving to the left as well unless you intentionally move the stick to a more diagonal position.
MoveRight is this script's confusingly named means of horizontal (think strafing) movement (recall the positive and negative thing from before). Anyway if the conditions above are met (i.e. the stick is moved a suitable amount) then it will take the negative* of the value the stick provides, multiply it by the movscale factor (dpad stuff) and pass that onto the MoveRight function.
You would then have to pick a number to substitute when it is pressed, or maybe even clone the function for a different key to have one move left and the other move right. Can also lose the dead zone check if it is going to keys, or better yet change that for the key press of your choice instead.

*this is also how you invert sticks if you wanted that (disgusting behaviour if you ask me but maybe you are into flight sims, exception for left-right which is a funny prank to pull on your friends), and also fiddling here is how you can swap what stick it looks for/passes data to if you wanted say forward/back and rotation on the one stick).

Similar things exist for the other aspects of the script, you getting to devise keys for them, assuming you want to keep them that is (you might not want the reset commands).
 

Malik177

Member
OP
Newcomer
Joined
Jun 17, 2022
Messages
12
Trophies
0
Age
23
Location
New York
XP
103
Country
United States
Are they not available for pennies any more? "Compatible" Windows/PC things were going for next to nothing at one point and the script/3d in general does benefit from the kind of input those things can give vs hoping keyboard and mouse does what you want (though at the same time some of that does appear to be a concession to them not doing wonderfully for all aspects).
Most people were also all about having their joysticks appear as mouse and keyboard for things that did not support them but you can probably find something to go the other way and have a virtual joypad.

Anyway had a quick scan. If you are big enough and ugly enough to wind up on the issues page of a source repository then you can probably muddle through remapping/redoing for keyboard input for some of this.
https://wiki.desmume.org/index.php?title=DeSmuME_Manual_for_the_Windows_port
Has the DS specific stuff, most of it is based on the fceux take on the matter (as opposed to the TAS videos efforts)
https://fceux.com/web/help/Commands.html
http://www.lua.org/manual/5.4/
https://www.tutorialspoint.com/lua/index.htm if you wanted a more general intro to programming (not my favourite but it works for this, if you find another works better for you then by all means, sounds like you already have this as a project to deal with).

Most of the heart of the script you can probably leave alone and instead look at the inputs.

I am not sure how much detail to go into.
In schoolboy maths concerning 3d spaces you will probably have been introduced to the option to move things (translation), rotate things (rotation) and make things bigger or smaller (scaling). In not always in schoolboy maths you would then be introduced to matrices and vectors which work wonderfully for a lot of 3d things as well. This looks fairly independent of the control aspects you likely care about in this. Curiously rotation is limited to two axes (this script using the pitch, yaw and roll convention, or I guess pitch and yaw as there is no roll option) but I guess free look Dutch angle is probably just going to confuse things and there are not really enough analogue inputs to do it well so best to skip it.
There is a scan through all the IDs of controller and a check to see if it has the required axes (someone might be using a N64 controller, old school joystick or similar). Can probably lose this if you wanted.
Left and right bumper appear to be used to set a global scaling factor (think DPI switch on a gaming/graphics mouse) which you will probably want to keep in this if only because some games operate on some odd scales.
Dpad then gets used to set the independent movement and rotation scaling factors.

Code:
if(math.abs(key.x)>0.25) then --Left Stick
        MoveRight(-key.x * movscale);
end

This might benefit from some unpacking.
if then end are part of the if loop in this language (sometimes also seen as IF ELSE in other things), that is to say IF this thing happens THEN do this other thing. Loops will be covered in any programming language course but they are usually joined by While loops (while this is the case then do this, usually ending when something trips a flag) and FOR loops which are a bit more advanced in their setup but allow you to do a more repetitive task on a whole series of data.
abs refers to absolute which as a crude explanation makes things positive. When a joystick is in the middle it is typically referred to as 0,0 and will have negative numbers in one direction and positive the other.
-- is Lua's way of comments in code it seems. Something there to help explain code and thus can be ignored for this.
> is greater than (is the left hand part greater than the right), which serves two purposes here. https://www.tutorialspoint.com/lua/lua_operators.htm
1) As a crude dead zone -- analogue sticks wobble, send out noise and more besides. To that end most code using them will ignore things coming out unless it is beyond a certain threshold.
2) Accounts for human factor -- as a mighty gamer of many years I can send a stick down the exact path I want but not everybody can, this then means it only registers and activates when you go beyond a threshold and don't find your up on the stick movement slightly moving to the left as well unless you intentionally move the stick to a more diagonal position.
MoveRight is this script's confusingly named means of horizontal (think strafing) movement (recall the positive and negative thing from before). Anyway if the conditions above are met (i.e. the stick is moved a suitable amount) then it will take the negative* of the value the stick provides, multiply it by the movscale factor (dpad stuff) and pass that onto the MoveRight function.
You would then have to pick a number to substitute when it is pressed, or maybe even clone the function for a different key to have one move left and the other move right. Can also lose the dead zone check if it is going to keys, or better yet change that for the key press of your choice instead.

*this is also how you invert sticks if you wanted that (disgusting behaviour if you ask me but maybe you are into flight sims, exception for left-right which is a funny prank to pull on your friends), and also fiddling here is how you can swap what stick it looks for/passes data to if you wanted say forward/back and rotation on the one stick).

Similar things exist for the other aspects of the script, you getting to devise keys for them, assuming you want to keep them that is (you might not want the reset commands).
So all I need to do is the controller realated ones? Also are you able to modify this text to where it can work with keyboard imputs? What I want is to able to freely move the camera with keyboard imputs instead of having a controller to do so.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,348
Country
United Kingdom
All you need to do is a phrase that also joins "just" in being dirty words for much of computing/programming.

You would have to remove/disable the controller detection, replace its controller reads with fetches for key presses, decide what value to replace the analogue inputs with* (keys are on or off/pressed or not pressed after all) and also do the button presses and then have your modification.
In an ideal world you would have a controller (or maybe just disable the check) and migrate element by element to a keyboard press, and while I could do it all at once I would still give great consideration to that approach.

*a more advanced script might replace it with acceleration, many gamers will intuitively pulse the button to get them moving at the speed they want (see pulse width modulation or PWM) and you could go one further and include a modifier button a la hold shift to run in a FPS. Mapping things to a mouse would be more annoying but you could plausibly get there too.

As far as editing it then I don't see why not. Why don't you try? Edit a few things in there to be something else (could be the text prompts on screen even) and get a feel for it.
 
  • Like
Reactions: KiiWii

Malik177

Member
OP
Newcomer
Joined
Jun 17, 2022
Messages
12
Trophies
0
Age
23
Location
New York
XP
103
Country
United States
All you need to do is a phrase that also joins "just" in being dirty words for much of computing/programming.

You would have to remove/disable the controller detection, replace its controller reads with fetches for key presses, decide what value to replace the analogue inputs with* (keys are on or off/pressed or not pressed after all) and also do the button presses and then have your modification.
In an ideal world you would have a controller (or maybe just disable the check) and migrate element by element to a keyboard press, and while I could do it all at once I would still give great consideration to that approach.

*a more advanced script might replace it with acceleration, many gamers will intuitively pulse the button to get them moving at the speed they want (see pulse width modulation or PWM) and you could go one further and include a modifier button a la hold shift to run in a FPS. Mapping things to a mouse would be more annoying but you could plausibly get there too.

As far as editing it then I don't see why not. Why don't you try? Edit a few things in there to be something else (could be the text prompts on screen even) and get a feel for it.
alright ill see what i can do also if you are able to do this for me I would. really apppricate it by the way I always wanted to have the chance to explore the many DS games out of bounds. Sucks zeromus and windwakr won't do it
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan
    The snack that smiles back, Ballsack!
  • TwoSpikedHands @ TwoSpikedHands:
    I really would like to make a hack that I would enjoy playing, and maybe other people would too. swapping to the EU version would also mean my US friends could not legally play it
  • TwoSpikedHands @ TwoSpikedHands:
    I am definitely considering porting over some of the EU features without using the actual ROM itself, tbh that would probably be the best way to go about it... but i'm sad that the voice acting is so.... not good on the US version. May not be a way around that though
  • TwoSpikedHands @ TwoSpikedHands:
    I appreciate the insight!
  • The Real Jdbye @ The Real Jdbye:
    @TwoSpikedHands just switch, all the knowledge you learned still applies and most of the code and assets should be the same anyway
  • The Real Jdbye @ The Real Jdbye:
    and realistically they wouldn't

    be able to play it legally anyway since they need a ROM and they probably don't have the means to dump it themselves
  • The Real Jdbye @ The Real Jdbye:
    why the shit does the shitbox randomly insert newlines in my messages
  • Veho @ Veho:
    It does that when I edit a post.
  • Veho @ Veho:
    It inserts a newline in a random spot.
  • The Real Jdbye @ The Real Jdbye:
    never had that i don't think
  • Karma177 @ Karma177:
    do y'all think having an sd card that has a write speed of 700kb/s is a bad idea?
    trying to restore emunand rn but it's taking ages... (also when I finished the first time hekate decided to delete all my fucking files :wacko:)
  • The Real Jdbye @ The Real Jdbye:
    @Karma177 that sd card is 100% faulty so yes, its a bad idea
  • The Real Jdbye @ The Real Jdbye:
    even the slowest non-sdhc sd cards are a few MB/s
  • Karma177 @ Karma177:
    @The Real Jdbye it hasn't given me any error trying to write things on it so I don't really think it's faulty (pasted 40/50gb+ folders and no write errors)
  • DinohScene @ DinohScene:
    run h2testw on it
    +1
  • DinohScene @ DinohScene:
    when SD cards/microSD write speeds drop below a meg a sec, they're usually on the verge of dying
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Samsung SD format can sometimes fix them too
  • Purple_Heart @ Purple_Heart:
    yes looks like an faulty sd
  • Purple_Heart @ Purple_Heart:
    @Psionic Roshambo i may try that with my dead sd cards
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    It's always worth a shot
  • TwoSpikedHands @ TwoSpikedHands:
    @The Real Jdbye, I considered that, but i'll have to wait until i can get the eu version in the mail lol
  • I @ I-need-help-with-wup-wiiu:
    i need help with nusspli failed downloads, can someone respond to my thread? pretty please:wub:
  • Sheeba- @ Sheeba-:
    I can't wait to hack my 11.00 PS4 pro
  • BakerMan @ BakerMan:
    Wake up, it's da first of da month
    BakerMan @ BakerMan: Wake up, it's da first of da month