How to use mouse wheel on Simulator?

What MCU/Processor/Board and compiler are you using?

CodeBlocks MinGW on Windows

What do you want to achieve?

Use my mouse wheel to simulate an encoder

What have you tried so far?

According to my guess I need to change #define USE_MOUSEWHEEL to 1.

But this doesn’t change anything.

You also have to initialize the mouse wheel driver. Defining USE_MOUSEWHEEL to 1 just enables compilation of it.

I tried this too. I initialized mousewheel using the exact same code. I inserted it in main.c.

Still I am not able to scroll anything.

Similarly I tried to enable and initialize a keyboard but it also didn’t have any effect.

Did you add it to a group? Did you add the objects you want to use it with to a group as well? Did you test it with the lv_test_group example?

A code sample would be really helpful to understand the problem. Otherwise I am just speculating as to how your code was written.

This is what I have done until now

  1. Set these in lv_drv_conf.h
#  define USE_KEYBOARD        1
#  define USE_MOUSE           1
  1. Set these in lv_ex_conf.h
#define LV_EX_KEYBOARD     1
  1. Included lv_test_group.h in main.c
  2. Called lv_test_group_1(); from main.c

Output

image

Problem

According to a touchless demo online I believe this is correct. I am also able to navigate using the touch arrows on top of the screen.

However, I am not able to use my keyboard or any other input device.

Might be worth a full clean and rebuild. Perhaps lv_test_group_1 has not picked up on the fact that you enabled the keyboard and mouse. Also, the mousewheel is a separate option (LV_EX_MOUSEWHEEL, USE_MOUSEWHEEL or something like that).

I tried a full clean and rebuild and it is still not working.

Yes, I omitted it earlier because when I enabled mousewheel CodeBlocks was showing me an error Undefined reference to mousewheel_read. I thought that let’s first try running a keyboard then I will try mousewheel.

Anyway mousewheel is atleast compiling now. I added mousewheel.c to project files.

I am still not able to use any input device despite everything compiling correctly.

I have edited my previous reply due to some misunderstanding. The problem is not solved yet but moderator marked it as solution.

Can you use keyboard navigation? By pressing the tab key the next object should be highlighted.

No, keyboard is also not working.

This time I cloned a fresh copy. Followed these steps :

  1. Set these in lv_drv_conf.h
#  define USE_KEYBOARD        1
#  define USE_MOUSE           1
#  define USE_MOUSEWHEEL      1
  1. Set these in lv_ex_conf.h
#define LV_EX_KEYBOARD     1
#define LV_EX_MOUSEWHEEL   1
  1. Included lv_test_group.h in main.c
  2. Called lv_test_group_1(); from main.c
  3. Add mousewheel.c and mousewheel.h to CodeBlocks project files

Is there some variable that should be set but I have missed ?

That should be enough. I’ll check it with the CodeBlocks project.

@embeddedt
Are the keyboard and mouswheel drivers added in the Windows driver?

No, the Windows driver only supports basic mouse input (left click/moving) at the moment. It was done as a quick native replacement to the SDL driver.

I have wanted to update it for some time but I haven’t gotten a chance yet. :slightly_smiling_face:

No problem, at least we know why it’s not working. :slight_smile:

@il3ven
You can either extend Windows driver with keyboard and mouse wheel support (Pull request is welcome :wink: ) or use the Visual Studio project (simple on windows).

Thank you for your help. I have setup the Visual Studio Project. Keyboard and Mouse are also working in it.

2 Likes