How to see which mouse button was pressed (Unity Input System)

I have switched my game to use the new Unity Input System, and I want to know which mouse button was pressed when an action is called.

Here’s how it’s set up: Input System

Whenever one of these three mouse buttons are pressed, the MouseButtonClicked action will fire. I want to somehow know which one of these buttons was pressed from this single action, rather than making 3 seperate actions for 3 seperate mouse buttons.

I have tried reading the values from InputAction.CallbackContext context but I can’t seem to get a proper value from the mouse button which was pressed.

How can I do this?

Approximation of a function part of the input of NMaximize

I need to maximize the following function (the input to NMaximize below)

    NMaximize[{((1/3) + f[p]*(1 - p)*(((1/(Sqrt[2]/2))*p)^2-1))/(1+(1-p)*     (((1/(Sqrt[2]/2))*p)^2 - 1)), p >= Sqrt[2]/2, p <= 1}, {p}] 

where $ f(\cdot)$ is defined as follows

    f[p_?NumericQ] := NMinimize[{-((a + a^2 + b - 2 a b + b^2 + c - 2 a c - 2 b c + c^2)     /((-1 + a) (a + b + c))), 0 <= a, a <= b, b <= c, c <= 1, c <= a + b, (a + b + c)/3 <= p},      {a, b, c}, Method -> "DifferentialEvolution"][[1]] 

However, as expected, the computation does not end and there are several alert messages. For the underlying mathematical problem I am trying to solve, I could replace $ f(\cdot)$ by a simple function $ g(\cdot)$ that approximates it, but I need $ g(p)\le f(p)$ for all $ p\in[0,1]$ . I tried to use InterpolatingPolynomial with a few values of $ f(\cdot)$ . However, $ f(\cdot)$ is neigher concave nor convex in $ [0,1]$ , and I am struggling to obtain a good approximation of $ f(\cdot)$ which satisfies the $ g(p)\le f(p)$ in $ [0,1]$ .

Do you know how any method for generating such approximation function $ g(\cdot)$ (or solving the maximization problem in a different way)?

Difference between shader input element classification between D3D12 and Vulkan

I’m confused about the difference between the shader input element classifications in D3D12 and Vulkan. For example, in Vulkan I could have the following declarations:

struct vertex {     glm::vec3 pos;     glm::vec3 col; };  VkVertexInputBindingDescription input_binding_description {     .binding = 0,     .stride = sizeof(vertex),     .inputRate = VK_VERTEX_INPUT_RATE_VERTEX };  std::array<VkVertexInputAttributeDescription, 2> input_attribute_descriptions {     VkVertexInputAttributeDescription{         .location = 0,         .format = VK_FORMAT_R32G32B32_SFLOAT,         .offset = offsetof(vertex, pos)     },         VkVertexInputAttributeDescription{         .location = 1,         .format = VK_FORMAT_R32G32B32_SFLOAT,         .offset = offsetof(vertex, col)     } }; 

Here the input rate is specified per vertex and not per attribute. On the other hand, in D3D12, we would have

struct Vertex {     XMFLOAT3 pos;     XMFLOAT3 col; };  std::array<D3D12_INPUT_ELEMENT_DESC, 2> input_element_descs = {     { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,     D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },     { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12,     D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } }; 

And as you can see, the input rate is specified per attribute. Why is that? Is there a difference between the meaning of the input classification in D3d12 and Vulkan that I’m missing? I’m not familiar with D3D12, but at first glance, it doesn’t make sense to me to have different input classifications for the attributes of a vertex.

reading input from multiple mice in QB64 in Windows 10?

I am looking to write a non-network multiplayer game for Windows 10 with QB64 that accepts input from 2 or more USB mice plugged into the system. Like a simple Pong game where additional players plug mice into a USB hub to use as game controllers.

I have been googling this and found some older threads

  • Is it possible to detect two different mice at the same time, and have their movements recorded seperately? Asked 8 years, 9 months ago
  • How do I read input from multiple keyboards/mice on one computer? Asked 7 years, 6 months ago

however these are pretty old threads from before Windows 10, also they seem to be more oriented towards C++ or .NET.

Can anyone provide some example how it might be done with QB64 under Windows 10?

Thanks

Fixed physics time step and input lag

Everywhere I read says I should fix the time step of my physics simulation, and interpolate the result to the actual frame rate of my graphics. This helps with simplicity, networking, reproducibility, numerical stability, etc.

But as I understand it, fixed time step guarantees between 1 and 2 Δt of input lag, because you have to calculate one step ahead in order to interpolate. If I use 90 Hz physics, it gives me an input lag of about 17 ms, on average.

Since I often see gaming enthusiasts talking about 1 ms input lag, 1 ms delay, and how that makes a difference, I wonder how fast-action games does it, and how they reduce the input lag using fixed time step.

Or they don’t, and 1 ms delay is just marketing mumbo jumbo?

Is it possible for the runtime and input size in an algorithm to be inversely related?

I’m wondering if it’s possible for algorithms that have monotonically decreasing runtime with the input-size – just as a fun mental exercise. If not, is it possible to disprove this claim? I haven’t been able to come up with an example or counterexample so far, and this sounds like an interesting problem.

P.S. Something like $ O(\frac{1}{n})$ , I guess (if it exists)

Is nonce useless when user input is reflected within an inline script?

I stumbled upon a web app which is accepting user input and putting it into a variable within script tag.

The script tag does have a nonce attribute.

enter image description here

As am working on bypassing the XSS filter, I had this thought that this practice of reflecting user input within an inline script with nonce attribute beats the purpose of using it.

Is my understand correct or am I missing something here ?

How to seperate gui input from world input?

I have a GUI interface and a player that hase code to detect when the mouse is pressed.

When i mess with my GUI buttons the code for the player also fires off; an undesired behavior. The code in the player is meant for mining or using his current item not meant for buttons.

Some people have suggested using _unhandled_input and mouse filters, but i havent gotten either of those to work. Im just wondering what the common thing to do in the situation?

Build PDA for a language with unknown input alphabet

$ L_1 ,L_2$ are regular language. We form a new language $ L_{12}$ as follows: $ L_{12}=\left \{ w_1\cdot w_2|w_1\in L_1\wedge w_2\in L_2\wedge|w_1|=|w_2| \right \}$

In this exersice I am not given any alphabet and I’m required to build PDA for $ L_{12}$ , but by definition $ M=\left \{Q,\sum,\Gamma ,\delta ,q_0,-|,F\right\}$ and I don’t have any alphabet to work with.By intuition if the alphabet is similiar can effect the solution than if it wasn’t similiar.