Skip to content

Keyboard supportΒ #21

@Flix01

Description

@Flix01

Hi, I've seen that a gamepad is mandatory, and that the "keyboard support patch" proposed here has a broken link.

Here are my changes in file controller.cpp:

vec3 gamepad_get_stick(int stick, const float deadzone = 0.2f)
{
// I've replaced all the original content of this function with the following:
vec3 pad(0,0,0);float am = 1.f;
if (IsKeyDown(KEY_RIGHT_SHIFT) || IsKeyDown(KEY_LEFT_SHIFT)) am*=0.5f;  // use SHIFT to slow down/walk
if (IsKeyDown(KEY_RIGHT_CONTROL) || IsKeyDown(KEY_LEFT_CONTROL)) am*=2.f; // use CTRL to speed up
if (stick==GAMEPAD_STICK_LEFT)	{
        // use ARROW keys to move the character
	if (IsKeyDown(KEY_RIGHT)) pad.x+=am;
	if (IsKeyDown(KEY_LEFT)) pad.x-=am; 
	if (IsKeyDown(KEY_UP)) pad.z-=am;
	if (IsKeyDown(KEY_DOWN)) pad.z+=am;
}
else if (stick==GAMEPAD_STICK_RIGHT)	{
        // use the number pad to move the camera
	if (IsKeyDown(KEY_KP_6)) pad.x-=am;
	if (IsKeyDown(KEY_KP_4)) pad.x+=am; 
	if (IsKeyDown(KEY_KP_8)) pad.z+=am;
	if (IsKeyDown(KEY_KP_2)) pad.z-=am;
}
return pad;
}

This works for me (I'm on Ubuntu Linux).
I'm not making a pull request. I've just posted my code here in case somebody is interested.

@orangeduck: feel free to close this issue whenever you want, and thanks for sharing the project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions