小编SP5*_*RFD的帖子

input_event结构描述(来自linux/input.h)

有人可以告诉我input_event结构使用的数据类型的属性是什么?

它在input.h文件中定义如下:

struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
Run Code Online (Sandbox Code Playgroud)

但没有其他描述!即使是谷歌搜索也没有给我带来任何有趣

我唯一知道的是time从纪元提供秒或毫秒并value给出按下按钮的代码.但即便是value财产的价值对我来说也不是很清楚.在我的程序中,每次击键都会产生六个事件.以下事件是按ENTER键的响应:

type=4,code=4,value=458792
type=1,code=28,value=1
type=0,code=0,value=0
type=4,code=4,value=458792
type=1,code=28,value=0
type=0,code=0,value=0 
Run Code Online (Sandbox Code Playgroud)

那些是为了a信件:

type=4,code=4,value=458756
type=1,code=30,value=1
type=0,code=0,value=0
atype=4,code=4,value=458756
type=1,code=30,value=0
type=0,code=0,value=0
Run Code Online (Sandbox Code Playgroud)

我想将值解码为真实的字母,但我不明白属性的含义.

请帮忙!

c c++ linux structure input

23
推荐指数
1
解决办法
3万
查看次数

如何以一种形式传递@RequestParam 和@ModelAttribute

我想将 @RequestParam 和 @ModelAttribute 混合在一种弹簧形式和控制器中。

我在控制器中做的事情如下:

@RequestMapping("/user/edit/{userId}")
public ModelAndView editUser(@PathVariable String userId, 
    @ModelAttribute User user, BindingResult bindingResult,
    @RequestParam Set<String> groups) {

    if(bindingResults.hasErrors() {
        //return back to form and correct errors
    } else {
        //save data and get out of form 
    }
} 
Run Code Online (Sandbox Code Playgroud)

有简单的用户 bean(id、firstName、lastName 等)但没有“groups”属性。还有简单的 Group bean(id、名称、描述),但与用户没有任何联系。所以在逻辑层面上用户和组是完全分离的。

在我的表单中,编辑用户时,有一个包含所有组的 id 的 html SELECT 元素。您可以选择多个 id 并填充用户数据并将其发送到控制器。

到目前为止,一切都运行良好。我正确填写了@ModelAttibute User。我还得到了填充了选定 ID(字符串)的 @RequestParam Set[String] 组。

现在我想做更多的事情。我需要写一些东西,而不是@RequestParam Set[String] 组会给我@RequestParam Set[Group] 组。当然,我可以直接在我的控制器方法 editUser(...) 中转换它,但这不是一个很好的解决方案。所以我决定编写一个自定义的 @InitBinder 方法,它可以很好地为我完成它。

问题来了。

我写了 initBinder 如下:

[...]
webDataBinder.registerCustomEditor(Set.class, "groups", new CustomCollectionEditor(Set.class) { …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

5
推荐指数
1
解决办法
5218
查看次数

如何从Freemarker调用JavaScript函数?

我有一些基本的JavaScript函数:

<script type="text/javascript">
    function someTestFunction(param1, param2) {
        //do something
    }
</script>
Run Code Online (Sandbox Code Playgroud)

和Freemarker代码:

<#if something==somethingElse>
    // call: someTestFunction(something, 123)
<#else>
    // call: someTestFunction(somethingElse, 345)
</#if>
Run Code Online (Sandbox Code Playgroud)

我的问题是:是否可能,如果可以,如何从freemarker标签内部调用someTestFunction()?

javascript freemarker

5
推荐指数
1
解决办法
2万
查看次数

配置 Eclipse 进行 Linux 内核模块开发

我正在尝试配置 Eclipse 以在 Ubuntu 下开发 Linux 内核模块。到目前为止,我已经从目录添加了Properties> Paths and Symbols> Includes>标头,但它并没有从我的代码中删除所有内容。GNU C/usr/src/'uname -r'/includeSyntax error

之后,我的代码如下所示:

将标头添加到路径后的代码

我还应该做什么才能愉快地开发内核模块?

eclipse linux kernel

5
推荐指数
1
解决办法
2万
查看次数

指针和'char buffer [128]'的引用

我有一个简单的程序:

char buffer[128];                      // creates an array of 128 elements
memset(&buffer, 65, sizeof(buffer));   // fills buffer with 'A' (ascii 65) letter
cout << buffer << endl;                // prints whole buffer - 128 times 'A' letter
cout << &buffer << endl;               // prints adress of a buffer (first element of it)
cout << buffer[0] << endl;             // prints first element of a buffer
Run Code Online (Sandbox Code Playgroud)

直到现在一切都很好,但我不明白为什么,当我这称呼:

cout << &buffer[0] << endl;          
Run Code Online (Sandbox Code Playgroud)

imho上面的代码应该打印缓冲区中第一个元素的地址(&buffer与之相同),但它会打印整个缓冲区,就像cout << buffer << endl;

为什么会这样?

c++ pointers reference

-1
推荐指数
1
解决办法
850
查看次数