Jump to content

Leadwerks::Key::RButton and Leadwerks::Key::MButton are set to the wrong values.


Era
 Share

Recommended Posts

I have the following code in App::Start()

 


 std::cout << "Left Button: " << Key::LButton << std::endl;
 std::cout << "Middle Button: " << Key::MButton << std::endl;
 std::cout << "Right Button: " << Key::RButton << std::endl;

 

It outputs the following:

Left Button: 1
Middle Button: 4
Right Button: 2

 

Middle button should be 2 and right button should be 3.

 

I know this because I tested with the following code:


 if (window->MouseDown(1)) {
   std::cout << "Left Button Pressed" << endl;
 }

 if (window->MouseDown(3)) {
   std::cout << "Right Button Pressed" << endl;
 }

 if (window->MouseDown(2)) {
   std::cout << "Middle Button Pressed" << endl;
 }

 

Note: I tested this on Linux standalone

Link to comment
Share on other sites

As to what Aggror posted that is how the mouse buttons have always been since the very early days of LE. Just out of curiosity, what do you get if you run this lua script on your machine:

function App:Start()

self.window = Window:Create()

self.context = Context:Create(self.window)

self.world = World:Create()

self.camera = Camera:Create()

self.camera:Move(0,0,-3)

local light = DirectionalLight:Create()

light:SetRotation(35,35,0)

 

self.model = Model:Box()

self.model:SetColor(0.0,0.0,1.0)

 

return true

end

 

function App:Loop()

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

 

Time:Update()

self.world:Update()

self.world:Render()

 

mouse = nil

if self.window:MouseDown(1) then mouse = 1 end

if self.window:MouseDown(2) then mouse = 2 end

if self.window:MouseDown(3) then mouse = 3 end

self.context:SetBlendMode(Blend.Alpha)

self.context:DrawText("Mouse down: "..tostring(mouse),2,2);

 

self.context:Sync(false)

 

return true

end

 

When I click the left, right, and middle then it reports them in the order like Aggror shows.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Looking at this again, it appears the value of 'Key.MButton' is assigned as 4 like the OP alluded to -when it should be 3

System:Print("Left: "..Key.LButton)

System:Print("Right: "..Key.RButton)

System:Print("Middle: "..Key.MButton)

returns:

Left: 1

Right: 2

Middle: 4

 

So if I would have used the variable instead of the value of 3 then it would not have worked when clicking the middle mouse button (wheel):

if self.window:MouseDown(Key.MButton) then mouse = 3 end

 

EDIT--The value of 'Key.MButton' should be opened as a bug report.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Well it is strange that you get 2 for right mouse button. Because here on Ubuntu 14.04 with a Steelseries Kana mouse I set up this enum for mouse buttons and it is displaying the proper mapping

 

namespace MouseButtons
{
enum Buttons {
Left = 1,
Middle,
Right
};
}

 

I am testing it with this

 

{
// Debugging
if (window->MouseHit(MouseButtons::Left)) {
 std::cout << "LeftButton pressed." << std::endl;
}
if (window->MouseHit(MouseButtons::Middle)) {
 std::cout << "MiddleButton pressed." << std::endl;
}
if (window->MouseHit(MouseButtons::Right)) {
 std::cout << "RightButton pressed." << std::endl;
}
}

 

EDIT:

 

Ahh, in X11 The mouse buttons are Left =1, Middle = 2, and Right = 3 and in Leadwerks they are not accounting for it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...